Recognize -zfollow,ssl,ascii,0 for compatibility
[metze/wireshark/wip.git] / doc / text2pcap.pod
1 =begin man
2
3 =encoding utf8
4
5 =end man
6
7 =head1 NAME
8
9 text2pcap - Generate a capture file from an ASCII hexdump of packets
10
11 =head1 SYNOPSIS
12
13 B<text2pcap>
14 S<[ B<-a> ]>
15 S<[ B<-d> ]>
16 S<[ B<-D> ]>
17 S<[ B<-e> E<lt>l3pidE<gt> ]>
18 S<[ B<-h> ]>
19 S<[ B<-i> E<lt>protoE<gt> ]>
20 S<[ B<-l> E<lt>typenumE<gt> ]>
21 S<[ B<-n> ]>
22 S<[ B<-m> E<lt>max-packetE<gt> ]>
23 S<[ B<-o> hex|oct|dec ]>
24 S<[ B<-q> ]>
25 S<[ B<-s> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt> ]>
26 S<[ B<-S> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt> ]>
27 S<[ B<-t> E<lt>timefmtE<gt> ]>
28 S<[ B<-T> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
29 S<[ B<-u> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
30 S<[ B<-v> ]>
31 E<lt>I<infile>E<gt>|-
32 E<lt>I<outfile>E<gt>|-
33
34 =head1 DESCRIPTION
35
36 B<Text2pcap> is a program that reads in an ASCII hex dump and writes the
37 data described into a B<pcap> capture file.  B<text2pcap> can
38 read hexdumps with multiple packets in them, and build a capture file of
39 multiple packets.  B<text2pcap> is also capable of generating dummy
40 Ethernet, IP and UDP, TCP, or SCTP headers, in order to build fully
41 processable packet dumps from hexdumps of application-level data only.
42
43 B<Text2pcap> understands a hexdump of the form generated by I<od -Ax
44 -tx1 -v>.  In other words, each byte is individually displayed, with
45 spaces separating the bytes from each other.  Each line begins with an offset
46 describing the position in the packet, each new packet starts with an offset
47 of 0 and there is a space separating the offset from the following bytes.
48 The offset is a hex number (can also be octal or decimal - see B<-o>),
49 of more than two hex digits.
50
51 Here is a sample dump that B<text2pcap> can recognize:
52
53     000000 00 0e b6 00 00 02 00 0e b6 00 00 01 08 00 45 00
54     000010 00 28 00 00 00 00 ff 01 37 d1 c0 00 02 01 c0 00
55     000020 02 02 08 00 a6 2f 00 01 00 01 48 65 6c 6c 6f 20
56     000030 57 6f 72 6c 64 21
57     000036
58
59 Note the last byte must either be followed by the expected next offset value
60 as in the example above or a space or a line-end character(s).
61
62 There is no limit on the width or number of bytes per line. Also the
63 text dump at the end of the line is ignored. Bytes/hex numbers can be
64 uppercase or lowercase. Any text before the offset is ignored,
65 including email forwarding characters '>'. Any lines of text between
66 the bytestring lines is ignored. The offsets are used to track the
67 bytes, so offsets must be correct. Any line which has only bytes
68 without a leading offset is ignored. An offset is recognized as being
69 a hex number longer than two characters. Any text after the bytes is
70 ignored (e.g. the character dump). Any hex numbers in this text are
71 also ignored. An offset of zero is indicative of starting a new
72 packet, so a single text file with a series of hexdumps can be
73 converted into a packet capture with multiple packets. Packets may be
74 preceded by a timestamp. These are interpreted according to the format
75 given on the command line (see B<-t>). If not, the first packet
76 is timestamped with the current time the conversion takes place. Multiple
77 packets are written with timestamps differing by one microsecond each.
78 In general, short of these restrictions, B<text2pcap> is pretty liberal
79 about reading in hexdumps and has been tested with a variety of
80 mangled outputs (including being forwarded through email multiple
81 times, with limited line wrap etc.)
82
83 There are a couple of other special features to note. Any line where
84 the first non-whitespace character is '#' will be ignored as a
85 comment. Any line beginning with #TEXT2PCAP is a directive and options
86 can be inserted after this command to be processed by
87 B<text2pcap>. Currently there are no directives implemented; in the
88 future, these may be used to give more fine grained control on the
89 dump and the way it should be processed e.g. timestamps, encapsulation
90 type etc.
91
92 B<Text2pcap> also allows the user to read in dumps of
93 application-level data, by inserting dummy L2, L3 and L4 headers
94 before each packet. The user can elect to insert Ethernet headers,
95 Ethernet and IP, or Ethernet, IP and UDP/TCP/SCTP headers before each
96 packet. This allows Wireshark or any other full-packet decoder to
97 handle these dumps.
98
99 =head1 OPTIONS
100
101 =over 4
102
103 =item -a
104
105 Enables ASCII text dump identification. It allows one to identify the start of
106 the ASCII text dump and not include it in the packet even if it looks like HEX.
107
108 B<NOTE:> Do not enable it if the input file does not contain the ASCII text dump.
109
110 =item -d
111
112 Displays debugging information during the process. Can be used
113 multiple times to generate more debugging information.
114
115 =item -D
116
117 The text before the packet starts either with an I or O indicating that
118 the packet is inbound or outbound.
119 This is only stored if the output format is pcapng.
120
121 =item -e E<lt>l3pidE<gt>
122
123 Include a dummy Ethernet header before each packet. Specify the L3PID
124 for the Ethernet header in hex. Use this option if your dump has Layer
125 3 header and payload (e.g. IP header), but no Layer 2
126 encapsulation. Example: I<-e 0x806> to specify an ARP packet.
127
128 For IP packets, instead of generating a fake Ethernet header you can
129 also use I<-l 101> to indicate a raw IP packet to Wireshark. Note that
130 I<-l 101> does not work for any non-IP Layer 3 packet (e.g. ARP),
131 whereas generating a dummy Ethernet header with I<-e> works for any
132 sort of L3 packet.
133
134 =item -h
135
136 Displays a help message.
137
138 =item -i E<lt>protoE<gt>
139
140 Include dummy IP headers before each packet. Specify the IP protocol
141 for the packet in decimal. Use this option if your dump is the payload
142 of an IP packet (i.e. has complete L4 information) but does not have
143 an IP header with each packet. Note that an appropriate Ethernet header
144 is automatically included with each packet as well.
145 Example: I<-i 46> to specify an RSVP packet (IP protocol 46).  See
146 L<http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml> for
147 the complete list of assigned internet protocol numbers.
148
149 =item -l
150
151 Specify the link-layer header type of this packet.  Default is Ethernet
152 (1).  See L<http://www.tcpdump.org/linktypes.html> for the complete list
153 of possible encapsulations.  Note that this option should be used if
154 your dump is a complete hex dump of an encapsulated packet and you wish
155 to specify the exact type of encapsulation.  Example: I<-l 7> for ARCNet
156 packets encapsulated BSD-style.
157
158 =item -m E<lt>max-packetE<gt>
159
160 Set the maximum packet length, default is 262144.
161 Useful for testing various packet boundaries when only an application
162 level datastream is available.  Example:
163
164 I<od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap>
165
166 will convert from plain datastream format to a sequence of Ethernet
167 TCP packets.
168
169 =item -n
170
171 Write the file in pcapng format rather than pcap format.
172
173 =item -o hex|oct|dec
174
175 Specify the radix for the offsets (hex, octal or decimal). Defaults to
176 hex. This corresponds to the C<-A> option for I<od>.
177
178 =item -q
179
180 Be completely quiet during the process.
181
182 =item -s E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt>
183
184 Include dummy SCTP headers before each packet.  Specify, in decimal, the
185 source and destination SCTP ports, and verification tag, for the packet.
186 Use this option if your dump is the SCTP payload of a packet but does
187 not include any SCTP, IP or Ethernet headers.  Note that appropriate
188 Ethernet and IP headers are automatically also included with each
189 packet.  A CRC32C checksum will be put into the SCTP header.
190
191 =item -S E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt>
192
193 Include dummy SCTP headers before each packet.  Specify, in decimal, the
194 source and destination SCTP ports, and a verification tag of 0, for the
195 packet, and prepend a dummy SCTP DATA chunk header with a payload
196 protocol identifier if I<ppi>.  Use this option if your dump is the SCTP
197 payload of a packet but does not include any SCTP, IP or Ethernet
198 headers.  Note that appropriate Ethernet and IP headers are
199 automatically included with each packet.  A CRC32C checksum will be put
200 into the SCTP header.
201
202 =item -t E<lt>timefmtE<gt>
203
204 Treats the text before the packet as a date/time code; I<timefmt> is a
205 format string of the sort supported by strptime(3).
206 Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
207
208 B<NOTE:> The subsecond component delimiter must be specified (.) but no
209 pattern is required; the remaining number is assumed to be fractions of
210 a second.
211
212 B<NOTE:> Date/time fields from the current date/time are
213 used as the default for unspecified fields.
214
215 =item -T E<lt>srcportE<gt>,E<lt>destportE<gt>
216
217 Include dummy TCP headers before each packet. Specify the source and
218 destination TCP ports for the packet in decimal. Use this option if
219 your dump is the TCP payload of a packet but does not include any TCP,
220 IP or Ethernet headers. Note that appropriate Ethernet and IP headers
221 are automatically also included with each packet.
222 Sequence numbers will start at 0.
223
224 =item -u E<lt>srcportE<gt>,E<lt>destportE<gt>
225
226 Include dummy UDP headers before each packet. Specify the source and
227 destination UDP ports for the packet in decimal. Use this option if
228 your dump is the UDP payload of a packet but does not include any UDP,
229 IP or Ethernet headers. Note that appropriate Ethernet and IP headers
230 are automatically also included with each packet.
231 Example: I<-u1000,69> to make the packets look like TFTP/UDP packets.
232
233 =item -v
234
235 Print the version and exit.
236
237 =item -4 E<lt>srcipE<gt>,E<lt>destipE<gt>
238
239 Prepend dummy IP header with specified IPv4 dest and source address.
240 This option should be accompanied by one of the following options: -i, -s, -S, -T, -u
241 Use this option to apply "custom" IP addresses.
242 Example: I<-4 10.0.0.1,10.0.0.2> to use 10.0.0.1 and 10.0.0.2 for all IP packets.
243
244 =item -6 E<lt>srcipE<gt>,E<lt>destipE<gt>
245
246 Prepend dummy IP header with specified IPv6 dest and source address.
247 This option should be accompanied by one of the following options: -i, -s, -S, -T, -u
248 Use this option to apply "custom" IP addresses.
249 Example: I<-6 fe80:0:0:0:202:b3ff:fe1e:8329, 2001:0db8:85a3:0000:0000:8a2e:0370:7334> to
250 use fe80:0:0:0:202:b3ff:fe1e:8329 and 2001:0db8:85a3:0000:0000:8a2e:0370:7334 for all IP packets.
251
252 =back
253
254 =head1 SEE ALSO
255
256 od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
257 editcap(1), strptime(3), pcap-filter(7) or tcpdump(8)
258
259 =head1 NOTES
260
261 B<Text2pcap> is part of the B<Wireshark> distribution.  The latest version
262 of B<Wireshark> can be found at L<https://www.wireshark.org>.
263
264 =head1 AUTHORS
265
266   Ashok Narayanan          <ashokn[AT]cisco.com>