Skip to content

About

Python and Scapy network packet sniffer with multi-layer protocol dissection and PCAP export for CodeAlpha Cyber Security Internship

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

CodeAlpha Network Sniffer

A Python-based network packet sniffer developed as part of the CodeAlpha Cyber Security Internship.

The application captures live network traffic, analyzes packet information using Scapy, displays useful network details, and saves captured packets in PCAP format for further analysis.

Features

  • Live network packet capture.
  • IPv4 and IPv6 address identification.
  • Ethernet MAC address extraction.
  • ARP, ICMP, TCP and UDP protocol identification.
  • TCP source and destination port extraction.
  • TCP flag identification.
  • DNS query and response analysis.
  • Extraction of DNS A and AAAA records.
  • Basic HTTP/TLS identification based on port numbers.
  • Payload extraction in hexadecimal format.
  • BPF packet filtering.
  • Save captured packets as PCAP files.
  • Configurable interface and packet count.

Technologies Used

  • Python 3
  • Scapy
  • Kali Linux
  • Wireshark (for PCAP inspection)

Project Structure

CodeAlpha_NetworkSniffer/
│
├── captures/
├── logs/
├── packet_analyzer.py
├── sniffer.py
├── test_analyzer.py
├── requirements.txt
├── README.md
└── .gitignore

Installation

1. Clone the repository

git clone https://github.com/psycho-champ/CodeAlpha_NetworkSniffer.git
cd CodeAlpha_NetworkSniffer

2. Install dependencies

pip install -r requirements.txt

3. Run the application

Root privileges are required for live packet capture.

sudo python3 sniffer.py

Usage

Capture packets on a specific interface

sudo python3 sniffer.py -i eth0

Capture a specific number of packets

sudo python3 sniffer.py -i eth0 -c 20

Capture TCP packets only

sudo python3 sniffer.py -i eth0 -c 20 -f "tcp"

Capture UDP packets only

sudo python3 sniffer.py -i eth0 -c 20 -f "udp"

Capture ICMP packets only

sudo python3 sniffer.py -i eth0 -c 20 -f "icmp"

Capture packets continuously

sudo python3 sniffer.py -i eth0 -c 0

Press CTRL+C to stop the capture. Captured packets are saved automatically.

Specify an output file

sudo python3 sniffer.py -i eth0 -c 20 -o captures/my_capture.pcap

Packet Analysis

The analyzer extracts information including:

  • Timestamp
  • Packet size
  • Source and destination MAC addresses
  • Source and destination IP addresses
  • Network and transport protocols
  • Source and destination ports
  • TCP flags
  • DNS queries and answers
  • Raw payload data in hexadecimal format

TLS identification is based on port 443 and is not a guarantee that the traffic is encrypted TLS.

Inspecting Captures

Captured PCAP files can be opened using Wireshark:

wireshark captures/your_capture.pcap

Security and Ethical Use

This tool is intended for educational purposes and authorized network analysis.

Only capture traffic on networks and devices for which you have permission.

Avoid sharing PCAP files publicly because they may contain sensitive network information.

Internship

Program: CodeAlpha Cyber Security Internship
Project: Task 1 - Basic Network Sniffer
Language: Python
Domain: Cyber Security / Network Security

About

Python and Scapy network packet sniffer with multi-layer protocol dissection and PCAP export for CodeAlpha Cyber Security Internship

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages