Day 12 Notes
Day 12 Notes
Day 12 Notes
Sniffing, in the context of network security, refers to the process of monitoring and
capturing data packets that are transmitted over a network. This technique can be used by
network administrators for legitimate purposes such as network monitoring and
troubleshooting, but it can also be exploited by attackers to intercept sensitive information such
as passwords, email content, and other confidential data. Here’s a detailed explanation of
sniffing:
Types of Sniffing
1. Passive Sniffing:
o Definition: In passive sniffing, the sniffer quietly listens to the network without
altering the traffic.
o Scope: Works effectively in a network environment using hubs because hubs
broadcast all network traffic to all devices.
o Detection: Difficult to detect because it doesn't generate any extra network
traffic.
2. Active Sniffing:
o Definition: In active sniffing, the attacker actively injects packets into the
network to induce responses that help in capturing data.
o Scope: Effective in switched networks where data is sent directly to the intended
recipient, requiring the attacker to disrupt normal operation.
o Techniques: Includes methods like MAC Flooding, ARP Spoofing, and DNS
Spoofing to force the switch into broadcasting traffic.
Two common sniffing techniques: Man-in-the-Middle (MITM) attacks and ARP Spoofing,
along with practical demonstrations.
1. Man-in-the-Middle (MITM) Attack
Explanation
A Man-in-the-Middle (MITM) attack occurs when an attacker intercepts the communication
between two parties without their knowledge. The attacker can eavesdrop, capture sensitive
data, or even alter the communication.
Practical Demonstration
Tools Needed
Kali Linux: A popular Linux distribution for penetration testing.
Ettercap: A comprehensive suite for MITM attacks on a LAN.
Wireshark: A network protocol analyzer to capture and inspect packets.
Steps
1. Setup the Environment:
o Ensure all devices (attacker's machine, victim's machine, and the router) are
connected to the same network.
2. Launch Ettercap:
$ ettercap -G
o This command opens the graphical user interface of Ettercap.
3. Configure Ettercap:
o In the Ettercap GUI, select Sniff > Unified Sniffing.
o Choose the network interface (e.g., eth0) and click OK.
4. Scan for Hosts:
o Go to Hosts > Scan for hosts.
o After scanning, view the host list via Hosts > Hosts List.
5. Select Targets:
o Add the router (gateway) to Target 1.
o Add the victim's machine to Target 2.
o Use the Add to Target 1 and Add to Target 2 buttons respectively.
6. Start MITM Attack:
o Navigate to Mitm > ARP poisoning.
o Check Sniff remote connections and click OK.
7. Capture and Analyze Traffic:
o Open Wireshark and start capturing on the same network interface.
o Filter the packets by the victim's IP address to view intercepted traffic.
o Look for interesting packets, such as HTTP requests, which may contain sensitive
information.
2. ARP Spoofing
Explanation
ARP Spoofing is a technique where the attacker sends falsified ARP (Address Resolution
Protocol) messages to associate their MAC address with the IP address of another host, usually
the gateway. This allows the attacker to intercept, modify, or stop data intended for the target
IP.
Practical Demonstration
Tools Needed
Kali Linux: For the attacker's machine.
arpspoof: A tool for ARP spoofing.
Wireshark: To capture and analyze traffic.
Steps
1. Setup the Environment:
o Ensure all devices (attacker's machine, victim's machine, and the router) are on
the same network.
2. Enable IP Forwarding:
$ echo 1 > /proc/sys/net/ipv4/ip_forward
o This allows the attacker’s machine to forward packets between the victim and
the router.
3. Launch arpspoof:
$ arpspoof -i eth0 -t <victim_ip> -r <router_ip>
o Replace <victim_ip> with the IP address of the victim machine.
o Replace <router_ip> with the IP address of the router.
4. Start Wireshark:
o Open Wireshark and start capturing on the same network interface.
o Filter packets by the victim’s IP address to view intercepted traffic.
5. Analyze Captured Traffic:
o Look for HTTP packets to find sensitive information like login credentials.
o Example Wireshark filter: http && ip.addr == <victim_ip>
Practical Usage: -
1. Starting Wireshark:
o Open Wireshark and select the network interface you want to capture traffic on
(e.g., eth0 or wlan0).
2. Capturing Packets:
o Click on the selected interface to start capturing packets.
o You will see a continuous stream of packets being captured in real-time.
3. Filtering Traffic:
o Use the display filter bar to filter packets of interest. For example:
http: Filters HTTP traffic.
ip.addr == 192.168.1.1: Filters packets to/from the IP address
192.168.1.1.
tcp.port == 80: Filters TCP traffic on port 80.
4. Analyzing Packets:
o Click on any packet to view detailed information.
o The packet details pane shows protocol information and data at various layers.
5. Saving and Exporting Captures:
o Save captured packets to a file for later analysis using File > Save As.
o Export packet data in various formats.
Example
Capture HTTP traffic between a client and server:
Start Wireshark and begin capturing on the network interface.
Filter traffic by typing http in the filter bar.
Open a web browser and visit an HTTP website.
Observe the HTTP requests and responses in Wireshark.
Tcpdump: -
Overview
Tcpdump is a powerful command-line packet analyzer. It allows users to capture and
display the packet headers on a network interface. Tcpdump is widely used for its simplicity and
effectiveness in capturing network traffic.
Features
Command-Line Interface: Operates entirely from the command line, making it suitable
for scripting and remote administration.
Filtering: Uses Berkeley Packet Filter (BPF) syntax for powerful and precise filtering.
Performance: Lightweight and efficient, making it ideal for use on servers and systems
with limited resources.
Versatility: Can capture and save packets to a file for later analysis or export them to
other tools like Wireshark.
Installation
Tcpdump is typically pre-installed on most Unix-like operating systems. On Debian-based
systems (e.g., Ubuntu), you can install it using:
$ wireshark http_traffic.pcap
Comparison and Usage Scenarios
Wireshark:
o Best suited for detailed packet analysis with a graphical interface.
o Ideal for in-depth examination of complex network issues.
o Useful for educational purposes and protocol analysis.
Tcpdump:
o Excellent for quick packet captures and remote analysis via SSH.
o Preferred for automated scripts and headless systems.
o Efficient for capturing packets on high-traffic networks with minimal resource
usage.
By understanding and utilizing both Wireshark and Tcpdump, you can effectively
capture, analyze, and troubleshoot network traffic in various environments.
Countermeasures to Sniffing
1. Encryption:
o Explanation: Encrypting data packets ensures that even if they are captured, the
information remains unreadable.
o Example: Using protocols like SSL/TLS, VPNs, or WPA2 for wireless networks.
2. Switches:
o Explanation: Using switches instead of hubs can reduce the risk of passive
sniffing, as they send data only to the intended recipient.
o Example: Implementing port security features on switches.
3. Network Monitoring:
o Explanation: Continuously monitoring network traffic can help detect unusual
patterns that may indicate sniffing activities.
o Example: Using Intrusion Detection Systems (IDS) like Snort.
4. Static ARP Entries:
o Explanation: Prevent ARP spoofing by manually assigning IP-to-MAC address
mappings.
o Example: Configuring static ARP entries on critical devices.
5. Network Segmentation:
o Explanation: Dividing the network into smaller segments can limit the impact of
sniffing and isolate suspicious activity.
o Example: Using VLANs to segregate network traffic.
Understanding sniffing and implementing robust countermeasures is crucial for
maintaining network security and protecting sensitive information from unauthorized access.
Social Engineering
Social engineering is a manipulation technique that exploits human error to gain private
information, access, or valuables. In the context of cybersecurity, it involves tricking people into
divulging confidential information or performing actions that compromise security. Unlike
technical hacking, social engineering relies on human interaction and often involves
manipulating people into breaking normal security procedures.
Pretexting: -
Description
Pretexting is a social engineering technique where an attacker creates a fabricated
scenario, or pretext, to engage a target and extract information or perform actions that benefit
the attacker. The attacker often pretends to be someone the victim trusts, such as a colleague,
IT support, or authority figure.
Common Scenarios
1. Impersonation of Authority Figures:
o Example: An attacker pretends to be a police officer or investigator needing
personal information for an investigation.
2. Tech Support Scams:
o Example: An attacker calls an employee, pretending to be from the IT
department, and asks for login credentials to fix a technical issue.
3. Vendor or Supplier Impersonation:
o Example: An attacker pretends to be a vendor requesting payment details or
other sensitive information.
4. Emergency Scenarios:
o Example: An attacker creates a sense of urgency, such as claiming there is a
security breach that requires immediate action from the victim.
Indicators of Pretexting
Unsolicited Requests: Unexpected calls or emails asking for sensitive information.
Pressure Tactics: Creating a sense of urgency or pressure to act quickly.
Inconsistent Information: Details that do not match known facts about the person or
organization the attacker is impersonating.
Requests for Sensitive Information: Asking for information that should not be disclosed,
such as passwords or financial details.
Countermeasures
1. Verification Protocols:
o Verify the identity of anyone requesting sensitive information through a
separate, trusted communication channel.
2. Employee Training:
o Train employees to recognize pretexting attempts and follow proper verification
procedures.
3. Access Control:
o Limit access to sensitive information to authorized personnel only.
4. Incident Reporting:
o Encourage employees to report suspicious interactions to the security team
immediately.
5. Regular Security Audits:
o Conduct regular audits and penetration tests to identify and address
vulnerabilities that could be exploited through pretexting.
By understanding and implementing countermeasures against these social engineering
techniques, organizations can significantly reduce the risk of falling victim to phishing and
pretexting attacks.