• This repository has been archived on 11/Jun/2022
  • Stars
    star
    854
  • Rank 53,369 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

x86/x64 C++ Hooking Library

PolyHook - x86/x64 Hooking Library

Provides abstract C++ 11 interface for various hooking methods

Technical Writeup: https://www.codeproject.com/articles/1100579/polyhook-the-cplusplus-x-x-hooking-library

OUTDATED

Please use V2: https://github.com/stevemk14ebr/PolyHook_2_0. Consider sponsoring my development by clicking sponsor up in the top right!

Hooking Methods*:

  1. Detour
  • Description: Modifies opcode to jmp to hook and allocates a trampoline for jmp back
  • Length Disassembler Support (Capstone)
  • Supports Code Relocation, including EIP/RIP relative instructions
  1. Virtual Function Detour :
  • Description: Detours the function pointed to by the Vtable
  1. Virtual Function Pointer Swap
  • Description: Swaps the pointer in the Vtable to your hook
  1. Virtual Table Pointer Swap
  • Description: Swaps the Vtable pointer after copying pointers in source Vtable, then swaps virtual function pointer in the new copy
  1. Import Address Table
  • Description: Swaps pointer in the import address table to the hook
  1. VEH
  • Description: Intercepts an exception generated on purpose, sets instruction pointer to handler, then resets exception generating mechanism

  • Methods to generate exception: INT3 Breakpoints, Guard Page violations.

  • Note: it is important to call the GetProtectionObject function INSIDE of your callback as per my example for all VEH hooks

  • Other exception generation methods are in development

  • All methods support x86 and x64

  • Relies on modified capstone branch https://github.com/stevemk14ebr/capstone

  • More Information can be found at the wiki to the right

Credits to DarthTon, evolution536, Dogmatt

Samples:

The file Tests.cpp provides examples for every type of hooking method. Accompanied with these examples is unit testing code provided by the fantastic library Catch (https://github.com/philsquared/Catch/blob/master/docs/tutorial.md). With the addition of this code the example may look a little complex, the general interface is extremely simple, all hook types expose setup, hook, and unhook methods:

std::shared_ptr<PLH::Detour> Detour_Ex(new PLH::Detour);
Detour_Ex->SetupHook((BYTE*)&MessageBoxA,(BYTE*) &hkMessageBoxA); //can cast to byte* to
Detour_Ex->Hook();
oMessageBoxA = Detour_Ex->GetOriginal<tMessageBoxA>();
Detour_Ex->UnHook();

LICENSE:

MIT

More Repositories

1

PolyHook_2_0

C++20, x86/x64 Hooking Libary v2.0
C++
1,561
star
2

RETools

My reversing tools. Some custom, some not.
C++
140
star
3

UniHook

Intercept arbitrary functions at run-time, without knowing their typedefs
C
84
star
4

CompileTime-String-Encryption

C++ 17 compile time string encryption supporting vs2010-2019
C
69
star
5

DX11Overlay

Object Oriented Overlay For Game Hacking
C++
40
star
6

BF4-AtomBot

Latest version of my personal BF4 Hack
C
39
star
7

Snake

C# Snake Game
C#
15
star
8

Star-Wars-BattleFront-Hack

C
11
star
9

OpenSSL_Wrapper

RSA/AES OpenSSL Wrapper
C++
11
star
10

HashBrowns

C++ BCrypt Library, using OpenWall's library
C++
9
star
11

VS2013-Compile-Time-XOR

Compile time string XOR for visual studio 2010-2013
C++
9
star
12

PVZ-Hack

Personal MultiHack for Plants Vs. Zombies: Garden Warfare
C++
8
star
13

MultiSnap

An alternative "Aero-Snap" experience for multi-monitor setups
C#
7
star
14

GeLuBigNum

A (tiny) bignumber library that implements multiplication with the Genaille Lucas rulers.
C++
5
star
15

DaMenu

C++ 11 Event Drive, Object Oriented GUI.
C++
4
star
16

Random-Generator

C++ Style PRNG
C++
3
star
17

GetAllControls

Enumerates controls and windows of injected process
C++
3
star
18

VideoCall

JS WebRTC video chat client + relay server
JavaScript
3
star
19

Fractal-Generator

C# Fractal Generator
C#
3
star
20

Auto-Voter

VB.Net Automated Poll Voter
Visual Basic
2
star
21

FlareOn2020_Wednesday-3

In memory bot for flareon 2020 challenge #3
C++
2
star
22

FanController

Arduino based custom PC fan controller, supports up to 5 fans.
C++
1
star
23

NgrokRouter

Displays and serves open ngrok tunnels via json
JavaScript
1
star
24

JetSpeedBF3

Bf3 Hack to show the speed of a jet while in 3rd person
C++
1
star
25

DES

Des Utility, 8 character ascii key, N byte data processed in 64bit blocks
C++
1
star
26

PySON

Simple class to convert a JSON string or Python dictionary into relational classes
Python
1
star
27

JarvisPy

Jarvis voice assistant. For use with Rpi3 B + Respeaker Mic Array v2.0
Python
1
star