/Pcap2CSV

๐Ÿ“ฆ Convert PCAP network capture files to CSV format for easy analysis and reporting! ๐Ÿ“Š

Primary LanguagePythonMIT LicenseMIT

Pcap2CSV

Pcap2CSV is a Python utility for converting packet capture (PCAP) files into CSV format. This tool allows for easy analysis of network traffic by converting detailed packet data into a structured CSV file, which can be used for further analysis or reporting. ๐Ÿ“Š

Features

  • ๐Ÿ—‚๏ธ Convert PCAP files to CSV format
  • ๐ŸŒ Support for IP, TCP, UDP, and other protocols
  • ๐Ÿ–ฅ๏ธ Simple command-line interface
  • ๐Ÿงช Includes utility scripts for generating test PCAP files
  • โœ… Unit tests to ensure code reliability

Installation

  1. Clone the Repository ๐Ÿš€

    git clone https://github.com/mobiwn/Pcap2CSV.git
    cd Pcap2CSV
  2. Set Up a Virtual Environment ๐Ÿ—๏ธ

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install Dependencies ๐Ÿ“ฆ

    pip install -r requirements.txt

Usage

Converting a PCAP File to CSV

To convert a PCAP file to CSV, use the convert_pcap.py script:

python scripts/convert_pcap.py <pcap_file> <csv_file>

Example:

python scripts/convert_pcap.py tests/data/test.pcap tests/data/test.csv

Generating a Test PCAP File

To generate a test PCAP file with random packets, use the generate_test_pcap.py script:

python scripts/generate_test_pcap.py

This will generate a test.pcap file in the tests/data/ directory.

Project Structure

Here is the structure of the Pcap2CSV project as visible in GitHub:

Pcap2CSV/
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ pcap2csv/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ converter.py
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ convert_pcap.py
โ”‚   โ””โ”€โ”€ generate_test_pcap.py
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ __pycache__/
    โ”œโ”€โ”€ data/
    โ””โ”€โ”€ test_converter.py

Running Tests

To run the unit tests, use the following command:

python -m unittest discover -s tests

Contributing

Contributions are welcome! Please open an issue or submit a pull request to propose changes or improvements. ๐Ÿค

License

This project is licensed under the MIT License - see the LICENSE file for details. ๐Ÿ“œ

Contact

For any questions or support, please contact mobin.kh15@gmail.com. ๐Ÿ“ง