1TEXT2PCAP(1)            The Wireshark Network Analyzer            TEXT2PCAP(1)
2
3
4

NAME

6       text2pcap - Generate a capture file from an ASCII hexdump of packets
7

SYNOPSIS

9       text2pcap [ -a ] [ -d ] [ -D ] [ -e <l3pid> ] [ -h ] [ -i <proto> ]
10       [ -l <typenum> ] [ -n ] [ -N <intf-name> ] [ -m <max-packet> ]
11       [ -o hex|oct|dec ] [ -q ] [ -s <srcport>,<destport>,<tag> ]
12       [ -S <srcport>,<destport>,<ppi> ] [ -t <timefmt> ]
13       [ -T <srcport>,<destport> ] [ -u <srcport>,<destport> ] [ -v ]
14       [ -4 <srcip>,<destip> ] [ -6 <srcip>,<destip> ] <infile>|- <outfile>|-
15

DESCRIPTION

17       Text2pcap is a program that reads in an ASCII hex dump and writes the
18       data described into a pcap or pcapng capture file.  text2pcap can read
19       hexdumps with multiple packets in them, and build a capture file of
20       multiple packets.  text2pcap is also capable of generating dummy
21       Ethernet, IP and UDP, TCP, or SCTP headers, in order to build fully
22       processable packet dumps from hexdumps of application-level data only.
23
24       Text2pcap understands a hexdump of the form generated by od -Ax -tx1
25       -v.  In other words, each byte is individually displayed, with spaces
26       separating the bytes from each other.  Each line begins with an offset
27       describing the position in the packet, each new packet starts with an
28       offset of 0 and there is a space separating the offset from the
29       following bytes.  The offset is a hex number (can also be octal or
30       decimal - see -o), of more than two hex digits.
31
32       Here is a sample dump that text2pcap can recognize:
33
34           000000 00 0e b6 00 00 02 00 0e b6 00 00 01 08 00 45 00
35           000010 00 28 00 00 00 00 ff 01 37 d1 c0 00 02 01 c0 00
36           000020 02 02 08 00 a6 2f 00 01 00 01 48 65 6c 6c 6f 20
37           000030 57 6f 72 6c 64 21
38           000036
39
40       Note the last byte must either be followed by the expected next offset
41       value as in the example above or a space or a line-end character(s).
42
43       There is no limit on the width or number of bytes per line. Also the
44       text dump at the end of the line is ignored. Bytes/hex numbers can be
45       uppercase or lowercase. Any text before the offset is ignored,
46       including email forwarding characters '>'. Any lines of text between
47       the bytestring lines is ignored. The offsets are used to track the
48       bytes, so offsets must be correct. Any line which has only bytes
49       without a leading offset is ignored. An offset is recognized as being a
50       hex number longer than two characters. Any text after the bytes is
51       ignored (e.g. the character dump). Any hex numbers in this text are
52       also ignored. An offset of zero is indicative of starting a new packet,
53       so a single text file with a series of hexdumps can be converted into a
54       packet capture with multiple packets. Packets may be preceded by a
55       timestamp. These are interpreted according to the format given on the
56       command line (see -t). If not, the first packet is timestamped with the
57       current time the conversion takes place. Multiple packets are written
58       with timestamps differing by one microsecond each.  In general, short
59       of these restrictions, text2pcap is pretty liberal about reading in
60       hexdumps and has been tested with a variety of mangled outputs
61       (including being forwarded through email multiple times, with limited
62       line wrap etc.)
63
64       There are a couple of other special features to note. Any line where
65       the first non-whitespace character is '#' will be ignored as a comment.
66       Any line beginning with #TEXT2PCAP is a directive and options can be
67       inserted after this command to be processed by text2pcap. Currently
68       there are no directives implemented; in the future, these may be used
69       to give more fine grained control on the dump and the way it should be
70       processed e.g. timestamps, encapsulation type etc.
71
72       Text2pcap also allows the user to read in dumps of application-level
73       data, by inserting dummy L2, L3 and L4 headers before each packet. The
74       user can elect to insert Ethernet headers, Ethernet and IP, or
75       Ethernet, IP and UDP/TCP/SCTP headers before each packet. This allows
76       Wireshark or any other full-packet decoder to handle these dumps.
77

OPTIONS

