I want to collect tcpdump examples, as many as possible!
E.g.: how to filter FTP passwords on eth0; OR how to filter HTTP 404 errors, etc.
|
|
||||
|
|
closed as not constructive by slhck♦ Aug 17 '12 at 21:02
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
It doesn't do any filtering, but this example creates a handy continuous packet sniffer:
Put it in /etc/rc.local to run on boot. It captures all packets on interface It writes ~128MB files and will automatically rotate up to 100 of them. When it captures 128MB of data, it will close the file, open a new one, and fork the specified command with the old filename as an argument - in this case a little Perl script that compresses the previous capture file for quicker transfer off the IDS server. I use this when I have to monitor a connection for a long time (like a day or two) and need to go back and find an event that occurred at a specific time. The small files are much easier to handle in Wireshark than one huge pcap file. |
||||
|
|
|
Capture only HTTP POST data:
A bit unwieldly but certainly useful. Then we want to compare the first 4 bytes of TCP data to 'POST'. The TCP header is minimum 20 (decimal) bytes, but since the TCP options are variable length, from 0 to 40 bytes (padded to a 32-bit boundary and starting at ), we have to test every 4 bytes from 20 to 60 (decimal). Finally,
How to translate POST to 1347375956: First we have the uppercase letters P,O,S,T. If you look at an ASCII to HEX table (http://www.asciitable.com/), you will see: P = 0x50 O = 0x4f S = 0x53 T = 0x54 Then we put it into a long HEX number. 0x504f5354, and start the HEX to DEC conversion from the right side. 4 X 16^0 = 4 5 X 16^1 = 80 3 X 16^2 = 768 5 X 16^3 = 20480 f X 16^4 = 983040 (remember 0xf = 15) 4 X 16^5 = 4194304 0 X 16^6 = 0 5 X 16^7 = 1342177280 Sum of all 1347375956 = POST |
||||
|
|
|
Capture everything to a file (so you can analyze it later with Wireshark or something):
|
||||
|
|
|
If you want to monitor clients DNS requests on an OpenWRT router:
|
||||
|
|
|
Filter-making cheat sheet: http://staff.washington.edu/dittrich/talks/core02/tools/tcpdump-filters.txt |
||||
|
|