Day 12 Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Sniffing

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.

Common Sniffing Techniques


1. MAC Flooding:
o Description: Overloads a switch with fake MAC addresses, causing it to revert to
broadcast mode.
o Outcome: The switch starts sending all traffic to all ports, allowing the attacker to
capture the data.
2. ARP Spoofing:
o Description: Involves sending fake ARP (Address Resolution Protocol) messages
to associate the attacker’s MAC address with the IP address of another host.
o Outcome: The attacker can intercept, modify, or block data intended for the
target IP address.
3. DNS Spoofing:
o Description: The attacker sends fake DNS responses to redirect the victim to
malicious sites.
o Outcome: Victims can be tricked into providing sensitive information to a fake
website.

Tools Used for Sniffing


1. Wireshark:
o Description: A widely-used network protocol analyzer that captures and displays
packet data for analysis.
o Usage: Network troubleshooting, protocol development, and education.
2. Tcpdump:
o Description: A command-line packet analyzer tool available for Unix-based
systems.
o Usage: Captures and displays packets being transmitted or received over a
network.
3. Cain & Abel:
o Description: A tool for password recovery and network analysis, often used for
sniffing network traffic.
o Usage: ARP spoofing, password cracking, and other security-related tasks.
sniffing Techniques (MITM, ARP Spoofing)

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>

Sniffing Tools: Wireshark and Tcpdump


Both Wireshark and Tcpdump are powerful tools used for network packet analysis and
sniffing. Let's explore each tool in detail, including their features, usage, and practical examples.
Wireshark: -
Overview
Wireshark is a widely-used network protocol analyzer that captures and interactively
browses the contents of network packets. It is popular among network administrators, security
professionals, and developers for diagnosing network issues and analyzing traffic.
Features
 User-Friendly GUI: Provides a graphical interface to capture and analyze network
packets.
 Protocol Support: Supports a wide range of network protocols, with detailed packet
information.
 Filtering: Allows complex filtering options to focus on specific traffic.
 Reassembly: Reassembles TCP streams and displays them in a readable format.
 Color Coding: Uses color coding to highlight different types of traffic and protocols.

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:

$ sudo apt-get install tcpdump


Practical Usage
1. Capturing Packets:
$ sudo tcpdump -i eth0
o Captures packets on the eth0 interface.
2. Filtering Traffic:
o Use BPF syntax for filtering. Examples:
 $ tcpdump -i eth0 tcp port 80: Captures TCP traffic on port 80.
 $ tcpdump -i eth0 host 192.168.1.1: Captures traffic to/from the IP
address 192.168.1.1.
 $ tcpdump -i eth0 'tcp[tcpflags] & (tcp-syn|tcp-ack) != 0': Captures SYN
and ACK packets.
3. Saving Captures:
$ sudo tcpdump -i eth0 -w capture.pcap
o Saves captured packets to a file named capture.pcap for later analysis.
4. Reading Captures:
$ sudo tcpdump -r capture.pcap
o Reads and displays packets from a saved capture file.
Example
Capture and save HTTP traffic on the network interface eth0:

$ sudo tcpdump -i eth0 tcp port 80 -w http_traffic.pcap


 Open the saved file in Wireshark for detailed analysis:

$ 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.

Social Engineering Techniques: Phishing and Pretexting


Social engineering techniques exploit human behavior to gain unauthorized access to
systems, data, or physical locations. Two common techniques are phishing and pretexting. Let's
explore each in detail.
Phishing: -
Description
Phishing is a technique where attackers impersonate legitimate entities to deceive individuals
into providing sensitive information, such as usernames, passwords, credit card numbers, or
other personal data. Phishing attacks are typically conducted via email, but can also occur
through text messages (smishing) or other forms of electronic communication.
Types of Phishing
1. Email Phishing:
o Description: Attackers send mass emails that appear to come from reputable
sources (e.g., banks, social media sites) to trick recipients into clicking malicious
links or downloading attachments.
o Example: An email pretending to be from a bank, asking the recipient to verify
their account by clicking a link and entering their login details on a fake website.
2. Spear Phishing:
o Description: A targeted phishing attack where the attacker customizes the email
based on information about the victim to make it more convincing.
o Example: An email addressed specifically to a company executive with
personalized content and a request to transfer funds.
3. Whaling:
o Description: A type of spear phishing that targets high-profile individuals such as
executives or government officials.
o Example: An email appearing to be from a trusted advisor, asking the CEO to
approve a financial transaction.
4. Smishing (SMS Phishing):
o Description: Phishing conducted through SMS text messages.
o Example: A text message claiming to be from a service provider, asking the
recipient to click a link to resolve an issue with their account.
5. Vishing (Voice Phishing):
o Description: Phishing conducted via phone calls.
o Example: A caller pretending to be from technical support, asking for login
credentials to fix a computer issue.
Indicators of Phishing
 Suspicious URLs: Links that do not match the legitimate website or have slight
misspellings.
 Unusual Requests: Emails asking for personal information or urgent actions.
 Generic Greetings: Use of generic greetings like "Dear Customer" instead of the
recipient’s name.
 Unexpected Attachments: Unsolicited emails with attachments.
 Poor Grammar and Spelling: Often, phishing emails contain grammatical errors and
misspellings.
Countermeasures
1. Education and Training:
o Regularly train employees to recognize phishing attempts and report suspicious
emails.
2. Email Filtering:
o Use advanced email filtering solutions to detect and block phishing emails.
3. Multi-Factor Authentication (MFA):
o Implement MFA to add an extra layer of security, reducing the risk even if
credentials are compromised.
4. Verification Procedures:
o Establish procedures for verifying the legitimacy of email requests, especially
those involving sensitive information or financial transactions.
5. Regular Updates and Patching:
o Keep software and systems updated to protect against vulnerabilities exploited
by phishing attacks.

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.

You might also like