1TEXT2PCAP(1) The Wireshark Network Analyzer TEXT2PCAP(1)
2
3
4
6 text2pcap - Generate a capture file from an ASCII hexdump of packets
7
9 text2pcap [ -a ] [ -d ] [ -D ] [ -e <l3pid> ] [ -h ] [ -i <proto> ]
10 [ -l <typenum> ] [ -n ] [ -m <max-packet> ] [ -o hex|oct|dec ] [ -q ]
11 [ -s <srcport>,<destport>,<tag> ] [ -S <srcport>,<destport>,<ppi> ]
12 [ -t <timefmt> ] [ -T <srcport>,<destport> ]
13 [ -u <srcport>,<destport> ] <infile>|- <outfile>|-
14
16 Text2pcap is a program that reads in an ASCII hex dump and writes the
17 data described into a pcap capture file. text2pcap can read hexdumps
18 with multiple packets in them, and build a capture file of multiple
19 packets. text2pcap is also capable of generating dummy Ethernet, IP
20 and UDP, TCP, or SCTP headers, in order to build fully processable
21 packet dumps from hexdumps of application-level data only.
22
23 Text2pcap understands a hexdump of the form generated by od -Ax -tx1
24 -v. In other words, each byte is individually displayed and surrounded
25 with a space. Each line begins with an offset describing the position
26 in the file. The offset is a hex number (can also be octal or decimal -
27 see -o), of more than two hex digits. Here is a sample dump that
28 text2pcap can recognize:
29
30 000000 00 e0 1e a7 05 6f 00 10 ........
31 000008 5a a0 b9 12 08 00 46 00 ........
32 000010 03 68 00 00 00 00 0a 2e ........
33 000018 ee 33 0f 19 08 7f 0f 19 ........
34 000020 03 80 94 04 00 00 10 01 ........
35 000028 16 a2 0a 00 03 50 00 0c ........
36 000030 01 01 0f 19 03 80 11 01 ........
37
38 There is no limit on the width or number of bytes per line. Also the
39 text dump at the end of the line is ignored. Bytes/hex numbers can be
40 uppercase or lowercase. Any text before the offset is ignored,
41 including email forwarding characters '>'. Any lines of text between
42 the bytestring lines is ignored. The offsets are used to track the
43 bytes, so offsets must be correct. Any line which has only bytes
44 without a leading offset is ignored. An offset is recognized as being a
45 hex number longer than two characters. Any text after the bytes is
46 ignored (e.g. the character dump). Any hex numbers in this text are
47 also ignored. An offset of zero is indicative of starting a new packet,
48 so a single text file with a series of hexdumps can be converted into a
49 packet capture with multiple packets. Packets may be preceded by a
50 timestamp. These are interpreted according to the format given on the
51 command line (see -t). If not, the first packet is timestamped with the
52 current time the conversion takes place. Multiple packets are written
53 with timestamps differing by one microsecond each. In general, short
54 of these restrictions, text2pcap is pretty liberal about reading in
55 hexdumps and has been tested with a variety of mangled outputs
56 (including being forwarded through email multiple times, with limited
57 line wrap etc.)
58
59 There are a couple of other special features to note. Any line where
60 the first non-whitespace character is '#' will be ignored as a comment.
61 Any line beginning with #TEXT2PCAP is a directive and options can be
62 inserted after this command to be processed by text2pcap. Currently
63 there are no directives implemented; in the future, these may be used
64 to give more fine grained control on the dump and the way it should be
65 processed e.g. timestamps, encapsulation type etc.
66
67 Text2pcap also allows the user to read in dumps of application-level
68 data, by inserting dummy L2, L3 and L4 headers before each packet. The
69 user can elect to insert Ethernet headers, Ethernet and IP, or
70 Ethernet, IP and UDP/TCP/SCTP headers before each packet. This allows
71 Wireshark or any other full-packet decoder to handle these dumps.
72
74 -a Enables ASCII text dump identification. It allows to identify the
75 start of the ASCII text dump and not include it in the packet even
76 if it looks like HEX.
77
78 NOTE: Do not enable it if the input file does not contain the ASCII
79 text dump.
80
81 -d Displays debugging information during the process. Can be used
82 multiple times to generate more debugging information.
83
84 -D The text before the packet starts either with an I or O indicating
85 that the packet is inbound or outbound. This is only stored if the
86 output format is PCAP-NG.
87
88 -e <l3pid>
89 Include a dummy Ethernet header before each packet. Specify the
90 L3PID for the Ethernet header in hex. Use this option if your dump
91 has Layer 3 header and payload (e.g. IP header), but no Layer 2
92 encapsulation. Example: -e 0x806 to specify an ARP packet.
93
94 For IP packets, instead of generating a fake Ethernet header you
95 can also use -l 101 to indicate a raw IP packet to Wireshark. Note
96 that -l 101 does not work for any non-IP Layer 3 packet (e.g. ARP),
97 whereas generating a dummy Ethernet header with -e works for any
98 sort of L3 packet.
99
100 -h Displays a help message.
101
102 -i <proto>
103 Include dummy IP headers before each packet. Specify the IP
104 protocol for the packet in decimal. Use this option if your dump is
105 the payload of an IP packet (i.e. has complete L4 information) but
106 does not have an IP header with each packet. Note that an
107 appropriate Ethernet header is automatically included with each
108 packet as well. Example: -i 46 to specify an RSVP packet (IP
109 protocol 46).
110
111 -l Specify the link-layer header type of this packet. Default is
112 Ethernet (1). See <http://www.tcpdump.org/linktypes.html> for the
113 complete list of possible encapsulations. Note that this option
114 should be used if your dump is a complete hex dump of an
115 encapsulated packet and you wish to specify the exact type of
116 encapsulation. Example: -l 7 for ARCNet packets encapsulated BSD-
117 style.
118
119 -m <max-packet>
120 Set the maximum packet length, default is 65535. Useful for
121 testing various packet boundaries when only an application level
122 datastream is available. Example:
123
124 od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap
125
126 will convert from plain datastream format to a sequence of Ethernet
127 TCP packets.
128
129 -n Write PCAP-NG file instead of a PCAP.
130
131 -o hex|oct|dec
132 Specify the radix for the offsets (hex, octal or decimal). Defaults
133 to hex. This corresponds to the "-A" option for od.
134
135 -q Be completely quiet during the process.
136
137 -s <srcport>,<destport>,<tag>
138 Include dummy SCTP headers before each packet. Specify, in
139 decimal, the source and destination SCTP ports, and verification
140 tag, for the packet. Use this option if your dump is the SCTP
141 payload of a packet but does not include any SCTP, IP or Ethernet
142 headers. Note that appropriate Ethernet and IP headers are
143 automatically also included with each packet. A CRC32C checksum
144 will be put into the SCTP header.
145
146 -S <srcport>,<destport>,<ppi>
147 Include dummy SCTP headers before each packet. Specify, in
148 decimal, the source and destination SCTP ports, and a verification
149 tag of 0, for the packet, and prepend a dummy SCTP DATA chunk
150 header with a payload protocol identifier if ppi. Use this option
151 if your dump is the SCTP payload of a packet but does not include
152 any SCTP, IP or Ethernet headers. Note that appropriate Ethernet
153 and IP headers are automatically included with each packet. A
154 CRC32C checksum will be put into the SCTP header.
155
156 -t <timefmt>
157 Treats the text before the packet as a date/time code; timefmt is a
158 format string of the sort supported by strptime(3). Example: The
159 time "10:15:14.5476" has the format code "%H:%M:%S."
160
161 NOTE: The subsecond component delimiter must be specified (.) but
162 no pattern is required; the remaining number is assumed to be
163 fractions of a second.
164
165 NOTE: Date/time fields from the current date/time are used as the
166 default for unspecified fields.
167
168 -T <srcport>,<destport>
169 Include dummy TCP headers before each packet. Specify the source
170 and destination TCP ports for the packet in decimal. Use this
171 option if your dump is the TCP payload of a packet but does not
172 include any TCP, IP or Ethernet headers. Note that appropriate
173 Ethernet and IP headers are automatically also included with each
174 packet. Sequence numbers will start at 0.
175
176 -u <srcport>,<destport>
177 Include dummy UDP headers before each packet. Specify the source
178 and destination UDP ports for the packet in decimal. Use this
179 option if your dump is the UDP payload of a packet but does not
180 include any UDP, IP or Ethernet headers. Note that appropriate
181 Ethernet and IP headers are automatically also included with each
182 packet. Example: -u1000,69 to make the packets look like TFTP/UDP
183 packets.
184
186 od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
187 editcap(1), strptime(3), pcap-filter(7) or tcpdump(8)
188
190 Text2pcap is part of the Wireshark distribution. The latest version of
191 Wireshark can be found at <http://www.wireshark.org>.
192
194 Ashok Narayanan <ashokn[AT]cisco.com>
195
196
197
1981.10.14 2015-05-12 TEXT2PCAP(1)