Skip to content

Instantly share code, notes, and snippets.

@gavz
gavz / PinTrace.cpp
Created May 7, 2024 10:33 — forked from GitMirar/PinTrace.cpp
Pintool for API call tracing
/*
* PinTrace
*
* API call trace tool built with intel pin (https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads).
*
* CC by [email protected]
*
* This module can either be run in audit mode (-a flag) or provided with a config file (-c path/to/config).
*
* The config format is as follows:
@gavz
gavz / win32_hook.h
Created May 3, 2024 22:14 — forked from ghorsington/win32_hook.h
EAT and IAT hook
/*
* EAT-based hooking for x86/x64.
*
* Big thanks to ez (https://github.com/ezdiy/) for making this!
*
* Creates "hooks" by modifying the module's export address table.
* The procedure works in three main parts:
*
* 1. Reading the module's PE file and getting all exported functions.
* 2. Finding the right function to "hook" by simple address lookup
/*
* fork.c
* Experimental fork() on Windows. Requires NT 6 subsystem or
* newer.
*
* Copyright (c) 2012 William Pitcock <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
// iThome 2020 Demo: Signature Patcher for Explorer
// author: [email protected]
#include <iostream>
#include <Windows.h>
int main() {
DWORD explorer_pid;
GetWindowThreadProcessId(FindWindowA("Shell_TrayWnd", NULL), &explorer_pid);
if (HANDLE token = OpenProcess(PROCESS_ALL_ACCESS, FALSE, explorer_pid)) {
@gavz
gavz / vehMon.cpp
Created May 3, 2024 22:14 — forked from aaaddress1/vehMon.cpp
VEH Monitor
// VEH Montior by [email protected]
#include <stdio.h>
#include <windows.h>
#pragma warning( disable : 4996 )
LONG __stdcall TrapFilter(PEXCEPTION_POINTERS pexinf) {
if (pexinf->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && ((DWORD)pexinf->ExceptionRecord->ExceptionAddress & 0x80000000))
pexinf->ContextRecord->Eip = pexinf->ContextRecord->Eip ^ 0x80000000;
else if (pexinf->ExceptionRecord->ExceptionCode != EXCEPTION_SINGLE_STEP)
return EXCEPTION_CONTINUE_SEARCH;
@gavz
gavz / http_download.h
Created May 3, 2024 22:13 — forked from aaaddress1/http_download.h
using WinHTTP to obtain binary data (MSVC)
// using WinHTTP to obtain binary data (MSVC)
// by [email protected]
#include <vector>
#include <stdio.h>
#include <windows.h>
#include <Winhttp.h>
#pragma comment(lib, "winhttp")
using namespace std;
vector<char>* httpRecv(const wchar_t url[]) {
@gavz
gavz / memcpy32.cpp
Created May 3, 2024 22:13 — forked from aaaddress1/memcpy32.cpp
memcpy32.cpp
// memcpy 32bit by [email protected]
#include <stdint.h>
#include <stdio.h>
#include <windows.h>
int main(void) {
int dummy(0x41414242);
char buf[8] = {0};
((void(cdecl *)(DWORD, DWORD, DWORD))"\x8B\x7C\x24\x04\x8B\x74\x24\x08\x8B\x4C\x24\x0C\xF3\xA4\xC3")((size_t)buf, (size_t)&dummy, sizeof(dummy));
puts(buf);
@gavz
gavz / wow64_read64Env.cpp
Created May 3, 2024 22:12 — forked from aaaddress1/wow64_read64Env.cpp
fetch current EXE path from 64 bit PEB->Ldr (In 32 bit mode)
// fetch current EXE path from 64 bit PEB->Ldr (In 32 bit mode)
// by [email protected]
#include <stdint.h>
#include <stdio.h>
#include <windows.h>
typedef struct _PEB_LDR_DATA64
{
ULONG Length;
BOOLEAN Initialized;
ULONG64 SsHandle;
@gavz
gavz / wow64Mem_Forensics.cpp
Created May 3, 2024 22:12 — forked from aaaddress1/wow64Mem_Forensics.cpp
get 64 bit windows API address in pure 32 bit mode
// get 64 bit Windows API in pure 32 bit mode!
// it's necessary to disable all the compiler optimization if you're using MSVC.
// more detail check out ReWolf's amazing trick: blog.rewolf.pl/blog/?p=102
// by [email protected]
#include <iostream>
#include <stdio.h>
#include <windows.h>
// ref: raw.githubusercontent.com/rwfpl/rewolf-wow64ext/master/src/wow64ext.h
#include "wow64ext.h"
@gavz
gavz / x96_shellcode.py
Created May 3, 2024 22:12 — forked from aaaddress1/x96_shellcode.py
Python Script to Generate x96 Windows Shellcode
# x96_shellcode.py
# ref: gist.github.com/aaaddress1/3c0ae754f8a40024881343a085954049
# by [email protected]
'''
entry:
call $+5
mov ax, cs
sub ax, 23h
je retTo32b
nop