From 271aa6f289288a1cc11173bbd9e7ca65b934c23b Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:22:38 -0400 Subject: [PATCH 01/16] salt the hash --- pokemongo_bot/api_wrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py index 9739c29627..03f98f3dc8 100644 --- a/pokemongo_bot/api_wrapper.py +++ b/pokemongo_bot/api_wrapper.py @@ -27,8 +27,10 @@ def __init__(self, config=None): self.useVanillaRequest = False self.config = config if self.config is not None: + key_string = self.config.username + salt = self.config.hash_salt # 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() if ApiWrapper.DEVICE_ID is None: # Set to a realistic default ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34" From d895a0e91129ec2a8b5c8715fd8f0c1ecf664b48 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:23:31 -0400 Subject: [PATCH 02/16] Update config.json.example --- configs/config.json.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/config.json.example b/configs/config.json.example index a01d0b8103..0c1d49b186 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -189,6 +189,7 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, + "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From 13e8b12afa8c9dc1475b2d530da964b1f8b46fba Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:23:44 -0400 Subject: [PATCH 03/16] Update config.json.cluster.example --- configs/config.json.cluster.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/config.json.cluster.example b/configs/config.json.cluster.example index ec6cf873bb..5fcf2aa440 100644 --- a/configs/config.json.cluster.example +++ b/configs/config.json.cluster.example @@ -170,6 +170,7 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, + "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From c487760087d6929f9233d222fdb7f5d8930616b4 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:24:04 -0400 Subject: [PATCH 04/16] Update config.json.map.example --- configs/config.json.map.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/config.json.map.example b/configs/config.json.map.example index 03041f6122..d225870fc0 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -423,6 +423,7 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, + "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From f393688fd9788ea66970aa38d84ace1f94833eb2 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:24:22 -0400 Subject: [PATCH 05/16] Update config.json.optimizer.example --- configs/config.json.optimizer.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/config.json.optimizer.example b/configs/config.json.optimizer.example index 2825077dfd..0174752227 100644 --- a/configs/config.json.optimizer.example +++ b/configs/config.json.optimizer.example @@ -236,6 +236,7 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, + "hash_salt": "xRpgobot", "catch": { "any": { "always_catch": true From 1190861301e7e6cac9435a46f963972afe334f9c Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:26:18 -0400 Subject: [PATCH 06/16] Update config.json.path.example --- configs/config.json.path.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/config.json.path.example b/configs/config.json.path.example index a85bd7d0bb..f0da89be00 100644 --- a/configs/config.json.path.example +++ b/configs/config.json.path.example @@ -171,6 +171,7 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, + "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From 81b6e0fca2817f71b4115d36f3b9a73ed321e2af Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:27:33 -0400 Subject: [PATCH 07/16] Update pokecli.py --- pokecli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pokecli.py b/pokecli.py index f2fb345c4c..6e02c9f44e 100644 --- a/pokecli.py +++ b/pokecli.py @@ -520,6 +520,7 @@ def _json_loader(filename): config.plugins = load.get('plugins', []) config.raw_tasks = load.get('tasks', []) config.daily_catch_limit = load.get('daily_catch_limit', 800) + config.hash_salt = load.get('hash_salt', "xRpgobot") # salts the hash for device_id generation config.vips = load.get('vips', {}) if config.map_object_cache_time < 0.0: From f910e320d6b226611dbcbaa3a3680f47b0613f01 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:57:15 -0400 Subject: [PATCH 08/16] Update api_wrapper.py --- pokemongo_bot/api_wrapper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py index 03f98f3dc8..4498171d25 100644 --- a/pokemongo_bot/api_wrapper.py +++ b/pokemongo_bot/api_wrapper.py @@ -1,6 +1,6 @@ import time import logging -import random +import random, base64, struct import hashlib from pgoapi.exceptions import (ServerSideRequestThrottlingException, @@ -11,7 +11,7 @@ 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 @@ -19,7 +19,7 @@ class PermaBannedException(Exception): pass -class ApiWrapper(PGoApi): +class ApiWrapper(Datastore, PGoApi): DEVICE_ID = None def __init__(self, config=None): @@ -28,7 +28,8 @@ def __init__(self, config=None): self.config = config if self.config is not None: key_string = self.config.username - salt = self.config.hash_salt + 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(key_string + salt).hexdigest() if ApiWrapper.DEVICE_ID is None: From 86dab856e2df8a2567cc64ed994440215b8bd478 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:58:52 -0400 Subject: [PATCH 09/16] Update config.json.cluster.example --- configs/config.json.cluster.example | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/config.json.cluster.example b/configs/config.json.cluster.example index 5fcf2aa440..ec6cf873bb 100644 --- a/configs/config.json.cluster.example +++ b/configs/config.json.cluster.example @@ -170,7 +170,6 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, - "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From c13e20ab89f17d9dd3a7329c085d544703f350a5 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:59:04 -0400 Subject: [PATCH 10/16] Update config.json.example --- configs/config.json.example | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/config.json.example b/configs/config.json.example index 0c1d49b186..a01d0b8103 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -189,7 +189,6 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, - "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From 0043b26973beb1db153ec1d644155ef560fb928f Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:59:35 -0400 Subject: [PATCH 11/16] Update config.json.map.example --- configs/config.json.map.example | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/config.json.map.example b/configs/config.json.map.example index d225870fc0..03041f6122 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -423,7 +423,6 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, - "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From d2cf88cfff7a3cd239b14ccfcf129e041733eabb Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 17:59:47 -0400 Subject: [PATCH 12/16] Update config.json.optimizer.example --- configs/config.json.optimizer.example | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/config.json.optimizer.example b/configs/config.json.optimizer.example index 0174752227..2825077dfd 100644 --- a/configs/config.json.optimizer.example +++ b/configs/config.json.optimizer.example @@ -236,7 +236,6 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, - "hash_salt": "xRpgobot", "catch": { "any": { "always_catch": true From f778abd5125d03106f33f7979d07719640b5bb41 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 18:00:01 -0400 Subject: [PATCH 13/16] Update config.json.path.example --- configs/config.json.path.example | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/config.json.path.example b/configs/config.json.path.example index f0da89be00..a85bd7d0bb 100644 --- a/configs/config.json.path.example +++ b/configs/config.json.path.example @@ -171,7 +171,6 @@ "reconnecting_timeout": 15, "logging_color": true, "daily_catch_limit": 800, - "hash_salt": "xRpgobot", "catch": { "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}, "// Example of always catching Rattata:": {}, From 93bd318b51bcba1acd63c4b9bec8bc1ba69decca Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 18:22:04 -0400 Subject: [PATCH 14/16] store device_id to file --- pokemongo_bot/api_wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py index 4498171d25..10facc9e5f 100644 --- a/pokemongo_bot/api_wrapper.py +++ b/pokemongo_bot/api_wrapper.py @@ -2,7 +2,8 @@ import logging import random, base64, struct import hashlib - +import os +import json from pgoapi.exceptions import (ServerSideRequestThrottlingException, NotLoggedInException, ServerBusyOrOfflineException, NoPlayerPositionSetException, EmptySubrequestChainException, @@ -32,6 +33,8 @@ def __init__(self, config=None): 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(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" From 3ac43ada350c985abca0fa30c9d9dc7d84480fc8 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 18:22:53 -0400 Subject: [PATCH 15/16] Update api_wrapper.py --- pokemongo_bot/api_wrapper.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py index 10facc9e5f..2f189e0833 100644 --- a/pokemongo_bot/api_wrapper.py +++ b/pokemongo_bot/api_wrapper.py @@ -2,8 +2,6 @@ import logging import random, base64, struct import hashlib -import os -import json from pgoapi.exceptions import (ServerSideRequestThrottlingException, NotLoggedInException, ServerBusyOrOfflineException, NoPlayerPositionSetException, EmptySubrequestChainException, From bcc8b6c6a524cdf6ec103eb068f2d90697c0a94f Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 19 Aug 2016 18:23:30 -0400 Subject: [PATCH 16/16] Update pokecli.py --- pokecli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pokecli.py b/pokecli.py index 6e02c9f44e..f2fb345c4c 100644 --- a/pokecli.py +++ b/pokecli.py @@ -520,7 +520,6 @@ def _json_loader(filename): config.plugins = load.get('plugins', []) config.raw_tasks = load.get('tasks', []) config.daily_catch_limit = load.get('daily_catch_limit', 800) - config.hash_salt = load.get('hash_salt', "xRpgobot") # salts the hash for device_id generation config.vips = load.get('vips', {}) if config.map_object_cache_time < 0.0: