binlex
binlex::Decompiler Class Reference
Inheritance diagram for binlex::Decompiler:
binlex::DecompilerBase binlex::Common

Classes

struct  Section
 
struct  Trait
 

Public Member Functions

BINLEX_EXPORT Decompiler (const binlex::File &firef)
 
BINLEX_EXPORT bool Setup (cs_arch architecture, cs_mode mode_type)
 
BINLEX_EXPORT void SetInstructions (bool instructions, uint index)
 
BINLEX_EXPORT void * CreateTraitsForSection (uint index)
 
BINLEX_EXPORT void LinearDisassemble (void *data, size_t data_size, size_t offset, uint index)
 
BINLEX_EXPORT void Decompile (void *data, size_t data_size, size_t offset, uint index)
 
BINLEX_EXPORT void FreeTraits (uint index)
 
BINLEX_EXPORT bool IsAddress (map< uint64_t, uint > &addresses, uint64_t address, uint index)
 
BINLEX_EXPORT json GetTrait (struct Trait &trait)
 
vector< json > GetTraits ()
 
BINLEX_EXPORT void AppendQueue (set< uint64_t > &addresses, uint operand_type, uint index)
 
- Public Member Functions inherited from binlex::DecompilerBase
 DecompilerBase (const binlex::File &firef)
 
BINLEX_EXPORT void WriteTraits ()
 
BINLEX_EXPORT void py_SetThreads (uint threads, uint thread_cycles, uint thread_sleep)
 
BINLEX_EXPORT void py_SetCorpus (const char *corpus)
 
BINLEX_EXPORT void py_SetInstructions (bool instructions)
 
BINLEX_EXPORT void py_SetTags (const vector< string > &tags)
 
BINLEX_EXPORT void py_SetMode (string mode)
 

Static Public Member Functions

static BINLEX_EXPORT void AddDiscoveredBlock (uint64_t address, struct Section *sections, uint index)
 
static BINLEX_EXPORT void CollectOperands (cs_insn *insn, int operand_type, struct Section *sections, uint index)
 
static BINLEX_EXPORT uint CollectInsn (cs_insn *insn, struct Section *sections, uint index)
 
static BINLEX_EXPORT void AppendTrait (struct Trait *trait, struct Section *sections, uint index)
 
static BINLEX_EXPORT bool IsNopInsn (cs_insn *ins)
 
static BINLEX_EXPORT bool IsSemanticNopInsn (cs_insn *ins)
 
static BINLEX_EXPORT bool IsTrapInsn (cs_insn *ins)
 
static BINLEX_EXPORT bool IsPrivInsn (cs_insn *ins)
 
static BINLEX_EXPORT bool IsEndInsn (cs_insn *insn)
 
static BINLEX_EXPORT uint IsConditionalInsn (cs_insn *insn)
 
static BINLEX_EXPORT uint64_t MaxAddress (set< uint64_t > coverage)
 
static BINLEX_EXPORT bool IsFunction (map< uint64_t, uint > &addresses, uint64_t address)
 
static BINLEX_EXPORT bool IsBlock (map< uint64_t, uint > &addresses, uint64_t address)
 
static BINLEX_EXPORT bool IsVisited (map< uint64_t, int > &visited, uint64_t address)
 
static BINLEX_EXPORT bool IsWildcardInsn (cs_insn *insn)
 
static BINLEX_EXPORT string WildcardInsn (cs_insn *insn)
 
static BINLEX_EXPORT void ClearTrait (struct Trait *trait)
 
static BINLEX_EXPORT void * TraitWorker (void *args)
 
static BINLEX_EXPORT void * FinalizeTrait (struct Trait &trait)
 
- Static Public Member Functions inherited from binlex::Common
static BINLEX_EXPORT string GetTLSH (const uint8_t *data, size_t len)
 
static BINLEX_EXPORT string GetFileTLSH (const char *file_path)
 
static BINLEX_EXPORT string SHA256 (char *trait)
 
static BINLEX_EXPORT string GetFileSHA256 (char *file_path)
 
static BINLEX_EXPORT string GetSHA256 (const uint8_t *data, size_t len)
 
static BINLEX_EXPORT vector< char > TraitToChar (string trait)
 
static BINLEX_EXPORT string RemoveWildcards (string trait)
 
static BINLEX_EXPORT uint GetByteSize (string s)
 
static BINLEX_EXPORT string RemoveSpaces (string s)
 
static BINLEX_EXPORT string WildcardTrait (string trait, string bytes)
 
static BINLEX_EXPORT string TrimRight (const std::string &s)
 
static BINLEX_EXPORT string HexdumpBE (const void *data, size_t size)
 
static BINLEX_EXPORT string Wildcards (uint count)
 
static BINLEX_EXPORT string HexdumpMemDisp (uint64_t disp)
 
static BINLEX_EXPORT float Entropy (string trait)
 
static BINLEX_EXPORT void Hexdump (const char *desc, const void *addr, const int len)
 

Public Attributes

struct Section sections [DECOMPILER_MAX_SECTIONS]
 

Static Public Attributes

static cs_arch arch
 
static cs_mode mode
 

Additional Inherited Members

- Protected Attributes inherited from binlex::DecompilerBase
const binlex::Filefile_reference
 

Member Function Documentation

◆ AddDiscoveredBlock()

static BINLEX_EXPORT void binlex::Decompiler::AddDiscoveredBlock ( uint64_t  address,
struct Section sections,
uint  index 
)
static

Add discovered block address to queue

Parameters
addressthe block address
operand_typethe operand type
indexthe section index
Returns
bool

◆ AppendTrait()

static BINLEX_EXPORT void binlex::Decompiler::AppendTrait ( struct Trait trait,
struct Section sections,
uint  index 
)
static

