Giter Site home page Giter Site logo

can1357 / linux-pe Goto Github PK

View Code? Open in Web Editor NEW
242.0 8.0 42.0 195 KB

COFF and Portable Executable format described using standard C++ with no dependencies.

License: BSD 3-Clause "New" or "Revised" License

C++ 99.82% CMake 0.18%
pe portable-executable coff windows

linux-pe's People

Contributors

can1357 avatar es3n1n avatar immortalety avatar qfrtt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linux-pe's Issues

compling errors

im getting these errors while compiling:
image
image
this is my CMake file:
image
i already tried enabling fms extentions but it didnt do nothing

error C2027: use of undefined type "std::array<uint64_t,2>"

vs2019,c++ 20,msvc

test code
main.cpp

#include <fstream>
#include <vector>

#include <nt/image.hpp>

inline bool open_binary_file(const std::string& file,
                             std::vector<uint8_t>& data) {
  std::ifstream fstr(file, std::ios::binary);
  if (!fstr.is_open()) return false;

  fstr.unsetf(std::ios::skipws);
  fstr.seekg(0, std::ios::end);

  const auto file_size = fstr.tellg();

  fstr.seekg(NULL, std::ios::beg);
  data.reserve(static_cast<uint32_t>(file_size));
  data.insert(data.begin(), std::istream_iterator<uint8_t>(fstr),
              std::istream_iterator<uint8_t>());
  return true;
}

constexpr auto path = "demo.exe";

int main()
{
	std::vector< uint8_t > module_data, tmp;
	if (!open_binary_file(path, module_data))
	{
		std::printf("[!] failed to open binary = %s\n", path);
		return -1;
	}

	auto img = reinterpret_cast<win::image_t<> *>(module_data.data());
	auto image_size = img->get_nt_headers()->optional_header.size_image;
	const auto image_base = img->get_nt_headers()->optional_header.image_base;

	// page align the vector allocation so that unicorn-engine is happy girl...
	tmp.resize(image_size + 0x1000);
	const std::uintptr_t module_base =
		reinterpret_cast<std::uintptr_t>(tmp.data()) +
		(0x1000 - (reinterpret_cast<std::uintptr_t>(tmp.data()) & 0xFFFull));

	std::memcpy((void*)module_base, module_data.data(), 0x1000);
	std::for_each(img->get_nt_headers()->get_sections(),
		img->get_nt_headers()->get_sections() + img->get_nt_headers()->file_header.num_sections,
		[&](const auto& section_header)
		{
			std::memcpy((void*)(module_base + section_header.virtual_address),
				module_data.data() + section_header.ptr_raw_data, section_header.size_raw_data);
		});

	auto win_img = reinterpret_cast<win::image_t<>*>(module_base);

	auto baseimport_dir =
		win_img->get_directory(win::directory_id::directory_entry_import);

	auto baseiat_dir =
		win_img->get_directory(win::directory_id::directory_entry_iat);

	std::printf("[!] import dir:%x size:%x\n", baseimport_dir->rva, baseimport_dir->size);
	std::printf("[!] iat dir:%x size:%x\n", baseiat_dir->rva, baseiat_dir->size);
}

Linux support

Library says its linux-pe, yet there is no way to use it on linux.
What compiler should I use if not gcc-10 nor clang-11 can compile it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.