-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmvapi.py
166 lines (135 loc) · 5.61 KB
/
mvapi.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import json
import requests
import urllib3
from mvlogger import *
#############################################################################
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
#############################################################################
proxies = {'https' : 'http://127.0.0.1:8888'}
#############################################################################
def create_user():
api_url = 'https://app4.moovitapp.com/services-app/services/V4/UserDetails/CreateUser'
headers = {
'CLIENT_VERSION': '5.94.2.537',
'Host': 'app4.moovitapp.com',
'Content-Type': 'application/octet-stream',
'Content-Length': '253'
}
data = open(r'real_create_user_request_from_israel.bin', 'rb').read()
response = requests.post(api_url, verify=False, proxies=proxies ,headers=headers, data=data)
user_key = None
if response.ok:
user_key = (response.content[10:42]).decode('utf-8')
logging.info(f'Create User-Key -> {user_key}')
return user_key
def firebase_register(user_key):
logging.info(f'Registering {user_key} to firebase')
api_url = 'https://app4.moovitapp.com/services-app/services/Firebase/Register'
headers = {
'USER_KEY' : user_key,
'App-Id' : '1'
}
response = requests.post(api_url, verify=False, proxies=proxies, headers=headers)
if response.ok:
custom_token = response.content[7:-1]
return custom_token
else:
logging.error('Failed registering to firebase')
exit(1)
def verify_firebase_token(firebase_token):
logging.info(f'Verifing firebase token')
api_url = 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=AIzaSyBkZSYR6T3PYyZ6ery0LP_6e7k1Ia3TRjM'
headers = {
'X-Android-Package' : 'com.tranzmate',
'X-Android-Cert' : 'C56ABF7C6890113ED6654E381E2A1797DA3E7F6A'
}
x = {
"token": firebase_token.decode('utf-8'),
"returnSecureToken": True
}
data = json.dumps(x)
headers['Content-Length'] = str(len(data))
response = requests.post(api_url, verify=False ,proxies=proxies, headers=headers, data=data)
if response.ok:
custom_token = json.loads(response.content)
logging.info('Firebase token has verified')
return custom_token
else:
logging.error('Failed to verify firebase token')
exit(1)
def user_profile(user_key):
global proxies
api_url = 'https://app4.moovitapp.com/services-app/services/V4/UserDetails/UserProfile'
headers = {
'USER_KEY': user_key
}
data = open(r"user_profile.bin", 'rb').read()
response = requests.post(api_url, verify=False ,proxies=proxies, headers=headers, data=data)
return response
def generate_verification_token(user_key, access_token, phone_number):
logging.info(f'Generating OTP verification for {phone_number}')
api_url = 'https://app4.moovitapp.com/services-app/services/PaymentContext/GenerateVerificationToken'
headers = {
'CLIENT_VERSION': '5.94.2.537',
'USER_KEY': user_key,
'Access-Token': access_token,
'Host': 'app4.moovitapp.com',
'Content-Length': '44'
}
data = open(r'generate_verification_token.bin', 'rb').read()
data = data.replace(data[7:16], bytes(phone_number, 'utf-8'))
response = requests.post(api_url, verify=False, proxies=proxies ,headers=headers, data=data)
if response.ok:
logging.info('Generated.')
return True
logging.error('Failed to generate OTP')
return False
def register_verification(user_key, access_token, code):
api_url = 'https://app4.moovitapp.com/services-app/services/PaymentContext/RegistrationVerification'
headers = {
'CLIENT_VERSION' : '5.94.2.537',
'USER_KEY' : user_key,
'Access-Token' : access_token,
'Host' : 'app4.moovitapp.com',
'Content-Length' : '32'
}
data = open(r'registration_verification.bin', 'rb').read()
data = data.replace(data[23:27], code)
response = requests.post(api_url, verify=False, proxies=proxies ,headers=headers, data=data)
if response.ok:
logging.info(f'OTP verified, OTP: {code}')
return True
return False
def get_payment_account(user_key, token):
api_url = 'https://app4.moovitapp.com/services-app/services/PaymentContext/GetPaymentAccount'
headers = {
'CLIENT_VERSION' : '5.94.2.537',
'USER_KEY' : user_key,
'Access-Token' : token,
'Host' : 'app4.moovitapp.com',
'Content-Length' : '1'
}
data = b'\x00'
response = requests.post(api_url, verify=False, proxies=proxies ,headers=headers, data=data)
if response.ok:
logging.info('Got PaymentAccount')
return response
def get_train_ticket(user_key, token):
api_url = 'https://app4.moovitapp.com/services-app/services/PTB/Activations/SetActivationByLocation'
headers = {
'CLIENT_VERSION' : '5.94.2.537',
'USER_KEY' : user_key,
'Access-Token' : token,
'Host' : 'app4.moovitapp.com',
'Content-Length' : '49'
}
data = open(r'set_activation_by_location.bin', 'rb').read()
response = requests.post(api_url, verify=False, proxies=proxies ,headers=headers, data=data)
if response.ok:
var_id_index = response.content.find(b'\x0B\x00\x0C\x00\x00\x00')
ticket_len = response.content[var_id_index + 6]
ticket = response.content[var_id_index + 7: var_id_index + 7 + ticket_len].decode('utf-8')
logging.info(f'Train Ticket: {ticket}')
return ticket
else:
logging.error('Train Ticket Failed')