0% found this document useful (0 votes)
62 views50 pages

Red Team Malware Tools Overview

Koadic C3 is an advanced JScript/VBScript RAT that uses COM objects and system binaries like rundll32.exe, mshta.exe, and regsvr32.exe as a command and control mechanism. It has a plugin architecture that allows it to perform tasks like privilege escalation, credential dumping, and lateral movement. The presentation demonstrates Koadic's abilities like bypassing UAC and using Mimikatz through COM objects. Mitigations like blocking Windows script hosts and deleting COM objects are discussed.

Uploaded by

Austral Angler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views50 pages

Red Team Malware Tools Overview

Koadic C3 is an advanced JScript/VBScript RAT that uses COM objects and system binaries like rundll32.exe, mshta.exe, and regsvr32.exe as a command and control mechanism. It has a plugin architecture that allows it to perform tasks like privilege escalation, credential dumping, and lateral movement. The presentation demonstrates Koadic's abilities like bypassing UAC and using Mimikatz through COM objects. Mitigations like blocking Windows script hosts and deleting COM objects are discussed.

Uploaded by

Austral Angler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Koadic C3

COM Command & Control

DEF CON 25 - July 2017


Agenda
● Current open-source "malware" options for red teams
● Koadic (C3)
○ Advanced JScript/VBScript RAT
● The hell we went through
● Demos
whoami /all
● @zerosum0x0
● @Aleph___Naught
● @JennaMagius
● @The_Naterz

Red Team @ RiskSense, Inc


First things first...
● "SMBLoris" attack
○ Windows 0-day denial-of-service
SMBLoris
Notes
● Not responsible for other people's actions
● A ton of overlapping research, incremental work
○ Consolidate research/techniques
○ "Advances state of the art"
● Meme slides = dirty hack/workaround
● Prototype
○ Used on real engagements
○ Submit fixes, not tixes
Intrusion Phases
● Reconnaissance
● Initial Exploitation
● Establish Persistence
● Install Tools
● Move Laterally
● Collect, Exfil, and Exploit

Source: Rob Joyce, NSA/TAO Director, Enigma 2016


Current State of Windows Post Exploitation
● Yet but a few open-source "malware" options for red teams
○ Meterpreter
○ Cobalt Strike
○ PowerShell Empire
● Roll your own…
○ A decent option- the bad guys do
Downsides of PE Malware
● Meterpreter is amazing software!
● Post-exploitation (and some exploits [psexec]) often involve
dropping a binary
○ Binaries are what AV love
○ Need to evade payload
■ Veil Evasion
■ Shellter
Downside of PowerShell
● Empire is amazing software!
● Requires PowerShell (duh)
○ Officially- Server 2008 SP2*
○ Requires modern .NET
● Extensive logging/disabling mechanisms

* [Link]
WTS C3 - COM C&C
● Target Win2k SP0
○ Possibly earlier
● JScript/VBScript
○ Baked directly into the core of Windows
■ Not an addon-- harder to limit
○ Powerful COM exposed by the OS
○ Creative use of default .exe's
● Ways to execute completely in memory
○ The main benefit of PowerShell
COM Background
● Component Object Model
○ Language neutral
○ Object oriented
○ Binary interface
○ Distributed
● Arguable precursor to .NET
○ Slightly different goals and implementation
■ AKA "still relevant"?
● Found EVERYWHERE in Windows
Downsides of WSH
● No access to Windows API
● No real threading
● Missing a lot of "standard" functions
○ Base64
■ Can be done with other programs
● Unicode strings
○ Bad for making structs/shellcode
Downsides of VBScript
● Shlemiel the Painter problem with string indexing (Mid)
○ Inefficient string iterations
○ @JennaMagius: "Bring the Bucket With You"
● Insane exception handling method
○ "On error resume next", for every scope
● Definitely not lingua franca
Readline Improvements
● Readline is the interactive shell
● When shells/messages start to rain in…
○ Output overwrites input
● @JennaMagius fixed it, redraw
○ Commit to Metasploit in PR #7570
○ Still an issue in Empire
Koadic Terminology
● Zombie
○ a hooked target
● Stager
○ web server to perform hook
● Implant
○ starts jobs on a zombie
● Job
○ does something interesting
Architecture Overview
Plugin Architecture
● run() method
○ Stager - Spawns HTTP server
○ Implant - Starts Job
● ~VARIABLE~ based JS files
● "[Link]" helper functions
○ Run commands
○ Upload/download
○ File I/O
○ HTTP I/O
■ Report on jobs
Implant Categories
● Pivot
● Persistence
● Manage
● Elevate
● Gather
● Scan
● Fun
● Inject
Stager Architecture
● Generally, hook by manual command
○ Can hook from IE, Office macros, etc.
● Python simple HTTP/S threaded server
○ Encryption through TLS/SSL (depending on target)
● Long-poll
● When a job is ready, clones itself twice and dies
Stager Job Cloning
● Hook: If not "Session ID"
○ Assigned a session ID
■ Fork stage
● Stage: If "Session ID" present
○ long-poll to get a "Job ID"
■ Fork stage
■ Fork job
■ Exit
● Job: If "Session ID" && "Job ID"
○ Send job payload
■ Do work
■ Report
■ Exit
[Link]
● COM Scriptlets
○ Still written to disk
● Present on Windows 2000
● Less sandboxed than MSHTA
[Link] Stager
● HTML "Applications"
○ Access to registry, filesystem, shell, etc.
○ Some IE security zone sandboxing
● Payload is tiny
○ But missing on Windows 2000
Hidden HTA
● Experimented with
many techniques
to hide window

