-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhack-7.py
More file actions
32 lines (28 loc) · 902 Bytes
/
hack-7.py
File metadata and controls
32 lines (28 loc) · 902 Bytes
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
import new
myconsts = (None, "Hello Byte Code World!")
mycode = ("\x64" # LOAD_CONST
"\x01" # 0x0001
"\x00" #
"\x47" # PRINT_ITEM
"\x48" # PRINT_NEWLINE
"\x64" # LOAD_CONST
"\x00" # 0x0000
"\x00" #
"\x53") # RETURN_VALUE
# Create the code object
co = new.code(0, # co_argcount,
0, # co_nlocals,
1, # co_stacksize,
0, # co_flags,
mycode, # co_code,
myconsts, # co_consts,
(), # co_names
(), # co_varnames
"test.py", # co_filename,
"myfunc", # co_name,
0, # co_firstlineno,
"") # co_lnotab)
# Create the function object
myfunc = new.function(co, {})
# Invoke the function
myfunc()