From 42fdee32aa486f47e9e076b76753e5dc20d40794 Mon Sep 17 00:00:00 2001 From: Windows93-Applications Date: Mon, 6 Jan 2025 13:53:40 -0500 Subject: [PATCH] Add exe_analyser.py --- exe_analyser.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 exe_analyser.py diff --git a/exe_analyser.py b/exe_analyser.py new file mode 100644 index 0000000..f15d555 --- /dev/null +++ b/exe_analyser.py @@ -0,0 +1,28 @@ +import pefile +import sys + +def analyze_executable(file_path): + try: + pe = pefile.PE(file_path) + file_hash = hashlib.sha256(open(file_path, 'rb').read()).hexdigest() + print(f"Analyzing {file_path}...") + print(f"File Name: {pe.filename}") + print(f"Machine: {pe.FILE_HEADER.Machine}") + print(f"Number of Sections: {len(pe.sections)}") + print(f"Entry Point: {hex(pe.OPTIONAL_HEADER.AddressOfEntryPoint)}") + print(f"File hash (SHA256): {file_hash}") + print("\nSections:") + for section in pe.sections: + print(f"- Name: {section.Name.decode().strip()}") + print(f" Virtual Size: {section.Misc_VirtualSize}") + print(f" Raw Size: {section.SizeOfRawData}") + print(f" Characteristics: {hex(section.Characteristics)}") + + except Exception as e: + print(f"Error analyzing file: {e}") + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python exe_analyzer.py ") + else: + analyze_executable(sys.argv[1])