● Later saw malware


samples do same
thing
[Link]
● Abuses path/command line parsing
○ Loads [Link]
○ Executes JScript
● Basically same thing as [Link]
● Less Window visibility
○ MSHTA stager forks to [Link]
Script Unresponsive
● Can long-poll HTTP forever, np
○ Because it's a COM call
● Run too many lines of JScript
○ Even just a few milliseconds?
○ Abort!!

HKCU\Software\Microsoft\Internet Explorer\Styles\MaxScriptStatements
"Uploading" Files
● Binary data is hard to work with…
● Writing byte-by-byte uses limited instructions
● [Link]([Link])
○ Can't write stream directly to file
○ But… information theory allows it
"Uploading" Files
"Downloading" Files
● Post data is double encoded
○ Windows-1252
○ UTF-8
● Can't send NULL bytes \x00
○ We add another layer of encoding
■ \\ = \\\\
■ \0 = \\\x30
● Extremely slow to decode()
○ So we use hard-coded lookup table
DEMO
Upload+Download, SHA256 verify
UAC Bypasses
● [Link] by @enigma0x3
○ HKCU\Software\Classes\mscfile\shell\open\command
● [Link] by @enigma0x3
○ HKCU\Software\Classes\exefile\shell\runas\command
● [Link] by [Link]
○ HKCU\Software\Classes\ms-settings\shell\open\command
● UACME by @hFireF0X
○ Future work, 35+ methods
Dumping NTLM on Local Machines
● Stored in registry hives
○ reg save HKLM\SAM [Link] /y
○ reg save HKLM\SYSTEM [Link] /y
○ reg save HKLM\SECURITY [Link] /y
● Download to C3 server
● Decode with CoreSecurity/Impacket
○ [Link] -sam %s -system %s -security %s LOCAL
Dumping NTLM from Domain Controllers
● Make shadow copy
○ vssadmin create shadow /for=C:
○ copy shadow\windows\ntds\[Link] %TEMP%\[Link]
○ reg save HKLM\SECURITY [Link]
● Download to C3 Server
● Decode with CoreSecurity/Impacket
○ [Link] -ntds %s -system %s -hashes LMHASH:NTHASH LOCAL
DEMO
Bypass UAC, Hashdump
HTTP
● Several HTTP COM Object ProgIDs
○ [Link]
○ [Link]
○ [Link]
○ [Link]
○ [Link]
○ etc.
● Same basic interface
○ Drastically different behaviors
TCP Scanner
● Use HTTP object to "port scan"
○ AJAX Port Scanner
● Depending on status code, determine if port open
PSExec
● Microsoft signed
● No need to "upload" binary
○ \\[Link]@SSL\tools\
● "Dirty bit" are you sure?
○ Bypass is: use a different way to exec it?
● psexec \\computer\ -u domain\user -p pwd -accepteula ~CMD~
WMI
● Start command remotely
● Runs in session 0
○ No GUI = no UAC bypass
■ Need hacks
DEMO
TCP Scan, Pivot
Excel COM Object
● Work gave us Office licenses, we found a good use for them…
● Many workstations have Office
● Excel spreadsheets can be created in memory
○ No need for GUI at all
● Excel spreadsheets have macros
○ Run any VBA, with access to Windows API
■ Shellcode
■ Reflective DLLS
DotNetToJs
● Attack by @tiraniddo
● Uses COM objects installed with .NET
● Load custom serialized object
○ Access to Windows API
DynamicWrapperX
● Written by Yuri Popov (Freeware)
● Allows access to Windows API
● Drop DLL and Manifest
● Registration-free COM
○ Avoids COM registry writes
○ @subTee "re-discovered"
[Link]
● @clymb3r fork added to Mimikatz core
○ Goal: we want to use this existing DLL
● PowerShell Empire uses "memory module"
○ DLL mapping performed in PowerShell
■ Not reflective injection
■ We're limited on instructions
● "[Link]"
[Link]
● Normal Reflective DLL
● Built-in HTTP
● Determines if x64 system and x86 process
○ Forks if necessary
● Process hollowing of %WINDIR%\sysnative\[Link]
● Injects [Link]
○ privilege::debug - SeDebugPrivilege
○ token::elevate - NT AUTHORITY\SYSTEM
○ Runs the custom command
■ sekurlsa::logonPasswords
DEMO
Mimikatz
Mitigations
● Device Guard/AppLocker/CI
● Block:
○ WSH
○ HTA
○ SCT
● Delete all .exes!
● Delete all COM objects!
○ Including script parsers!
Add to Metasploit
● Additional targets for command/Binary drop modules
○ Such as psexec
● Iterate over all methods of forking to shellcode
○ Until one works
Future Work
● Clean up code
● JavaScript Minimizer/obfuscator
● getsystem
● Persistence implants
● Close some DoS vectors
Related Talks
● COM in Sixty Seconds
○ James Forshaw @ INFILTRATE 2017
● Windows Archaeology
○ Casey Smith and Matt Nelson @ BSides Nashville 2017
● Establishing a Foothold with JavaScript
○ Casey Smith @ Derbycon 2016
Thanks!
● @zerosum0x0
● @Aleph___Naught

[Link]

● DEF CON Workshop - Saturday @ 14:30 - Octavarius 5


○ Windows Post-Exploitation/Malware Forward Engineering
○ shellcode, winapi, COM, .NET

You might also like