Append Additional Traits

Parameters
traittrait to append
sectionssections pointer
indexthe section index
Returns
bool

◆ ClearTrait()

static BINLEX_EXPORT void binlex::Decompiler::ClearTrait ( struct Trait trait)
static

Clear Trait Values Except Type

Parameters
traitthe trait struct address

◆ CollectInsn()

static BINLEX_EXPORT uint binlex::Decompiler::CollectInsn ( cs_insn *  insn,
struct Section sections,
uint  index 
)
static

Collect Instructions for Processing

Parameters
insnthe instruction
indexthe section index
Returns
operand type

◆ CollectOperands()

static BINLEX_EXPORT void binlex::Decompiler::CollectOperands ( cs_insn *  insn,
int  operand_type,
struct Section sections,
uint  index 
)
static

Collect Function and Conditional Operands for Processing

Parameters
insnthe instruction
operand_typethe operand type
indexthe section index
Returns
bool

◆ CreateTraitsForSection()

BINLEX_EXPORT void* binlex::Decompiler::CreateTraitsForSection ( uint  index)

Create traits from data contains in binary sections

Parameters
argspointer to worker arguments
Returns
NULL

◆ Decompile()

BINLEX_EXPORT void binlex::Decompiler::Decompile ( void *  data,
size_t  data_size,
size_t  offset,
uint  index 
)

Decompiles Target Data

Parameters
datapointer to data
data_sizesize of data
offsetinclude section offset
indexthe section index

◆ GetTrait()

BINLEX_EXPORT json binlex::Decompiler::GetTrait ( struct Trait trait)

Gets Trait as JSON

Parameters
traitpointer to trait structure
Returns
json string

◆ GetTraits()

vector<json> binlex::Decompiler::GetTraits ( )
virtual

Get Traits as JSON

Returns
list of traits json objects

Implements binlex::DecompilerBase.

◆ IsAddress()

BINLEX_EXPORT bool binlex::Decompiler::IsAddress ( map< uint64_t, uint > &  addresses,
uint64_t  address,
uint  index 
)

Check if Function or Block Address Collected

Parameters
addressthe address to check
Returns
bool

◆ IsBlock()

static BINLEX_EXPORT bool binlex::Decompiler::IsBlock ( map< uint64_t, uint > &  addresses,
uint64_t  address 
)
static

Checks if Address if Function

Parameters
addressaddress to check
Returns
bool

◆ IsConditionalInsn()

static BINLEX_EXPORT uint binlex::Decompiler::IsConditionalInsn ( cs_insn *  insn)
static

Checks if Instruction is Conditional

Parameters
insnthe instruction
Returns
edges if > 0; then is conditional

◆ IsEndInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsEndInsn ( cs_insn *  insn)
static

Checks if the Instruction is an Ending Instruction

Parameters
insnthe instruction
Returns
bool

◆ IsFunction()

static BINLEX_EXPORT bool binlex::Decompiler::IsFunction ( map< uint64_t, uint > &  addresses,
uint64_t  address 
)
static

Checks if Address if Function

Parameters
addressaddress to check
Returns
bool

◆ IsNopInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsNopInsn ( cs_insn *  ins)
static

Checks if the Instruction is a nop

Parameters
insnthe instruction
Returns
bool

◆ IsPrivInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsPrivInsn ( cs_insn *  ins)
static

Checks if the Instruction is privileged

Parameters
insnthe instruction
Returns
bool

◆ IsSemanticNopInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsSemanticNopInsn ( cs_insn *  ins)
static

Checks if the Instruction is a semantic nop (padding)

Parameters
insnthe instruction
Returns
bool

◆ IsTrapInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsTrapInsn ( cs_insn *  ins)
static

Checks if the Instruction is a trap

Parameters
insnthe instruction
Returns
bool

◆ IsVisited()

static BINLEX_EXPORT bool binlex::Decompiler::IsVisited ( map< uint64_t, int > &  visited,
uint64_t  address 
)
static

Checks if Address was Already Visited

Parameters
addressaddress to check
Returns
bool

◆ IsWildcardInsn()

static BINLEX_EXPORT bool binlex::Decompiler::IsWildcardInsn ( cs_insn *  insn)
static

Checks if Instruction is Wildcard Instruction

Parameters
insnthe instruction
Returns
bool

◆ LinearDisassemble()

BINLEX_EXPORT void binlex::Decompiler::LinearDisassemble ( void *  data,
size_t  data_size,
size_t  offset,
uint  index 
)

Performs a linear disassembly of the data

Parameters
datapointer to data
data_sizesize of data
offsetinclude section offset
indexthe section index

◆ MaxAddress()

static BINLEX_EXPORT uint64_t binlex::Decompiler::MaxAddress ( set< uint64_t >  coverage)
static

Checks Code Coverage for Max Address

Parameters
coverageset of addresses decompiled
Returns
the maximum address from the set

◆ SetInstructions()

BINLEX_EXPORT void binlex::Decompiler::SetInstructions ( bool  instructions,
uint  index 
)
Parameters
instructionsbool to collect instructions traits or not
indexthe section index

◆ Setup()

BINLEX_EXPORT bool binlex::Decompiler::Setup ( cs_arch  architecture,
cs_mode  mode_type 
)

Set up Capstone Decompiler Architecure and Mode

Parameters
architectureCapstone Decompiler Architecure
mode_typeCapstone Mode
Returns
bool

◆ WildcardInsn()

static BINLEX_EXPORT string binlex::Decompiler::WildcardInsn ( cs_insn *  insn)
static

Wildcard Instruction

Parameters
insnthe instruction
Returns
trait wildcard byte string

The documentation for this class was generated from the following file: