-
-
Save thomasbhatia/29176289f03c0c36ecaf to your computer and use it in GitHub Desktop.
Replay pcap/pcapng TCP traffic using netcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For development it may be useful to be able to replay TCP traffic (e.g. HTTP). The dump can be created using WireShark or tcpdump: | |
$ tcpdump -s 0 port http -i en0 -w dump.pcap | |
To generate data files that can be replayed through netcat we use tcptrace: | |
$ tcptrace -e input.pcapng | |
Finally replay the HTTP traffic using netcat to host 192.168.1.1 port 80 | |
$ cat a2b_contents.dat | nc -v 192.168.1.1 80 | |
If you need to replay the raw network traffic, we need to do some massaging using tcpprep and tcprewrite before using tcpreplay to replay the raw packages. Note that due to limitation of tcprewrite this will not replay any traffic to the network: http://tcpreplay.synfin.net/wiki/FAQ#Doestcpreplaysupportsendingtraffictoaserver. | |
$ tcpprep --port --cachefile=dump.cache --pcap=dump.pcapng | |
$ tcprewrite --portmap=80:8080 --endpoints=127.0.0.1:127.0.0.2 --cachefile=dump.cache --infile=dump.pcapng --outfile=transformed.pcapng | |
$ tcpreplay -i en0 transformed.pcapng |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment