Skip to main content

pegreet

PyPI - Version PyPI - Python Version

Greet your malware samples before you tear them apart.

pegreet is a tool that performs static analysis and feature extraction on Portable Executable files. As a cli app, it should help with first steps in malware analysis / reverse engineering. As a library, it can be used to extract useful information from samples in bulk for use in exploratory data analysis or building malware classification models.


Table of Contents

Features

Implemented

  • dump general file information
  • compute hashes (MD5, SHA1, SHA256, Imphash, SSDEEP)
  • calculate entropy
  • detect packers via PEiD signatures
  • dump info from headers
  • dump info from sections
  • dump imports and exports
  • annotate suspicious Windows API functions
  • display file parsing warnings
  • disassemble code from entry point
  • find strings
  • categorize strings

To Do

  • recognize known malicious section names
  • annotate suspicious entropy and size mismatches
  • extract resources
  • lookup on VirusTotal
  • lookup for public sandbox reports
  • check file against YARA rules
  • check digital signature
  • sort strings with StringSifter
  • extract obfuscated strings with FLOSS
  • custom output (csv, json, markdown)

Screenshots

i

Installation

as a module

<virtual environment shenanigans>
pip install pegreet

as a cli app

pipx install pegreet

Usage

as a module

from pathlib import Path
import pegreet

pe = pegreet.load(Path('data/samples/petya.exe'))

info_data = pegreet.info(pe)
print(info_data)
print(pegreet.pretty_info(info_data))

strings_data = pegreet.find_strings(pe)
print(strings_data)
print(pegreet.pretty_strings(strings_data))

print(pegreet.disasm(pe, num_lines=40))

as a cli app

$ pegreet --help

 Usage: pegreet [OPTIONS] COMMAND [ARGS]...

╭─ Options ───────────────────────────────────────────╮
│ --help                        Show this message and │
│                               exit.                 │
╰─────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────╮
│ disassemble  disassemble a specified number         │
│              instructions from entry point          │
│ info         print useful info                      │
│ strings      print strings                          │
╰─────────────────────────────────────────────────────╯


$ pegreet info data/samples/petya.exe
...


$ pegreet strings --show-uncategorized data/samples/petya.exe
...


$ pegreet disassemble data/samples/petya.exe 40
...

Notes

I started this project in 2020 in an attempt to learn about PE files and feature extraction for use in malware data science.

There are many other (better) tools available that implement similar functionality (see below). What I tried to do with pegreet is to focus on only the features that are useful to malware analysis to make it easier to digest the information. pegreet also provides annotations for suspicious indicators that can be used as jumping points for an investigation.

The pefile library was used extensively to implement the parsing of PE files. I would like to explore using the LIEF project instead as it supports multiple executable formats and it was used in the EMBER dataset. Maybe I'll follow this project up with an 'ELFgreet'.

Resources

Similar Tools

PE file info

License

pegreet is distributed under the terms of any of the following licenses:

Metadata

Release files for pegreet 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pegreet 0.4.2
File Size Uploaded Provenance Actions
pegreet-0.4.2.tar.gz 11.1 MB Without provenance Details for pegreet-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pegreet 0.4.2
File Interpreter ABI Platform Actions
pegreet-0.4.2-py3-none-any.whl Python 3 none any Details for pegreet-0.4.2-py3-none-any.whl

Total release size: 11.1 MB

Release files / pegreet-0.4.2.tar.gz

Download URL pegreet-0.4.2.tar.gz
Size 11.1 MB
Tags Source
SHA-256 checksum
How to use checksums
743042e38eba155edab6464d8f866327caece974de6ba6134e07805931f1a25d
BLAKE2b-256 checksum
How to use checksums
7b75d77d5ed95a9dbcfa8ba1c1aab35d2a614833256a538bfc859e638d53b63c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.1

Release files / pegreet-0.4.2-py3-none-any.whl

Download URL pegreet-0.4.2-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc649c83186a68469e37396a646a0e0eebad7c86fd200f1a33ab7e66d6169475
BLAKE2b-256 checksum
How to use checksums
3eaa652f84c9cbb798a278ecbde39ae55a111fb196618e2571e2af9d6de7c67d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.1

Security for pegreet 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page