circle-external-buffer-oob-poc / poc /circledump_direct_driver.cpp
AgentRen's picture
Add Circle external buffer OOB PoC
8602386 verified
Raw
History Blame Contribute Delete
967 Bytes
#include <circledump/Dump.h>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
namespace
{
std::vector<char> read_file(const std::string &path)
{
std::ifstream in(path, std::ios::binary | std::ios::ate);
if (!in)
throw std::runtime_error("failed to open input");
const auto size = in.tellg();
if (size < 0)
throw std::runtime_error("failed to measure input");
std::vector<char> data(static_cast<size_t>(size));
in.seekg(0);
in.read(data.data(), static_cast<std::streamsize>(data.size()));
if (!in)
throw std::runtime_error("failed to read input");
return data;
}
} // namespace
int main(int argc, char **argv)
{
if (argc != 2)
{
std::cerr << "usage: " << argv[0] << " model.circle\n";
return 2;
}
auto raw = read_file(argv[1]);
auto *model = circle::GetModel(raw.data());
circledump::ModelEx modelex{model, &raw};
std::cout << modelex << std::endl;
return 0;
}