BackDoorBuster/detection/pyc_detection.py

23 lines
523 B
Python

from typing import List, Tuple
import uncompyle6
import io
def disassemble_pyc(file_path: str) -> str:
"""
Disassembles a .pyc file using uncompyle6.
Args:
file_path (str): The path to the .pyc file.
Returns:
str: The disassembled code as a string.
"""
output = io.StringIO()
try:
uncompyle6.main.decompile_file(file_path, output)
return output.getvalue()
except Exception as e:
print(f"Error occurred while disassembling: {e}")
return ""