DarkWidow
This is a Dropper/PostExploitation Tool (or can be used in both situations) targeting Windows.
Capabilities:
- Indirect Dynamic Syscall
- SSN + Syscall address sorting via Modified TartarusGate approach
- Remote Process Injection via APC Early Bird (MITRE ATT&CK TTP: T1055.004)
- Spawns a sacrificial Process as the target process
- ACG(Arbitrary Code Guard)/BlockDll mitigation policy on spawned process
- PPID spoofing (MITRE ATT&CK TTP: T1134.004)
- Api resolving from TIB (Directly via offset (from TIB) -> TEB -> PEB -> resolve Nt Api) (MITRE ATT&CK TTP: T1106)
- Cursed Nt API hashing
Bonus: If blessed with Admin privilege =>
- Disables Event Log via killing EventLog Service Threads (MITRE ATT&CK TTP: T1562.002)
Disadv: If threads are resumed, all events that occurred during the suspension of Event Logger, get logged Again!
So, thought of killing them instead!
"It's more Invasive than suspension, but the decision is always up to the operator. Besides, killing threads get logged on the kernel level" - @SEKTOR7net
While Killing only those threads in the indirect syscall implant, was facing an error. I was unable to get the "eventlog" SubProcessTag Value. So thought of killing all threads, i.e. killing the whole process (responsible svchost.exe). Yeah creating an IOC!.
= EDR/Ring-3/UserLand hook Bypass!
Compile:
Directly via VS compiler:
Also add /MT compiler flag! => To statically links CRT functions together in a binary (Yeah, U guessed it, it bloats the implant)
- Also via compile.bat (prefer option 1.)
./compile.bat
Usage:
PS C:> .\x64\Release\indirect.exe
[!] Wrong!
[->] Syntax: .\x64\Release\indirect.exe <PPID to spoof>
In Action:
DarkWidow.mp4
Sofos XDR Bypass:
Further Improvements:
- PPID spoofing (Emotet method)
- Much Stealthier Use Case of EventLog Disabling!
Portions of the Code and links those helped:
-
TIB:
-
GS and FS register:
-
PEB LDR structure:
-
TIB -> TEB -> PEB -> Resolve Nt API and API hashing
-
https://stackoverflow.com/questions/41277888/iterating-over-peb-dllname-shows-only-exe-name
-
https://doxygen.reactos.org/d7/d55/ldrapi_8c_source.html#l01124
-
labs.cognisys.group, a blog by @D1rkMtr
-
A pic of the snippet from the above link, which I used here to resolve API dynamically without HardCoding Offsets:
-
The Api hashing Script that I have Used:
-
def create_hash(input_string):
# Initialize the hash value to zero
hash_value = 0
# Iterate through each character in the input string
for char in input_string:
# Add the ASCII value of the character to the hash_value
hash_value += ord(char)
return hash_value
if __name__ == "__main__":
input_string = input("Enter the string to hash: ")
hashed_value = create_hash(input_string)
print("Hash:", hashed_value)
-
ACG(Arbitrary Code Guard)/BlockDll mitigation policy:
- links:
- Protecting Your Malware by @xpn
- Wraith by @winterknife
- spawn and HOLLOW by @0xBoku
-
PPID Spoofing Detection:
- PPID Spoofing Detect by @spotheplanet
- If got time, I will be adding a detection Portion to this portion! -> [Remaining..............................................!]
-
Moneta Detection and PESieve Detection:\
-
How Thread Stack Looks of the Implant Process:
Implant Process | Legit Cmd process |
---|---|
It follows that by executing the return instruction in the memory of the ntdll.dll in the indirect syscall POC, the return address can be successfully spoofed, the ntdll.dll can be placed at the top of the call stack and the EDR will interpret a higher legitimacy. - @VirtualAllocEx from DirectSyscall Vs Indirect Syscall
Also thanks to, @peterwintrsmith!
-
Killing Event Log Threads:
- rto-win-evasion by @SEKTOR7net
- Phant0m by @hlldz
- Goblin by @winterknife
- disabling-windows-event-logs-by-suspending-eventlog-service-threads by @spotheplanet
From here:
To here:
- This Method, Ended up causing errors in indirect syscall implementation. So, I ended up killing all those threads present within responsible svchost.exe (reason: Go up).
Major Thanks for helping me out (Directly/indirectly (pun NOT intended :))):
- @SEKTOR7net
- @peterwintrsmith
- @Jean_Maes_1994
- @D1rkMtr
- @spotheplanet
- @0xBoku
- @Sh0ckFR
- @winterknife
- @monnappa22
- @xpn
- @hlldz
I hope I didn't miss someone!