Skip to content

Commit

Permalink
added code for beta farmer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mila432 committed Jul 18, 2016
1 parent 8e328fb commit ac6bef6
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 43 deletions.
68 changes: 34 additions & 34 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

api_url='https://pgorelease.nianticlabs.com/plfe/rpc'
login_url='https://sso.pokemon.com/sso/oauth2.0/authorize?client_id=mobile-app_pokemon-go&redirect_uri=https%3A%2F%2Fwww.nianticlabs.com%2Fpokemongo%2Ferror'
login_oauth='https://sso.pokemon.com/sso/oauth2.0/accessToken'

proxies = {
'http': 'http://127.0.0.1:8888',
'https': 'http://127.0.0.1:8888',
}
use_proxy=False
debug=True

google=True
pub=None

s=requests.session()
if use_proxy:
s.proxies.update(proxies)
s.verify=False
s.headers.update({'User-Agent':'Niantic App'})
#public
API_URL = 'https://pgorelease.nianticlabs.com/plfe/rpc'
LOGIN_URL = 'https://sso.pokemon.com/sso/login?service=https%3A%2F%2Fsso.pokemon.com%2Fsso%2Foauth2.0%2FcallbackAuthorize'
LOGIN_OAUTH = 'https://sso.pokemon.com/sso/oauth2.0/accessToken'
PTC_CLIENT_SECRET = 'w8ScCUXJQc6kXKw8FiOhd8Fixzht18Dq3PEVkUCP5ZPxtgyWsbTvWHFLm2wNY0JR'

SESSION = requests.session()
SESSION.headers.update({'User-Agent': 'Niantic App'})
if use_proxy:
SESSION.proxies.update(proxies)
SESSION.verify = False
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

api_url='https://pgorelease.nianticlabs.com/plfe/rpc'
login_url='https://sso.pokemon.com/sso/oauth2.0/authorize?client_id=mobile-app_pokemon-go&redirect_uri=https%3A%2F%2Fwww.nianticlabs.com%2Fpokemongo%2Ferror'
login_oauth='https://sso.pokemon.com/sso/oauth2.0/accessToken'

proxies = {
'http': 'http://127.0.0.1:8888',
'https': 'http://127.0.0.1:8888',
}
use_proxy=True
debug=True
distance=0
google=True
pub=None

s=requests.session()
if use_proxy:
s.proxies.update(proxies)
s.verify=False
s.headers.update({'User-Agent':'Niantic App'})
#public
API_URL = 'https://pgorelease.nianticlabs.com/plfe/rpc'
LOGIN_URL = 'https://sso.pokemon.com/sso/login?service=https%3A%2F%2Fsso.pokemon.com%2Fsso%2Foauth2.0%2FcallbackAuthorize'
LOGIN_OAUTH = 'https://sso.pokemon.com/sso/oauth2.0/accessToken'
PTC_CLIENT_SECRET = 'w8ScCUXJQc6kXKw8FiOhd8Fixzht18Dq3PEVkUCP5ZPxtgyWsbTvWHFLm2wNY0JR'

SESSION = requests.session()
SESSION.headers.update({'User-Agent': 'Niantic App'})
if use_proxy:
SESSION.proxies.update(proxies)
SESSION.verify = False
DEBUG = True
51 changes: 51 additions & 0 deletions dirty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import logic
import stops
import api
import time
import pokemon_pb2
import location
import config

def start_private_show(access_token,ltype,loc):
location.set_location(loc)
print '[+] Token:',access_token[:40]+'...'
prot1=logic.gen_first_data(access_token,ltype)
local_ses=api.get_rpc_server(access_token,prot1)
new_rcp_point='https://%s/rpc'%(local_ses.rpc_server,)
work_stop(local_ses,new_rcp_point)

def work_stop(local_ses,new_rcp_point):
proto_all=logic.all_stops(local_ses)
all_stops=api.use_api(new_rcp_point,proto_all)
maps = pokemon_pb2.maps()
maps.ParseFromString(all_stops)
data_list=location.get_near(maps)
data_list = sorted(data_list, key = lambda x: x[1])
print '[+] found: %s Pokestops within %s m'%(len(data_list),config.distance,)
if local_ses is not None and data_list is not None:
print '[+] starting show'
for t in data_list:
print '[!] farming pokestop..'
work_with_stops(t,local_ses.ses,new_rcp_point)

def work_with_stops(current_stop,ses,new_rcp_point):
Kinder= logic.gen_stop_data(ses,current_stop)
tmp_api=api.use_api(new_rcp_point,Kinder)
if tmp_api is not None:
map = pokemon_pb2.map()
map.ParseFromString(tmp_api)
st= map.sess[0].status
if st==4:
print "[!] +%s"%map.sess[0].amt
elif st==3:
print "[!] used"
elif st==2:
print "[!] charging"
elif st==1:
print "[!] teleport.."
time.sleep(14)
work_with_stops(current_stop,ses,new_rcp_point)
else:
print "[?]:",st
else:
print '[-] tmp_api empty'
64 changes: 64 additions & 0 deletions location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import pokemon_pb2
import base64
import struct
import config
from math import radians, cos, sin, asin, sqrt
from geopy.distance import vincenty
from geopy.geocoders import GoogleV3

COORDS_LATITUDE = 0
COORDS_LONGITUDE = 0
COORDS_ALTITUDE = 0
FLOAT_LAT = 0
FLOAT_LONG = 0

def get_location_coords():
return (COORDS_LATITUDE, COORDS_LONGITUDE, COORDS_ALTITUDE)

def set_location(location_name):
geolocator = GoogleV3()
loc = geolocator.geocode(location_name)

print('[!] Your given location: {}'.format(loc.address.encode('utf-8')))
print('[!] lat/long/alt: {} {} {}'.format(loc.latitude, loc.longitude, loc.altitude))
set_location_coords(loc.latitude, loc.longitude, loc.altitude)

def set_location_coords(lat, long, alt):
global COORDS_LATITUDE, COORDS_LONGITUDE, COORDS_ALTITUDE
global FLOAT_LAT, FLOAT_LONG
FLOAT_LAT = lat
FLOAT_LONG = long
COORDS_LATITUDE = f2i(lat)
COORDS_LONGITUDE = f2i(long)
COORDS_ALTITUDE = f2i(alt)

def i2f(int):
return struct.unpack('<Q', struct.pack('<d', int))[0]

def f2h(float):
return hex(struct.unpack('<Q', struct.pack('<d', float))[0])

def f2i(float):
return struct.unpack('<Q', struct.pack('<d', float))[0]

def l2f(float):
return struct.unpack('d', struct.pack('Q', int(bin(float), 0)))[0]

def h2f(hex):
return struct.unpack('<d', struct.pack('<Q', int(hex,16)))[0]

def get_near(map):
ms=[]
for cell in [map]:
for block in cell.b:
for obj in block.c:
for stop in obj.s:
if is_near(stop.lat,stop.lon,COORDS_LATITUDE,COORDS_LONGITUDE):
ms.append((stop.name,stop.lat,stop.lon))
return ms

def is_near(locx,locy,myx,myy):
tmp1 = (l2f(locx), l2f(locy))
tmp2 = (l2f(myx), l2f(myy))
res=vincenty(tmp1, tmp2).meters
return res<config.distance
22 changes: 13 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import os
import platform
import sys
from getpass import getpass

import config
import login
import public
from getpass import getpass
import public_proto_pb2
try:
import pokemon_pb2
import logic
Expand All @@ -21,7 +22,6 @@
import api
config.pub=False
except:
import public_proto_pb2
config.pub=True

def get_acces_token(usr,pws,type):
Expand All @@ -40,33 +40,37 @@ def get_acces_token(usr,pws,type):
access_token= login.login_pokemon(usr,pws)
ltype='ptc'
return access_token,ltype

def main():
if platform.system() == 'Windows':
if 'nux' not in platform.system():
os.system("title Pokemon GO API Python")
os.system("cls")
else:
# Catches "Linux" and "Darwin" (OSX)
os.system("clear")
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--username", help="Login", required=True)
parser.add_argument("-u", "--username", help="Login", default=None)
parser.add_argument("-p", "--password", help="Password", default=None)
parser.add_argument("-t", "--type", help="Google/PTC", required=True)
parser.add_argument("-l", "--location", help="Location", required=True)
parser.add_argument("-d", "--distance", help="Distance", required=True)
args = parser.parse_args()
if not args.username:
args.username = getpass("Username: ")
if not args.password:
args.password = getpass("Google/PTC Password: ")
args.password = getpass("Password: ")
if 'ptc' in args.type.lower() or 'goo' in args.type.lower():
config.distance=args.distance
access_token,ltype=get_acces_token(args.username,args.password,args.type.lower())
if access_token is not None:
print '[!] using:',config.pub
if config.pub:
public.start_work(access_token,ltype)
else:
dirty.start_private_show(access_token,ltype)
dirty.start_private_show(access_token,ltype,args.location)
else:
print '[-] access_token bad'
else:
print '[!] used type "%s" only Google or PTC valid'%(args.type.lower())

if __name__ == '__main__':
main()

0 comments on commit ac6bef6

Please sign in to comment.