Skip to content

Miracle-Godwin-Ogbo/CodeAlpha_Basic_Network_Sniffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Basic Network Sniffer

Python Scapy CodeAlpha Status Platform

A Python-based network packet sniffer developed as Task 1 of the CodeAlpha Cybersecurity Internship. This project captures live network traffic and analyzes packet information including source and destination IP addresses, protocols, ports, services, payloads, and packet statistics using the Scapy library.

The project demonstrates the fundamentals of packet sniffing, network protocol analysis, and traffic monitoring while strengthening practical Python programming and cybersecurity skills.


🎯 Project Objective

The objective of this project was to:

  • Capture live network traffic packets
  • Analyze packet structure and contents
  • Understand how data flows through a network
  • Learn the basics of TCP/IP networking
  • Display useful packet information such as:
    • Source IP Address
    • Destination IP Address
    • Protocol
    • Source and Destination Ports
    • Services
    • Packet Length
    • Payload Data

✨ Features

  • Capture live network traffic
  • Supports user-defined packet count
  • Detect TCP, UDP and ICMP packets
  • Display source and destination IP addresses
  • Display source and destination ports
  • Detect common network services (HTTP, HTTPS, DNS, FTP, SSH, SMTP, etc.)
  • Detect encrypted HTTPS traffic
  • Display packet payloads
  • Display packet capture time
  • Display packet length
  • Generate a protocol summary after packet capture
  • Validate user input
  • Simple command-line interface

🛠️ Technologies Used

  • Python 3.13
  • Scapy
  • Visual Studio Code
  • Git
  • GitHub
  • Kali Linux
  • Windows Command Prompt

⚙️ How It Works

Packet Capture

  1. The user enters the number of packets to capture.
  2. Scapy captures live packets from the selected network interface.
  3. Each packet is inspected individually.

Packet Analysis

For every packet, the program displays:

  • Time
  • Source IP Address
  • Destination IP Address
  • Source Port
  • Destination Port
  • Service
  • Protocol
  • Packet Length
  • Payload Information

Capture Summary

After packet capture is complete, the program displays:

  • Total packets captured
  • TCP packet count
  • UDP packet count
  • ICMP packet count

▶️ Installation

1. Clone the Repository

git clone https://github.com/Miracle-Godwin-Ogbo/CodeAlpha_Basic_Network_Sniffer.git

2. Navigate to the Project Directory

cd CodeAlpha_Basic_Network_Sniffer

3. Install the Required Dependency

Windows

Install the required Python package using:

pip install -r requirements.txt

Kali Linux (Recommended)

Recent versions of Kali Linux implement PEP 668, which restricts installing Python packages system-wide using pip.

Install Scapy using Kali's package manager instead:

sudo apt update
sudo apt install python3-scapy

Alternative: If you prefer using requirements.txt, you can run:

pip3 install -r requirements.txt --break-system-packages

This overrides Kali's package protection and is generally recommended only for testing or virtual machine environments.


▶️ Running the Program

Windows

python network_sniffer.py

Kali Linux

sudo python3 network_sniffer.py

Note: Root (sudo) privileges are required on most Linux distributions to capture live network packets.


🧪 Example

User Input

How many packets do you want to capture?

10

Program Output

============================================================
Packet             : 1
Time               : 00:21:33
Source IP          : 172.20.10.3
Source Port        : 62509
Destination IP     : 140.82.113.26
Destination Port   : 443
Service            : HTTPS
Protocol           : TCP
Packet Length      : 84 bytes
Payload            : Encrypted HTTPS Data

Capture Summary

========================================
        CAPTURE SUMMARY
========================================
Total Packets Captured : 10
TCP Packets            : 6
UDP Packets            : 4
ICMP Packets           : 0
========================================

Capture Complete!

⚠️ Notes

  • Ensure Python 3 is installed before running the program.
  • The program captures only the number of packets specified by the user.
  • HTTPS payloads are encrypted and are displayed as Encrypted HTTPS Data.
  • Only capture traffic on networks that you own or have explicit authorization to analyze.


📸 Screenshots

The screenshots below demonstrate the development, execution, and testing of the Basic Network Sniffer project on both Windows and Kali Linux.

1. Visual Studio Code

The project developed and executed within Visual Studio Code.

Successful Packet Capture

Packet Capture

Capture Summary

Capture Summary

Input Validation

Demonstrates the program handling invalid user input.

Input Error


2. Windows Command Prompt

The project running successfully from the Windows Command Prompt.

Successful Execution

Windows Run

Invalid Input Handling

Windows Error Output


3. Kali Linux

The project cloned from GitHub and executed successfully on Kali Linux.

Successful Execution

Kali Linux Run

Invalid Input Handling

Kali Linux Error Output


📚 Concepts Learned

  • Packet Sniffing
  • Network Traffic Analysis
  • Scapy
  • TCP/IP Networking
  • TCP, UDP and ICMP Protocols
  • IP Addressing
  • Port Numbers
  • Common Network Services
  • Packet Payload Analysis
  • Python Loops
  • Conditional Statements
  • Dictionaries
  • Input Validation
  • Python Error Handling

🚀 Future Improvements

  • Export captured packets to PCAP format
  • Save packet logs to a file
  • Filter packets by protocol
  • Filter packets by IP address
  • Display MAC addresses
  • Display TCP Flags
  • Add packet timestamps from the capture itself
  • Real-time packet monitoring
  • Build a graphical user interface (GUI)

👨‍💻 Author

Miracle Godwin Ogbo

Junior Penetration Tester | Cybersecurity Analyst | Python Developer

Developed during the CodeAlpha Cybersecurity Internship.

GitHub

https://github.com/Miracle-Godwin-Ogbo

LinkedIn

https://www.linkedin.com/in/miracle-godwin-ogbo-19a3a2241


⚠️ Disclaimer

This project was developed for educational purposes as part of the CodeAlpha Cybersecurity Internship. It demonstrates packet sniffing and network traffic analysis using Python and Scapy.

The tool should only be used on networks that you own or where you have explicit authorization to capture network traffic. Unauthorized packet sniffing may violate privacy, organizational policies, or applicable laws.

Releases

Packages

Contributors

Languages