Skip to content

Commit

Permalink
Captcha, POGOProtos and PotoAPI Check (#5901)
Browse files Browse the repository at this point in the history
Added a simple captcha check. Manual captcha solving is planned. WILL NOT add 2captcha service.

Also checking the version of POGOProtos to alert user of a possible PogoAPI changes. Can't think of a better solution as I can't find anyway to get versioning from PogoAPI.
  • Loading branch information
MerlionRock authored and solderzzc committed Feb 7, 2017
1 parent 334459a commit 80668cb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
25 changes: 25 additions & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def _register_events(self):
)
self.event_manager.register_event('api_error')
self.event_manager.register_event('config_error')

self.event_manager.register_event('captcha')

self.event_manager.register_event('login_started')
self.event_manager.register_event('login_failed')
Expand Down Expand Up @@ -934,6 +936,7 @@ def check_session(self, position):
#self.api.set_hash_lib(self.get_hash_lib())

def login(self):
status = {}
self.event_manager.emit(
'login_started',
sender=self,
Expand Down Expand Up @@ -979,6 +982,28 @@ def login(self):
level='info',
formatted="Login successful."
)

# When successful login, do a captcha check
#Basic Captcha detection, more to come
response_dict = self.api.check_challenge()
captcha_url = response_dict['responses']['CHECK_CHALLENGE']['challenge_url']
if len(captcha_url) > 1:
status['message'] = 'Captcha Encountered, URL: {captcha_url}'
self.event_manager.emit(
'captcha',
sender=self,
level='critical',
formatted=status['message']
)
sys.exit(1)

self.event_manager.emit(
'captcha',
sender=self,
level='info',
formatted="Captcha Check Passed"
)

self.heartbeat()

def get_encryption_lib(self):
Expand Down
23 changes: 19 additions & 4 deletions pokemongo_bot/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ class ApiWrapper(PGoApi, object):
def __init__(self, config=None):
self.config = config
self.gen_device_id()
self.capi = float(0.55)
self.POGOProtos = float(2.6)
# Check if bot is using lastest POGOProtos, only do so if check_niantic_api is set to true
# If a new Protos is availible, it mean there's a possibility of a new API
latestProtos = float(0.0)
if self.config.check_niantic_api is True:
if latestProtos > self.POGOProtos:
link = "https://raw.githubusercontent.com/AeonLucid/POGOProtos/master/.current-version"
f = urllib.urlopen(link)
myfile = f.read()
latestProtos = float(myfile[0:3])
print("\033[1;31;40m We have detected a possibility of a new pogo API. Try upgarding it by using ./setup.sh -u command")
print("\033[1;31;40m This message might still be shown after updating unless a new commit is done in Github\n")

device_info = {
"device_id": ApiWrapper.DEVICE_ID,
"device_brand": 'Apple',
Expand Down Expand Up @@ -92,16 +106,17 @@ def create_request(self):

def login(self, provider, username, password):
# login needs base class "create_request"
officalAPI = float(0.0)
self.useVanillaRequest = True
if self.config.check_niantic_api is True:
capi = '0.45.0'
link = "https://pgorelease.nianticlabs.com/plfe/version"
f = urllib.urlopen(link)
myfile = f.read()
self.config.check_niantic_api
print "Niantic Official API Version:" + myfile
if capi not in myfile:
print("\033[1;31;40m We have detected a Pokemon API Change. The current API version 0.45.0 is no longer supported. Exiting...")
print "Niantic Official API Version:" + myfile.strip()
officalAPI = float(myfile[2:6])
if officalAPI > self.capi:
print("\033[1;31;40m We have detected a Pokemon API Change. The current API version" + str(self.capi) + ".x is no longer supported. Exiting...")
sys.exit(1)

try:
Expand Down

0 comments on commit 80668cb

Please sign in to comment.