Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salt hash for device_id #4289

Merged
merged 16 commits into from
Aug 19, 2016
14 changes: 9 additions & 5 deletions pokemongo_bot/api_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import time
import logging
import random
import random, base64, struct
import hashlib

from pgoapi.exceptions import (ServerSideRequestThrottlingException,
NotLoggedInException, ServerBusyOrOfflineException,
NoPlayerPositionSetException, EmptySubrequestChainException,
Expand All @@ -11,24 +10,29 @@
from pgoapi.protos.POGOProtos.Networking.Requests.RequestType_pb2 import RequestType
from pgoapi.protos.POGOProtos.Networking.Envelopes.Signature_pb2 import Signature
from pgoapi.utilities import get_time

from pokemongo_bot.datastore import Datastore
from human_behaviour import sleep


class PermaBannedException(Exception):
pass


class ApiWrapper(PGoApi):
class ApiWrapper(Datastore, PGoApi):
DEVICE_ID = None

def __init__(self, config=None):
PGoApi.__init__(self)
self.useVanillaRequest = False
self.config = config
if self.config is not None:
key_string = self.config.username
rand_float = random.SystemRandom().random()
salt = base64.b64encode((struct.pack('!d', rand_float)))
# Unique device id per account in the same format as ios client
ApiWrapper.DEVICE_ID = hashlib.md5(self.config.username).hexdigest()
ApiWrapper.DEVICE_ID = hashlib.md5(key_string + salt).hexdigest()
with open("DeviceID.txt", "w") as text_file:
text_file.write("Device ID: {0}".format(ApiWrapper.DEVICE_ID))
if ApiWrapper.DEVICE_ID is None:
# Set to a realistic default
ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34"
Expand Down