forked from bravegnu/python-byte-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack-8.py
More file actions
30 lines (25 loc) · 827 Bytes
/
hack-8.py
File metadata and controls
30 lines (25 loc) · 827 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
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
import new
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)
myfunc = new.function(co, {})
myfunc()