Coder Social home page Coder Social logo

yaoyi2008 / pindemonium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phat3/pindemonium

0.0 1.0 0.0 20.91 MB

A pintool in order to unpack malware

License: GNU General Public License v3.0

C++ 52.49% C 43.86% Python 1.01% AutoHotkey 0.02% Batchfile 0.04% Makefile 0.46% Ruby 0.24% JavaScript 1.76% HTML 0.12%

pindemonium's Introduction

PINdemonium

An unpacker for windows executables exploiting the capabilities of PIN.

Dependencies

Installation

  1. Download the linked version of PIN

  2. Unzip PIN to the root directory and rename the folder to pin

  3. Clone this repository

  4. Extract the archive in PINdemonium/ScyllaDependencies/diStorm.rar into PINdemonium/Scylla/

  5. Extract the archive in PINdemonium/ScyllaDependencies/tinyxml.rar into PINdemonium/Scylla/

  6. Extract the archive in PINdemonium/ScyllaDependencies/WTL.rar into PINdemonium/Scylla/

  7. Open the file PinUnpacker.sln with Visual Studio 2010 ( NB: The version is mandatory )

  8. Create a folder C:\pin and copy the folders PINdemonium\PINdemoniumDependencies and PINdemonium\PINdemoniumResults in C:\pin\

  9. Be sure that you are compiling in Release mode

  10. Be sure that all the module inside the project are compiled using the platform toolset v100 ( you can see this with right click on the module -> Properties -> platform toolset field )

  11. Compile the solution

  12. Optional : Create a folder called PINdemoniumPlugins in C:\pin\

	\---C
	    \---pin
			   \+---source
			   	| 	     
			   	|
			   	|
			   \+---PINdemoniumResults
			   	|
			   	|
			   	|
			   	|
			   \+---PINdemoniumDependencies 
			   	|						  
			   	|			              	\---config.json
			   	|					\---Yara
			   	|								\--yara_rules.yar
			   	|								\--rules
			   	|					\---Scylla
			   	|								\---ScyllaDLLRelease
			   	|									\---ScyllaDLLx86.dll
			   	|								\---ScyllaDLLDebug
			   	|									\---ScyllaDLLx86.dll
			   	|								\---ScyllaDumper.exe
			   	|
			   	|
			   	|
			   \+---PINdemoniumPlugins
			   	|
			   	|
			   	|
			   	|
			   \+---PINdemonium.dll

Usage

  1. Run this command from the directory C:\pin\

    pin -t PINdemonium.dll [-flags] -- <path_to_the_exe_to_be_instrumented>
    

    Flags :

    • -iwae <number_of_jump_to_dump> : specify if you want or not to track the inter_write_set analysis dumps and how many jump

    • -poly-patch: if the binary you are analyzing has some kind of polymorphic behavior this activate the patch in order to avoid pin to execute the wrong trace.

    • -plugin <name_of_the_plugin>: specify if you want to call a custom plugin if the IAT-fix fails (more information on in the Plugin system section).

  2. Check your result in C:\pin\PINdemoniumResults\< current_date_and_time >\

Plugin System

PINdemonium provides a plugin system in order to extend the functionalities of the IAT fixing module.

To write your own plugin you have to:

  1. Copy the sample project called PINdemoniumPluginTemplate located in PINdemonium\PINdemoniumPlugins\ wherever you want.

  2. Change the name of the project with a name of your choice

  3. Implement the function runPlugin

  4. Compile the project

  5. Copy the compiled Dll in C:\pin\PINdemoniumPlugins

  6. Launch PINdemonium with the flag plugin active followed by your plugin name (EX : -plugin PINdemoniumStolenAPIPlugin.dll)

Inside the template two helper function are provided:

  • readMemoryFromProcess : this function reads the memory from the specified process, at the specified address and copies the read bytes into a buffer

  • writeMemoryToProcess : this function writes the bytes contained inside a specified buffer into the process memory starting from a specified address

Yara Rules

Every time a dump is taken yara is invoked and the rules contained inside C:\pin\PINdemoniumDependencies\Yara\yara_rules.yar are checked. The current rule comes from https://github.com/Yara-Rules/rules: - rules\evasion_packer : Try to identify antiVM/antiDebug techniques and the presence of a known packer - rules\malware: Try to identify the malware family of the unpacked stage

Config

Config file located at C:\pin\PINdemoniumDependencies\config.json contains variables which allow to set the location of the outputs

Results

Results are located at C:\pin\PINdemoniumResults\< current_date_and_time >\ and contains:

  • report_PINdemonium: Json file which contains the most important information about the unpacking process;
  • log_PINdemonium.txt: Log which contains useful debugging information

Report Structure

{  
	//Array containing information for each dump
   "dumps":[             
      {  
         "eip":4220719,         	 //EIP where the dump was taken     
         "start_address":4220439,	 //start address of the Write-set block
         "end_address":4221043,		 //end address of the Write-set block
         "heuristics":[
            {	
            	//Yara Rules Heuristic
               "matched_rules":["ASProtectv12AlexeySolodovnikovh1"],
                "name":"YaraRulesHeuristic",
                "result":true
            },
            {  
            	//Long Jump Heuristic
               "length":1801,					
               "name":"LongJumpHeuristic",
               "prev_ip":4218918,
               "result":true
            },
            {  
            	//Entropy Heuristic
               "current_entropy":5.7026081085205078,    
               "difference_entropy_percentage":0.0014407391427084804,
               "name":"EntropyHeuristic",
               "result":false
            },
            {  
            	//Jump Outer Section Heuristic
               "current_section":".data",			
               "name":"JumpOuterSectionHeuristic",
               "prev_section":".data",
               "result":false
            }
         ],
         "imports":[  
			//.... Imported functions....
         ],
         "intra_writeset":false,
         "number":0,
         "reconstructed_imports":0
       
      },
   ]
}

Thanks

This work has been possible thanks to:

  1. NtQuery/Scylla

  2. Yara-Rules/rules

  3. VirusTotal/yara

pindemonium's People

Contributors

degrigis avatar fonstest avatar phat3 avatar pindemonium avatar r0rshark avatar stefano92 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.