-
Notifications
You must be signed in to change notification settings - Fork 360
/
main.py
85 lines (77 loc) · 2.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import requests
import base64
import time
import re
import json
try:
import pokemon_pb2
import pokemon
from protobuf_codec import Codec
except:
print '[!] ask mila for files..'
exit()
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
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'
proxies = {
'http': 'http://127.0.0.1:8888',
'https': 'http://127.0.0.1:8888',
}
use_proxy=True
debug=True
s=requests.session()
if use_proxy:
s.proxies.update(proxies)
s.headers.update({'User-Agent':'Niantic App'})
s.verify=False
def get_api(access_token):
try:
r=s.post(api_url,data=base64.b64decode(pokemon.generate_login(access_token)),verify=False)
pok = pokemon_pb2.Login()
pok.ParseFromString(r.content)
return 'https://'+pok.api_point+'/rpc'
except:
print '[-] server offline'
time.sleep(3)
get_api()
def use_api(target_api,access_token):
if debug:
print '[!] using api:',target_api
r=s.post(target_api,data=base64.b64decode(pokemon.generate_login(access_token)),verify=False)
return r.content
def login_pokemon(user,passw):
print '[!] doing login for:',user
head={'User-Agent':'niantic'}
r=s.get(login_url,headers=head)
jdata=json.loads(r.content)
data={'lt':jdata['lt'],
'execution':jdata['execution'],
'_eventId':'submit',
'username':user,
'password':passw}
r1=s.post(login_url,data=data,headers=head)
ticket=re.sub('.*ticket=','',r1.history[0].headers['Location'])
data1={'client_id':'mobile-app_pokemon-go',
'redirect_uri':'https://www.nianticlabs.com/pokemongo/error',
'client_secret':'w8ScCUXJQc6kXKw8FiOhd8Fixzht18Dq3PEVkUCP5ZPxtgyWsbTvWHFLm2wNY0JR',
'grant_type':'refresh_token',
'code':ticket}
r2=s.post(login_oauth,data=data1)
access_token=re.sub('&expires.*','',r2.content)
access_token=re.sub('.*access_token=','',access_token)
return access_token
def main():
access_token= login_pokemon('username','verystrongpassword')
if access_token is not None:
print '[+] Token:',access_token[:40]+'...'
new_api= get_api(access_token)
if 'Milaly432' in use_api(new_api,access_token):
print '[+] logged in'
else:
print '[-] protobuf sux..'
if __name__ == '__main__':
main()