pefile-go

command module
v0.0.0-...-deef810 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2016 License: MIT Imports: 4 Imported by: 0

README

pefile

Parsing Pefile (Portable Executable) in Golang

$ cd pefile-go/
$ go build
$ ./pefile-go ./exe_test_files/00b6ea24092c43db96e4dec79dfcdafd301c78a3d0ebaa27d8d5e4934793876d
Features :
  1. Import Hash calculation
  2. Section Hash Calculation ( md5, sha1,sha256,sha512)
  3. Extract Section string

Usage

	pefile, err := pe.NewPEFile(args[0])
	if err != nil {
		log.Println("Ooopss looks like there was a problem")
		log.Println(err)
		return
	}

	log.Println("Imphash : ", pefile.GetImpHash())

	for _, section := range pefile.Sections {
		fmt.Println("-------------------------")
		data := pefile.GetData(section)
		name := fmt.Sprintf("%s", section.Data.Name)
		md5 := section.Get_hash_md5(data)
		sha256 := section.Get_hash_sha256(data)
		entropy := section.Get_entropy(data)
		fmt.Println("name:", name)
		fmt.Println("md5 : ", md5)
		fmt.Println("sha256:", sha256)
		fmt.Println("entropy:", entropy)
	}

pefile is a multi-platform Python module to parse and work with Portable Executable (aka PE) files. Most of the information contained in the PE headers is accessible as well as all sections' details and their data.

The structures defined in the Windows header files will be accessible as attributes in the PE instance. The naming of fields/attributes will try to adhere to the naming scheme in those headers. Only shortcuts added for convenience will depart from that convention.

pefile requires some basic understanding of the layout of a PE file. Armed with it it's possible to explore nearly every single feature of the file format.

Features

Some of the tasks that pefile makes possible are:

Please, refer to Usage Examples for some code snippets showing how to use pefile.

A few examples of what a dump produced with pefile look like can be found here for a packed file, here for one of kernel32.dll and here for one of TinyPE.

In order to work with authenticated binaries, including Authenticode signatures, please check the project verify-sigs

pefile runs in several pipelines scanning hundreds of thousands of new PE files every day and, while not perfect, it has grown to be pretty robust over time. That being said small glitches are found every now and then. If you bump into a PE that does not appear to be processed correctly, do report it please! it will help make pefile a tiny bit more tough.

Dependencies

pefile is self-contained. It has no dependecies and it is endianness independent, it works on OS X, Windows, and Linux.

Projects and products using pefile

Additional resources

PDFs of posters depicting the PE file format:

The following links provide detailed information about the PE format and its structures.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL