.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "TEXT2PCAP 1" .TH TEXT2PCAP 1 "2021-12-09" "3.4.10" "The Wireshark Network Analyzer" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" text2pcap \- Generate a capture file from an ASCII hexdump of packets .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBtext2pcap\fR [\ \fB\-a\fR\ ] [\ \fB\-d\fR\ ] [\ \fB\-D\fR\ ] [\ \fB\-e\fR\ \ ] [\ \fB\-h\fR\ ] [\ \fB\-i\fR\ \ ] [\ \fB\-l\fR\ \ ] [\ \fB\-n\fR\ ] [\ \fB\-N\fR\ \ ] [\ \fB\-m\fR\ \ ] [\ \fB\-o\fR\ hex|oct|dec\ ] [\ \fB\-q\fR\ ] [\ \fB\-s\fR\ ,,\ ] [\ \fB\-S\fR\ ,,\ ] [\ \fB\-t\fR\ \ ] [\ \fB\-T\fR\ ,\ ] [\ \fB\-u\fR\ ,\ ] [\ \fB\-v\fR\ ] [\ \fB\-4\fR\ ,\ ] [\ \fB\-6\fR\ ,\ ] <\fIinfile\fR>|\- <\fIoutfile\fR>|\- .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBText2pcap\fR is a program that reads in an \s-1ASCII\s0 hex dump and writes the data described into a \fBpcap\fR or \fBpcapng\fR capture file. \fBtext2pcap\fR can read hexdumps with multiple packets in them, and build a capture file of multiple packets. \fBtext2pcap\fR is also capable of generating dummy Ethernet, \s-1IP\s0 and \s-1UDP, TCP,\s0 or \s-1SCTP\s0 headers, in order to build fully processable packet dumps from hexdumps of application-level data only. .PP \&\fBText2pcap\fR understands a hexdump of the form generated by \fIod \-Ax \&\-tx1 \-v\fR. In other words, each byte is individually displayed, with 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. The offset is a hex number (can also be octal or decimal \- see \fB\-o\fR), of more than two hex digits. .PP Here is a sample dump that \fBtext2pcap\fR can recognize: .PP .Vb 5 \& 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 .Ve .PP 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). .PP 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 converted into a packet capture with multiple packets. Packets may be preceded by a timestamp. These are interpreted according to the format given on the command line (see \fB\-t\fR). If not, the first packet is timestamped with the current time the conversion takes place. Multiple packets are written with timestamps differing by one microsecond each. In general, short of these restrictions, \fBtext2pcap\fR is pretty liberal 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.) .PP 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 \&\fBtext2pcap\fR. Currently there are no directives implemented; in the 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. .PP \&\fBText2pcap\fR also allows the user to read in dumps of application-level data, by inserting dummy L2, L3 and L4 headers before each packet. The user can elect to insert Ethernet headers, Ethernet and \s-1IP,\s0 or Ethernet, \s-1IP\s0 and \s-1UDP/TCP/SCTP\s0 headers before each packet. This allows Wireshark or any other full-packet decoder to handle these dumps. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\-a" 4 .IX Item "-a" Enables \s-1ASCII\s0 text dump identification. It allows one to identify the start of the \s-1ASCII\s0 text dump and not include it in the packet even if it looks like \s-1HEX.\s0 .Sp \&\fB\s-1NOTE:\s0\fR Do not enable it if the input file does not contain the \s-1ASCII\s0 text dump. .IP "\-d" 4 .IX Item "-d" Displays debugging information during the process. Can be used multiple times to generate more debugging information. .IP "\-D" 4 .IX Item "-D" The text before the packet starts either with an I or O indicating that the packet is inbound or outbound. This is used when generating dummy headers. The indication is only stored if the output format is pcapng. .IP "\-e " 4 .IX Item "-e " Include a dummy Ethernet header before each packet. Specify the L3PID for the Ethernet header in hex. Use this option if your dump has Layer 3 header and payload (e.g. \s-1IP\s0 header), but no Layer 2 encapsulation. Example: \fI\-e 0x806\fR to specify an \s-1ARP\s0 packet. .Sp For \s-1IP\s0 packets, instead of generating a fake Ethernet header you can also use \fI\-l 101\fR to indicate a raw \s-1IP\s0 packet to Wireshark. Note that \&\fI\-l 101\fR does not work for any non-IP Layer 3 packet (e.g. \s-1ARP\s0), whereas generating a dummy Ethernet header with \fI\-e\fR works for any sort of L3 packet. .IP "\-h" 4 .IX Item "-h" Displays a help message. .IP "\-i " 4 .IX Item "-i " Include dummy \s-1IP\s0 headers before each packet. Specify the \s-1IP\s0 protocol for the packet in decimal. Use this option if your dump is the payload of an \s-1IP\s0 packet (i.e. has complete L4 information) but does not have an \s-1IP\s0 header with each packet. Note that an appropriate Ethernet header is automatically included with each packet as well. Example: \fI\-i 46\fR to specify an \s-1RSVP\s0 packet (\s-1IP\s0 protocol 46). See for the complete list of assigned internet protocol numbers. .IP "\-l" 4 .IX Item "-l" Specify the link-layer header type of this packet. Default is Ethernet (1). See for the complete list 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 to specify the exact type of encapsulation. Example: \fI\-l 7\fR for ARCNet packets encapsulated BSD-style. .IP "\-m " 4 .IX Item "-m " Set the maximum packet length, default is 262144. Useful for testing various packet boundaries when only an application level datastream is available. Example: .Sp \&\fIod \-Ax \-tx1 \-v stream | text2pcap \-m1460 \-T1234,1234 \- stream.pcap\fR .Sp will convert from plain datastream format to a sequence of Ethernet \&\s-1TCP\s0 packets. .IP "\-n" 4 .IX Item "-n" Write the file in pcapng format rather than pcap format. .IP "\-N " 4 .IX Item "-N " Specify a name for the interface included when writing a pcapng format file. By default no name is defined. .IP "\-o hex|oct|dec" 4 .IX Item "-o hex|oct|dec" Specify the radix for the offsets (hex, octal or decimal). Defaults to hex. This corresponds to the \f(CW\*(C`\-A\*(C'\fR option for \fIod\fR. .IP "\-q" 4 .IX Item "-q" Be completely quiet during the process. .IP "\-s ,," 4 .IX Item "-s ,," Include dummy \s-1SCTP\s0 headers before each packet. Specify, in decimal, the source and destination \s-1SCTP\s0 ports, and verification tag, for the packet. Use this option if your dump is the \s-1SCTP\s0 payload of a packet but does not include any \s-1SCTP, IP\s0 or Ethernet headers. Note that appropriate Ethernet and \s-1IP\s0 headers are automatically also included with each packet. A \s-1CRC32C\s0 checksum will be put into the \s-1SCTP\s0 header. .IP "\-S ,," 4 .IX Item "-S ,," Include dummy \s-1SCTP\s0 headers before each packet. Specify, in decimal, the source and destination \s-1SCTP\s0 ports, and a verification tag of 0, for the packet, and prepend a dummy \s-1SCTP DATA\s0 chunk header with a payload protocol identifier if \fIppi\fR. Use this option if your dump is the \s-1SCTP\s0 payload of a packet but does not include any \s-1SCTP, IP\s0 or Ethernet headers. Note that appropriate Ethernet and \s-1IP\s0 headers are automatically included with each packet. A \s-1CRC32C\s0 checksum will be put into the \s-1SCTP\s0 header. .IP "\-t " 4 .IX Item "-t " Treats the text before the packet as a date/time code; \fItimefmt\fR is a format string of the sort supported by \fBstrptime\fR\|(3). Example: The time \*(L"10:15:14.5476\*(R" has the format code \*(L"%H:%M:%S.\*(R" .Sp \&\fB\s-1NOTE:\s0\fR The subsecond component delimiter must be specified (.) but no pattern is required; the remaining number is assumed to be fractions of a second. .Sp \&\fB\s-1NOTE:\s0\fR Date/time fields from the current date/time are used as the default for unspecified fields. .IP "\-T ," 4 .IX Item "-T ," Include dummy \s-1TCP\s0 headers before each packet. Specify the source and destination \s-1TCP\s0 ports for the packet in decimal. Use this option if your dump is the \s-1TCP\s0 payload of a packet but does not include any \s-1TCP, IP\s0 or Ethernet headers. Note that appropriate Ethernet and \s-1IP\s0 headers are automatically also included with each packet. Sequence numbers will start at 0. .IP "\-u ," 4 .IX Item "-u ," Include dummy \s-1UDP\s0 headers before each packet. Specify the source and destination \s-1UDP\s0 ports for the packet in decimal. Use this option if your dump is the \s-1UDP\s0 payload of a packet but does not include any \s-1UDP, IP\s0 or Ethernet headers. Note that appropriate Ethernet and \s-1IP\s0 headers are automatically also included with each packet. Example: \fI\-u1000,69\fR to make the packets look like \s-1TFTP/UDP\s0 packets. .IP "\-v" 4 .IX Item "-v" Print the version and exit. .IP "\-4 ," 4 .IX Item "-4 ," Prepend dummy \s-1IP\s0 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 \*(L"custom\*(R" \s-1IP\s0 addresses. Example: \fI\-4 10.0.0.1,10.0.0.2\fR to use 10.0.0.1 and 10.0.0.2 for all \s-1IP\s0 packets. .IP "\-6 ," 4 .IX Item "-6 ," Prepend dummy \s-1IP\s0 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 \*(L"custom\*(R" \s-1IP\s0 addresses. Example: \fI\-6 fe80::202:b3ff:fe1e:8329,2001:0db8:85a3::8a2e:0370:7334\fR to use fe80::202:b3ff:fe1e:8329 and 2001:0db8:85a3::8a2e:0370:7334 for all \s-1IP\s0 packets. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBod\fR\|(1), \fBpcap\fR\|(3), \fBwireshark\fR\|(1), \fBtshark\fR\|(1), \fBdumpcap\fR\|(1), \fBmergecap\fR\|(1), \&\fBeditcap\fR\|(1), \fBstrptime\fR\|(3), \fBpcap\-filter\fR\|(7) or \fBtcpdump\fR\|(8) .SH "NOTES" .IX Header "NOTES" \&\fBText2pcap\fR is part of the \fBWireshark\fR distribution. The latest version of \fBWireshark\fR can be found at . .SH "AUTHORS" .IX Header "AUTHORS" .Vb 1 \& Ashok Narayanan .Ve