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 ] [ -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> ] [ -v ] <infile>|- <outfile>|-
14

DESCRIPTION

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

OPTIONS

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

SEE ALSO

210       od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
211       editcap(1), strptime(3), pcap-filter(7) or tcpdump(8)
212

NOTES

214       Text2pcap is part of the Wireshark distribution.  The latest version of
215       Wireshark can be found at <https://www.wireshark.org>.
216

AUTHORS

218         Ashok Narayanan          <ashokn[AT]cisco.com>
219
220
221
2222.6.2                             2018-07-18                      TEXT2PCAP(1)
Impressum