-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest-noflag-dev.py
52 lines (34 loc) · 1.19 KB
/
test-noflag-dev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import os
import shutil
import sys
from pwn import *
DIRECTORY = os.environ.get('VMM_DIRECTORY', '/app')
DEBUG_CONSOLE_PATH = os.environ.get('VMM_DEBUG_CONSOLE_PATH', '/app/ooowsserial-debug.py')
DISK_IMAGE_PATH = os.environ.get('VMM_DISK_IMAGE_PATH', '/app/disk')
OS_BOOTED = b"OOO OS BOOTED"
NOFLAG_FILE = b"noflag_file"
TEST1_TXT = b"ABCDEFGHIJ"
TEST2_TXT = b"QRSTUVWXYZ"
def main():
os.chdir(DIRECTORY)
shutil.copyfile(DEBUG_CONSOLE_PATH, "./devices-bin/ooowsserial.py")
p = process(["./vmm", "test", DISK_IMAGE_PATH, "1", "devices.config"])
p.recvuntil(OS_BOOTED)
p.recvuntil(b'$')
with open("/tmp/noflxg_test", "wb") as f:
f.write(TEST1_TXT)
p.sendline(NOFLAG_FILE + b' /tmp/noflxg_test')
output = p.recvuntil(b'$')
if not TEST1_TXT in output:
print("PUBLIC: unable to read contents of file")
sys.exit(-1)
with open("/tmp/noflxg_test2", "wb") as f:
f.write(TEST2_TXT)
p.sendline(NOFLAG_FILE + b' /tmp/noflxg_test2')
output = p.recvuntil(b'$')
if not TEST2_TXT in output:
print("PUBLIC: unable to read contents of file")
sys.exit(-1)
if __name__ == '__main__':
main()