mac80211-injection.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. How to use packet injection with mac80211
  2. =========================================
  3. mac80211 now allows arbitrary packets to be injected down any Monitor Mode
  4. interface from userland. The packet you inject needs to be composed in the
  5. following format:
  6. [ radiotap header ]
  7. [ ieee80211 header ]
  8. [ payload ]
  9. The radiotap format is discussed in
  10. ./Documentation/networking/radiotap-headers.txt.
  11. Despite 13 radiotap argument types are currently defined, most only make sense
  12. to appear on received packets. The following information is parsed from the
  13. radiotap headers and used to control injection:
  14. * IEEE80211_RADIOTAP_RATE
  15. rate in 500kbps units, automatic if invalid or not present
  16. * IEEE80211_RADIOTAP_ANTENNA
  17. antenna to use, automatic if not present
  18. * IEEE80211_RADIOTAP_DBM_TX_POWER
  19. transmit power in dBm, automatic if not present
  20. * IEEE80211_RADIOTAP_FLAGS
  21. IEEE80211_RADIOTAP_F_FCS: FCS will be removed and recalculated
  22. IEEE80211_RADIOTAP_F_WEP: frame will be encrypted if key available
  23. IEEE80211_RADIOTAP_F_FRAG: frame will be fragmented if longer than the
  24. current fragmentation threshold. Note that
  25. this flag is only reliable when software
  26. fragmentation is enabled)
  27. The injection code can also skip all other currently defined radiotap fields
  28. facilitating replay of captured radiotap headers directly.
  29. Here is an example valid radiotap header defining these three parameters
  30. 0x00, 0x00, // <-- radiotap version
  31. 0x0b, 0x00, // <- radiotap header length
  32. 0x04, 0x0c, 0x00, 0x00, // <-- bitmap
  33. 0x6c, // <-- rate
  34. 0x0c, //<-- tx power
  35. 0x01 //<-- antenna
  36. The ieee80211 header follows immediately afterwards, looking for example like
  37. this:
  38. 0x08, 0x01, 0x00, 0x00,
  39. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  40. 0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
  41. 0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
  42. 0x10, 0x86
  43. Then lastly there is the payload.
  44. After composing the packet contents, it is sent by send()-ing it to a logical
  45. mac80211 interface that is in Monitor mode. Libpcap can also be used,
  46. (which is easier than doing the work to bind the socket to the right
  47. interface), along the following lines:
  48. ppcap = pcap_open_live(szInterfaceName, 800, 1, 20, szErrbuf);
  49. ...
  50. r = pcap_inject(ppcap, u8aSendBuffer, nLength);
  51. You can also find sources for a complete inject test applet here:
  52. http://penumbra.warmcat.com/_twk/tiki-index.php?page=packetspammer
  53. Andy Green <andy@warmcat.com>