Hello, Is it possible to capture tcpdump data from the screen (not a file) and then import into Wireshark? For example, I want to run the following tcpdump command: ./tcpdump -vvvvv -i eth0 Then I want to be able to import this into Wireshark (Window GuI version) for analysis. Thanks in advance asked 13 Aug '12, 13:51 gil_happy |
4 Answers:
OK, I did some testing, you can use the following also. Dump the packet data with '-xx' (double x to get the link layer data too) like this:
Then copy the output and process it with sed like this:
If you redirect that output to a file, it can be imported in Wireshark with "File -> Import...", just make sure you enable timestamps and give "%T" as time format. (if you're on Windows, you might want to consider installing a sed program or cygwin) answered 14 Aug '12, 14:12 SYN-bit ♦♦ |
Unfortunately that is not possible, as the packet bytes get lost. You might be able to use some scripting to be able to import "tcpdump -s0 -x -i eth0" output. If the problem is that you can only copy screen output, you might want to save the trace locally with "tcpdump -s0 -w tmp.cap" and then use uuencode to create ascii text on the screen which you can copy & paste and uudecode. Or do it in one go: "tcpdump -s0 -i en1 -w - -c 10 2>/dev/null | uuencode tmp.cap" answered 13 Aug '12, 15:14 SYN-bit ♦♦ Thanks for the info... Unfortunately the problem is that if I save it to a file (which is a remote device), I have no way to pull the pcap file off the unit. That is why I was wondering if there was a way to dump the screen output into Wireshark. Thanks for the help. (14 Aug '12, 12:43) gil_happy That's why I suggested to uuencode the binary file, you can copy the output from the console/terminal/screen and paste it into a file on your own system to uudecode it back to a binary file. I have used this when I only had a 9600 bps serial console available, it takes time, but at least you get all the data :-) (if the box does not have uuencode but does have perl, you can paste this code to it to do the encoding :-) (14 Aug '12, 13:34) SYN-bit ♦♦ |
There are some other options as well. xxd
Copy the output and save it as dump.hex on another system. Then use xxd on that system to revert the hex dump back to a binary.
You can now open dump.pcap in Wireshark. remote capture with ssh
Then open dump.pcap in Wireshark. UPDATE: HOWTO:
Regards answered 14 Aug '12, 17:47 Kurt Knochner ♦ edited 16 Aug '12, 02:44 I did not know about xxd, we learn everyday :-) However, for this purpose, I think uuencode is a lot more efficient:
But if xxd is available and uuencode is not... :-) UPDATE: OK, when using xxd, you might want to use -p to reduce the size:
(15 Aug '12, 00:10) SYN-bit ♦♦
That's the only good reason to use xxd, as uuencode tends to be missing on some linux systems ;-) (15 Aug '12, 01:17) Kurt Knochner ♦ |
I recently used a remote command over ssh to pipe back into a local copy of tshark which then wrote into local files.
Note that I had installed a public key for the user on the remote system so no user input was required on the ssh connection. answered 15 Aug '12, 02:23 grahamb ♦ Thanks for all suggestions to date.. unfortunately the SSH suggestion is not an option. Here is what I have done so far.
I then copied and pasted the output on my screen and saved it to Notepad. Now I'm trying to figure out how to Import back to Wireshark or even 'Packet Dump Decode'. I don't know if I'm doing something incorrectly, or if I need to make minor edit to the pasted output? (15 Aug '12, 07:32) gil_happy hexdump does not seem to have a 'reverse' option. Do you have uuencode or xdd on the box? (15 Aug '12, 07:46) SYN-bit ♦♦ if you don't have uuencode (preferred) or xxd, did you try the option posted by SYN-bit (tcpdump -xxx ...)? That will work. Another option would be to convert the output of hexdump to a format that xxd (windows version) accepts. See the UPDATE in my answer above. (16 Aug '12, 02:33) Kurt Knochner ♦ |
Fabulous... I will give this a go tomorrow.
However, if I just want to sniff everything on a particular interface, e.g. eth0, what would the syntax be? Note, there is not a lot of traffic on this interface.
Thanks
Then the syntax would be: