-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientProbes_db.py
executable file
·55 lines (44 loc) · 1.56 KB
/
clientProbes_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python2.7
# Script to grab the probes sent out by the client in Dot11 frames ...
import sys
import sqlite3
from scapy.all import *
probes={}
def insertToDB(bssid, ssid_set):
ssid_probes=""
for ssid in ssid_set:
ssid_probes+=ssid
ssid_probes+=" "
connection.execute("insert into clients (location, bssid, ssid) values (?, ?, ?)", (sys.argv[4], bssid, ssid_probes))
connection.commit()
def getProbes(pkt):
if pkt.haslayer(Dot11ProbeReq):
client_addr=pkt.addr2
pkt=pkt.getlayer(Dot11ProbeReq)
if not probes.has_key(client_addr):
probes[client_addr]=set()
while pkt:
if pkt.ID==0 and pkt.info not in probes[client_addr]:
### Got the SSID field ...
if pkt.len==0:
ssid="Someone Hideous or Broadcast"
else:
ssid=pkt.info
print "New Probe Request Found: ", client_addr, " is looking for ", ssid
probes[client_addr].add(ssid)
if len(probes)==0:
return
print "\n\n------------------------------------------------- Client Probe Request Table -------------------------------------------------\n"
for client in probes:
print '\t\t', client, ' is looking for ',
for ssid in probes[client]:
print ssid, ' ... ',
print "\n"
print "-------------------------------------------------------------------------------------------------------------------------------\n\n"
break
pkt=pkt.payload
sniff(iface=sys.argv[1], count=int(sys.argv[2]), prn=getProbes)
connection=sqlite3.connect(sys.argv[3])
for client_addr in probes:
insertToDB(client_addr, probes[client_addr])
connection.close()