A robust, production-quality Bash tool that automates tshark extractions from PCAP files with organized output and on-demand GitHub tool integration.
- Automated extraction of various protocol data from PCAP files using tshark
- Organized output directory structure with timestamped folders
- Interactive menu system for selecting specific extractors
- On-demand cloning and execution of GitHub helper repositories
- Chained analysis capabilities (using outputs to refine later checks)
- Real-time output display during extraction
- Comprehensive summary reports (text and JSON)
- Cross-platform support (Linux, macOS, and Windows via WSL)
- Built-in dependency checker and installer
- tshark (from Wireshark)
- git
- awk, sed, grep, sort, uniq, paste, mktemp, find, xargs, tee, wc
- python3
- exiftool (for metadata extraction from exported files)
- file (for file type detection)
- jq (for JSON processing)
- timeout (for command timeouts)
-
Clone the repository:
git clone https://github.com/yourusername/pcap-auto-extractor.git cd pcap-auto-extractor -
Make the scripts executable:
chmod +x pcap-auto-extractor.sh requirements.sh
-
Check and install dependencies:
./requirements.sh --install
-
Run the extractor:
./pcap-auto-extractor.sh <pcap-file>
sudo apt update
sudo apt install wireshark-cli git python3brew install wireshark git python3sudo apt update
sudo apt install wireshark-cli git python3./pcap-auto-extractor.sh <pcap-file>./pcap-auto-extractor.sh <pcap-file> [options]--parallel N: Run up to N extractors in parallel (default: 1)--dry-run: Show commands that would be executed without running them--json-report: Generate a machine-readable JSON summary report--tools-root DIR: Set the root directory for cloned tools (default: /tmp/tools)
# Basic analysis
./pcap-auto-extractor.sh capture.pcap
# Run with 4 parallel extractors and generate JSON report
./pcap-auto-extractor.sh capture.pcap --parallel 4 --json-report
# Dry run to see what would be executed
./pcap-auto-extractor.sh capture.pcap --dry-runThe script creates a timestamped output directory in ~/Documents/Pcap_Extracts/ with the following structure:
~/Documents/Pcap_Extracts/YYYYMMDD_HHMMSS/
├── logs/
│ ├── run.log # Main execution log
│ └── errors.log # Error log
├── files/ # Exported binary files
│ ├── http/ # HTTP objects (images, documents, etc.)
│ ├── smb/ # SMB files
│ ├── nfs/ # NFS files
│ ├── tftp/ # TFTP files
│ └── ftp/ # FTP files
├── http/ # HTTP textual outputs
│ ├── http_requests.tsv # HTTP requests (method, host, URI)
│ ├── hosts.txt # HTTP hosts
│ ├── post_bodies.txt # HTTP POST bodies
│ ├── cookies.txt # HTTP cookies
│ └── uris_<host>.txt # URIs for specific hosts
├── dns/ # DNS outputs
│ ├── dns_queries.txt # DNS queries
│ ├── dns_answers.tsv # DNS answers
│ ├── txt_records.txt # DNS TXT records
│ ├── all_qnames.txt # All QNames
│ └── exfil_suspicions.txt # DNS exfiltration indicators
├── kerberos/ # Kerberos outputs
│ ├── users_realms.tsv # Kerberos users and realms
│ ├── ciphers_all.txt # Kerberos ciphers
│ ├── asrep_candidates.txt # AS-REP candidates
│ └── krbpa2john_output.txt # Output from krbpa2john tool
├── tcp/ # TCP outputs
│ ├── synack_srcports.txt # SYN+ACK source ports
│ ├── tcp_conversations.txt # TCP conversations
│ └── ip_conversations.txt # IP conversations
├── creds/ # Credentials
│ ├── http_auth_headers.txt # HTTP auth headers
│ └── ftp_user_pass.tsv # FTP credentials
├── meta/ # Metadata
│ ├── interfaces.txt # Network interfaces
│ ├── linktypes.txt # Link types
│ ├── io_phs.txt # I/O stats
│ └── fields_kerberos.txt # Kerberos fields
├── other/ # Other protocols
│ ├── ftp_commands.tsv # FTP commands
│ └── smtp_subjects.txt # SMTP subjects
├── tools/ # Cloned GitHub tools and outputs
│ └── <repo-name>/ # Each cloned repository
├── SUMMARY.txt # Human-readable summary
└── summary.json # Machine-readable summary (if requested)
The script provides an interactive menu system with the following options:
- Extract ALL (safe, modular): Run all available extractors
- Run a specific extractor: Select and run a single extractor
- GitHub Tools: Clone and run helper repositories
- Show Summary: Display and save analysis summary
- Exit: Exit the program
The script includes extractors for:
- Interface listing
- Link types
- PCAP stats
- Kerberos fields
- Requests
- Hosts
- POST bodies
- Auth headers
- Cookies
- Export objects
- Queries
- Answers
- TXT records
- All QNames
- Exfiltration detection
- SYN+ACK ports
- Conversations
- IP conversations
- Users and realms
- Ciphers
- AS-REP candidates
- FTP commands
- FTP credentials
- SMTP subjects
- JA3 fingerprints
- HTTP hosts analysis
- Kerberos analysis
- POST bodies analysis
The script can clone and run helper repositories on demand:
-
decrypt-winrm (https://github.com/h4sh5/decrypt-winrm)
- Decrypts WinRM traffic using server certificate and private key
-
ctf-tools (https://github.com/truongkma/ctf-tools)
- Contains John the Ripper with krbpa2john.py for Kerberos cracking
-
john (https://github.com/openwall/john)
- John the Ripper password cracker (bleeding-jumbo branch)
- Select "GitHub Tools" from the main menu
- Choose a repository from the list
- The script will clone the repository to
/tmp/tools/<repo-name> - Follow prompts to provide required inputs
- The tool will be executed and outputs saved to the appropriate directory
The script performs automated follow-up analysis based on initial findings:
- If HTTP hosts are found, it extracts URIs for each unique host
- If Kerberos users and ciphers are found, it generates AS-REP candidates
- If DNS QNames are found, it performs exfiltration detection
- If HTTP POST bodies are found, it analyzes them for potential credentials
The included requirements.sh script helps manage dependencies:
./requirements.sh --check./requirements.sh --installThe script automatically detects the operating system and installs the appropriate packages:
- Debian/Ubuntu: Uses
apt - Red Hat/CentOS/Fedora: Uses
yum - Arch Linux: Uses
pacman - macOS: Uses
Homebrew - Windows: Provides manual installation instructions
- The script validates the PCAP file path before processing
- GitHub repositories are only cloned when selected by the user
- User-provided credentials are handled securely
- All external commands are logged
- The script does not modify any system files
-
Permission denied when running tshark
- On Linux, you may need to add your user to the wireshark group:
sudo usermod -a -G wireshark $USER - Log out and log back in for changes to take effect
- On Linux, you may need to add your user to the wireshark group:
-
Missing dependencies
- The script checks for required dependencies at startup
- Use the
requirements.shscript to install missing packages
-
Large PCAP files
- Processing large files may take significant time
- Consider using the
--dry-runoption to preview commands before execution
The script creates two log files in the output directory:
logs/run.log: Main execution log with timestampslogs/errors.log: Error messages and diagnostic information
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- tshark and Wireshark for the powerful packet analysis capabilities
- The creators of the various GitHub tools integrated in this script
- The cybersecurity community for inspiration and feedback
If you encounter any issues or have questions, please file an issue on the GitHub repository.