generating complete headers now... all that is left is to debug it!

merge-requests/2/head
_xeroxz 4 years ago
parent c6aa516c3b
commit e17e938c28

@ -82,17 +82,15 @@ namespace vm
std::uintptr_t decrypt_key = end_of_module, start_addr; std::uintptr_t decrypt_key = end_of_module, start_addr;
if ( vmctx->exec_type == vmp2::exec_type_t::backward ) if ( vmctx->exec_type == vmp2::exec_type_t::backward )
{ {
std::for_each( virt_labels.begin(), virt_labels.end(), [ & ]( const vlabel_data &label ) { std::for_each( virt_labels.begin()->vinstrs.begin(), virt_labels.begin()->vinstrs.end(),
std::for_each( label.vinstrs.begin(), label.vinstrs.end(), [ & ]( const vinstr_data &vinstr ) { [ & ]( const vinstr_data &vinstr ) {
( ++decrypt_key ) += vinstr.imm_size ? vinstr.imm_size / 8 : 0; ( ++decrypt_key ) += vinstr.imm_size ? vinstr.imm_size / 8 : 0;
} ); } );
} );
}
start_addr = decrypt_key;
// invert the encoded virtual instructions operands if vip advances backward...
if ( vmctx->exec_type == vmp2::exec_type_t::backward )
std::reverse( virt_labels.begin(), virt_labels.end() ); std::reverse( virt_labels.begin(), virt_labels.end() );
}
start_addr = decrypt_key;
// loop over the instructions and encrypt them... // loop over the instructions and encrypt them...
for ( auto &label : virt_labels ) for ( auto &label : virt_labels )

@ -150,6 +150,8 @@ namespace vm
u8 bin[ 0x100000 ]; // this will the vmp binary... u8 bin[ 0x100000 ]; // this will the vmp binary...
u8 map_area[ 0x10000 ]; // map the binary into this space... u8 map_area[ 0x10000 ]; // map the binary into this space...
u8 __%s_vinstrs[%d] = {};
u8 __vmcall_shell_code[ 2 ][ 15 ] = { { u8 __vmcall_shell_code[ 2 ][ 15 ] = { {
0x68, 0xE9, 0xD6, 0xFF, 0x0B, // push xxxx 0x68, 0xE9, 0xD6, 0xFF, 0x0B, // push xxxx
0x68, 0xE9, 0xD6, 0xFF, 0x0B, // push xxxx 0x68, 0xE9, 0xD6, 0xFF, 0x0B, // push xxxx

@ -219,7 +219,14 @@ std::string gen_code( std::vector< vm::compiled_label_data > &labels, std::strin
result.append( "\t\t};\n\n" ); result.append( "\t\t};\n\n" );
result.append( string_format( "\t\tu8 map_area[0x%x];\n\n", vmctx.image_size ) ); result.append( string_format( "\t\tu8 map_area[0x%x];\n\n", vmctx.image_size ) );
result.append( string_format( "\t\tu8 __vlabels[%d] =\n", labels.size() ) ); for ( auto &label : labels )
{
result.append( string_format( "\t\tu8 __%s_vinstrs[%d] =\n", label.label_name.c_str(), label.vinstrs.size() ) );
result.append( "\t\t{\n\t\t\t" );
for (auto& byte : label.vinstrs)
result.append( string_format( "0x%x, ", byte ) );
result.append( "\n\t\t};\n\n" );
}
result.append( string_format( "\t\tu8 __vmcall_shell_code[%d][15] =\n" result.append( string_format( "\t\tu8 __vmcall_shell_code[%d][15] =\n"
"\t\t{\n", "\t\t{\n",
@ -240,7 +247,7 @@ std::string gen_code( std::vector< vm::compiled_label_data > &labels, std::strin
// one jmp instruction... // one jmp instruction...
jmp_code.append( "0xE9, " ); jmp_code.append( "0xE9, " );
for (auto i = 0u; i < 4; ++i) for ( auto i = 0u; i < 4; ++i )
jmp_code.append( "0x0, " ); jmp_code.append( "0x0, " );
result.append( string_format( "\t\t\t{ %s },\n", jmp_code.c_str() ) ); result.append( string_format( "\t\t\t{ %s },\n", jmp_code.c_str() ) );

@ -139,8 +139,8 @@ namespace vm
enum class calls : u32 enum class calls : u32
{ {
get_world = 0xbffd6fe9, get_world = 0xbffd6ff5,
get_hello = 0xbffd6fdd, get_hello = 0xbffd6fe9,
}; };
inline _pair_t< u8, calls > call_map[2] = inline _pair_t< u8, calls > call_map[2] =
@ -158,6 +158,16 @@ namespace vm
u8 map_area[0x29000]; u8 map_area[0x29000];
u8 __get_world_vinstrs[12] =
{
0xff, 0xff, 0xff, 0xfe, 0xc7, 0xf0, 0xd6, 0x30, 0x1a, 0xff, 0x94, 0x80,
};
u8 __get_hello_vinstrs[12] =
{
0xff, 0xff, 0xff, 0xfe, 0xc7, 0xf1, 0xd6, 0x58, 0x72, 0xa7, 0xec, 0xd8,
};
u8 __vmcall_shell_code[2][15] = u8 __vmcall_shell_code[2][15] =
{ {
{ 0x68, 0x0, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x0, 0xE9, 0x0, 0x0, 0x0, 0x0, }, { 0x68, 0x0, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x0, 0xE9, 0x0, 0x0, 0x0, 0x0, },

Loading…
Cancel
Save