4 text2pcap - Generate a capture file from an ASCII hexdump of packets
12 S<[ B<-o> hex|oct|dec ]>
13 S<[ B<-l> E<lt>typenumE<gt> ]>
14 S<[ B<-e> E<lt>l3pidE<gt> ]>
15 S<[ B<-i> E<lt>protoE<gt> ]>
16 S<[ B<-m> E<lt>max-packetE<gt> ]>
17 S<[ B<-u> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
18 S<[ B<-T> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
19 S<[ B<-s> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt> ]>
20 S<[ B<-S> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt> ]>
21 S<[ B<-t> E<lt>timefmtE<gt> ]>
23 E<lt>I<outfile>E<gt>|-
27 B<Text2pcap> is a program that reads in an ASCII hex dump and writes the
28 data described into a B<libpcap> capture file. B<text2pcap> can
29 read hexdumps with multiple packets in them, and build a capture file of
30 multiple packets. B<text2pcap> is also capable of generating dummy
31 Ethernet, IP and UDP, TCP, or SCTP headers, in order to build fully
32 processable packet dumps from hexdumps of application-level data only.
34 B<Text2pcap> understands a hexdump of the form generated by I<od -Ax -tx1>.
35 In other words, each byte is individually displayed and
36 surrounded with a space. Each line begins with an offset describing
37 the position in the file. The offset is a hex number (can also be
38 octal or decimal - see B<-o>), of more than two hex digits.
39 Here is a sample dump that B<text2pcap> can recognize:
41 000000 00 e0 1e a7 05 6f 00 10 ........
42 000008 5a a0 b9 12 08 00 46 00 ........
43 000010 03 68 00 00 00 00 0a 2e ........
44 000018 ee 33 0f 19 08 7f 0f 19 ........
45 000020 03 80 94 04 00 00 10 01 ........
46 000028 16 a2 0a 00 03 50 00 0c ........
47 000030 01 01 0f 19 03 80 11 01 ........
49 There is no limit on the width or number of bytes per line. Also the
50 text dump at the end of the line is ignored. Bytes/hex numbers can be
51 uppercase or lowercase. Any text before the offset is ignored,
52 including email forwarding characters '>'. Any lines of text between
53 the bytestring lines is ignored. The offsets are used to track the
54 bytes, so offsets must be correct. Any line which has only bytes
55 without a leading offset is ignored. An offset is recognized as being
56 a hex number longer than two characters. Any text after the bytes is
57 ignored (e.g. the character dump). Any hex numbers in this text are
58 also ignored. An offset of zero is indicative of starting a new
59 packet, so a single text file with a series of hexdumps can be
60 converted into a packet capture with multiple packets. Multiple
61 packets are read in with timestamps differing by one second each. In
62 general, short of these restrictions, B<text2pcap> is pretty liberal
63 about reading in hexdumps and has been tested with a variety of
64 mangled outputs (including being forwarded through email multiple
65 times, with limited line wrap etc.)
67 There are a couple of other special features to note. Any line where
68 the first non-whitespace character is '#' will be ignored as a
69 comment. Any line beginning with #TEXT2PCAP is a directive and options
70 can be inserted after this command to be processed by
71 B<text2pcap>. Currently there are no directives implemented; in the
72 future, these may be used to give more fine grained control on the
73 dump and the way it should be processed e.g. timestamps, encapsulation
76 B<Text2pcap> also allows the user to read in dumps of
77 application-level data, by inserting dummy L2, L3 and L4 headers
78 before each packet. The user can elect to insert Ethernet headers,
79 Ethernet and IP, or Ethernet, IP and UDP/TCP headers before each
80 packet. This allows Wireshark or any other full-packet decoder to
89 Displays a help message.
93 Displays debugging information during the process. Can be used
94 multiple times to generate more debugging information.
98 Be completely quiet during the process.
102 Specify the radix for the offsets (hex, octal or decimal). Defaults to
103 hex. This corresponds to the C<-A> option for I<od>.
107 Specify the link-layer type of this packet. Default is Ethernet
108 (1). See I<net/bpf.h> for the complete list of possible
109 encapsulations. Note that this option should be used if your dump is a
110 complete hex dump of an encapsulated packet and you wish to specify
111 the exact type of encapsulation. Example: I<-l 7> for ARCNet packets.
113 =item -e E<lt>l3pidE<gt>
115 Include a dummy Ethernet header before each packet. Specify the L3PID
116 for the Ethernet header in hex. Use this option if your dump has Layer
117 3 header and payload (e.g. IP header), but no Layer 2
118 encapsulation. Example: I<-e 0x806> to specify an ARP packet.
120 For IP packets, instead of generating a fake Ethernet header you can
121 also use I<-l 12> to indicate a raw IP packet to Wireshark. Note that
122 I<-l 12> does not work for any non-IP Layer 3 packet (e.g. ARP),
123 whereas generating a dummy Ethernet header with I<-e> works for any
126 =item -i E<lt>protoE<gt>
128 Include dummy IP headers before each packet. Specify the IP protocol
129 for the packet in decimal. Use this option if your dump is the payload
130 of an IP packet (i.e. has complete L4 information) but does not have
131 an IP header. Note that this automatically includes an appropriate
132 Ethernet header as well. Example: I<-i 46> to specify an RSVP packet
135 =item -m E<lt>max-packetE<gt>
137 Set the maximum packet length, default is 64000.
138 Useful for testing various packet boundaries when only an application
139 level datastream is available. Example:
141 I<od -Ax -tx1 stream | text2pcap -m1460 -T1234,1234 - stream.pcap>
143 will convert from plain datastream format to a sequence of Ethernet
146 =item -u E<lt>srcportE<gt>,E<lt>destportE<gt>
148 Include dummy UDP headers before each packet. Specify the source and
149 destination UDP ports for the packet in decimal. Use this option if
150 your dump is the UDP payload of a packet but does not include any UDP,
151 IP or Ethernet headers. Note that this automatically includes
152 appropriate Ethernet and IP headers with each packet. Example: I<-u
153 1000,69> to make the packets look like TFTP/UDP packets.
155 =item -T E<lt>srcportE<gt>,E<lt>destportE<gt>
157 Include dummy TCP headers before each packet. Specify the source and
158 destination TCP ports for the packet in decimal. Use this option if
159 your dump is the TCP payload of a packet but does not include any TCP,
160 IP or Ethernet headers. Note that this automatically includes
161 appropriate Ethernet and IP headers with each packet.
162 Sequence numbers will start a 0.
164 =item -s E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt>
166 Include dummy SCTP headers before each packet. Specify, in decimal, the
167 source and destination SCTP ports, and verification tag, for the packet.
168 Use this option if your dump is the SCTP payload of a packet but does
169 not include any SCTP, IP or Ethernet headers. Note that this
170 automatically includes appropriate Ethernet and IP headers with each
171 packet. A CRC32C checksum will be put into the SCTP header.
173 =item -S E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt>
175 Include dummy SCTP headers before each packet. Specify, in decimal, the
176 source and destination SCTP ports, and a verification tag of 0, for the
177 packet, and prepend a dummy SCTP DATA chunk header with a payload
178 protocol identifier if I<ppi>. Use this option if your dump is the SCTP
179 payload of a packet but does not include any SCTP, IP or Ethernet
180 headers. Note that this automatically includes appropriate Ethernet and
181 IP headers with each packet. A CRC32C checksum will be put into the
184 =item -t E<lt>timefmtE<gt>
186 Treats the text before the packet as a date/time code; I<timefmt> is a
187 format string of the sort supported by strptime(3).
188 Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
190 B<NOTE:> The subsecond component delimiter must be specified (.) but no
191 pattern is required; the remaining number is assumed to be fractions of
194 B<NOTE:> Date/time fields from the current date/time are
195 used as the default for unspecified fields.
201 od(1), tcpdump(8), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
202 editcap(1), strptime(3).
206 B<Text2pcap> is part of the B<Wireshark> distribution. The latest version
207 of B<Wireshark> can be found at L<http://www.wireshark.org>.
211 Ashok Narayanan <ashokn[AT]cisco.com>