pecheck

pecheck.py is a Python script designed for the analysis and investigation of Portable Executable (PE) files. PE files are a file format for executables, object code, and DLLs, used in 32-bit and 64-bit versions of Windows operating systems. The pecheck.py utility provides a command-line interface (CLI) that allows security analysts to perform detailed examinations of PE files without executing them.

Features and Capabilities

  • Comprehensive Report: It generates comprehensive reports that detail various aspects of the PE file, including headers, sections, imported and exported functions, resources, and more. These reports can highlight suspicious or anomalous elements that may indicate the file's purpose or origin.

  • Anomaly Detection: The tool can identify anomalies within the PE structure, such as unusual section names, sizes, or characteristics that deviate from standard executable formats. These anomalies often point to efforts to obfuscate the file's true intention.

  • Signature Verification: pecheck.py can verify digital signatures of PE files, providing insights into the file's authenticity and integrity. This is particularly useful for distinguishing between legitimate files and those that might have been tampered with.

  • Hash Calculation: It calculates various cryptographic hashes for the file, such as MD5, SHA-1, and SHA-256. These hashes serve as unique identifiers for the files and can be used to check against databases of known malicious software.

Running pecheck.py

To analyze a PE file, run pecheck.py followed by the path to the file you wish to analyze:

python pecheck.py /path/to/suspicious_file.exe

Analyzing the Output

Upon execution, pecheck.py will display its analysis in the terminal window. Here's how to interpret some key sections of the output:

Headers and Sections

  • DOS Header: This section provides information on whether the file has a valid DOS header, which is expected in all PE files.

  • File Header: Look for details such as the target machine, number of sections, and timestamps. A recent timestamp might indicate a newly compiled file.

  • Optional Header: Here, you'll find indicators like the entry point and image base, which could highlight suspicious behavior if the values seem off for a typical application.

  • Imported Functions: Lists the external functions the PE file calls. Malware often uses specific API calls related to network access, file manipulation, or system monitoring.

  • Exported Functions: If the file exports functions, it might be a DLL utilized by other malware components. If you see functions related to encryption or networking, further investigation is warranted.

  • Strings: pecheck.py extracts ASCII and Unicode strings from the PE file. URLs, IP addresses, suspicious file paths, or registry keys can be indicators of malicious intent.

Deeper Analysis

Based on the initial findings, you might decide to conduct a deeper analysis:

  • Cross-reference imports with known malicious software functionalities.

  • Check strings against threat intelligence databases for known malicious domains or IP addresses.

  • Analyze the file's behavior in a sandbox environment if suspicious elements are found.

Last updated