-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSSIDlookup.py
executable file
·120 lines (112 loc) · 5.25 KB
/
SSIDlookup.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/python
############################################################################
# #
# Name: Geolocate SSIDs using Google and WiGLE #
# #
# Description: SSIDlookup accepts one input to the command line #
# and utilizes WiGLE to obtain the BSSID which uses the #
# iSniff GPS/undocumented API call to determine location of #
# APs. #
# #
# Usage: ./SSIDlookup.py <SSID> <cookie> #
# #
# Requirements: Python #
# python-requests #
# BeautifulSoup #
# bs4 #
# iSniffGPS wloc (included) #
# A cookie from WiGLE input into wigle.py #
# (obtain from a browser after logging in here: #
# http://WiGLE.net/gps/gps/GPSDB/login) #
# #
# Authors: Larry Pesce - [email protected] @haxorthematrix #
# Don Weber - [email protected] @cutaway #
# #
# Credits: * Nathan Sweaney - [email protected], for his work on KLV #
# where some of this code was adapted from/inspired by. #
# * Secure Ideas - RE: Nathan Sweaney #
# * @hubert3 - hubert(at)pentest.com, for his hard work on #
# iSniffGPS, as this project would not be possible without it. #
# * Francois-Xavier Aguessy and Come Demoustier - For their work #
# in the undocumented Apple API call for geolocation. #
# * @cutaway - for being a great friend, co-worker, and #
# instructing this python n00b in the ways of the force. #
# * InGuardians - for giving me a chance, and the honor of #
# working with and for my heroes. #
# * @edwardmccabe and anonymous donors for sample files! #
# #
# Date: September 19, 2014 #
# #
############################################################################
import sys
import applewloc
import pygmaps
import os
import webbrowser
def usage():
print "%s Usage"%sys.argv[0]
print " -h: help"
print " -s <ssid>: SSID to search. Put SSIDs with spaces and special characters in double quotes."
print " -c <cookie>: The Wigle cookie to use. This requires a Wigle account with an active session or unexpired cookie."
print " -d: Turn on debugging."
sys.exit()
# Defaults
ssid = None
cookie = None # Update this value with your 10 year Wigle cookie
DEBUG = False
ssid_count = 0
output_file = "mymap.draw.html"
writemap = True
mymap = None
openbrowser = False
# Process options
ops = ['-s','-c','-d','-o','-w','-h']
while len(sys.argv) > 1:
op = sys.argv.pop(1)
if op == '-s':
ssid = sys.argv.pop(1)
if op == '-c':
cookie = sys.argv.pop(1)
if op == '-d':
DEBUG = True
applewloc.DEBUG = True
if op == '-o':
output_file = sys.argv.pop(1)
if op == '-w':
openbrowser = True
if op == '-h':
usage()
if op not in ops:
print "Unknown option:",op
usage()
# Test for user input
if not ssid or not cookie: usage()
if DEBUG: print "In ssid:",ssid
if DEBUG: print "In cookie:",cookie
# Get list of possible BSSIDs by searching Wigle for specific SSID
bssids = applewloc.getSSIDloc(ssid=ssid,cookie=cookie)
# Process each of the BSSIDs returned by Wigle
# Wigle dictionary format: {'stayoffmylawn [00:25:9C:ED:0F:EB] [6]': (33.65253067, -112.03952026)
for key,value in bssids.items():
if key:
key = key.split()[1][1:-1]
else:
continue
#print_locs(AppleWloc(bssid=key))
networks = applewloc.AppleWloc(bssid=key)
#print "networks: ", networks
applewloc.print_locs(networks)
if ssid_count == 0 :
if networks.keys()[0] != None:
base_bssid = networks.keys()[0]
mymap = pygmaps.maps((networks[base_bssid][0]),(networks[base_bssid][1]), 4)
ssid_count = 1
for e in networks:
mymap.addpoint(networks[e][0],networks[e][1],color = "#FF0000",title = [e])
mymap.draw('./'+output_file)
output_file = os.path.abspath(output_file)
print "File written to:", output_file
# Open in web browser
if openbrowser == True:
webbrowser.open_new_tab("file://"+output_file)
print "%s Done."%sys.argv[0]