
Rogue Assembly Hunter ist ein Dienstprogramm zum Auffinden 'interessanter' .NET CLR-Module in laufenden Prozessen.
__________ _____ . .
_____ \ ____ ____ __ __ ____ / _ \ ______ ______ ____ _ | | | ..
| // _ \ / __| | _/ __ \ / /\ \ / // __// __ \ / | __ | |< | |
| | ( <> ) // > | /\ / / | \ \ _ \ /| Y Y \ _\ \ |_ |
|| /_/_ /|/ _ > _| /____ >____ >___ >|| / /____/ |
/ // / / / / / / / /
___ ___ __
/ | \ __ __ / | ___________
/ ~ \ | / \ __/ __ _ __
\ Y / | / | \ | \ /| | /
_| /|/|| /| _ >|
/ / /
Rogue Assembly Hunter ist ein Dienstprogramm zum Auffinden von „interessanten“ .NET CLR-Modulen in laufenden Prozessen.
.NET ist eine sehr leistungsfähige und vielseitige Entwicklungsplattform und Laufzeitumgebung zum Erstellen und Ausführen von verwalteten .NET-Anwendungen. In den letzten Jahren wurde .NET von Red Teams (und ähnlichen Gruppen) übernommen, um Handwerkszeug für offensive Operationen zu instrumentieren. Insbesondere der Wechsel von offensivem PowerShell zu .NET war (für viele) ein logischer Schritt, da PowerShell v5+ eine erhöhte Transparenz und opportunistische Sichtbarkeit bietet. Infolgedessen wurde offensive .NET-Tooling und -Handwerkszeug erfolgreich eingesetzt, um hostbasierte Sicherheitsfunktionen zu umgehen, Anwendungssteuerungen zu umgehen und bösartigen Code (ähnlich wie PowerShell) zu erstellen, zu inszenieren, zu liefern und auszuführen.
Aus präventiver Sicht unternimmt Microsoft mehr, um .NET-instrumentierte Bedrohungen zu bekämpfen und die gesamte .NET-Angriffsfläche zu minimieren. Beispielsweise hat Microsoft AMSI-Inspektionsfunktionen in .NET Framework 4.8 hinzugefügt, und WDAC-/WLDP-Mechanismen sind sehr effektiv. Aus Erkennungs-/Reaktionsperspektive ist eine weitere Sichtbarkeit und Einsicht in das .NET-Ökosystem stets vorteilhaft, um neue Wege zur Bekämpfung von .NET-spezifischen Bedrohungen zu entdecken.
Im Jahr 2017 veröffentlichte Joe Desimone (@dez_) einen fantastischen Artikel mit dem Titel Hunting For In-Memory .NET Attacks. Der Artikel, der auch heute noch relevant ist, beschreibt moderne .NET-Angriffsvektoren sowie On-Demand- und ereignisbasierte Erkennungstechniken. Begleitend zum Artikel veröffentlichte Joe ein Tool (Get-ClrReflection), um proaktiv In-Memory-.NET-CLR-Module zu erkennen (und abzurufen), denen ein ordnungsgemäßer Datenträgerverweis fehlt. Inspiriert von Joes Arbeit und unter Ausnutzung der Introspectionsfähigkeiten der CLRMD-Laufzeitdiagnosebibliothek (+ der anschließenden Datenzugriffsfähigkeiten von mscordacwks.dll) wurde Rogue Assembly Hunter erstellt, um:
--checks und --sleep zu verwenden, um dies zu verbessern (insbesondere im „watch“-Modus). In einigen Fällen kann es schwierig sein, eine bestimmte Assembly-Ladung aufgrund der Ausführungsgeschwindigkeit zu „erwischen“ (z. B. execute-assembly und Opferprozesse).[*] Parameters:
--mode=<.> : Required | Select analysis mode. Options include sweep, process, and watch.
--hunt=<.> : Optional | Select the hunt scan type to find interesting CLR modules. Specify all (default), memory-only, unusual-dir,
sig-status, imposter-file, or list.
--export=<.> : Optional, Experimental | Specify a file path to export loaded CLR modules for in-memory hunt scans and imposter-file hunt scans
(e.g. --hunt=memory-only/imposter-file/all).
--pid=<.> : Optional | Specify a targeted process by PID. Must be used with --mode=process parameter/value.
--checks=<.> : Optional | Specify a value for scan cycles. This may help reduce race condition misses during scans but could also repeat result output.
Default value is 1.
--sleep=<.> : Optional | Specify a value for sleep seconds. This may help reduce race condition misses during scans by delaying the check cycle.
Default value is 0 seconds.
--debug : Optional | Display exception information (e.g. process connect errors).
--nobanner : Optional | Suppress the display banner. Useful for executing with the PowerShell script or for use cases that leverage automation.
--suppress : Optional | Do not scan the RogueAssemblyHunter process during --mode=sweep or --mode=watch.
--help : Optional | Show this help. This will override any other cmdline parameters and exit the application. *This is the default without parameters.
[*] Modes (--mode=)
- sweep : Scan/iterate through all processes (Note: Only processes of like architecture/'bitness' will be successfully scanned. Compile to run for x86/x64/etc.).
- process : Scan a single process. Use with --pid=<PID>.
- watch : Scan new processes when created. Adjust scan attributes with --checks and --sleep. (Note: This is experimental. Race conditions are likely.)
[*] Hunts (--hunt=)
- all : Default value. Analyze with all hunt options (Except 'list').
- memory-only : Memory hunt. Analyze CLR modules that are not backed by disk.
- unusual-dir : Unusual directory hunt. Analyze CLR modules loaded outside of 'normal' directories.
Edit '_huntUnusualDirectoryFilter' to customize.
- sig-status : File signature hunt. Analyze CLR modules with anomalous signature status (e.g. unsigned). Note: This is experimental. False positives are possible.
Edit '_huntSigExclusionsFilter' to customize.
- imposter-file : Unexpected CLR module hunt. Analyze CLR module with suspicious disk file backing. Experimental.
- list : Iterate through all CLR modules and list accordingly.
[*] Example Usage
- Example 1 : Scan processes and run through all hunts for accessible 64-bit processes (except 'list') -
RogueAssemblyHunter_x64.exe --mode=sweep
- Example 2 : Scan processes, list all CLR modules in accessible 32-bit managed processes, and show error information -
RogueAssemblyHunter_x86.exe --mode=sweep --hunt=list --debug
- Example 3 : Watch for new processes, scan all CLR modules (if managed and 64-bit), do not scan the RogueAssemblyHunter process, and do 2 checks with a 3 second delay between -
RogueAssemblyHunter_x64.exe --mode=watch --suppress --checks=2 --sleep=3
- Example 4 : Scan single process by PID, list in-memory only CLR module findings, and export CLR modules to specified path -
RogueAssemblyHunter_x86.exe --mode=process --pid=4650 --hunt=memory-only --export=c:\evilassemblies\
- Example 5 : Scan processes, list in-memory only CLR module findings for accessible 64-bit processes, do no scan RogueAssemblyHunter process, and do not show title banner -
RogueAssemblyHunter_x64.exe --mode=sweep --hunt=memory-only --suppress --nobanner
Der Einfachheit halber wurden ein PowerShell-Skript sowie zwei kompilierte Binärdateien (RogueAssemblyHunter_x64.exe und RogueAssemblyHunter_x86.exe) im Ordner \Release beigefügt. Passen Sie diese bei Bedarf an Ihre Anwendungsfälle an (z. B. Bereitstellung, Einbettung, Prüfungen, Ruhezeit usw.).
Beispielverwendung:
Führen Sie Invoke-RogueAssemblyHunter im Sweep-Modus aus und überprüfen Sie alle Jagdoptionen
cd c:\path\to\RogueAssemblyHunter
import-module .\Invoke-RogueAssemblyHunter.ps1
Invoke-RogueAssemblyHunter
Führen Sie Invoke-RogueAssemblyHunter im Watch-Modus aus und überprüfen Sie alle Jagdoptionen
cd c:\path\to\RogueAssemblyHunter
import-module .\Invoke-RogueAssemblyHunter.ps1
Invoke-RogueAssemblyHunter -ScanMode watch
SHA256-Hashes:
e804711a8b6469f1b13b388de47dfa6dde1c85279d365db7b6e19e1644990fa6 Invoke-RogueAssemblyHunter.ps1
cc985d918e566671aa209142abc55bd798ca6c1a18730b785ac8c18d489736c3 RogueAssemblyHunter_x64.exe
ae3aead43871e263cd8465d5356c4daaae0635714321f872c931ec825008287a RogueAssemblyHunter_x86.exe