Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. from scapy.all import *
  2.  
  3. class Handler :
  4. def __init__(self) :
  5. self.wap_list = []
  6. self.TempWAP = None
  7.  
  8.  
  9.  
  10. def process_packet_capture(self, packet_capture) :
  11. for packet in packet_capture :
  12. if packet.haslayer(Dot11) :
  13. if packet.subtype == 8 :
  14. bssid = packet.addr3
  15. if packet.haslayer(Dot11Elt) :
  16. p = packet[Dot11Elt]
  17. while isinstance(p, Dot11Elt) :
  18. if p.ID == 0 :
  19. essid = p.info
  20. if p.ID == 3 :
  21. channel = ord(p.info)
  22. p = p.payload
  23.  
  24. self.TempWAP = WirelessAccessPoint(bssid, essid, channel)
  25.  
  26. if self.check_for_duplicates() == False:
  27. self.wap_list.append(self.TempWAP)
  28.  
  29. def check_for_duplicates(self) :
  30. for w in self.wap_list :
  31. if self.TempWAP.bssid == w.bssid :
  32. return True
  33. return False
  34.  
  35. class WirelessAccessPoint :
  36. def __init__(self, bssid, essid, channel) :
  37. self.bssid = bssid
  38. self.essid = essid
  39. self.channel = channel
  40.  
  41. from scapy.all import *
  42. from access_point_detection_classes_module import *
  43.  
  44. def main() :
  45.  
  46. H = Handler()
  47.  
  48. packet_capture = sniff(count = 50)
  49.  
  50. H.process_packet_capture(packet_capture)
  51.  
  52. for w in H.wap_list :
  53. print w.bssid
  54. print w.essid
  55. print w.channel
  56. print '++++++++++++++++++++++++'
  57.  
  58.  
  59.  
  60.  
  61. # enable_managed_mode('wlan0')
  62.  
  63. if __name__ == "__main__" :
  64. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement