-
Notifications
You must be signed in to change notification settings - Fork 1
/
stage6.py
executable file
·39 lines (31 loc) · 1.25 KB
/
stage6.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
#!/usr/bin/env python3
from ctypes import *
def blep(foo):
print('Stage 6:', foo)
try:
mono = CDLL('libmonosgen-2.0.so.1')
mono.mono_jit_init.restype = c_void_p
mono.mono_domain_assembly_open.restype = c_void_p
mono.mono_assembly_get_image.restype = c_void_p
mono.mono_class_from_name.restype = c_void_p
mono.mono_class_get_method_from_name.restype = c_void_p
mono.mono_runtime_invoke.restype = c_void_p
mono.mono_object_to_string = c_void_p
mono.mono_string_new.restype = c_void_p
mono.mono_string_to_utf8.restype = c_char_p
mono.mono_get_root_domain.restype = c_void_p
dom = c_void_p(mono.mono_get_root_domain())
asm = c_void_p(mono.mono_domain_assembly_open(dom, b"stage7.exe"))
img = c_void_p(mono.mono_assembly_get_image(asm))
cls = c_void_p(mono.mono_class_from_name(img, b"", b"Stage7Runner"))
met = c_void_p(mono.mono_class_get_method_from_name(cls, b"blep", 1))
arg = c_void_p(mono.mono_string_new(dom, c_char_p(foo.encode())))
mrv = mono.mono_runtime_invoke(met, None, byref(arg), None)
prv = mono.mono_string_to_utf8(mono.mono_object_to_string(mrv)).decode()
print('Return value[6]:', prv)
return prv
except Exception as e:
import traceback
traceback.print_exc()
if __name__ == '__main__':
print(blep('test'))