Name | pcap2har JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | A Python project for converting PCAP files to HAR (HTTP Archive) format |
upload_time | 2025-09-07 06:05:40 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10.0 |
license | MIT |
keywords |
analysis
har
http
network
pcap
wireshark
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pcap2har
[](https://github.com/mikekap/pcap2har/actions/workflows/test.yml)
A Python project for converting PCAP files to HAR (HTTP Archive) format.
## Description
This project provides tools to analyze network packet capture files (PCAP) and convert them to HAR format for web traffic analysis.
## Installation
### From PyPI (Recommended)
```bash
pip install pcap2har
```
### From Source
This project uses `uv` for package management. Make sure you have `uv` installed:
```bash
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
```
Then install dependencies:
```bash
uv sync
```
## Usage
After installation, you can use the `pcap2har` command directly:
```bash
# Basic usage
pcap2har <pcap_file>
# With output file
pcap2har <pcap_file> -o output.har
# Pretty print output
pcap2har <pcap_file> --pretty
# Set log level
pcap2har <pcap_file> --log-level DEBUG
```
### Development Usage
If running from source:
```bash
# Basic usage
uv run python -m pcap2har.main <pcap_file>
# With output file
uv run python -m pcap2har.main <pcap_file> -o output.har
# Pretty print output
uv run python -m pcap2har.main <pcap_file> --pretty
```
## Development
1. Clone the repository
2. Install dependencies: `uv sync`
3. Run tests: `uv run python -m pytest tests/`
4. Format code: `uv run black .`
5. Lint code: `uv run flake8 pcap2har/ tests/`
## CI/CD
This project uses GitHub Actions for continuous integration:
- **Tests**: Runs on every PR and push to main/master across Python 3.10-3.13
- **Security**: Weekly security audits and dependency updates
- **Releases**: Automatic builds when tags are pushed
### Local Development
To run the same checks locally:
```bash
# Install dependencies
uv sync --group dev
# Run tests
uv run pytest
# Run specific test
uv run pytest tests/test_http2.py -v
# Check formatting
uv run black .
# Run linting
uv run flake8 pcap2har/ tests/
# Security audit
uv run uv audit
```
### Test Structure
The project uses `pytest-goldie` for golden tests. Tests are organized as follows:
```
tests/
├── test_http2.py # HTTP/2 tests
├── test_http3.py # HTTP/3 tests
├── test_main.py # Main module tests
├── resources/ # Test PCAP files
│ ├── http2-dump.pcap # HTTP/2 test data
│ └── http3-connection7.pcap # HTTP/3 test data
└── goldens/ # Golden test outputs
├── test_http2.py-test_http2_parse
└── test_http3.py-test_http3_parse
```
To add a new test:
1. Create a new test file (e.g., `tests/test_new_protocol.py`)
2. Use the `golden` fixture for golden testing
3. Add test PCAP files to `tests/resources/`
4. Run the test to generate golden output: `uv run python -m pytest tests/test_new_protocol.py -v`
### Pre-commit Commands
Before committing code, run these commands to ensure quality:
```bash
# Format code
uv run black pcap2har/ tests/
# Lint code
uv run flake8 pcap2har/ tests/
# Run tests
uv run python -m pytest tests/ -v
```
### Useful tshark Commands
The project includes a `capture.pcapng` file for testing. Here are useful commands for filtering and analyzing the capture:
```bash
# Filter by TCP stream (useful for isolating HTTP/2 conversations)
tshark -r capture.pcapng -Y "tcp.stream eq 2" -w tests/resources/http2-dump.pcap
# Filter by TCP stream and HTTP/2 traffic
tshark -r capture.pcapng -Y "tcp.stream eq 2 and http2" -w tests/resources/http2-dump.pcap
# View HTTP/2 frames in a specific stream
tshark -r capture.pcapng -Y "tcp.stream eq 2 and http2" -T fields -e frame.number -e http2.type -e http2.streamid -e http2.headers.method -e http2.headers.path
# Filter by HTTP/3 traffic
tshark -r capture.pcapng -Y "http3" -w tests/resources/http3-dump.pcap
# Filter by specific ports
tshark -r capture.pcapng -Y "tcp.port == 443" -w tests/resources/https-dump.pcap
# Filter by IP address
tshark -r capture.pcapng -Y "ip.addr == 192.168.1.1" -w tests/resources/ip-filtered.pcap
# View packet statistics
tshark -r capture.pcapng -q -z io,phs
# Extract specific protocol data
tshark -r capture.pcapng -Y "http2" -T json > http2-data.json
```
### Generating Test Data
The project includes a `capture_packets.sh` script for capturing new network traffic:
```bash
# Make script executable
chmod +x capture_packets.sh
# Capture traffic while browsing a website
./capture_packets.sh https://example.com
# This will create capture.pcapng with decrypted TLS traffic
# Use tshark commands above to filter and extract specific conversations
```
## License
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "pcap2har",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10.0",
"maintainer_email": null,
"keywords": "analysis, har, http, network, pcap, wireshark",
"author": null,
"author_email": "Mike Kaplinskiy <mike.kaplinskiy@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d5/4b/5513bf42979ae81a3c24bc1e84a535443be9a3cde27dc8f38bda7bd934af/pcap2har-0.1.0.tar.gz",
"platform": null,
"description": "# pcap2har\n\n[](https://github.com/mikekap/pcap2har/actions/workflows/test.yml)\n\nA Python project for converting PCAP files to HAR (HTTP Archive) format.\n\n## Description\n\nThis project provides tools to analyze network packet capture files (PCAP) and convert them to HAR format for web traffic analysis.\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install pcap2har\n```\n\n### From Source\n\nThis project uses `uv` for package management. Make sure you have `uv` installed:\n\n```bash\n# Install uv if you haven't already\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\nThen install dependencies:\n\n```bash\nuv sync\n```\n\n## Usage\n\nAfter installation, you can use the `pcap2har` command directly:\n\n```bash\n# Basic usage\npcap2har <pcap_file>\n\n# With output file\npcap2har <pcap_file> -o output.har\n\n# Pretty print output\npcap2har <pcap_file> --pretty\n\n# Set log level\npcap2har <pcap_file> --log-level DEBUG\n```\n\n### Development Usage\n\nIf running from source:\n\n```bash\n# Basic usage\nuv run python -m pcap2har.main <pcap_file>\n\n# With output file\nuv run python -m pcap2har.main <pcap_file> -o output.har\n\n# Pretty print output\nuv run python -m pcap2har.main <pcap_file> --pretty\n```\n\n## Development\n\n1. Clone the repository\n2. Install dependencies: `uv sync`\n3. Run tests: `uv run python -m pytest tests/`\n4. Format code: `uv run black .`\n5. Lint code: `uv run flake8 pcap2har/ tests/`\n\n## CI/CD\n\nThis project uses GitHub Actions for continuous integration:\n\n- **Tests**: Runs on every PR and push to main/master across Python 3.10-3.13\n- **Security**: Weekly security audits and dependency updates\n- **Releases**: Automatic builds when tags are pushed\n\n### Local Development\n\nTo run the same checks locally:\n\n```bash\n# Install dependencies\nuv sync --group dev\n\n# Run tests\nuv run pytest\n\n# Run specific test\nuv run pytest tests/test_http2.py -v\n\n# Check formatting\nuv run black .\n\n# Run linting\nuv run flake8 pcap2har/ tests/\n\n# Security audit\nuv run uv audit\n```\n\n### Test Structure\n\nThe project uses `pytest-goldie` for golden tests. Tests are organized as follows:\n\n```\ntests/\n\u251c\u2500\u2500 test_http2.py # HTTP/2 tests\n\u251c\u2500\u2500 test_http3.py # HTTP/3 tests \n\u251c\u2500\u2500 test_main.py # Main module tests\n\u251c\u2500\u2500 resources/ # Test PCAP files\n\u2502 \u251c\u2500\u2500 http2-dump.pcap # HTTP/2 test data\n\u2502 \u2514\u2500\u2500 http3-connection7.pcap # HTTP/3 test data\n\u2514\u2500\u2500 goldens/ # Golden test outputs\n \u251c\u2500\u2500 test_http2.py-test_http2_parse\n \u2514\u2500\u2500 test_http3.py-test_http3_parse\n```\n\nTo add a new test:\n\n1. Create a new test file (e.g., `tests/test_new_protocol.py`)\n2. Use the `golden` fixture for golden testing\n3. Add test PCAP files to `tests/resources/`\n4. Run the test to generate golden output: `uv run python -m pytest tests/test_new_protocol.py -v`\n\n### Pre-commit Commands\n\nBefore committing code, run these commands to ensure quality:\n\n```bash\n# Format code\nuv run black pcap2har/ tests/\n\n# Lint code\nuv run flake8 pcap2har/ tests/\n\n# Run tests\nuv run python -m pytest tests/ -v\n```\n\n### Useful tshark Commands\n\nThe project includes a `capture.pcapng` file for testing. Here are useful commands for filtering and analyzing the capture:\n\n```bash\n# Filter by TCP stream (useful for isolating HTTP/2 conversations)\ntshark -r capture.pcapng -Y \"tcp.stream eq 2\" -w tests/resources/http2-dump.pcap\n\n# Filter by TCP stream and HTTP/2 traffic\ntshark -r capture.pcapng -Y \"tcp.stream eq 2 and http2\" -w tests/resources/http2-dump.pcap\n\n# View HTTP/2 frames in a specific stream\ntshark -r capture.pcapng -Y \"tcp.stream eq 2 and http2\" -T fields -e frame.number -e http2.type -e http2.streamid -e http2.headers.method -e http2.headers.path\n\n# Filter by HTTP/3 traffic\ntshark -r capture.pcapng -Y \"http3\" -w tests/resources/http3-dump.pcap\n\n# Filter by specific ports\ntshark -r capture.pcapng -Y \"tcp.port == 443\" -w tests/resources/https-dump.pcap\n\n# Filter by IP address\ntshark -r capture.pcapng -Y \"ip.addr == 192.168.1.1\" -w tests/resources/ip-filtered.pcap\n\n# View packet statistics\ntshark -r capture.pcapng -q -z io,phs\n\n# Extract specific protocol data\ntshark -r capture.pcapng -Y \"http2\" -T json > http2-data.json\n```\n\n### Generating Test Data\n\nThe project includes a `capture_packets.sh` script for capturing new network traffic:\n\n```bash\n# Make script executable\nchmod +x capture_packets.sh\n\n# Capture traffic while browsing a website\n./capture_packets.sh https://example.com\n\n# This will create capture.pcapng with decrypted TLS traffic\n# Use tshark commands above to filter and extract specific conversations\n```\n\n## License\n\nMIT \n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python project for converting PCAP files to HAR (HTTP Archive) format",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [
"analysis",
" har",
" http",
" network",
" pcap",
" wireshark"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d838077c1eb82edd8e8b4eb746790c4c51d2f176a4a3ee0718a6ed6f68789274",
"md5": "8f132d44da2e9a29163c2e22635e10bc",
"sha256": "16626812be27496162d64f7669c0f0083734f72957ddd90a46aa1709d8263bd4"
},
"downloads": -1,
"filename": "pcap2har-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f132d44da2e9a29163c2e22635e10bc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.0",
"size": 8474,
"upload_time": "2025-09-07T06:05:39",
"upload_time_iso_8601": "2025-09-07T06:05:39.425802Z",
"url": "https://files.pythonhosted.org/packages/d8/38/077c1eb82edd8e8b4eb746790c4c51d2f176a4a3ee0718a6ed6f68789274/pcap2har-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d54b5513bf42979ae81a3c24bc1e84a535443be9a3cde27dc8f38bda7bd934af",
"md5": "8ce9efe5b86519f93a1aeac52beef5f2",
"sha256": "f190b26ffbd586d2c3ae1d28f908962649f214060609a3aa44baeb509327ae32"
},
"downloads": -1,
"filename": "pcap2har-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "8ce9efe5b86519f93a1aeac52beef5f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.0",
"size": 1753066,
"upload_time": "2025-09-07T06:05:40",
"upload_time_iso_8601": "2025-09-07T06:05:40.594856Z",
"url": "https://files.pythonhosted.org/packages/d5/4b/5513bf42979ae81a3c24bc1e84a535443be9a3cde27dc8f38bda7bd934af/pcap2har-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-07 06:05:40",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pcap2har"
}