79       -a  Enables ASCII text dump identification. It allows one to identify
80           the start of the ASCII text dump and not include it in the packet
81           even if it looks like HEX.
82
83           NOTE: Do not enable it if the input file does not contain the ASCII
84           text dump.
85
86       -d  Displays debugging information during the process. Can be used
87           multiple times to generate more debugging information.
88
89       -D  The text before the packet starts either with an I or O indicating
90           that the packet is inbound or outbound. This is used when
91           generating dummy headers.  The indication is only stored if the
92           output format is pcapng.
93
94       -e <l3pid>
95           Include a dummy Ethernet header before each packet. Specify the
96           L3PID for the Ethernet header in hex. Use this option if your dump
97           has Layer 3 header and payload (e.g. IP header), but no Layer 2
98           encapsulation. Example: -e 0x806 to specify an ARP packet.
99
100           For IP packets, instead of generating a fake Ethernet header you
101           can also use -l 101 to indicate a raw IP packet to Wireshark. Note
102           that -l 101 does not work for any non-IP Layer 3 packet (e.g. ARP),
103           whereas generating a dummy Ethernet header with -e works for any
104           sort of L3 packet.
105
106       -h  Displays a help message.
107
108       -i <proto>
109           Include dummy IP headers before each packet. Specify the IP
110           protocol for the packet in decimal. Use this option if your dump is
111           the payload of an IP packet (i.e. has complete L4 information) but
112           does not have an IP header with each packet. Note that an
113           appropriate Ethernet header is automatically included with each
114           packet as well.  Example: -i 46 to specify an RSVP packet (IP
115           protocol 46).  See
116           <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml>
117           for the complete list of assigned internet protocol numbers.
118
119       -l  Specify the link-layer header type of this packet.  Default is
120           Ethernet (1).  See <http://www.tcpdump.org/linktypes.html> for the
121           complete list of possible encapsulations.  Note that this option
122           should be used if your dump is a complete hex dump of an
123           encapsulated packet and you wish to specify the exact type of
124           encapsulation.  Example: -l 7 for ARCNet packets encapsulated BSD-
125           style.
126
127       -m <max-packet>
128           Set the maximum packet length, default is 262144.  Useful for
129           testing various packet boundaries when only an application level
130           datastream is available.  Example:
131
132           od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap
133
134           will convert from plain datastream format to a sequence of Ethernet
135           TCP packets.
136
137       -n  Write the file in pcapng format rather than pcap format.
138
139       -N <intf-name>
140           Specify a name for the interface included when writing a pcapng
141           format file. By default no name is defined.
142
143       -o hex|oct|dec
144           Specify the radix for the offsets (hex, octal or decimal). Defaults
145           to hex. This corresponds to the "-A" option for od.
146
147       -q  Be completely quiet during the process.
148
149       -s <srcport>,<destport>,<tag>
150           Include dummy SCTP headers before each packet.  Specify, in
151           decimal, the source and destination SCTP ports, and verification
152           tag, for the packet.  Use this option if your dump is the SCTP
153           payload of a packet but does not include any SCTP, IP or Ethernet
154           headers.  Note that appropriate Ethernet and IP headers are
155           automatically also included with each packet.  A CRC32C checksum
156           will be put into the SCTP header.
157
158       -S <srcport>,<destport>,<ppi>
159           Include dummy SCTP headers before each packet.  Specify, in
160           decimal, the source and destination SCTP ports, and a verification
161           tag of 0, for the packet, and prepend a dummy SCTP DATA chunk
162           header with a payload protocol identifier if ppi.  Use this option
163           if your dump is the SCTP payload of a packet but does not include
164           any SCTP, IP or Ethernet headers.  Note that appropriate Ethernet
165           and IP headers are automatically included with each packet.  A
166           CRC32C checksum will be put into the SCTP header.
167
168       -t <timefmt>
169           Treats the text before the packet as a date/time code; timefmt is a
170           format string of the sort supported by strptime(3).  Example: The
171           time "10:15:14.5476" has the format code "%H:%M:%S."
172
173           NOTE: The subsecond component delimiter must be specified (.) but
174           no pattern is required; the remaining number is assumed to be
175           fractions of a second.
176
177           NOTE: Date/time fields from the current date/time are used as the
178           default for unspecified fields.
179
180       -T <srcport>,<destport>
181           Include dummy TCP headers before each packet. Specify the source
182           and destination TCP ports for the packet in decimal. Use this
183           option if your dump is the TCP payload of a packet but does not
184           include any TCP, IP or Ethernet headers. Note that appropriate
185           Ethernet and IP headers are automatically also included with each
186           packet.  Sequence numbers will start at 0.
187
188       -u <srcport>,<destport>
189           Include dummy UDP headers before each packet. Specify the source
190           and destination UDP ports for the packet in decimal. Use this
191           option if your dump is the UDP payload of a packet but does not
192           include any UDP, IP or Ethernet headers. Note that appropriate
193           Ethernet and IP headers are automatically also included with each
194           packet.  Example: -u1000,69 to make the packets look like TFTP/UDP
195           packets.
196
197       -v  Print the version and exit.
198
199       -4 <srcip>,<destip>
200           Prepend dummy IP header with specified IPv4 dest and source
201           address.  This option should be accompanied by one of the following
202           options: -i, -s, -S, -T, -u Use this option to apply "custom" IP
203           addresses.  Example: -4 10.0.0.1,10.0.0.2 to use 10.0.0.1 and
204           10.0.0.2 for all IP packets.
205
206       -6 <srcip>,<destip>
207           Prepend dummy IP header with specified IPv6 dest and source
208           address.  This option should be accompanied by one of the following
209           options: -i, -s, -S, -T, -u Use this option to apply "custom" IP
210           addresses.  Example: -6
211           fe80::202:b3ff:fe1e:8329,2001:0db8:85a3::8a2e:0370:7334 to use
212           fe80::202:b3ff:fe1e:8329 and 2001:0db8:85a3::8a2e:0370:7334 for all
213           IP packets.
214

SEE ALSO

216       od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
217       editcap(1), strptime(3), pcap-filter(7) or tcpdump(8)
218

NOTES

220       Text2pcap is part of the Wireshark distribution.  The latest version of
221       Wireshark can be found at <https://www.wireshark.org>.
222

AUTHORS

224         Ashok Narayanan          <ashokn[AT]cisco.com>
225
226
227
2283.0.1                             2019-04-08                      TEXT2PCAP(1)
Impressum