TAP - Tcpdump Analysing Parser ============================== AUTHOR: ithilgore VERSION: 0.6 LICENCE: GPL 3 Compilation ----------- gcc tap.c -o tap Usage ------ tcpdump -X | ./tap or tcpdump -X > file cat file | ./tap For the moment TAP supports the analysis of only IP at L3 and TCP at L4. When I have enough time I will complete functionality for the rest of the most popular protocols. Do NOT use tcpdump's options xx or XX which print the link layer header as well, since this has not as yet been implemented. You can, however, use any other tcpdump option at will. Only options messing with the order that the raw data is printed to stdout, will influence (usually in a bad way) the parser. Note that you can change the default colors by changing the default values in lines: #define WC GREEN /* Window Colour "| + -" */ #define FC RED /* Field Colour */ #define VC BLUE /* Value Colour */ This project is still at its early stages and containes many unresolved cases. Sample output: #tcpdump -X host 10.0.0.50 and port 4000 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 03:57:11.174352 IP fitz.den.39953 > 10.0.0.50.terabase: P 3734525651:3734525655(4) ack 3064238355 win 92 0x0000: 4500 0038 4f48 4000 4006 d73a 0a00 000c E..8OH@.@..:.... 0x0010: 0a00 0032 9c11 0fa0 de98 56d3 b6a4 9113 ...2......V..... 0x0020: 8018 005c 1468 0000 0101 080a 00d2 db6c ...\.h.........l 0x0030: 4562 2754 4141 410a Eb'TAAA. 03:57:11.368946 IP 10.0.0.50.terabase > fitz.den.39953: . ack 4 win 17376 0x0000: 4500 0034 d456 4000 4006 5230 0a00 0032 E..4.V@.@.R0...2 0x0010: 0a00 000c 0fa0 9c11 b6a4 9113 de98 56d7 ..............V. 0x0020: 8010 43e0 acc2 0000 0101 080a 4562 2762 ..C.........Eb'b 0x0030: 00d2 db6c ...l 03:57:12.309608 IP fitz.den.39953 > 10.0.0.50.terabase: P 4:8(4) ack 1 win 92 0x0000: 4500 0038 4f49 4000 4006 d739 0a00 000c E..8OI@.@..9.... 0x0010: 0a00 0032 9c11 0fa0 de98 56d7 b6a4 9113 ...2......V..... 0x0020: 8018 005c 1468 0000 0101 080a 00d2 dcc1 ...\.h.......... 0x0030: 4562 2762 4242 420a Eb'bBBB. 03:57:12.508817 IP 10.0.0.50.terabase > fitz.den.39953: . ack 8 win 17376 0x0000: 4500 0034 afa1 4000 4006 76e5 0a00 0032 E..4..@.@.v....2 0x0010: 0a00 000c 0fa0 9c11 b6a4 9113 de98 56db ..............V. 0x0020: 8010 43e0 ab67 0000 0101 080a 4562 2764 ..C..g......Eb'd 0x0030: 00d2 dcc1 .... #tcpdump -X host 10.0.0.50 and port 4000 | ./tap +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Ver: 4 |IHL: 5 | ToS: 00 | Total Length: 0038 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification: 4f48 |F: 2 | Fragment Offset: 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL: 40 | Protocol: 06 | Header Checksum: d73a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address: 0a00 000c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address: 0a00 0032 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port: 9c11 | Destination Port: 0fa0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number: de98 56d3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number: b6a4 9113 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |DO: 8 |Reserved: 0| Flags: 18 | Window: 005c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum: 1468 | Urgent Pointer: 0000 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 0101 080a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 00d2 db6c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 4562 2754 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data: 4141 410a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Ver: 4 |IHL: 5 | ToS: 00 | Total Length: 0034 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification: d456 |F: 2 | Fragment Offset: 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL: 40 | Protocol: 06 | Header Checksum: 5230 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address: 0a00 0032 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address: 0a00 000c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port: 0fa0 | Destination Port: 9c11 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number: b6a4 9113 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number: de98 56d7 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |DO: 8 |Reserved: 0| Flags: 10 | Window: 43e0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum: acc2 | Urgent Pointer: 0000 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 0101 080a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 4562 2762 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 00d2 db6c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Ver: 4 |IHL: 5 | ToS: 00 | Total Length: 0038 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification: 4f49 |F: 2 | Fragment Offset: 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL: 40 | Protocol: 06 | Header Checksum: d739 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address: 0a00 000c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address: 0a00 0032 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port: 9c11 | Destination Port: 0fa0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number: de98 56d7 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number: b6a4 9113 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |DO: 8 |Reserved: 0| Flags: 18 | Window: 005c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum: 1468 | Urgent Pointer: 0000 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 0101 080a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 00d2 dcc1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TCP Options: 4562 2762 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data: 4242 420a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+