PageRenderTime 76ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 1ms

/src/pentest/wifitap/scapy.py

https://github.com/sullivanmatt/Raspberry-Pwn
Python | 11715 lines | 9687 code | 258 blank | 1770 comment | 454 complexity | 1b2f061e41fe70968da8169cdb376e4a MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. #! /usr/bin/env python
  2. #############################################################################
  3. ## ##
  4. ## scapy.py --- Interactive packet manipulation tool ##
  5. ## see http://www.secdev.org/projects/scapy/ ##
  6. ## for more informations ##
  7. ## ##
  8. ## Copyright (C) 2003 Philippe Biondi <phil@secdev.org> ##
  9. ## ##
  10. ## This program is free software; you can redistribute it and/or modify it ##
  11. ## under the terms of the GNU General Public License version 2 as ##
  12. ## published by the Free Software Foundation; version 2. ##
  13. ## ##
  14. ## This program is distributed in the hope that it will be useful, but ##
  15. ## WITHOUT ANY WARRANTY; without even the implied warranty of ##
  16. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
  17. ## General Public License for more details. ##
  18. ## ##
  19. #############################################################################
  20. #
  21. # $Log: scapy.py,v $
  22. # Revision 1.0.4.74 2006/08/27 17:36:08 pbi
  23. # - tweaked make_*_table() to add horizontal separation lines
  24. #
  25. # Revision 1.0.4.73 2006/08/27 16:11:06 pbi
  26. # - added multiplot to plot many series from the same packet list. The function must returns
  27. # a couple whose first element is the label of a serie and the second is the data to plot.
  28. #
  29. # Revision 1.0.4.72 2006/08/27 15:13:36 pbi
  30. # - WARNING: API change. crc32() is now the zlib function.
  31. # crc32(0xffffffffL, s) --> ~crc32(z)&0xffffffffL
  32. #
  33. # Revision 1.0.4.71 2006/08/27 14:16:47 pbi
  34. # - fixed possible failures in DNS.summary()
  35. #
  36. # Revision 1.0.4.70 2006/08/27 14:11:38 pbi
  37. # - improved L3PacketSocket to build the list of interfaces only when needed (promisc=1)
  38. #
  39. # Revision 1.0.4.69 2006/08/27 14:10:05 pbi
  40. # - added gz parameter to PcapWriter (and thus wrpcap()) to gzip captures
  41. # - added abilty to read gzipped pcap files in PcapReader (and thus rdpcap())
  42. #
  43. # Revision 1.0.4.68 2006/08/27 13:59:20 pbi
  44. # - changed Net representation for it to work with Packet.command()
  45. #
  46. # Revision 1.0.4.67 2006/08/27 13:58:48 pbi
  47. # - added diffplot() to PacketList to plot a function of couples (l[i],l[i+delay])
  48. #
  49. # Revision 1.0.4.66 2006/08/27 12:52:13 pbi
  50. # - added prototype to psdump() and pdfdump() docstring
  51. #
  52. # Revision 1.0.4.65 2006/08/27 12:47:32 pbi
  53. # - have srloop() and srploop() return results of all probes
  54. #
  55. # Revision 1.0.4.64 2006/08/11 12:24:31 pbi
  56. # - patched getmacbyip() to handle IP multicast and return the right MAC multicast
  57. #
  58. # Revision 1.0.4.63 2006/08/11 12:13:45 pbi
  59. # - fixed lambda filtering in PacketList.plot()
  60. #
  61. # Revision 1.0.4.62 2006/08/11 12:12:51 pbi
  62. # - fixed reinstantiation of a PacketList as parameter to another PacketList
  63. #
  64. # Revision 1.0.4.61 2006/08/11 12:11:10 pbi
  65. # - added docstring to route.delt()
  66. #
  67. # Revision 1.0.4.60 2006/08/11 12:10:41 pbi
  68. # - fixed /proc/net/route parsing to handle reject routes
  69. #
  70. # Revision 1.0.4.59 2006/08/05 15:38:50 pbi
  71. # - added ActionField(): a wrapper to put arround a field that will trigger the call of a method
  72. # each time a value is manually set into a field
  73. #
  74. # Revision 1.0.4.58 2006/08/05 15:37:31 pbi
  75. # - fix: moved call to superclass' constructor in EnumField's constructor
  76. #
  77. # Revision 1.0.4.57 2006/07/28 21:57:19 pbi
  78. # - fixed get_if_hwaddr() exception catching in SourceMACField and ARPSourceMACField
  79. #
  80. # Revision 1.0.4.56 2006/07/28 17:24:39 pbi
  81. # - fixed typo in inet_pton
  82. #
  83. # Revision 1.0.4.55 2006/07/19 17:23:30 pbi
  84. # - fix: ls() look for Packet subclasses in both globals() and __builtin__
  85. #
  86. # Revision 1.0.4.54 2006/07/19 17:13:25 pbi
  87. # - forced _ special variable initisalization to None in autorun_commands()
  88. #
  89. # Revision 1.0.4.53 2006/07/17 17:35:48 pbi
  90. # - replaced getattr() by Packet.getfieldval() in FieldLenField.i2m()
  91. #
  92. # Revision 1.0.4.52 2006/07/17 17:28:20 pbi
  93. # - improved MACField.i2m()
  94. #
  95. # Revision 1.0.4.51 2006/07/17 17:27:40 pbi
  96. # - changed Packet.__iter__() to clone unrolled packets without transforming fields values through i2h() and h2i()
  97. #
  98. # Revision 1.0.4.50 2006/07/17 15:18:06 pbi
  99. # - added Packet.getfieldval() and NoPayload.getfieldval() to return the internal value of a field
  100. # - changed Packet.__getattr__() to use Packet.getfieldval()
  101. # - changed do_build, do_build_ps, guess_payload_class, __eq__, haslayer, getlayer to use Packet.getfieldval()
  102. #
  103. # Revision 1.0.4.49 2006/07/17 14:00:53 pbi
  104. # - fixed little endian fields for big endian machines (replaced @ by <)
  105. #
  106. # Revision 1.0.4.48 2006/07/17 13:43:04 pbi
  107. # - simplified PacketListField.addfield()
  108. #
  109. # Revision 1.0.4.47 2006/07/17 13:42:09 pbi
  110. # - simplified Dot11SCField.is_applicable()
  111. #
  112. # Revision 1.0.4.46 2006/07/17 13:40:55 pbi
  113. # - added __nonzero__() methods to Packet and Payload for the first to be true and the second
  114. # to be false without assembling the packet
  115. #
  116. # Revision 1.0.4.45 2006/07/17 13:37:19 pbi
  117. # - fixed Ether_Dot3_Dispatcher() to make it work with no arguments
  118. #
  119. # Revision 1.0.4.44 2006/07/13 09:52:57 pbi
  120. # - Fixed 3BytesField assembling (N. Bareil, ticket #6)
  121. #
  122. # Revision 1.0.4.43 2006/07/12 16:07:11 pbi
  123. # - fixed docstring of Packet.post_dissection()
  124. #
  125. # Revision 1.0.4.42 2006/07/12 13:36:01 pbi
  126. # - added Packet.from_hexcap() class method
  127. #
  128. # Revision 1.0.4.41 2006/07/12 13:35:37 pbi
  129. # - added a Packet.pre_dissect() hook
  130. #
  131. # Revision 1.0.4.40 2006/07/12 13:23:19 pbi
  132. # - Added a Ether/802.3 dispatcher for "Ethernet" linktype
  133. # - 802.1q use LLC payload if type < 1500
  134. # - enhanced Dot3.mysummary()
  135. #
  136. # Revision 1.0.4.39 2006/07/11 22:40:37 pbi
  137. # - fixed Dot11.answers() behaviour for management frames (L. Butti, ticket #5)
  138. #
  139. # Revision 1.0.4.38 2006/07/11 22:37:36 pbi
  140. # - fixed endianness of some 802.11 fields (L. Butti, ticket #3)
  141. #
  142. # Revision 1.0.4.37 2006/07/11 22:36:06 pbi
  143. # - removed SC field from 802.11 control frames (L. Butti, ticket #4)
  144. #
  145. # Revision 1.0.4.36 2006/07/11 22:10:01 pbi
  146. # - fixed TCPOptionsField to support SAck option (P. Lindholm, ticket #3)
  147. # - strengthened TCPOptionsField against bad options
  148. #
  149. # Revision 1.0.4.35 2006/07/11 21:57:37 pbi
  150. # - fix typo
  151. #
  152. # Revision 1.0.4.34 2006/06/23 17:35:43 pbi
  153. # - improved error message details for get_if_hwaddr()
  154. #
  155. # Revision 1.0.4.33 2006/06/23 17:33:38 pbi
  156. # - arping() function can update ARP cache if parameter cache=1 (D. Schuster, ticket #2)
  157. #
  158. # Revision 1.0.4.32 2006/06/23 16:27:44 pbi
  159. # - fixed: overloaded volatile fields were not fixed for sending
  160. #
  161. # Revision 1.0.4.31 2006/05/27 23:04:41 pbi
  162. # - fixed possible loop in TCP options
  163. #
  164. # Revision 1.0.4.30 2006/05/25 18:00:40 pbi
  165. # - added split_layers(), split_top_down() and split_bottom_up() to undo the
  166. # effects of bind_layers(), bind_top_down() and bind_bottom_up()
  167. #
  168. # Revision 1.0.4.29 2006/05/25 10:25:32 pbi
  169. # - added missing SPI field for ISAKMP_payload_Proposal
  170. #
  171. # Revision 1.0.4.28 2006/05/25 09:23:16 pbi
  172. # - almost reversed Field.h2i() removal patch (1.0.4.25) (changed my mind :))
  173. # - had Field.any2i() use Field.h2i()
  174. #
  175. # Revision 1.0.4.27 2006/05/24 21:15:22 pbi
  176. # - enhanced Packet.__getattr__ prettiness
  177. #
  178. # Revision 1.0.4.26 2006/05/24 20:50:47 pbi
  179. # - enhanced prettiness of DNSRRCountField
  180. #
  181. # Revision 1.0.4.25 2006/05/24 20:49:44 pbi
  182. # - removed h2i() methods from Field API
  183. #
  184. # Revision 1.0.4.24 2006/04/29 13:52:35 pbi
  185. # - added next_payload value overloading for ISAKMP layers
  186. #
  187. # Revision 1.0.4.23 2006/04/29 13:31:18 pbi
  188. # - removed forgotten debug prints..
  189. #
  190. # Revision 1.0.4.22 2006/04/29 13:20:30 pbi
  191. # - fixed ISAKMPTransformSetField
  192. # - fixed ISAKMP_payload_Transform length calculation
  193. #
  194. # Revision 1.0.4.21 2006/04/29 12:48:13 pbi
  195. # - WARNING: Field API changed. parameter shift must be now provided to the
  196. # length-varying field and not to the length field.
  197. # - added Field.i2len() method to return the length of a field (the number of
  198. # bytes in the raw packet string)
  199. #
  200. # Revision 1.0.4.20 2006/04/28 21:53:24 pbi
  201. # - fixed some problems with Packet.haslayer()/getlayer() for empty and list fields
  202. # - reduced Packet.haslayer()/getlayer() speed overhead to the same level as older versions
  203. #
  204. # Revision 1.0.4.19 2006/04/26 14:55:18 pbi
  205. # - fixed (again) filter attaching on linux/amd64 (W. Robinet)
  206. #
  207. # Revision 1.0.4.18 2006/04/26 12:55:29 pbi
  208. # - fixed Dot11WEP default icv value
  209. #
  210. # Revision 1.0.4.17 2006/04/26 12:55:01 pbi
  211. # - ATTENTION: API change: Packet.post_build() now takes current
  212. # assembled layer and assembled payload separately. Thus the
  213. # new prototype: post_build(self, pkt payload) -> pkt. post_build()
  214. # is in charge to join current layer and payload.
  215. # Old API will work for a small transition time.
  216. #
  217. # Revision 1.0.4.16 2006/04/25 15:23:49 pbi
  218. # - added internal _iterpacket parameter to SetGen to prevent iteration over Packet instances
  219. # - bugfix: prevented iteration over Packet instances in Packet.getlayer/haslayer/show()
  220. #
  221. # Revision 1.0.4.15 2006/04/24 12:27:35 pbi
  222. # - added NetFlow v1 protocol layer (M. Geli)
  223. #
  224. # Revision 1.0.4.14 2006/04/24 11:08:53 pbi
  225. # - big ISAKMPAttributeTypes update (W. McVey)
  226. # - changed ISAKMPTransformSetField to dissectTLV attributes (W. McVey)
  227. # - changed ISAKMPTransformSetField to assemble TLV attributes
  228. # - fixed ISAKMPTransformSetField to handle broken packets
  229. #
  230. # Revision 1.0.4.13 2006/04/23 21:12:08 pbi
  231. # - big p0f update (P. Lalet)
  232. #
  233. # Revision 1.0.4.12 2006/04/20 13:10:13 pbi
  234. # - fixed a bug with alias_type in Packet.guess_payload_class() when a field exists only
  235. # in the alias class
  236. #
  237. # Revision 1.0.4.11 2006/04/20 13:07:15 pbi
  238. # - enhanced LaTeXTheme2: used \bfseries and added colors to styles fail, success and even
  239. #
  240. # Revision 1.0.4.10 2006/04/20 09:13:49 pbi
  241. # - fixed SetGen to better test int couples for intervals
  242. #
  243. # Revision 1.0.4.9 2006/04/10 05:31:11 pbi
  244. # - use None value to specify timeout must be calculated in __sr_loop()
  245. #
  246. # Revision 1.0.4.8 2006/04/09 05:40:19 pbi
  247. # - added PacketListField.do_copy()
  248. # - modified fuzz() to handle PacketListField
  249. #
  250. # Revision 1.0.4.7 2006/04/08 16:05:24 pbi
  251. # - added PacketListField whose length come from another fiekd
  252. # - changed Packet.haslayer(), Packet.getlayer() and Packet.show() to handle PacketListField
  253. #
  254. # Revision 1.0.4.6 2006/04/02 14:49:28 pbi
  255. # - modified getlayer() to accept "LAYER.field" parameters to enable format strings' %
  256. # operator to work : "dst=%(IP.dst)s dport=%(TCP.dport)04i" % pkt
  257. #
  258. # Revision 1.0.4.5 2006/04/02 13:12:10 pbi
  259. # - added __mul__() and __rmul__() operators to handle multiplication with an int
  260. #
  261. # Revision 1.0.4.4 2006/03/27 13:32:50 pbi
  262. # - added missing fileno() to PcapReader and PcapWriter
  263. #
  264. # Revision 1.0.4.3 2006/03/22 12:59:35 pbi
  265. # - use binary mode to open files (Windows needs that...)
  266. #
  267. # Revision 1.0.4.2 2006/03/22 12:42:46 pbi
  268. # - replicated packet creation time when unrolling an implicit packet
  269. #
  270. # Revision 1.0.4.1 2006/03/17 12:48:28 pbi
  271. # Release 1.0.4
  272. #
  273. # Revision 1.0.3.34 2006/03/17 12:48:02 pbi
  274. # - added docstring for TracerouteResult.trace3D()
  275. #
  276. # Revision 1.0.3.33 2006/03/14 19:05:05 pbi
  277. # - added equality tests between two packets.
  278. #
  279. # Revision 1.0.3.32 2006/03/14 18:35:41 pbi
  280. # - added a timeout parameter to sniff()
  281. #
  282. # Revision 1.0.3.31 2006/03/14 17:48:30 pbi
  283. # - removed deprecated Packet.send()
  284. #
  285. # Revision 1.0.3.30 2006/03/14 17:46:03 pbi
  286. # - fix indentation quirk
  287. #
  288. # Revision 1.0.3.29 2006/03/14 15:12:59 pbi
  289. # - removed forgotten print in Packet.trace3D()
  290. #
  291. # Revision 1.0.3.28 2006/03/12 18:00:42 pbi
  292. # - made Packet.getlayer() and Packet.haslayer() also work with class names
  293. # - got rid of Packet.haslayer_str()
  294. #
  295. # Revision 1.0.3.27 2006/03/12 17:56:14 pbi
  296. # - improved Packet.getlayer(), Packet.haslayer() and Packet.haslayer_str()
  297. # to look into PacketFields.
  298. #
  299. # Revision 1.0.3.26 2006/03/09 22:25:00 pbi
  300. # - removed bad loop in L3PacketSocket and L2Socket when discarding outgoing packets (W. McVey)
  301. #
  302. # Revision 1.0.3.25 2006/03/09 22:15:38 pbi
  303. # - added Ctrl-Click to TracerouteResult.trace3D() to scan an IP
  304. #
  305. # Revision 1.0.3.24 2006/02/28 18:33:32 pbi
  306. # - added a "trans" parameter to colgen to handle automatic specific conversions into color object
  307. # - used colgen() in Packet.canvas_dump()
  308. #
  309. # Revision 1.0.3.23 2006/02/28 18:24:27 pbi
  310. # - removed makecol() from TracerouteResult.graph()
  311. #
  312. # Revision 1.0.3.22 2006/02/28 18:23:46 pbi
  313. # - turned makecol() TracerouteResult.graph()' internal function into colgen() generator tool
  314. #
  315. # Revision 1.0.3.21 2006/02/28 18:04:10 pbi
  316. # - added TracerouteResult.trace3D() to have a 3D traceroute visualization with VPython
  317. #
  318. # Revision 1.0.3.20 2006/02/27 18:03:46 pbi
  319. # - added get_trace() method to TraceouteResult() to extract traceroute data
  320. #
  321. # Revision 1.0.3.19 2006/02/27 15:13:36 pbi
  322. # - Fixed Dot11Beacon's fields' endianness (G. Lukas)
  323. #
  324. # Revision 1.0.3.18 2006/02/27 15:08:25 pbi
  325. # - factorised tex_escape() function from ps/pdfdump()
  326. # - added LatexTheme2 for autorun_get_latex_interactive_session()
  327. # - escape stuff in autorun_get_latex_interactive_session()
  328. #
  329. # Revision 1.0.3.17 2006/02/22 11:33:34 pbi
  330. # - added config.prog to reference external program pathes
  331. #
  332. # Revision 1.0.3.16 2006/02/22 11:19:26 pbi
  333. # - added afterglow clone attempt (http://sourceforge.net/projects/afterglow)
  334. #
  335. # Revision 1.0.3.15 2006/02/22 11:14:39 pbi
  336. # - added prog parameter to do_graph()
  337. #
  338. # Revision 1.0.3.15 2006/02/21 12:45:00 pbi
  339. # - added prog paramter to do_graph()
  340. #
  341. # Revision 1.0.3.14 2006/02/21 12:21:44 pbi
  342. # - removed hard dependancy on libreadline. Now works even if no libreadline is installed
  343. #
  344. # Revision 1.0.3.13 2006/02/19 14:06:28 pbi
  345. # - fixed show()'s indentation
  346. #
  347. # Revision 1.0.3.12 2006/02/19 13:49:18 pbi
  348. # - many docstrings corrections
  349. #
  350. # Revision 1.0.3.11 2006/02/17 16:29:38 pbi
  351. # - improved show() to use an exploded view for fields which hold packets
  352. # - added show_indent flag to Packet() that can be overloaded to 0 for layers that are followed by peers
  353. # and for whom indentation in show() is not desired
  354. #
  355. # Revision 1.0.3.10 2006/02/17 11:14:16 pbi
  356. # - changed conversation parameter to group getsrc/getdst into getsrcdst
  357. #
  358. # Revision 1.0.3.9 2006/02/17 10:57:53 pbi
  359. # - added docstrings for PacketList
  360. #
  361. # Revision 1.0.3.8 2006/02/16 15:45:51 pbi
  362. # - added docstrings to sr*(), wrpcap(), rdpcap()
  363. #
  364. # Revision 1.0.3.7 2006/02/16 15:37:44 pbi
  365. # - fixed conf.BTsocket assignment BluetoothSocket BluetoothL2CAPSocket
  366. #
  367. # Revision 1.0.3.6 2006/02/16 15:11:13 pbi
  368. # - added docstrings to many methods of Packet
  369. #
  370. # Revision 1.0.3.5 2006/02/16 14:09:07 pbi
  371. # - added BluetoothHCIsocket
  372. # - added L2socket to sniff
  373. # - added HCI_Hdr, L2CAP_Hdr layers, moved L2CAP to L2CAP_HdrCmd
  374. #
  375. # Revision 1.0.3.4 2006/02/12 01:06:52 pbi
  376. # - initialize payload's underlayer before payload's dissection
  377. #
  378. # Revision 1.0.3.3 2006/01/29 00:06:48 pbi
  379. # - added shortcut to PacketList to extract a given protocol with []. ex : lst[ICMP]
  380. #
  381. # Revision 1.0.3.2 2006/01/28 23:52:21 pbi
  382. # - removed useless (and racy) __del__() methods from PcapReader and PcapWriter
  383. #
  384. # Revision 1.0.3.1 2006/01/28 14:32:55 pbi
  385. # Release 1.0.3
  386. #
  387. # Revision 1.0.2.37 2006/01/28 13:14:25 pbi
  388. # - tweaked ls() for add-on classes to appear in the listing
  389. #
  390. # Revision 1.0.2.36 2006/01/28 13:02:15 pbi
  391. # - replaced remaining occurences of use of display() [deprecated, use show()]
  392. # - removed URL from dummy IPv6 classes names
  393. #
  394. # Revision 1.0.2.35 2006/01/17 18:02:42 pbi
  395. # - finished Packet.canvas_dup() escape() function. Every char is correctly translated into TeX
  396. #
  397. # Revision 1.0.2.34 2006/01/15 13:15:57 pbi
  398. # -added information-request and information-response to ICMP types (J. Bowie)
  399. #
  400. # Revision 1.0.2.33 2006/01/15 13:15:16 pbi
  401. # - fixed NetBIOSNameField incorrect length calculation (J. Bowie)
  402. #
  403. # Revision 1.0.2.32 2006/01/14 16:54:29 pbi
  404. # - added missing _IPv6optionHearder dummy class
  405. # - removed useless IPv6_instace() function
  406. #
  407. # Revision 1.0.2.31 2006/01/12 11:02:51 pbi
  408. # - fixed 1.0.2.29 collision fix (s/mtu/mtu_present/)
  409. #
  410. # Revision 1.0.2.30 2006/01/11 17:45:45 pbi
  411. # - fixed endianness problems in PcapReader()
  412. # - fixed PcapReader.read_all()
  413. # - added missing try/except to PcapReader.read_packet()
  414. # - removed PcapReader.read_PacketList() (read_all() already returns a PacketList)
  415. # - removed debug "print" from PcapWriter()
  416. # - added endianness parameter in PcapWriter()
  417. #
  418. # Revision 1.0.2.29 2006/01/11 17:00:01 pbi
  419. # - added Solaris support (wit help from S. Despret)
  420. # - added Solaris missing IPPROTO_GRE
  421. # - changed read_routes() to work with Solaris netstat
  422. # - fixed read_route() local variable collision (mtu became mtu_present)
  423. # - changed variable fl to flg
  424. #
  425. # Revision 1.0.2.28 2006/01/05 17:49:17 pbi
  426. # - re-added indentation in Packet.show(). Can be tweaked with "indent" parameter
  427. #
  428. # Revision 1.0.2.27 2006/01/04 15:04:17 pbi
  429. # - added missing try/except arround dissection in rdpcap()
  430. #
  431. # Revision 1.0.2.26 2005/12/23 00:51:51 pbi
  432. # - strengthened DNS disassembly
  433. #
  434. # Revision 1.0.2.25 2005/12/23 00:11:09 pbi
  435. # - have scapy work if Python IPv6 support is not compiled in socketmodule
  436. #
  437. # Revision 1.0.2.24 2005/12/23 00:08:50 pbi
  438. # - aliased socket.inet_ntoa into local namespace for consistency with other ?to?
  439. #
  440. # Revision 1.0.2.23 2005/12/22 17:58:08 pbi
  441. # - fixed and enhanced autorun_commands()
  442. #
  443. # Revision 1.0.2.22 2005/12/21 23:00:16 pbi
  444. # - fixed bug introduced by fix 1.0.2.19 on _
  445. #
  446. # Revision 1.0.2.21 2005/12/21 22:58:45 pbi
  447. # - added Packet.get_field() to get a field instance from its name
  448. # - modified some fields to use Packet.get_field() instead of a complex operation
  449. #
  450. # Revision 1.0.2.20 2005/12/19 12:43:52 pbi
  451. # - added FieldListField to create arrays of fields whose number is given in a FieldLenField
  452. #
  453. # Revision 1.0.2.19 2005/12/18 22:46:35 pbi
  454. # - fixed uninitialized _ in autorun_commands()
  455. #
  456. # Revision 1.0.2.18 2005/12/17 11:27:05 pbi
  457. # - Changed ColorTheme class be usable
  458. # - Added NoTheme class
  459. # - added autorun_get_text_interactive_session()
  460. # - added autorun_get_ansi_interactive_session()
  461. # - added autorun_get_latex_interactive_session() (miss some special chars filtering)
  462. #
  463. # Revision 1.0.2.17 2005/12/15 15:13:58 pbi
  464. # - IPv6 migration step 1: integrate some IPv6 routing stuff for IPv6 fork to work
  465. # as an add-on
  466. #
  467. # Revision 1.0.2.16 2005/12/07 18:02:26 pbi
  468. # - added fallbacks if tcpdump can't be run and libpcap is not used
  469. #
  470. # Revision 1.0.2.15 2005/12/07 17:44:11 pbi
  471. # - fixed socket filter pushing for x86_64 arch. (W. Robinet)
  472. #
  473. # Revision 1.0.2.14 2005/12/06 16:41:30 pbi
  474. # - added conf.check_TCPerror_seqack (default 0) to relax ICMP error matching for TCP
  475. # packets (some broken PIX play with sequence numbers and forget to tidy them up)
  476. #
  477. # Revision 1.0.2.13 2005/11/27 00:09:30 pbi
  478. # - added code to run interactive sessions automatically
  479. #
  480. # Revision 1.0.2.12 2005/11/26 11:33:55 pbi
  481. # - catch exceptions in ColorPrompt from bad color theme to avoid
  482. # program termination
  483. #
  484. # Revision 1.0.2.11 2005/11/26 11:10:44 pbi
  485. # - added class HTMLTheme2 with trigram instead of '<' and '>' to easily convert others into &lt; and &gt;
  486. #
  487. # Revision 1.0.2.10 2005/11/20 16:23:01 pbi
  488. # - improved a bit error handling of import dnet/pcap
  489. # - made INFO messages for missing files a bit more clear
  490. #
  491. # Revision 1.0.2.9 2005/11/19 08:39:09 pbi
  492. # - handle API change between pylibpcap 0.4 and 0.5
  493. #
  494. # Revision 1.0.2.8 2005/11/17 11:05:56 pbi
  495. # - changed Packet.sprintf() format string specificator to accept only the
  496. # field name and take the currend layer
  497. #
  498. # Revision 1.0.2.7 2005/11/17 10:24:53 pbi
  499. # - added onlyasc parameter to linehexdump()
  500. # - added onlyasc parameter to fragleak() and fragleak2()
  501. #
  502. # Revision 1.0.2.6 2005/11/15 04:55:11 pbi
  503. # - added Packet.command() to go from a packet instance to the Scapy command to generate it
  504. #
  505. # Revision 1.0.2.5 2005/11/15 03:04:51 pbi
  506. # - write history in an atexit registered function
  507. #
  508. # Revision 1.0.2.4 2005/11/15 02:58:44 pbi
  509. # - fixed Enum fields for them to work with lists of values
  510. #
  511. # Revision 1.0.2.3 2005/11/09 19:56:42 pbi
  512. # - added a ColorTheme.__repr__() to fix objects that used it, like conf object!
  513. #
  514. # Revision 1.0.2.2 2005/11/09 18:26:57 pbi
  515. # - fixed itom() to return positive values even for big endian platforms
  516. # - fixed RandIP default __init__ parameter to be 0.0.0.0/0 instead of 0/0
  517. #
  518. # Revision 1.0.2.1 2005/11/07 14:04:39 pbi
  519. # release 1.0.2
  520. #
  521. # Revision 1.0.1.13 2005/11/07 14:00:54 pbi
  522. # - fixed Dot11Auth.seqnum to be little endian
  523. # - added Dot11Auth.answers()
  524. #
  525. # Revision 1.0.1.12 2005/11/07 13:39:31 pbi
  526. # - fixed some stuff in the LaTeX color theme
  527. #
  528. # Revision 1.0.1.11 2005/11/07 13:38:36 pbi
  529. # - added timeout parameter to fragleak()
  530. # - created fragleak2()
  531. #
  532. # Revision 1.0.1.10 2005/11/07 13:37:20 pbi
  533. # - fixed LLC/SNAP binding to overload LLC.ctrl with 3
  534. #
  535. # Revision 1.0.1.9 2005/11/07 13:35:12 pbi
  536. # - changed Dot11.summary() to show src > dst
  537. # - added Dot11.answers()
  538. #
  539. # Revision 1.0.1.8 2005/11/07 13:33:43 pbi
  540. # - added DNS.answsers()
  541. #
  542. # Revision 1.0.1.7 2005/11/07 13:33:19 pbi
  543. # - added SignedIntField() and LESignedIntField
  544. # - converted PrismHeader's "signal" field to signed
  545. #
  546. # Revision 1.0.1.6 2005/11/01 12:22:02 pbi
  547. # - added hint_iface parameter to sendp()
  548. # - used hint_iface in arpcachepoison()
  549. #
  550. # Revision 1.0.1.5 2005/10/31 12:29:09 pbi
  551. # - added ConditionalField to wrap a field and apply a condition to its presense
  552. # - added NewDefaultValues metaclass to create new Packet classes from old ones
  553. # with new default default values
  554. # - added GRE protocol from rfc2784. (need more work for rfc1701)
  555. #
  556. # Revision 1.0.1.4 2005/10/27 15:12:32 pbi
  557. # - created VolatileValue class to handle volatile values like RandomField
  558. # - redesigned inheritence of random fields arround VolatileValue
  559. # - added DelayedEval() volatile value
  560. #
  561. # Revision 1.0.1.3 2005/10/27 14:59:11 pbi
  562. # - Changed color themes handling. Now LatexTheme and HTMLTheme are not ugly hacks anymore.
  563. #
  564. # Revision 1.0.1.2 2005/10/26 16:15:06 pbi
  565. # - added CharEnumField()
  566. # - declared s2i and i2s in EnumField before calling superclass' contructor
  567. #
  568. # Revision 1.0.1.1 2005/10/25 07:49:35 pbi
  569. # Release 1.0.1
  570. #
  571. # Revision 1.0.0.61 2005/10/25 07:48:48 pbi
  572. # - added rebuild option to Packet.p{s|df}dump() to dump a packet as-is
  573. #
  574. # Revision 1.0.0.60 2005/10/23 18:20:30 pbi
  575. # - PacketList.sr() return ( (matched couples), (unmatched packets) ) from the packet list
  576. #
  577. # Revision 1.0.0.59 2005/10/23 17:15:34 pbi
  578. # - added layer_shift option to every p{s|df}dump() method to explode hexa dump by layers
  579. #
  580. # Revision 1.0.0.58 2005/10/23 17:09:29 pbi
  581. # - return a loopback route when no default route is present. XXX: linux specific!
  582. #
  583. # Revision 1.0.0.57 2005/10/23 17:07:59 pbi
  584. # - split bind_layers() into bind_top_down() and bind_bottom_up()
  585. #
  586. # Revision 1.0.0.56 2005/10/23 16:57:26 pbi
  587. # - fixed dissection errors exception management when conf.debug_dissector is true
  588. #
  589. # Revision 1.0.0.55 2005/10/23 16:56:00 pbi
  590. # - made MACField's default value to be "00:00:00:00:00:00"
  591. # - fixed DestMACField's default value to be "ff:ff:ff:ff:ff:ff"
  592. #
  593. # Revision 1.0.0.54 2005/10/23 16:54:00 pbi
  594. # - fixed Field.randval() to work with string formats and modifiers
  595. # - fixed fuzz() not to overload default value if field's proposed randval is None
  596. #
  597. # Revision 1.0.0.53 2005/10/17 16:03:36 pbi
  598. # - uniformized to "lfilter" the paramter name for lambda expressions used as filters
  599. # - removed a superfluous line in crc32()
  600. #
  601. # Revision 1.0.0.52 2005/10/15 13:17:18 pbi
  602. # - AutoTime() and IntAutoTime() classes that give a field a time dependant value
  603. # - PacketList.timeskew_graph() should work on SndRcvList()
  604. #
  605. # Revision 1.0.0.51 2005/10/08 20:52:45 pbi
  606. # - added StreamSocket supersocket to emulate a datagram socket on a stream
  607. # socket that supports MSG_PEEK and whose base layer class knows its own size
  608. # and put the remaining in Padding()
  609. #
  610. # Revision 1.0.0.50 2005/10/08 12:46:56 pbi
  611. # - remove useless routes in netstat -rn output (P. Lalet)
  612. #
  613. # Revision 1.0.0.49 2005/10/08 12:41:23 pbi
  614. # - fixed netmask calculations (P. Lalet)
  615. #
  616. # Revision 1.0.0.48 2005/10/08 11:21:28 pbi
  617. # - use color for packet numbering in nsummary() et al.
  618. #
  619. # Revision 1.0.0.47 2005/10/06 12:57:25 pbi
  620. # - fixed MAC addresses calculation when IP is a Gen() instance (G. Valadon)
  621. #
  622. # Revision 1.0.0.46 2005/10/06 12:44:51 pbi
  623. # - added route.get_if_bcast() to get interface's broadcast address (F. Raynal)
  624. # - added a check in getmacbyip() to give a broadcast MAC for a broadcast IP
  625. # - added sndrcv() (thus sr*() family) "multi" parameter to accept many answers
  626. # from one stimulus. (If stimulus uses a broadcast dst address, you'll need
  627. # to set conf.checkIPaddr=0)
  628. #
  629. # Revision 1.0.0.45 2005/10/06 12:03:46 pbi
  630. # - changed sys.exit() into os._exit() in sndrcv() to prevent children to flush files buffers
  631. # that would be written a second time by the parent (SJ Murdoch)
  632. #
  633. # Revision 1.0.0.44 2005/10/06 11:44:48 pbi
  634. # - worked arround (I hope) all FreeBSD/MacOS/pcap issues (look at pcap_get_selectable_fd() note of pcap8 manpage).
  635. # Thus no more active waits or unseen packets. Still problems to interrupt a capture with ^C on some FreeBSD kernels :(
  636. #
  637. # Revision 1.0.0.43 2005/10/05 11:51:33 pbi
  638. # - added nofilter option to supersockets to handle ethertype filtering for non-linux stuff
  639. # and for ARP resolution to bypass conf.except_filter
  640. #
  641. # Revision 1.0.0.42 2005/10/05 11:28:14 pbi
  642. # - added RandMAC()
  643. # - added early support for fuzzing
  644. # - added fuzz()
  645. #
  646. # Revision 1.0.0.41 2005/10/05 11:14:57 pbi
  647. # - modified Packet.__iter__ to also evaluate random defaults fields
  648. #
  649. # Revision 1.0.0.40 2005/10/05 11:11:56 pbi
  650. # - filtered more characters for LaTeX in ps/pdf dump
  651. # - removed character that has magically appeared in DHCP_am
  652. #
  653. # Revision 1.0.0.39 2005/10/05 11:08:32 pbi
  654. # - fixed StrFixedLenField.addfield()
  655. #
  656. # Revision 1.0.0.38 2005/10/05 11:06:51 pbi
  657. # - overloaded RandFields repr() to give the class name
  658. # - added RandLong()
  659. # - added RandBin() to be RandString() for all chars
  660. # - added RandTermString()
  661. # - added RandIP default template to be "0/0"
  662. #
  663. # Revision 1.0.0.37 2005/10/05 11:01:20 pbi
  664. # - more tests in DHCP_am.make_reply() to handle garbage in
  665. #
  666. # Revision 1.0.0.36 2005/09/24 14:37:51 pbi
  667. # - added a "padding" option to TracerouteResult.graph() to show routers that pad
  668. #
  669. # Revision 1.0.0.35 2005/09/24 14:32:40 pbi
  670. # - added Packet.psdump() and Packet.pdfdump()
  671. # - added PacketList.psdump() and PacketList.pdfdump()
  672. #
  673. # Revision 1.0.0.34 2005/09/24 14:30:15 pbi
  674. # - ability to change the BPF filter in traceroute()
  675. #
  676. # Revision 1.0.0.33 2005/09/24 14:29:30 pbi
  677. # - completed PrismHeader layer
  678. #
  679. # Revision 1.0.0.32 2005/09/24 14:27:27 pbi
  680. # - deprecated "packet.haslayer(l)" by "l in Packet"
  681. # - deprecated "Packet.getlayer(l)" by "Packet[l]"
  682. #
  683. # Revision 1.0.0.31 2005/09/24 14:25:01 pbi
  684. # - better error message if gnuplot wrapper is missing
  685. # - fixed subclass test in dissection error treatment
  686. # - fixed Dot11Elt summary
  687. # - fixed __sr_loop() to prevent stats calc if no packet have been received
  688. # - fixed sniff() to break loop at the end of reading a file (offline optoin)
  689. #
  690. # Revision 1.0.0.30 2005/09/13 16:03:47 pbi
  691. # - added Dot11Elt.mysummary() for SSID displaying
  692. # - fixed Enum*.i2repr()
  693. #
  694. # Revision 1.0.0.29 2005/09/13 16:02:35 pbi
  695. # - fix build of packets with more than one padding
  696. #
  697. # Revision 1.0.0.28 2005/09/12 16:14:41 pbi
  698. # - new hexdump() which displays offsets
  699. #
  700. # Revision 1.0.0.27 2005/09/12 14:56:31 pbi
  701. # - new summary() and mysummary() semantic (backward compatible!) to enable more than one class to be expanded.
  702. # The higher gives its dependances along with its own summary
  703. #
  704. # Revision 1.0.0.26 2005/09/12 14:03:10 pbi
  705. # - added ip.dst in ICMP summary()
  706. #
  707. # Revision 1.0.0.25 2005/09/12 13:25:22 pbi
  708. # - added post_dissection() method, called at the end of the dissection, when the packet is ready
  709. # - added default_payload_class() called when layer bonds are not sufficient
  710. # - improved/fixed conf.debug_dissector() which failed when guess_payload_class() returned None
  711. #
  712. # Revision 1.0.0.24 2005/09/08 14:13:36 pbi
  713. # - added RandIP()
  714. #
  715. # Revision 1.0.0.23 2005/09/08 05:29:23 pbi
  716. # - added conf.debug_dissecto checks where it was missing in SuperSockets
  717. # - Slice pcap object only once we know its not None ! (N. Peterson)
  718. #
  719. # Revision 1.0.0.22 2005/09/06 17:08:47 pbi
  720. # - made AnsweringMachine() callable instead of using the run() method
  721. #
  722. # Revision 1.0.0.21 2005/09/06 17:05:19 pbi
  723. # - new logging/warning facility using the logging module
  724. #
  725. # Revision 1.0.0.20 2005/08/28 18:01:12 pbi
  726. # - 802.11 tweaks
  727. #
  728. # Revision 1.0.0.19 2005/08/28 18:00:14 pbi
  729. # - added Packet.decode_payload_as()
  730. #
  731. # Revision 1.0.0.18 2005/08/28 17:51:05 pbi
  732. # - Added XShortEnumField()
  733. #
  734. # Revision 1.0.0.17 2005/08/17 18:11:13 pbi
  735. # - fixed crc32() computation for big endian systems
  736. #
  737. # Revision 1.0.0.16 2005/08/17 12:54:47 pbi
  738. # - fix regression introduced in 1.0.0.4 (netstat parsing)
  739. #
  740. # Revision 1.0.0.15 2005/08/16 17:00:35 pbi
  741. # - fixed socket creation/attach filter race condition for L2Socket and L3PacketSocket.
  742. # No more packets shoud go through the filter.
  743. #
  744. # Revision 1.0.0.14 2005/08/16 16:58:59 pbi
  745. # - don't return outgoing packets in L2Socket and L3PacketSocket
  746. # - L2Socket and L3PacketSocket don't catch the exception if conf.dissector=1
  747. #
  748. # Revision 1.0.0.13 2005/08/16 16:56:09 pbi
  749. # - enhanced Packet.summary() code
  750. #
  751. # Revision 1.0.0.12 2005/08/16 16:53:31 pbi
  752. # - keep tcp/udp ports numeric in traceroute result
  753. #
  754. # Revision 1.0.0.11 2005/08/15 09:27:45 pbi
  755. # - added NTP.mysummary()
  756. #
  757. # Revision 1.0.0.10 2005/08/15 09:18:56 pbi
  758. # - fixed Ether.summary() (P. Lalet)
  759. #
  760. # Revision 1.0.0.9 2005/08/10 22:18:25 pbi
  761. # - moved code to build answering machines' functions into a metaclass
  762. #
  763. # Revision 1.0.0.8 2005/08/10 20:05:45 pbi
  764. # - added MobileIP protocol (rfc3344 and friends) (B. Andersson)
  765. #
  766. # Revision 1.0.0.7 2005/08/10 20:01:56 pbi
  767. # - changed Ether.mysummary() (P. Lalet)
  768. # - Update of Sebek protocols (P. Lalet)
  769. #
  770. # Revision 1.0.0.6 2005/08/10 19:53:19 pbi
  771. # - fix problem in declaraion of answering machine functions
  772. #
  773. # Revision 1.0.0.5 2005/08/10 15:43:03 pbi
  774. # - added resolution of numbers from /etc/ethertypes, /etc/protocols and
  775. # /etc/services (P. Lalet)
  776. # - tweaked some mysummary() accordingly
  777. #
  778. # Revision 1.0.0.4 2005/08/10 14:48:06 pbi
  779. # - Better netstat parsing for OpenBSD (P. Lalet)
  780. #
  781. # Revision 1.0.0.3 2005/08/10 14:41:21 pbi
  782. # - fixed regression introduced by previous patch : Gen and Packet are not
  783. # classes anymore but types.
  784. #
  785. # Revision 1.0.0.2 2005/08/09 21:40:57 pbi
  786. # - added ChangeDefaultValues metaclass to easily make a variant of a protocol
  787. #
  788. # Revision 1.0.0.1 2005/08/09 18:30:10 pbi
  789. # Release 1.0.0
  790. #
  791. # Revision 1.0 2005/08/09 18:26:09 pbi
  792. # 1.0 release
  793. #
  794. # Revision 0.9.17.110 2005/08/09 18:19:17 pbi
  795. # - nothing
  796. #
  797. # Revision 0.9.17.109 2005/08/08 13:57:16 pbi
  798. # - replaced use of __builtins__ by globals()
  799. # - promiscuous mode is now default mode
  800. # - added HTML color theme
  801. #
  802. # Revision 0.9.17.108 2005/08/05 14:12:48 pbi
  803. # - fix: IP fragmentation offset needs to be 0 for payload to be decoded
  804. # (actually fixed in 0.9.17.106)
  805. #
  806. # Revision 0.9.17.107 2005/08/05 14:04:03 pbi
  807. # - added 'filter' parameter to PacketList.padding()
  808. # - added PacketList.nzpadding() method
  809. # - added 'lfilter' parameter to sniff()
  810. #
  811. # Revision 0.9.17.106 2005/08/05 14:02:19 pbi
  812. # - removed scapy module reloading to prepare interactive mode
  813. # - tweaked interact() function, now fully functionnal
  814. #
  815. # Revision 0.9.17.105 2005/07/20 16:24:06 pbi
  816. # - small fix nmap database class
  817. #
  818. # Revision 0.9.17.104 2005/07/20 16:22:51 pbi
  819. # - modified Packet.guess_payload_class() semantic : added the payload as parameter
  820. # - fixed TCP.answers() to take in account length of payload
  821. # - added timeout arg to arping()
  822. #
  823. # Revision 0.9.17.103 2005/06/07 10:18:27 pbi
  824. # - added a try/catch for get_if_hw_addr
  825. # - fixed the netstat parsing for OpenBSD
  826. # - changed Dot11WEP's key ID field from "key" to "keyid"
  827. #
  828. # Revision 0.9.17.102 2005/06/07 09:54:51 pbi
  829. # - added LEShortEnumField
  830. # - added L2CAP layer
  831. # - added Bluetooth supersocket
  832. # - added srbt() and srbt1()
  833. #
  834. # Revision 0.9.17.101 2005/05/30 17:21:48 pbi
  835. # - Fixes for 0.9.17.100
  836. #
  837. # Revision 0.9.17.100 2005/05/30 17:08:41 pbi
  838. # - added NetBIOS, SMB & Co support (Sebastien Chenevot & Sylvain Sarmejeanne)
  839. #
  840. # Revision 0.9.17.99 2005/05/28 14:28:40 pbi
  841. # - WEP support and ICV computation
  842. #
  843. # Revision 0.9.17.98 2005/05/27 23:05:35 pbi
  844. # -fixed a smlal bug in graphic traceroute
  845. #
  846. # Revision 0.9.17.97 2005/05/27 19:53:04 pbi
  847. # - added WEP ciphering to Dot11WEP
  848. #
  849. # Revision 0.9.17.96 2005/05/25 15:15:10 pbi
  850. # - ability to give a WEP key as an argument to unwep()
  851. #
  852. # Revision 0.9.17.95 2005/05/25 15:05:03 pbi
  853. # - fixed pcap supersockets warnings
  854. #
  855. # Revision 0.9.17.94 2005/05/25 15:01:24 pbi
  856. # - fixed/cleaned ISAKMP
  857. #
  858. # Revision 0.9.17.93 2005/05/25 15:00:34 pbi
  859. # - fixed Packet.remove_underlayer() args
  860. # - fixed FieldLenField
  861. # - added Atheros Prism Header linktype
  862. #
  863. # Revision 0.9.17.92 2005/05/18 16:59:32 pbi
  864. # - some voip_play() stuff
  865. #
  866. # Revision 0.9.17.91 2005/05/18 16:59:01 pbi
  867. # - added BIOCIMMEDIATE option to fix BSD's BPF/pcap/select() behaviour issues
  868. # - made PCAP/DNET the default mode, even for Linux (it seems quicker)
  869. #
  870. # Revision 0.9.17.90 2005/05/18 16:57:07 pbi
  871. # - purge ARP cache when changing IP address of an interface
  872. # - fixed loopback interface detection get_if_raw_hwaddr() for dnet
  873. # - changed a bit Dot11PacketList behaviour
  874. # - fixed build() overload by EAP class
  875. # - fixed close()/recv() mix up in L2pcapListenSocket
  876. #
  877. # Revision 0.9.17.89 2005/05/03 19:18:22 pbi
  878. # - DNET/PCAP stuff reordering
  879. #
  880. # Revision 0.9.17.88 2005/05/03 00:10:12 pbi
  881. # - made Padding not be seen as a payload
  882. #
  883. # Revision 0.9.17.87 2005/04/29 22:37:39 pbi
  884. # - added L2 recognition for L2pcapListenSocket
  885. # - workarround for a bug in libpcap/wrapper?. .next() sometimes returns None
  886. # - added consistant get_if_addr() and get_if_raw_addr()
  887. # - added ifadd(), ifdel() and ifchange() methods to Route class
  888. #
  889. # Revision 0.9.17.86 2005/04/27 21:14:24 pbi
  890. # - small code cleaning
  891. #
  892. # Revision 0.9.17.85 2005/04/27 13:53:32 pbi
  893. # - early BSD port with libdnet and libpcap wrappers
  894. #
  895. # Revision 0.9.17.84 2005/04/24 14:57:45 pbi
  896. # - added a usable geolocation database from GeoIP.
  897. #
  898. # Revision 0.9.17.83 2005/04/24 10:34:57 pbi
  899. # - fixed fragment() (Peter Hardy)
  900. #
  901. # Revision 0.9.17.82 2005/04/23 15:29:21 pbi
  902. # - fixed sndrcv() when given an empty set of packets
  903. #
  904. # Revision 0.9.17.81 2005/04/23 13:55:32 pbi
  905. # - Some Sebek layers fixes (Pierre Lalet)
  906. #
  907. # Revision 0.9.17.80 2005/04/23 13:43:16 pbi
  908. # - Early IrDA support (Pierre Lalet)
  909. #
  910. # Revision 0.9.17.79 2005/04/23 13:42:34 pbi
  911. # - fixed SebekV1 and SebekV2 (Pierre Lalet)
  912. #
  913. # Revision 0.9.17.78 2005/04/23 13:41:33 pbi
  914. # - fixed BitField (Pierre Lalet)
  915. #
  916. # Revision 0.9.17.77 2005/04/23 13:36:15 pbi
  917. # - added threshold for warnings
  918. #
  919. # Revision 0.9.17.76 2005/04/23 11:27:51 pbi
  920. # - Renamed SndRcvAns into SndRcvList
  921. #
  922. # Revision 0.9.17.75 2005/04/23 11:26:12 pbi
  923. # - added color display in srloop()
  924. #
  925. # Revision 0.9.17.74 2005/04/22 13:30:10 pbi
  926. # - fixed dhcp_request()
  927. # - changed make_table semantic : take one lambda instead of 3
  928. # - fixed import_hexcap()
  929. # - fixed StrLenField
  930. # - changed traceroute() and arping() to also return unanswered packets
  931. # - ls() now sorts its output alphabetically
  932. # - LaTeX color theme for straight copy/paste into your doc.
  933. #
  934. # Revision 0.9.17.73 2005/04/15 15:56:08 pbi
  935. # - fixed ARP.answers()' return value
  936. # - made TracerouteResult.graph() use both ASN information source
  937. #
  938. # Revision 0.9.17.72 2005/04/09 22:25:23 pbi
  939. # - fix route.route() to handle extended IP sets (ex. 192.168.*.1-5)
  940. # - generalised statistics in packet lists
  941. # - added Dot11PacketList()
  942. # - added some DHCP options
  943. # - fixes in DHCP options building
  944. # - modified unwep() to decrypt a WEP packet if it was not already done
  945. #
  946. # Revision 0.9.17.71 2005/04/06 10:49:11 pbi
  947. # - forgotten debug msg in Net()
  948. #
  949. # Revision 0.9.17.70 2005/04/04 17:58:15 pbi
  950. # - modified Net() to recognize things like 172.16.*.1-10
  951. #
  952. # Revision 0.9.17.69 2005/04/04 14:24:00 pbi
  953. # - fix DHCP
  954. # - added dhcp_request()
  955. #
  956. # Revision 0.9.17.68 2005/03/28 22:18:04 pbi
  957. # - first attempt with time skew graphing
  958. #
  959. # Revision 0.9.17.67 2005/03/28 22:17:44 pbi
  960. # - use gzip compression for load_object/save_object
  961. # - made RandNum() and Emph() pickable
  962. # - changed prompt color in default color theme
  963. #
  964. # Revision 0.9.17.66 2005/03/28 14:30:01 pbi
  965. # - more DHCP work
  966. #
  967. # Revision 0.9.17.65 2005/03/28 14:29:03 pbi
  968. # - first attempt to generate libnet C code from a packet
  969. #
  970. # Revision 0.9.17.64 2005/03/28 14:28:20 pbi
  971. # - forgot to delete temporary variables in scapy's global scope
  972. #
  973. # Revision 0.9.17.63 2005/03/28 14:22:38 pbi
  974. # - added colors, color themes, colored prompt
  975. #
  976. # Revision 0.9.17.62 2005/03/24 16:19:33 pbi
  977. # - made it possible to use a PacketList as a parameter for send* or sr*
  978. #
  979. # Revision 0.9.17.61 2005/03/23 18:27:06 pbi
  980. # - used init_cookie for ISAKMP.answers()
  981. # - raised an exception in route.make_route if parameters are incomplete
  982. #
  983. # Revision 0.9.17.60 2005/03/23 17:07:56 pbi
  984. # - fixed session loading with -s
  985. # - prevented save_session() to trash current session
  986. # - changed AnsweringMachine to make send_reply() a bit more generic
  987. #
  988. # Revision 0.9.17.59 2005/03/22 16:52:44 pbi
  989. # - added _elt2show() to PacketList
  990. # - changed PacketList.show() to use _elt2show()
  991. #
  992. # Revision 0.9.17.58 2005/03/22 16:21:39 pbi
  993. # - added conversation() to PacketList
  994. # - added padding() to PacketList
  995. # - fixed StrNullField
  996. # - added haslayer_str() to Packet
  997. # - changed Packet.sprintf() to use haslayer_str
  998. # - changed answers() to ask payload if same class as other
  999. # - add count parameter to rdpcap
  1000. #
  1001. # Revision 0.9.17.57 2005/03/16 14:18:28 pbi
  1002. # - added StrNullField
  1003. #
  1004. # Revision 0.9.17.56 2005/03/14 18:14:28 pbi
  1005. # - LLNumTypes fix
  1006. # - Added linktype recognition to PcapWriter class
  1007. #
  1008. # Revision 0.9.17.55 2005/03/14 17:59:23 pbi
  1009. # - indentation cosmetic fix
  1010. #
  1011. # Revision 0.9.17.54 2005/03/14 17:53:56 pbi
  1012. # - wrpcap() now writes the correct linktype in the pcap file
  1013. #
  1014. # Revision 0.9.17.53 2005/03/14 17:22:23 pbi
  1015. # - added ISAKMP transforms decoding
  1016. #
  1017. # Revision 0.9.17.52 2005/03/14 16:40:58 pbi
  1018. # - added ikescan()
  1019. # - added ISAKMPTransformField
  1020. # - fixed PacketList's private methods names do begin only with one "_"
  1021. #
  1022. # Revision 0.9.17.51 2005/03/14 13:03:11 pbi
  1023. # - added a prn parameter to PacketList's summary() and nsummary()
  1024. #
  1025. # Revision 0.9.17.50 2005/03/14 12:56:24 pbi
  1026. # - make internal methods of PacketResult begins with __
  1027. #
  1028. # Revision 0.9.17.49 2005/03/14 12:52:41 pbi
  1029. # - Deprecated display() method (for all objects). Use show() instead.
  1030. #
  1031. # Revision 0.9.17.48 2005/03/14 12:48:29 pbi
  1032. # - Modified PacketField to stop at Padding instead of Raw
  1033. # - Added PacketLenField
  1034. # - More ISAKMP rework. Almost working.
  1035. #
  1036. # Revision 0.9.17.47 2005/03/14 10:20:49 pbi
  1037. # - added unwep() method to Dot11 packets
  1038. # - fixed 4 missing bytes in Dot11WEP
  1039. #
  1040. # Revision 0.9.17.46 2005/03/08 17:56:49 pbi
  1041. # - added a possibility to give a hint for srp() to choose the intended interface
  1042. # - added is_promisc() to find boxes in promisc mode (will not always work) (Javier Merino)
  1043. #
  1044. # Revision 0.9.17.45 2005/03/08 17:21:14 pbi
  1045. # - added PacketField
  1046. # - ISAKMP work
  1047. #
  1048. # Revision 0.9.17.44 2005/03/06 17:50:06 pbi
  1049. # - changed PCAP and DNET defaults
  1050. #
  1051. # Revision 0.9.17.43 2005/03/03 17:15:26 pbi
  1052. # - ISAKMP work
  1053. #
  1054. # Revision 0.9.17.42 2005/03/02 18:09:00 pbi
  1055. # - added make_world_trace() method to TracerouteResult for a xtraceroute-like
  1056. #
  1057. # Revision 0.9.17.41 2005/02/20 22:33:55 pbi
  1058. # - Sebek protocol definitions enhancements (Pierre Lalet)
  1059. #
  1060. # Revision 0.9.17.40 2005/02/20 22:31:49 pbi
  1061. # - added ARP answering machine (farpd) (Pierre Lalet)
  1062. #
  1063. # Revision 0.9.17.39 2005/02/20 22:22:23 pbi
  1064. # - Graphic traceroute enhanced to cope with TCP, UDP, ICMP or other traceroutes
  1065. # - ASN clustering in graphic traceroute can be controlled with the "ASN" parameter
  1066. #
  1067. # Revision 0.9.17.38 2005/02/18 21:03:26 pbi
  1068. # - MGCP early support
  1069. # - RandString()
  1070. #
  1071. # Revision 0.9.17.37 2005/02/10 22:33:13 pbi
  1072. # - export_object()/import_object() to copy/paste base64 gzipped pickled objects
  1073. # - prevent save_session from deleting unpicklable objects
  1074. # - added hexdump() and hexraw() methods to PacketList object
  1075. # - Raw packet answers any Raw packet
  1076. # - added conf.checkIPaddr to recognize broadcast replies (BOOTP/DHCP)
  1077. #
  1078. # Revision 0.9.17.36 2005/02/02 22:39:48 pbi
  1079. # - added GPRS dummy packet class
  1080. #
  1081. # Revision 0.9.17.35 2005/01/29 00:29:25 pbi
  1082. # - added l4 parameter to traceroute() for UDP, ICMP and other layer 4 traceroutes
  1083. # - tweaked TracerouteResult display()
  1084. #
  1085. # Revision 0.9.17.34 2005/01/26 23:43:19 pbi
  1086. # - removed some outdated functions
  1087. #
  1088. # Revision 0.9.17.33 2005/01/26 23:41:58 pbi
  1089. # - small simplification of TracerouteResult display() thanks to new sprintf()
  1090. # conditionnal statement
  1091. #
  1092. # Revision 0.9.17.32 2005/01/26 23:12:59 pbi
  1093. # - added conditionnal statements in format strings
  1094. #
  1095. # Revision 0.9.17.31 2005/01/26 22:30:36 pbi
  1096. # - removed an uneeded "else" in sprintf()
  1097. #
  1098. # Revision 0.9.17.30 2005/01/22 22:25:24 pbi
  1099. # - re-added node coloring lost code line in traceroute graphing code
  1100. #
  1101. # Revision 0.9.17.29 2005/01/22 21:48:55 pbi
  1102. # - fixed need for warning() before it was declared
  1103. #
  1104. # Revision 0.9.17.28 2005/01/22 21:47:11 pbi
  1105. # - added ARPingResult to handle arping() results
  1106. # - moved ARPing displaying logic to ARPing object
  1107. #
  1108. # Revision 0.9.17.27 2005/01/22 21:42:59 pbi
  1109. # - added args todo_graph()
  1110. # - added TracerouteResults object to handle traceroute results
  1111. # - moved traceroute displaying logic to TracerouteResult object
  1112. # - moved traceroute graphing logic to TracerouteResult object
  1113. #
  1114. # Revision 0.9.17.26 2005/01/20 22:59:07 pbi
  1115. # - graph_traceroute : added AS clustering, colors, tweaks
  1116. #
  1117. # Revision 0.9.17.25 2005/01/17 22:10:58 pbi
  1118. # - added do_graph() to draw GraphViz graphs using SVG output, displayed with ImageMagick
  1119. # - added graph_traceroute() to make a graph from multiple traceroutes
  1120. # - added timeout parameter to traceroute()
  1121. #
  1122. # Revision 0.9.17.24 2005/01/13 14:25:00 pbi
  1123. # - added Sebek v1 and v2 protocols (Pierre Lalet)
  1124. #
  1125. # Revision 0.9.17.23 2005/01/10 21:55:14 pbi
  1126. # - addded promisc and iface parameters to L3RawSocket
  1127. #
  1128. # Revision 0.9.17.22 2004/12/26 18:07:43 pbi
  1129. # - Improved PacketList with stability by addition and slicing
  1130. # - Added plot() to PacketList using Gnuplot
  1131. # - Added StrStopField
  1132. # - Added conf.debug_disssector to prevent dissector's exception from being catched
  1133. # - Added CookedLinux packet type
  1134. # - Show linktype number when it is unknown
  1135. #
  1136. # Revision 0.9.17.21 2004/12/26 16:04:57 pbi
  1137. # - removed strace in soxmix command line
  1138. # - DHCP support (from Mattias Wadman)
  1139. # - added missing make_table to PacketList class
  1140. # - have UDP class asks its payload for answers()
  1141. #
  1142. # Revision 0.9.17.20 2004/12/01 17:13:28 pbi
  1143. # - Early WEP support
  1144. # - voip_play() tweaks
  1145. # - Added LEShortField for Dot11 SC field
  1146. #
  1147. # Revision 0.9.17.19 2004/10/18 13:42:50 pbi
  1148. # - HSRP early support
  1149. # - Cisco CSSP Skinny early support
  1150. # - added Little Endian IntEnumField
  1151. # - added filter() method to PacketList
  1152. # - some voip_play() work
  1153. # - loop parameter value in send*() is used as the time to sleep between 2 loops
  1154. #
  1155. # Revision 0.9.17.18 2004/09/21 21:45:20 pbi
  1156. # - added recv() method to PcapReader to emulate a SuperSocket
  1157. # - added "offline" parameter to sniff() to use sniff on pcap files
  1158. # - removed voip_play_offline() and renamed voip_play_sniff() to voip_play()
  1159. # which is now available to play offline
  1160. #
  1161. # Revision 0.9.17.17 2004/09/21 21:32:41 pbi
  1162. # - added early PPPoE support (Ralf Ertzinger)
  1163. # - fixed DNS summary() to handle empty queries or answers
  1164. #
  1165. # Revision 0.9.17.16 2004/09/21 14:58:15 pbi
  1166. # - added VOIP playing functions (not tested)
  1167. #
  1168. # Revision 0.9.17.15 2004/09/17 22:00:47 pbi
  1169. # - transfert traceroute() and arping() options to sndrcv() ("retry", etc.)
  1170. # - fixed retry option in sndrcv()
  1171. # - tweaked AnweringMachine class
  1172. # - rewrited airpwn to use AnsweringMachine
  1173. #
  1174. # Revision 0.9.17.14 2004/09/13 16:57:01 pbi
  1175. # - added loopback routing
  1176. #
  1177. # Revision 0.9.17.13 2004/09/12 21:44:45 pbi
  1178. # - AnsweringMachine working as I wanted!
  1179. #
  1180. # Revision 0.9.17.12 2004/09/10 16:54:46 pbi
  1181. # - AnsweringMachine twaking
  1182. # - added DNS spoofing answering machine
  1183. #
  1184. # Revision 0.9.17.11 2004/09/08 13:42:38 pbi
  1185. # - renamed ScapyPcapWriter class to PcapWriter
  1186. # - added linktype parameter to PcapWriter (William McVey)
  1187. # - added PcapReader class (William McVey)
  1188. #
  1189. # Revision 0.9.17.10 2004/09/08 13:06:01 pbi
  1190. # - added some text correspondances to Radius code field
  1191. #
  1192. # Revision 0.9.17.9 2004/09/06 14:28:02 pbi
  1193. # - early radius support
  1194. #
  1195. # Revision 0.9.17.8 2004/09/06 14:17:11 pbi
  1196. # - added "store" parameter to sniff()
  1197. # - added AnsweringMachine class to handle request/response protocols
  1198. # - replaced bootpd by a AnsweringMachine subclass
  1199. # - created DHCP answering machine draft
  1200. #
  1201. # Revision 0.9.17.7 2004/09/03 22:11:35 pbi
  1202. # - finished airpwn()
  1203. #
  1204. # Revision 0.9.17.6 2004/08/13 16:49:51 pbi
  1205. # - added first version of airpwn() clone
  1206. #
  1207. # Revision 0.9.17.5 2004/08/11 15:25:08 pbi
  1208. # - added RIP protocol
  1209. #
  1210. # Revision 0.9.17.4 2004/08/09 14:00:20 pbi
  1211. # - added gzip support to sessions saving
  1212. # - can force pickle protocol to inferior values for pickle backward compatility
  1213. #
  1214. # Revision 0.9.17.3 2004/08/07 10:59:34 pbi
  1215. # - fixed self reloading when launched from a different directory
  1216. # - fixed session reloading problems with PacketList() and SndRcvAns()
  1217. # - added load_session(), save_session(), update_session()
  1218. #
  1219. # Revision 0.9.17.2 2004/07/28 21:16:12 pbi
  1220. # - added nsummary() method to SndRcvList() class
  1221. #
  1222. # Revision 0.9.17.1 2004/07/26 19:52:55 pbi
  1223. # Release 0.9.17
  1224. #
  1225. # Revision 0.9.16.18 2004/07/26 19:50:16 pbi
  1226. # - added ScapyPcapWriter class (William McVey)
  1227. #
  1228. # Revision 0.9.16.17 2004/07/26 19:24:48 pbi
  1229. # - do not need to be named 'scapy.py' anymore
  1230. # - use of PacketList() for rdpcap() and sniff()
  1231. # - fixed a bug in StrFixedLenField
  1232. # - early IKE and ISAKMP support
  1233. #
  1234. # Revision 0.9.16.16 2004/07/16 15:39:37 pbi
  1235. # - small fix on bootpd
  1236. #
  1237. # Revision 0.9.16.15 2004/07/10 13:13:25 pbi
  1238. # - finished testing ethertype in supersockets to decide wether or not to apply BPF filters
  1239. #
  1240. # Revision 0.9.16.14 2004/07/10 13:06:38 pbi
  1241. # - do not apply any BPF filter if ethertype is given to a supersocket (so that ARP requests will work
  1242. # whatever the conf.except_filter value is)
  1243. #
  1244. # Revision 0.9.16.13 2004/07/09 09:11:15 pbi
  1245. # - changed the header and blocked the licence to GPLv2 only
  1246. #
  1247. # Revision 0.9.16.12 2004/07/09 09:07:41 pbi
  1248. # - added an independant routing table (conf.route) and methods to manipulate it
  1249. # - tweaked results stats
  1250. #
  1251. # Revision 0.9.16.11 2004/07/05 22:43:49 pbi
  1252. # - wrapper classes for results presentations and manipulation
  1253. # - sndrcv() retry auto adjustment when giving a negative value
  1254. #
  1255. # Revision 0.9.16.10 2004/07/05 08:53:41 pbi
  1256. # - added retry option to sndrcv()
  1257. # - improved debug class
  1258. # - added ottl() and hops() methods for IPTools class
  1259. # - improved UDP and ICMP summary()
  1260. #
  1261. # Revision 0.9.16.9 2004/06/07 16:09:21 pbi
  1262. # - fix again TCP.answers() and TCPerror.answers()
  1263. #
  1264. # Revision 0.9.16.8 2004/06/07 16:06:27 pbi
  1265. # - fixed conf.checkIPsrc behaviour of answers() and hashret() for TCP/UDP/TCPerror/UDPerror
  1266. # - added conf.debug_match to keep track of unanswered packets in debug.sent and debug.recv
  1267. #
  1268. # Revision 0.9.16.7 2004/06/07 09:20:43 pbi
  1269. # - added LEIntField and StrFixedLenField
  1270. # - added partial PrismHeader support
  1271. #
  1272. # Revision 0.9.16.6 2004/04/29 15:46:19 pbi
  1273. # - fixed fragment()
  1274. #
  1275. # Revision 0.9.16.5 2004/03/31 09:24:43 pbi
  1276. # - fix nmap fingerprint db parsing to handle the new format (Jochen Bartl)
  1277. #
  1278. # Revision 0.9.16.4 2004/03/23 08:45:10 pbi
  1279. # - Support for reading big endian pcap files (Pekka Pietikainen)
  1280. #
  1281. # Revision 0.9.16.3 2004/02/28 11:12:12 pbi
  1282. # - got rid of some future warnings (N. Bareil <nbareil@mouarf.org>)
  1283. # - improved BitField() for arbitrary length bit fields (N. Bareil <nbareil@mouarf.org>)
  1284. # - NTP protocol (N. Bareil <nbareil@mouarf.org>)
  1285. #
  1286. # Revision 0.9.16.2 2004/02/22 17:49:51 pbi
  1287. # added first sketch of a bootp daemon: bootpd()
  1288. #
  1289. # Revision 0.9.16.1 2004/01/26 18:01:00 pbi
  1290. # Release 0.9.16
  1291. #
  1292. # Revision 0.9.15.15 2004/01/26 18:00:08 pbi
  1293. # - added more text for DNS codes
  1294. #
  1295. # Revision 0.9.15.14 2004/01/15 13:24:48 pbi
  1296. # - fixed the case where IP field is a list of nets
  1297. # - randomize IPID in traceroute() to work better with conf.checkIPsrc=0
  1298. # - added make_tex_table() and make_lined_table()
  1299. # - added IPID_count() to identify machines with their IPID
  1300. # - added sport and dport args to fragleak()
  1301. #
  1302. # Revision 0.9.15.13 2004/01/11 11:47:07 pbi
  1303. # - srploop() and srloop() improvements
  1304. #
  1305. # Revision 0.9.15.12 2004/01/11 01:28:21 pbi
  1306. # - srloop() and srploop

Large files files are truncated, but you can click here to view the full file