Skip to content

Instantly share code, notes, and snippets.

@thurask
Created March 8, 2016 23:57
Show Gist options
  • Save thurask/e713b145223775d96e42 to your computer and use it in GitHub Desktop.
Save thurask/e713b145223775d96e42 to your computer and use it in GitHub Desktop.
Scan for Priv factory images
import requests
def availability(url):
try:
avlty = requests.head(url)
status = int(avlty.status_code)
return status == 200 or 300 < status <= 308
except requests.ConnectionError:
return False
def scanner(branch, floor=0, ceil=999, variant="common"):
for x in range(floor, ceil+1):
ver = str(x).zfill(3) # zero pad
print("NOW SCANNING: {}".format(branch.upper() + ver), end="\r")
skel = "http://bbapps.download.blackberry.com/Priv/bbry_qc8992_autoloader_user-{2}-{0}{1}.zip".format(branch.upper(), ver, variant)
avail = availability(skel)
if avail:
print("\r")
print("{} AVAILABLE!".format(branch.upper() + ver))
print(skel)
if __name__ == "__main__":
while True:
branch = input("BRANCH (ex. AAD): ")
if len(branch) != 3:
print("BRANCH MUST BE 3 LETTERS, TRY AGAIN")
continue
else:
break
while True:
try:
floor = int(input("INITIAL OS (0-998): "))
except ValueError:
floor = 0
else:
if floor < 0:
print("INITIAL < 0, TRY AGAIN")
continue
elif floor > 999:
print("INITIAL BETWEEN 0 AND 999, TRY AGAIN")
continue
else:
break
while True:
try:
ceil = int(input("FINAL OS (1-999): "))
except ValueError:
ceil = 999
else:
if ceil < floor:
print("FINAL < INITIAL, TRY AGAIN")
continue
elif ceil > 999:
print("FINAL BETWEEN 1 AND 999, TRY AGAIN")
continue
else:
break
scanner(branch, floor, ceil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment