tcprewrite.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <!--#exec cmd="header tcprewrite" -->
  2. <ul>
  3. </ul><H2>NAME </H2><ul>
  4. tcprewrite - Rewrite the packets in a pcap file.
  5. </ul><H2>SYNOPSIS </H2><ul>
  6. <b>tcprewrite</b>
  7. [<b>-<i>flag</i></b> [<i>value</i>]]... [<b>--<i>opt-name</i></b> [[=| ]<i>value</i>]]...
  8. <p>
  9. All arguments must be options.
  10. </ul><H2>DESCRIPTION </H2><ul>
  11. This manual page documents, briefly, the <b>tcprewrite</b> command.
  12. Tcprewrite is a tool to rewrite packets stored in <i>pcap(3)</i> file format,
  13. such as crated by tools such as <i>tcpdump(1)</i> and <i>ethereal(1)</i>.
  14. Once a pcap file has had it's packets rewritten, they can be replayed back
  15. out on the network using <i>tcpreplay(1)</i>.
  16. <p>tcprewrite currently supports the following DLT types:
  17. * DLT_C_HDLC
  18. * DLT_EN10MB
  19. * DLT_LINUX_SSL
  20. * DLT_RAW
  21. <p>The packet editing features of tcprewrite which distinguish between "client"
  22. and "server" traffic requires a tcpprep(1) cache file.
  23. </ul><H2>OPTIONS </H2><ul>
  24. <p><dl compact><dt><b>-D</b> <i>string</i>, <b>--dmac</b>=<b><i>string</i></b>
  25. <dd>Rewrite destination MAC addresses.
  26. This option may appear up to 1 times.
  27. </dl>
  28. <p>
  29. Takes a pair of comma deliminated ethernet MAC addresses which
  30. will replace the destination MAC address of outbound packets.
  31. The first MAC address will be used for the server traffic
  32. and the optional second MAC address will be used for the client
  33. traffic.
  34. <p>Example:
  35. <pre>
  36. --dmac=00:12:13:14:15:16,00:22:33:44:55:66
  37. <br></pre>
  38. <p><dl compact><dt><b>-S</b> <i>string</i>, <b>--smac</b>=<b><i>string</i></b>
  39. <dd>Rewrite source MAC addresses.
  40. This option may appear up to 1 times.
  41. </dl>
  42. <p>
  43. Takes a pair of comma deliminated ethernet MAC addresses which
  44. will replace the source MAC address of outbound packets.
  45. The first MAC address will be used for the server traffic
  46. and the optional second MAC address will be used for the client traffic.
  47. <p>Example:
  48. <pre>
  49. --smac=00:12:13:14:15:16,00:22:33:44:55:66
  50. <br></pre>
  51. <p><dl compact><dt><b>-P</b> <i>number</i>, <b>--proto</b>=<b><i>number</i></b>
  52. <dd>Override L2 protocol type for DLT_RAW.
  53. This option may appear up to 1 times.
  54. This option takes an integer number as its argument.
  55. The value of <i>number</i> is constrained to being:
  56. <pre>
  57. in the range 0 through 65535
  58. <br></pre>
  59. </dl>
  60. <p>
  61. By default, pcap files encapsulated using DLT_RAW will have their protocol
  62. set to ETHERTYPE_IP (0x0800).
  63. <p><dl compact><dt><b>-l</b> <i>string</i>, <b>--dlink</b>=<b><i>string</i></b>
  64. <dd>Rewrite Data-Link layer with specified data.
  65. This option may appear up to 2 times.
  66. </dl>
  67. <p>
  68. Provide a series of comma deliminated hex values which will be
  69. used to rewrite or create the Layer 2 header of the packets.
  70. The first instance of this argument will rewrite both server
  71. and client traffic, but if this argument is specified a second
  72. time, it will be used for the client traffic.
  73. <p>Example:
  74. <pre>
  75. --dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00
  76. <br></pre>
  77. <p><dl compact><dt><b>-r</b> <i>string</i>, <b>--portmap</b>=<b><i>string</i></b>
  78. <dd>Rewrite TCP/UDP ports.
  79. This option may appear up to 1 times.
  80. </dl>
  81. <p>
  82. Specify a list of comma delimited port mappingings consisting of
  83. colon delimited port number pairs. Each colon delimited port pair
  84. consists of the port to match followed by the port number to rewrite.
  85. <p>Example:
  86. <pre>
  87. --portmap=80:8000,8080:80
  88. <br></pre>
  89. <p><dl compact><dt><b>-s</b> <i>number</i>, <b>--seed</b>=<b><i>number</i></b>
  90. <dd>Randomize src/dst IP addresses w/ given seed.
  91. This option may appear up to 1 times.
  92. This option takes an integer number as its argument.
  93. </dl>
  94. <p>
  95. Causes the source and destination IP addresses to be pseudo
  96. randomized but still maintain client/server relationships.
  97. Since the randomization is deterministic based on the seed,
  98. you can reuse the same seed value to recreate the traffic.
  99. <p><dl compact><dt><b>-N</b> <i>string</i>, <b>--pnat</b>=<b><i>string</i></b>
  100. <dd>Rewrite IP addresses using pseudo-NAT.
  101. This option may appear up to 2 times.
  102. </dl>
  103. <p>
  104. Takes a comma delimited series of colon delimited CIDR
  105. netblock pairs. Each netblock pair is evaluated in order against
  106. the IP addresses. If the IP address in the packet matches the
  107. first netblock, it is rewriten using the second netblock as a
  108. mask against the high order bits.
  109. <p>Example:
  110. <pre>
  111. --pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24
  112. <br></pre>
  113. <p><dl compact><dt><b>-e</b> <i>string</i>, <b>--endpoints</b>=<b><i>string</i></b>
  114. <dd>Rewrite IP addresses to be between two endpoints.
  115. This option may appear up to 1 times.
  116. This option must appear in combination with the following options:
  117. cachefile.
  118. </dl>
  119. <p>
  120. Takes a pair of colon delimited IP addresses which will be used to rewrite
  121. all traffic to appear to be between the two IP's.
  122. <p>Example:
  123. <pre>
  124. --endpoints=172.16.0.1:172.16.0.2
  125. <br></pre>
  126. <p><dl compact><dt><b>-b</b>, <b>--skipbroadcast</b>
  127. <dd>Skip rewriting broadcast/multicast IP's.
  128. </dl>
  129. <p>
  130. By default, --dmac, --smac, --seed, --pnat and --endpoints will rewrite
  131. broadcast and multicast IP and MAC addresses. Setting this flag
  132. will keep broadcast/multicast IP and MAC addresses from being rewritten.
  133. <p><dl compact><dt><b>-C</b>, <b>--fixcsum</b>
  134. <dd>Force recalculation of IP/TCP/UDP checksums.
  135. </dl>
  136. <p>
  137. Causes each IP packet to have it's checksums recalcualted and
  138. fixed. Automatically enabled for packets modified with <b>--seed</b>,
  139. <b>--pnat</b>, <b>--endpoints</b> or <b>--fixlen</b>.
  140. <p><dl compact><dt><b>-m</b> <i>number</i>, <b>--mtu</b>=<b><i>number</i></b>
  141. <dd>Override default MTU length (1500 bytes).
  142. This option may appear up to 1 times.
  143. This option takes an integer number as its argument.
  144. The value of <i>number</i> is constrained to being:
  145. <pre>
  146. in the range 1 through MAXPACKET
  147. <br></pre>
  148. </dl>
  149. <p>
  150. Override the default 1500 byte MTU size for determining the maximum padding length.
  151. <p><dl compact><dt><b>-F</b> <i>string</i>, <b>--fixlen</b>=<b><i>string</i></b>
  152. <dd>Pad or truncate packet data to match header length.
  153. This option may appear up to 1 times.
  154. </dl>
  155. <p>
  156. Packets may be truncated during capture if the snaplen is smaller then the
  157. packet. This option allows you to modify the packet to pad the packet back
  158. out to the size stored in the IPv4 header or rewrite the IP header total length
  159. to reflect the stored packet length.
  160. <p>
  161. <b>pad</b>
  162. Truncated packets will be padded out so that the packet length matches the
  163. IPv4 total length
  164. <p>
  165. <b>trunc</b>
  166. Truncated packets will have their IPv4 total length field rewritten to match
  167. the actual packet length
  168. <p>
  169. <b>del</b>
  170. Delete the packet
  171. <p><dl compact><dt><b>-T</b> <i>string</i>, <b>--vlan</b>=<b><i>string</i></b>
  172. <dd>Specify 802.1q VLAN tag mode.
  173. This option may appear up to 1 times.
  174. </dl>
  175. <p>
  176. Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3
  177. ethernet headers or remove the 802.1q VLAN tag information.
  178. <p>
  179. <b>add</b>
  180. Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header
  181. <p>
  182. <b>del</b>
  183. Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header
  184. <p><dl compact><dt><b>-t</b> <i>number</i>, <b>--vlan-tag</b>=<b><i>number</i></b>
  185. <dd>Specify the new 802.1q VLAN tag value.
  186. This option may appear up to 1 times.
  187. This option must appear in combination with the following options:
  188. vlan.
  189. This option takes an integer number as its argument.
  190. The value of <i>number</i> is constrained to being:
  191. <pre>
  192. in the range 0 through 4095
  193. <br></pre>
  194. </dl>
  195. <p>
  196. <p><p><dl compact><dt><b>-f</b> <i>number</i>, <b>--vlan-cfi</b>=<b><i>number</i></b>
  197. <dd>Specify the 802.1q VLAN CFI value.
  198. This option may appear up to 1 times.
  199. This option must appear in combination with the following options:
  200. vlan.
  201. This option takes an integer number as its argument.
  202. The value of <i>number</i> is constrained to being:
  203. <pre>
  204. in the range 0 through 1
  205. <br></pre>
  206. </dl>
  207. <p>
  208. <p><p><dl compact><dt><b>-p</b> <i>number</i>, <b>--vlan-pri</b>=<b><i>number</i></b>
  209. <dd>Specify the 802.1q VLAN priority.
  210. This option may appear up to 1 times.
  211. This option must appear in combination with the following options:
  212. vlan.
  213. This option takes an integer number as its argument.
  214. The value of <i>number</i> is constrained to being:
  215. <pre>
  216. in the range 0 through 7
  217. <br></pre>
  218. </dl>
  219. <p>
  220. <p><p><dl compact><dt><b>-L</b> <i>number</i>, <b>--dlt</b>=<b><i>number</i></b>
  221. <dd>Change DLT type for output pcap file.
  222. This option may appear up to 1 times.
  223. This option takes an integer number as its argument.
  224. The value of <i>number</i> is constrained to being:
  225. <pre>
  226. in the range 0 through 65535
  227. <br></pre>
  228. </dl>
  229. <p>
  230. By default, tcprewrite uses the same DLT (data link type) for the
  231. output pcap as the input pcap. However, if you are changing the
  232. Layer 2 data with --dlink, then you probably also want to change the
  233. DLT type stored in the pcap. Common DLT types are:
  234. <p>
  235. <b>0</b>
  236. No Layer 2 header (DLT_NULL)
  237. <p>
  238. <b>1</b>
  239. Ethernet (DLT_EN10MB)
  240. <p>
  241. <b>10</b>
  242. FDDI (DLT_FDDI)
  243. <p>
  244. <b>12</b>
  245. BSD Raw header (DLT_RAW)
  246. <p>
  247. <b>104</b>
  248. Cisco HDLC (DLT_C_HDLC)
  249. <p>
  250. <b>113</b>
  251. Linux SLL pseudo-header (DLT_LINUX_SLL)
  252. <p>For a full list of DLT types, see: src/common/dlt_names.h
  253. <p><p><dl compact><dt><b>-d</b> <i>number</i>, <b>--dbug</b>=<b><i>number</i></b>
  254. <dd>Enable debugging output.
  255. This option may appear up to 1 times.
  256. This option takes an integer number as its argument.
  257. The value of <i>number</i> is constrained to being:
  258. <pre>
  259. in the range 0 through 5
  260. <br></pre>
  261. The default <i>number</i> for this option is:
  262. </dl><br>
  263. 0
  264. <p>
  265. If configured with --enable-debug, then you can specify a verbosity
  266. level for debugging output. Higher numbers increase verbosity.
  267. <p><dl compact><dt><b>-i</b> <i>string</i>, <b>--infile</b>=<b><i>string</i></b>
  268. <dd>Input pcap file to be processed.
  269. This option may appear up to 1 times.
  270. </dl>
  271. <p>
  272. <p><p><dl compact><dt><b>-o</b> <i>string</i>, <b>--outfile</b>=<b><i>string</i></b>
  273. <dd>Output pcap file.
  274. This option may appear up to 1 times.
  275. </dl>
  276. <p>
  277. <p><p><dl compact><dt><b>-c</b> <i>string</i>, <b>--cachefile</b>=<b><i>string</i></b>
  278. <dd>Split traffic via tcpprep cache file.
  279. This option may appear up to 1 times.
  280. </dl>
  281. <p>
  282. Use tcpprep cache file to split traffic based upon client/server relationships.
  283. <p><dl compact><dt><b>-v</b>, <b>--verbose</b>
  284. <dd>Print decoded packets via tcpdump to STDOUT.
  285. This option may appear up to 1 times.
  286. </dl>
  287. <p>
  288. <p><p><dl compact><dt><b>-A</b> <i>string</i>, <b>--decode</b>=<b><i>string</i></b>
  289. <dd>Arguments passed to tcpdump decoder.
  290. This option may appear up to 1 times.
  291. This option must appear in combination with the following options:
  292. verbose.
  293. </dl>
  294. <p>
  295. When enabling verbose mode (<b>-v</b>) you may also specify one or
  296. more additional arguments to pass to <b>tcpdump</b> to modify
  297. the way packets are decoded. By default, -n and -l are used.
  298. Be sure to quote the arguments so that they are not interpreted
  299. by tcprewrite. The following arguments are valid:
  300. [ -aAeNqRStuvxX ]
  301. [ -E spi@ipaddr algo:secret,... ]
  302. [ -s snaplen ]
  303. <p><dl compact><dt><b>-V</b>, <b>--version</b>
  304. <dd>Print version information.
  305. </dl>
  306. <p>
  307. <p><p><dl compact><dt><b>-h</b>, <b>--less-help</b>
  308. <dd>Display less usage information and exit.
  309. </dl>
  310. <p>
  311. <p><p><dl compact><dt><b>-H</b>,<b> --help</b>
  312. <dd>Display usage information and exit.
  313. <dt><b>-!</b>,<b> --more-help</b>
  314. <dd>Extended usage information passed thru pager.
  315. <dt><b>-</b> [<i>rcfile</i>],<b> --save-opts</b>[=<i>rcfile</i>]
  316. <dd>Save the option state to <i>rcfile</i>. The default is the <i>last</i>
  317. configuration file listed in the <b>OPTION PRESETS</b> section, below.
  318. <dt><b>-</b> <i>rcfile</i>,<b> --load-opts</b>=<i>rcfile</i>,<b> --no-load-opts</b>
  319. <dd>Load options from <i>rcfile</i>.
  320. The <i>no-load-opts</i> form will disable the loading
  321. of earlier RC/INI files. <i>--no-load-opts</i> is handled early,
  322. out of order.
  323. </dl>
  324. </ul><H2>OPTION PRESETS </H2><ul>
  325. Any option that is not marked as <i>not presettable</i> may be preset
  326. by loading values from configuration ("RC" or ".INI") file(s).
  327. The <i>homerc</i> file is "<i>$$/</i>", unless that is a directory.
  328. In that case, the file "<i>.tcprewriterc</i>"
  329. is searched for within that directory.
  330. </ul><H2>SEE ALSO </H2><ul>
  331. tcpdump(1), tcpprep(1), tcpreplay(1)
  332. </ul><H2>AUTHOR </H2><ul>
  333. Copyright 2004-2005 Aaron Turner
  334. <p>For support please use the tcpreplay-users@lists.sourceforge.net mailing list.
  335. <p>
  336. Released under the Free BSD License.
  337. <p>
  338. This manual page was <i>AutoGen</i>-erated from the <b>tcprewrite</b>
  339. option definitions.
  340. </ul>
  341. <!--#exec cmd="trailer" -->