Code Monkey home page Code Monkey logo

triton-hxemu's Introduction

hxemu: Symbolic emulation through Triton in IDA Pro

hxemu is a small library that leverages triton to perform symbolic execution in an arbitrary context. As opposed to other emulators, like Unicorn or bochscpu, triton allows us to emulate code with partial contexts, or no context information at all. Unknown registers or memory cells are considered symbolic and the emulator state can be altered at will for analysis.

Features

  • Ability to run in unknown contexts.
  • User defined interface to run traces in said arbitrary context.

Building

We currently only support Windows, although porting it to other platforms should be trivial with minimal modifications, if any. You can build hxemu using cmake as follow:

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..
cmake --build .

Usage

Here is a quick example:

#include <hxemu.h>

class MyHook : public EmulatorHookInterface
{
public:
	void OnEmulateExit(Emulator& emulator, triton::arch::Instruction& instruction) override
	{
		// Do something after the instruction is emulated...
	}

	// ... Other callbacks
};

// Class building instruction resolved from the process address space
// This logic can be applied for small, incomplete traces, debuggee and even IDBs
class InstructionFactory : public InstructionFactoryInterface
{
public:
	std::optional<triton::arch::Instruction> FromAddress(uint64_t address)
	{
		// Build instruction object...
	}
}

bool Emulate(ea_t start_address)
{
	std::unique_ptr<InstructionFactory> factory = std::make_unique<InstructionFactory>();
	Emulator emulator(triton::arch::ARCH_X86_64, std::move(factory));

	std::shared_ptr<MyHook> hooks = std::make_shared<MyHook>();
	return emulator.Run(start_address, hooks);
}

The main emulation entry points are:

  • EmulateOnInstruction which emulates only one instruction in the current emulator context.
  • Run which emulates until RIP is unknown (meaning it doesn't have a concrete value).

Known Issues

Since triton symbolic engine is quite slow and heavy, emulation will be slow. It can also take a lot of your memory, even for small traces.

triton-hxemu's People

Contributors

ek0 avatar

Watchers

 avatar

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.