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

SEE ALSO

244       od(1), pcap(3), wireshark(1), tshark(1), dumpcap(1), mergecap(1),
245       editcap(1), strptime(3), pcap-filter(7) or tcpdump(8)
246

NOTES

248       This is the manual page for Text2pcap 3.6.0. Text2pcap is part of the
249       Wireshark distribution. The latest version of Wireshark can be found at
250       https://www.wireshark.org.
251

AUTHORS

253       Original Author
254       Ashok Narayanan <ashokn[AT]cisco.com>
255
256
257
258                                  2021-11-25                      TEXT2PCAP(1)
Impressum