1 Star 0 Fork 2

潘志浩 / Exe-decompiling

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
extract_object_file.py 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
one066 提交于 2022-01-04 13:48 . update: 2022-01-04 13:48:58
import os
import shutil
from update_pyc_head import UpdatePycHead
class ExtractObjectFile:
def __init__(self):
self.path = os.path.join(os.getcwd(), 'bucket')
self.exe_name = None
def get_exe_name(self):
"""get the EXE name
"""
try:
names = os.listdir(self.path)
exe_name = []
for i in names:
if i.endswith('exe'):
exe_name.append(i.split('.exe')[0])
return exe_name[0]
except IndexError:
print('Error:没有放入exe')
def remove_file(self):
"""remove redundant file
"""
file_path = os.path.join(self.path, f'{self.exe_name}.exe_extracted')
for root, dirs, files in os.walk(file_path):
for f in files:
os.remove(os.path.join(root, f))
shutil.rmtree(file_path)
os.remove(os.path.join(self.path, 'struct'))
os.remove(os.path.join(self.path, self.exe_name))
return
def get_target_file(self):
"""
Run pyinstxtractor.py to get the .pyc file
Get two target files
"""
os.system(f'python ../packages/pyinstxtractor.py {self.exe_name}.exe')
# move two target file to main path
struct_path = os.path.join(self.path, f'{self.exe_name}.exe_extracted', 'struct')
target_path = os.path.join(self.path, f'{self.exe_name}.exe_extracted', self.exe_name)
shutil.move(struct_path, self.path)
shutil.move(target_path, self.path)
def decompiling(self):
"""
decompiling
"""
os.chdir(self.path)
try:
self.exe_name = self.get_exe_name()
self.get_target_file()
update_pyc_head = UpdatePycHead()
update_pyc_head.restore_file(self.exe_name)
os.system(f'uncompyle6 {self.exe_name}.pyc')
os.system(f'uncompyle6 {self.exe_name}.pyc > {self.exe_name}.py')
self.remove_file()
except Exception as e:
print(e)
Python
1
https://gitee.com/BrucePan/Exe-decompiling.git
git@gitee.com:BrucePan/Exe-decompiling.git
BrucePan
Exe-decompiling
Exe-decompiling
master

搜索帮助