Giter VIP home page Giter VIP logo

myproc's Introduction

MyProc

MyProc (My Processus) is a windows Go module for in-process memory parsing and resolution of pointers and structures.

Static Badge Go Report GitHub

Table of contents

Features

myproc exports multiple functions and structures related to in-memory process parsing. The full list can be found here: pkg.go.dev/github.com/atsika/myproc

The most notable ones are:

  • NewDLL
  • NewProc

These functions are generic functions used to resolve module (DLL) handles and function (proc) addresses. They use Go reflection to determine the type of passed parameters.

They can be resolved by hash (API hashing), a common technique used to hide imported functions. The hashing algorithm used is FNV1A.

You can read more about those functions on my blog: https://blog.atsika.ninja/posts/custom_getmodulehandle_getprocaddress/

NewDLL

NewDLL accepts a string (DLL name) or a uint32 (DLL 32-bit hash). It returns a *windows.DLL. It retrieves a pointer to the PEB. Then, it parses the InLoadOrderModuleList by comparing the hashed DLL name with the given parameter. As a fallback, it tries to load the DLL. If the resolution fails, nil is returned.

NewProc

NewProc takes a *windows.DLL as first parameters and either a string (proc name), a uint16 (proc ordinal) or uint32 (proc 32-bit hash) as second parameter. It returns a *windows.Proc. It retrieves a pointer to the EXPORT_DIRECTORY of a module. It then parses it using the provided parameter to retrieve the function address. If the provided parameter is a string, then the resolution is done using binary search. Otherwise, a linear search is done. If the resolution fails, nil is returned.

Usage

  1. Import the module in your project.
import (
    "github.com/atsika/myproc"
)
  1. Resolve modules and functions.
kernel32 := myproc.NewDLL("kernel32.dll")
fmt.Printf("[string] kernel32 => %#2x\n", kernel32.Handle)

kernel32 = myproc.NewDLL(uint32(0xa3e6f6c3))
fmt.Printf("[hash]   kernel32 => %#2x\n", kernel32.Handle)

GetProcessHeap := myproc.NewProc(kernel32, "GetProcessHeap")
fmt.Printf("[string]  GetProcessHeap => %#2x\n", GetProcessHeap.Addr())

GetProcessHeap = myproc.NewProc(kernel32, uint16(0x2cc))
fmt.Printf("[ordinal] GetProcessHeap => %#2x\n", GetProcessHeap.Addr())

GetProcessHeap = myproc.NewProc(kernel32, uint32(0x967288f2))
fmt.Printf("[hash]    GetProcessHeap => %#2x\n", GetProcessHeap.Addr())

hHeap, _ , _ := GetProcessHeap.Call()
  1. Profit

An example of a classic process injection technique using this module and API hashing can be found in the example folder.

Changelog

  • 08/04/2024: Rename project and changed hashing algo (sdbm -> fnv1a) + ApiSet refacto
  • 21/02/2024: Added TEB definition
  • 31/08/2023: Added API sets V6 (Windows 10) resolution
  • 21/08/2023: Export some useful functions (GetPEB, GetDosHeader, GetNtHeaders, GetDataDirectory,...)
  • 01/08/2023: Initial release accompanying the blog post

Used in

License

This project is licensed under the MIT License - see the LICENSE file for details.

myproc's People

Stargazers

Leco 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.