File size: 3,075 Bytes
ec35913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import pefile
import tkinter as tk
from tkinter import filedialog

def extract_pe_info(file_path):
    try:
        pe = pefile.PE(file_path)
        info = {
            'AddressOfEntryPoint': hex(pe.OPTIONAL_HEADER.AddressOfEntryPoint),
            'MajorLinkerVersion': pe.OPTIONAL_HEADER.MajorLinkerVersion,
            'MajorImageVersion': pe.OPTIONAL_HEADER.MajorImageVersion,
            'MajorOperatingSystemVersion': pe.OPTIONAL_HEADER.MajorOperatingSystemVersion,
            'DllCharacteristics': hex(pe.OPTIONAL_HEADER.DllCharacteristics),
            'SizeOfStackReserve': pe.OPTIONAL_HEADER.SizeOfStackReserve,
            'NumberOfSections': pe.FILE_HEADER.NumberOfSections,
            'SizeOfImage': pe.OPTIONAL_HEADER.SizeOfImage,
            'SizeOfHeaders': pe.OPTIONAL_HEADER.SizeOfHeaders,
            'Subsystem': pe.OPTIONAL_HEADER.Subsystem,
            'Magic': pe.FILE_HEADER.Machine,
            'Characteristics': hex(pe.FILE_HEADER.Characteristics),
            'TimeDateStamp': pe.FILE_HEADER.TimeDateStamp,
            'ImageBase': hex(pe.OPTIONAL_HEADER.ImageBase),
            'CheckSum': pe.OPTIONAL_HEADER.CheckSum,

            'SizeOfCode': pe.OPTIONAL_HEADER.SizeOfCode,
            'SizeOfInitializedData': pe.OPTIONAL_HEADER.SizeOfInitializedData,
            'SizeOfUninitializedData': pe.OPTIONAL_HEADER.SizeOfUninitializedData,
            'AddressOfEntryPoint': hex(pe.OPTIONAL_HEADER.AddressOfEntryPoint),

            'ImageBase': hex(pe.OPTIONAL_HEADER.ImageBase),

            'MajorImageVersion': pe.OPTIONAL_HEADER.MajorImageVersion,
            'MajorSubsystemVersion': pe.OPTIONAL_HEADER.MajorSubsystemVersion,

            'SizeOfImage': pe.OPTIONAL_HEADER.SizeOfImage,
            'SizeOfHeaders': pe.OPTIONAL_HEADER.SizeOfHeaders,
            'Subsystem': pe.OPTIONAL_HEADER.Subsystem,

            'SizeOfHeapReserve': pe.OPTIONAL_HEADER.SizeOfHeapReserve,

            'NumberOfRvaAndSizes': pe.OPTIONAL_HEADER.NumberOfRvaAndSizes,
            'DataDirectory': pe.OPTIONAL_HEADER.DATA_DIRECTORY,
        }
        return info
    except Exception as e:
        return str(e)

def inspect_pe_attributes(file_path):
    try:
        pe = pefile.PE(file_path)
        # Récupérer la liste des entrées DATA_DIRECTORY
        data_directory_entries = pe.OPTIONAL_HEADER.DATA_DIRECTORY

        # Parcourir la liste pour trouver l'entrée du répertoire des ressources
        for entry in data_directory_entries:
            if entry.name == "IMAGE_DIRECTORY_ENTRY_RESOURCE":
                resource_size = entry.Size
                return resource_size
    except Exception as e:
        return f"Erreur d'inspection du fichier {file_path}: {str(e)}"



def upload_file():
    file_path = filedialog.askopenfilename()
    if file_path:
        pe_info = extract_pe_info(file_path)
        print(pe_info)

# Création de l'interface graphique
root = tk.Tk()
root.title("PE File Info Extractor")

upload_button = tk.Button(root, text="Upload PE File", command=upload_file)
upload_button.pack(pady=20)

root.mainloop()