2021-10-19 23:26:37 +00:00
include::../docbook/attributes.adoc[]
2021-06-18 10:20:51 +00:00
= text2pcap(1)
:doctype: manpage
:stylesheet: ws.css
:linkcss:
:copycss: ../docbook/{stylesheet}
2018-08-17 18:34:57 +00:00
2021-06-18 10:20:51 +00:00
== NAME
2001-05-16 21:32:05 +00:00
2001-07-05 21:27:11 +00:00
text2pcap - Generate a capture file from an ASCII hexdump of packets
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
== SYNOPSIS
[manarg]
*text2pcap*
[ *-a* ]
[ *-d* ]
[ *-D* ]
[ *-e* <l3pid> ]
[ *-h* ]
[ *-i* <proto> ]
[ *-l* <typenum> ]
[ *-n* ]
[ *-N* <intf-name> ]
[ *-m* <max-packet> ]
[ *-o* hex|oct|dec ]
[ *-q* ]
[ *-s* <srcport>,<destport>,<tag> ]
[ *-S* <srcport>,<destport>,<ppi> ]
[ *-t* <timefmt> ]
[ *-T* <srcport>,<destport> ]
[ *-u* <srcport>,<destport> ]
[ *-v* ]
[ *-4* <srcip>,<destip> ]
[ *-6* <srcip>,<destip> ]
<__infile__>|-
<__outfile__>|-
== DESCRIPTION
*Text2pcap* is a program that reads in an ASCII hex dump and writes the
data described into a *pcap* or *pcapng* capture file. *text2pcap* can
2005-09-02 16:50:51 +00:00
read hexdumps with multiple packets in them, and build a capture file of
2021-06-18 10:20:51 +00:00
multiple packets. *text2pcap* is also capable of generating dummy
2005-09-02 16:50:51 +00:00
Ethernet, IP and UDP, TCP, or SCTP headers, in order to build fully
processable packet dumps from hexdumps of application-level data only.
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
*Text2pcap* understands a hexdump of the form generated by __od -Ax
-tx1 -v__. In other words, each byte is individually displayed, with
2016-08-03 12:32:05 +00:00
spaces separating the bytes from each other. Each line begins with an offset
describing the position in the packet, each new packet starts with an offset
of 0 and there is a space separating the offset from the following bytes.
2021-06-18 10:20:51 +00:00
The offset is a hex number (can also be octal or decimal - see *-o*),
2016-08-03 12:32:05 +00:00
of more than two hex digits.
2021-06-18 10:20:51 +00:00
Here is a sample dump that *text2pcap* can recognize:
2001-05-16 21:32:05 +00:00
2013-12-26 03:45:12 +00:00
000000 00 0e b6 00 00 02 00 0e b6 00 00 01 08 00 45 00
000010 00 28 00 00 00 00 ff 01 37 d1 c0 00 02 01 c0 00
000020 02 02 08 00 a6 2f 00 01 00 01 48 65 6c 6c 6f 20
000030 57 6f 72 6c 64 21
000036
2001-05-16 21:32:05 +00:00
2016-08-03 16:00:31 +00:00
Note the last byte must either be followed by the expected next offset value
as in the example above or a space or a line-end character(s).
2001-05-16 21:32:05 +00:00
There is no limit on the width or number of bytes per line. Also the
text dump at the end of the line is ignored. Bytes/hex numbers can be
uppercase or lowercase. Any text before the offset is ignored,
including email forwarding characters '>'. Any lines of text between
the bytestring lines is ignored. The offsets are used to track the
bytes, so offsets must be correct. Any line which has only bytes
without a leading offset is ignored. An offset is recognized as being
a hex number longer than two characters. Any text after the bytes is
ignored (e.g. the character dump). Any hex numbers in this text are
also ignored. An offset of zero is indicative of starting a new
packet, so a single text file with a series of hexdumps can be
2021-12-02 19:34:45 +00:00
converted into a packet capture with multiple packets.
Packets may be preceded by a direction indicator and a timestamp if
indicated by the command line (see *-D* and *-t*). The format of the
timestamps is specified as a mandatory parameter to *-t*. If timestamp
parsing is not enabled or failed, the first packet is timestamped
with the current time the conversion takes place. Multiple packets
are written with timestamps differing by one microsecond each.
2021-06-18 10:20:51 +00:00
In general, short of these restrictions, *text2pcap* is pretty liberal
2001-05-16 21:32:05 +00:00
about reading in hexdumps and has been tested with a variety of
mangled outputs (including being forwarded through email multiple
times, with limited line wrap etc.)
There are a couple of other special features to note. Any line where
the first non-whitespace character is '#' will be ignored as a
comment. Any line beginning with #TEXT2PCAP is a directive and options
can be inserted after this command to be processed by
2021-06-18 10:20:51 +00:00
*text2pcap*. Currently there are no directives implemented; in the
2001-05-16 21:32:05 +00:00
future, these may be used to give more fine grained control on the
dump and the way it should be processed e.g. timestamps, encapsulation
type etc.
2021-06-18 10:20:51 +00:00
*Text2pcap* also allows the user to read in dumps of
2001-05-16 21:32:05 +00:00
application-level data, by inserting dummy L2, L3 and L4 headers
before each packet. The user can elect to insert Ethernet headers,
2010-11-19 00:05:38 +00:00
Ethernet and IP, or Ethernet, IP and UDP/TCP/SCTP headers before each
2006-05-31 19:12:15 +00:00
packet. This allows Wireshark or any other full-packet decoder to
2001-05-16 21:32:05 +00:00
handle these dumps.
2021-06-18 10:20:51 +00:00
== OPTIONS
2002-07-21 20:28:35 +00:00
2021-06-18 10:20:51 +00:00
-a::
+
--
2016-01-16 11:20:16 +00:00
Enables ASCII text dump identification. It allows one to identify the start of
2012-03-15 15:03:08 +00:00
the ASCII text dump and not include it in the packet even if it looks like HEX.
2021-06-18 10:20:51 +00:00
*NOTE:* Do not enable it if the input file does not contain the ASCII text dump.
--
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
-d::
+
--
2001-05-16 21:32:05 +00:00
Displays debugging information during the process. Can be used
multiple times to generate more debugging information.
2021-06-18 10:20:51 +00:00
--
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
-D::
+
--
2021-12-02 19:34:45 +00:00
The text before the packet may start either with an I or O indicating that
2018-11-21 18:36:18 +00:00
the packet is inbound or outbound. This is used when generating dummy headers.
The indication is only stored if the output format is pcapng.
2021-06-18 10:20:51 +00:00
--
2012-12-25 22:37:40 +00:00
2021-06-18 10:20:51 +00:00
-e <l3pid>::
+
--
2001-05-16 21:32:05 +00:00
Include a dummy Ethernet header before each packet. Specify the L3PID
2001-05-16 22:50:36 +00:00
for the Ethernet header in hex. Use this option if your dump has Layer
3 header and payload (e.g. IP header), but no Layer 2
2021-06-18 10:20:51 +00:00
encapsulation. Example: __-e 0x806__ to specify an ARP packet.
2001-05-16 22:50:36 +00:00
For IP packets, instead of generating a fake Ethernet header you can
2021-06-18 10:20:51 +00:00
also use __-l 101__ to indicate a raw IP packet to Wireshark. Note that
__-l 101__ does not work for any non-IP Layer 3 packet (e.g. ARP),
whereas generating a dummy Ethernet header with __-e__ works for any
2001-05-16 22:50:36 +00:00
sort of L3 packet.
2021-06-18 10:20:51 +00:00
--
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
-h::
+
--
2012-03-15 15:03:08 +00:00
Displays a help message.
2021-06-18 10:20:51 +00:00
--
2012-03-15 15:03:08 +00:00
2021-06-18 10:20:51 +00:00
-i <proto>::
+
--
2001-05-16 21:32:05 +00:00
Include dummy IP headers before each packet. Specify the IP protocol
for the packet in decimal. Use this option if your dump is the payload
of an IP packet (i.e. has complete L4 information) but does not have
2009-05-12 16:24:57 +00:00
an IP header with each packet. Note that an appropriate Ethernet header
2012-02-03 09:07:24 +00:00
is automatically included with each packet as well.
2021-06-18 10:20:51 +00:00
Example: __-i 46__ to specify an RSVP packet (IP protocol 46). See
https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml for
2013-09-11 17:31:24 +00:00
the complete list of assigned internet protocol numbers.
2021-06-18 10:20:51 +00:00
--
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
-l::
+
--
2012-03-15 15:03:08 +00:00
Specify the link-layer header type of this packet. Default is Ethernet
2021-06-18 10:20:51 +00:00
(1). See https://www.tcpdump.org/linktypes.html for the complete list
2012-03-15 15:03:08 +00:00
of possible encapsulations. Note that this option should be used if
your dump is a complete hex dump of an encapsulated packet and you wish
2021-06-18 10:20:51 +00:00
to specify the exact type of encapsulation. Example: __-l 7__ for ARCNet
2013-07-29 08:30:42 +00:00
packets encapsulated BSD-style.
2021-06-18 10:20:51 +00:00
--
2012-03-15 15:03:08 +00:00
2021-06-18 10:20:51 +00:00
-m <max-packet>::
+
--
2017-03-28 09:15:13 +00:00
Set the maximum packet length, default is 262144.
2003-04-27 00:41:52 +00:00
Useful for testing various packet boundaries when only an application
level datastream is available. Example:
2003-04-27 00:50:06 +00:00
2021-06-18 10:20:51 +00:00
__od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap__
2003-04-27 00:50:06 +00:00
2003-04-27 00:41:52 +00:00
will convert from plain datastream format to a sequence of Ethernet
TCP packets.
2021-06-18 10:20:51 +00:00
--
2003-04-27 00:41:52 +00:00
2021-06-18 10:20:51 +00:00
-n::
+
--
2018-01-09 00:38:10 +00:00
Write the file in pcapng format rather than pcap format.
2021-06-18 10:20:51 +00:00
--
2012-12-22 09:43:17 +00:00
2021-06-18 10:20:51 +00:00
-N <intf-name>::
+
--
2018-12-11 22:45:36 +00:00
Specify a name for the interface included when writing a pcapng format
file. By default no name is defined.
2021-06-18 10:20:51 +00:00
--
2018-12-11 22:45:36 +00:00
2021-06-18 10:20:51 +00:00
-o hex|oct|dec::
+
--
2012-03-15 15:03:08 +00:00
Specify the radix for the offsets (hex, octal or decimal). Defaults to
2021-06-18 10:20:51 +00:00
hex. This corresponds to the `-A` option for __od__.
--
2003-04-27 00:41:52 +00:00
2021-06-18 10:20:51 +00:00
-q::
+
--
2012-03-15 15:03:08 +00:00
Be completely quiet during the process.
2021-06-18 10:20:51 +00:00
--
2003-04-27 00:41:52 +00:00
2021-06-18 10:20:51 +00:00
-s <srcport>,<destport>,<tag>::
+
--
2002-04-13 18:36:24 +00:00
Include dummy SCTP headers before each packet. Specify, in decimal, the
2012-02-03 09:07:24 +00:00
source and destination SCTP ports, and verification tag, for the packet.
2002-04-13 18:36:24 +00:00
Use this option if your dump is the SCTP payload of a packet but does
2012-02-03 09:07:24 +00:00
not include any SCTP, IP or Ethernet headers. Note that appropriate
2009-05-12 16:24:57 +00:00
Ethernet and IP headers are automatically also included with each
2002-04-13 18:36:24 +00:00
packet. A CRC32C checksum will be put into the SCTP header.
2021-06-18 10:20:51 +00:00
--
2002-04-13 18:36:24 +00:00
2021-06-18 10:20:51 +00:00
-S <srcport>,<destport>,<ppi>::
+
--
2002-04-13 18:36:24 +00:00
Include dummy SCTP headers before each packet. Specify, in decimal, the
source and destination SCTP ports, and a verification tag of 0, for the
packet, and prepend a dummy SCTP DATA chunk header with a payload
2021-06-18 10:20:51 +00:00
protocol identifier if __ppi__. Use this option if your dump is the SCTP
2002-04-13 18:36:24 +00:00
payload of a packet but does not include any SCTP, IP or Ethernet
2012-02-03 09:07:24 +00:00
headers. Note that appropriate Ethernet and IP headers are
2010-11-09 03:20:15 +00:00
automatically included with each packet. A CRC32C checksum will be put
into the SCTP header.
2021-06-18 10:20:51 +00:00
--
2002-01-16 21:05:10 +00:00
2021-06-18 10:20:51 +00:00
-t <timefmt>::
+
--
Treats the text before the packet as a date/time code; __timefmt__ is a
2021-12-02 19:34:45 +00:00
format string of the sort supported by strftime(3).
2001-11-24 08:14:12 +00:00
Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
2021-12-02 19:34:45 +00:00
The special format string __ISO__ indicates that the string should be
parsed according to the ISO-8601 specification.
2001-11-24 08:14:12 +00:00
2021-06-18 10:20:51 +00:00
*NOTE:* The subsecond component delimiter must be specified (.) but no
2001-11-24 08:14:12 +00:00
pattern is required; the remaining number is assumed to be fractions of
a second.
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
*NOTE:* Date/time fields from the current date/time are
2007-09-20 16:12:17 +00:00
used as the default for unspecified fields.
2021-06-18 10:20:51 +00:00
--
2007-09-20 16:12:17 +00:00
2021-06-18 10:20:51 +00:00
-T <srcport>,<destport>::
+
--
2012-03-15 15:03:08 +00:00
Include dummy TCP headers before each packet. Specify the source and
destination TCP ports for the packet in decimal. Use this option if
your dump is the TCP payload of a packet but does not include any TCP,
IP or Ethernet headers. Note that appropriate Ethernet and IP headers
are automatically also included with each packet.
Sequence numbers will start at 0.
2021-06-18 10:20:51 +00:00
--
2011-09-05 20:03:03 +00:00
2021-06-18 10:20:51 +00:00
-u <srcport>,<destport>::
+
--
2012-03-15 15:03:08 +00:00
Include dummy UDP headers before each packet. Specify the source and
destination UDP ports for the packet in decimal. Use this option if
your dump is the UDP payload of a packet but does not include any UDP,
IP or Ethernet headers. Note that appropriate Ethernet and IP headers
are automatically also included with each packet.
2021-06-18 10:20:51 +00:00
Example: __-u1000,69__ to make the packets look like TFTP/UDP packets.
--
2014-06-20 18:48:27 +00:00
2021-06-18 10:20:51 +00:00
-v::
+
--
2014-06-20 18:48:27 +00:00
Print the version and exit.
2021-06-18 10:20:51 +00:00
--
2014-06-20 18:48:27 +00:00
2021-06-18 10:20:51 +00:00
-4 <srcip>,<destip>::
+
--
2013-06-16 16:50:17 +00:00
Prepend dummy IP header with specified IPv4 dest and source address.
This option should be accompanied by one of the following options: -i, -s, -S, -T, -u
Use this option to apply "custom" IP addresses.
2021-06-18 10:20:51 +00:00
Example: __-4 10.0.0.1,10.0.0.2__ to use 10.0.0.1 and 10.0.0.2 for all IP packets.
--
2013-06-16 16:50:17 +00:00
2021-06-18 10:20:51 +00:00
-6 <srcip>,<destip>::
+
--
2013-06-16 16:50:17 +00:00
Prepend dummy IP header with specified IPv6 dest and source address.
This option should be accompanied by one of the following options: -i, -s, -S, -T, -u
Use this option to apply "custom" IP addresses.
2021-06-18 10:20:51 +00:00
Example: __-6 fe80::202:b3ff:fe1e:8329,2001:0db8:85a3::8a2e:0370:7334__ to
2018-11-21 18:36:18 +00:00
use fe80::202:b3ff:fe1e:8329 and 2001:0db8:85a3::8a2e:0370:7334 for all IP packets.
2021-06-18 10:20:51 +00:00
--
2013-06-16 16:50:17 +00:00
2021-06-18 10:20:51 +00:00
== SEE ALSO
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
od(1), xref:https://www.tcpdump.org/manpages/pcap.3pcap.html[pcap](3), xref:wireshark.html[wireshark](1), xref:tshark.html[tshark](1), xref:dumpcap.html[dumpcap](1), xref:mergecap.html[mergecap](1),
2021-12-02 19:34:45 +00:00
xref:editcap.html[editcap](1), strftime(3), xref:https://www.tcpdump.org/manpages/pcap-filter.7.html[pcap-filter](7) or xref:https://www.tcpdump.org/manpages/tcpdump.1.html[tcpdump](8)
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
== NOTES
2001-05-16 21:32:05 +00:00
2021-10-01 23:36:17 +00:00
This is the manual page for *Text2pcap* {wireshark-version}.
*Text2pcap* is part of the *Wireshark* distribution.
The latest version of *Wireshark* can be found at https://www.wireshark.org.
2001-05-16 21:32:05 +00:00
2021-06-18 10:20:51 +00:00
== AUTHORS
2001-05-16 21:32:05 +00:00
2021-10-01 23:36:17 +00:00
.Original Author
[%hardbreaks]
Ashok Narayanan <ashokn[AT]cisco.com>