Facebook
From moi, 1 Year ago, written in Python.
This paste is a reply to oui from moi - go back
Embed
Viewing differences between oui and Re: oui
from capstone import *

pefile

def disassemble_file(file_path):
    
extract_raw_from_pe(pe_path, output_path):
    # Charger le fichier PE
    pe = pefile.PE(pe_path)

    # Extraire le code machine brut
    raw_data = bytearray()
    for section in pe.sections:
        raw_data += section.get_data()

    # Enregistrer le code machine brut dans un fichier binaire
    
with open(file_path, 'rb') open(output_path, 'wb') as f:
        binary_data = f.read()

    # Initialize the disassembler
    md = Cs(CS_ARCH_X86, CS_MODE_64)  # Specify the architecture and mode (64-bit in this example)

    # Disassemble the binary data
    for i in md.disasm(binary_data, 0x0):
        print(f"0x{i.address:x}:\t{i.mnemonic}\t{i.op_str}")

output_file:
        output_file.write(raw_data)

if __name__ == "__main__":
    # Specify the path to the executable file
    exe_path 
Spécifier le chemin vers le fichier PE x64
    pe_path 
= "path/to/your/file.exe"

    # Call the disassembly function
    disassemble_file(exe_path)
Spécifier le chemin de sortie pour le fichier brut (raw)
    output_path = "output/raw_code.raw"

    # Appeler la fonction d'extraction
    extract_raw_from_pe(pe_path, output_path)

Replies to Re: oui rss

Title Name Language When
Re: Re: oui moi python 1 Year ago.
captcha