- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip_null_patch.py
More file actions
Latest commit
21 lines (16 loc) · 752 Bytes
/
Copy pathzip_null_patch.py
File metadata and controls
21 lines (16 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importzipfile, opcode
fromtypesimportCodeType
def_patch_code_obj(code, custom_co_code):
returnCodeType(
code.co_argcount, code.co_kwonlyargcount, code.co_nlocals,
code.co_stacksize, code.co_flags, custom_co_code,
code.co_consts, code.co_names, code.co_varnames,
code.co_filename, code.co_name, code.co_firstlineno,
code.co_lnotab, code.co_freevars, code.co_cellvars
)
defpatch_zipfile():
code=zipfile.ZipInfo.__init__.__code__
patched_co_code=code.co_code
nop_padding=bytes([opcode.opmap["NOP"] for_inrange(34)])
patched_co_code=patched_co_code[:6] +nop_padding+patched_co_code[40:]
zipfile.ZipInfo.__init__.__code__=_patch_code_obj(code, patched_co_code)