1 Star 0 Fork 2

潘志浩 / Exe-decompiling

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
update_pyc_head.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
one 提交于 2021-09-22 11:09 . 清理代码 (#2)
import binascii
class UpdatePycHead:
"""
update pyc head
"""
@staticmethod
def hexadecimal_read_file(filename):
"""convert the file to hexadecimal
"""
byte_list = []
with open(f'{filename}', 'rb') as f:
byte = f.read(1)
while byte:
byte_list.append('%02x' % (ord(byte)))
byte = f.read(1)
f.close()
return byte_list
def correct_the_data(self, filename):
"""get your papers right
"""
struct = self.hexadecimal_read_file('struct')
norm = self.hexadecimal_read_file(filename)
for i in range(16):
norm.insert(i, struct[i])
return norm
def restore_file(self, filename):
"""restore hexadecimal byte to file
"""
norm = self.correct_the_data(filename)
pyc_name = filename.split(".")[0]
with open(f'{pyc_name}.pyc', 'wb') as f:
for byte in norm:
ascii_byte = binascii.a2b_hex(byte)
f.write(ascii_byte)
f.close()
Python
1
https://gitee.com/BrucePan/Exe-decompiling.git
git@gitee.com:BrucePan/Exe-decompiling.git
BrucePan
Exe-decompiling
Exe-decompiling
master

搜索帮助