A Python script that uses tcpdump to capture network traffic for a specified duration, runs custom commands during the capture, and saves the output to pcap files. This allows for capturing both the network traffic during the idle state and the traffic generated by the execution of the commands.
- Python 3.x
- tcpdump
Please ensure that you have
tcpdumpinstalled on your system. You can install it using the package manager for your distribution. For example, on Ubuntu:sudo apt-get install tcpdump
- Clone the repository:
git clone https://github.com/your_username/tcpdump-command-runner.git - Edit the
commandsandfileNameslists intcpdump_command_runner.pyto include your desired commands and output pcap file names. - Run the script:
python3 tcpdump_command_runner.pyThe script will iterate through the commands and file names, runningtcpdumpfor the specified duration (default is 8 hours) and executing each command during the capture. The captured network traffic, including the effects of the executed commands, will be saved to the corresponding pcap files.
You can change the capture duration by modifying the capture_duration variable in tcpdump_command_runner.py. The default value is 8 hours (8 * 60 * 60 seconds). To change the duration, simply update the value to your desired duration in seconds.
This project is licensed under the Unlicense License. See the LICENSE file for details.