forked from OvernightPancake/vercelsxm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
317 lines (266 loc) · 11 KB
/
app.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import sys
import requests
import uuid as uuid_module
from flask import Flask, request, render_template
app = Flask(__name__, static_url_path='', static_folder="./static")
SESSION = requests.session()
RESPONSES = {
'activated': {
'crm': {'resultCode': 'SUCCESS', 'opstatus': 0, 'httpStatusCode': 200},
'create': {'resultData': [{'resultCode': 'SUCCESS'}], 'opstatus': 0, 'httpStatusCode': 200},
'refresh': {'opstatus': 0, 'errors': [{'resultCode': 'SUCCESS'}], 'httpStatusCode': 200},
},
'already_activated': {
'crm': {'resultCode': 'SUCCESS', 'opstatus': 0, 'httpStatusCode': 200},
'create': {'resultData': [{'resultCode': 'FAILURE'}, {'code': '11-03-ACCT-1073'},
{'message': 'Device ID is already active'}], 'opstatus': 0, 'httpStatusCode': 200},
'refresh': {'opstatus': 0, 'errors': [{'resultCode': 'SUCCESS'}], 'httpStatusCode': 200},
}
}
def appconfig():
response = SESSION.post(
url="https://mcare.siriusxm.ca/authService/100000002/appconfig",
headers={
"X-Kony-Integrity": "GWSUSEVMJK;FEC9AA232EC59BE8A39F0FAE1B71300216E906B85F40CA2B1C5C7A59F85B17A4",
"X-HTTP-Method-Override": "GET",
"Accept": "*/*",
"X-Kony-App-Secret": "e3048b73f2f7a6c069f7d8abf5864115",
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"X-Kony-App-Key": "85ee60a3c8f011baaeba01ff3a5ae2c9",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
},
)
return response.json()
def login():
response = SESSION.post(
url="https://mcare.siriusxm.ca/authService/100000002/login",
headers={
"X-Kony-Platform-Type": "ios",
"Accept": "application/json",
"X-Kony-App-Secret": "e3048b73f2f7a6c069f7d8abf5864115",
"Accept-Language": "en-us",
"X-Kony-SDK-Type": "js",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-SDK-Version": "8.4.134",
"X-Kony-App-Key": "85ee60a3c8f011baaeba01ff3a5ae2c9",
},
)
return response.json().get('claims_token').get('value')
def version_control(token: str, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/DealerAppService7/VersionControl",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"deviceCategory": "iPhone",
"appver": "2.7.0",
"deviceLocale": "en_US",
"deviceModel": "iPhone 6 Plus",
"deviceVersion": "12.5.7",
"deviceType": "",
},
)
return response.json()
def get_properties(token: str, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/DealerAppService7/getProperties",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
)
return response.json()
def update_device_sat_refresh_with_priority(device_id: str, token: str, uuid: str) -> int:
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/USUpdateDeviceSATRefresh/updateDeviceSATRefreshWithPriority",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"deviceId": device_id,
"appVersion": "2.7.0",
"lng": "-86.210313195",
"deviceID": uuid,
"provisionPriority": "2",
"provisionType": "activate",
"lat": "32.37436705",
},
)
return response.json().get('seqValue', -1)
def get_crm_account_plan_information(device_id: str, token: str, seq_value: int, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/DemoConsumptionRules/GetCRMAccountPlanInformation",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"seqVal": seq_value,
"deviceId": device_id,
},
)
return response.json()
def db_update_for_google(device_id: str, token: str, seq_value: int, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/DBSuccessUpdate/DBUpdateForGoogle",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"OM_ELIGIBILITY_STATUS": "Eligible",
"appVersion": "2.7.0",
"flag": "failure",
"Radio_ID": device_id,
"deviceID": uuid,
"G_PLACES_REQUEST": "",
"OS_Version": "iPhone 12.5.7",
"G_PLACES_RESPONSE": "",
"Confirmation_Status": "SUCCESS",
"seqVal": seq_value,
},
)
return response.json()
def block_list_device(token: str, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/USBlockListDevice/BlockListDevice",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"deviceId": uuid,
},
)
return response.json()
def create_account(device_id: str, token: str, seq_value: int, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/DealerAppService3/CreateAccount",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"seqVal": seq_value,
"deviceId": device_id,
"oracleCXFailed": "1",
"appVersion": "2.7.0",
},
)
return response.json()
def update_device_sat_refresh_with_priority_cc(device_id: str, token: str, uuid: str):
response = SESSION.post(
url="https://mcare.siriusxm.ca/services/USUpdateDeviceRefreshForCC/updateDeviceSATRefreshWithPriority",
headers={
"Accept": "*/*",
"X-Kony-API-Version": "1.0",
"X-Kony-DeviceId": uuid,
"Accept-Language": "en-us",
"Accept-Encoding": "br, gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "SXM Dealer/2.7.0 CFNetwork/978.0.7 Darwin/18.7.0",
"X-Kony-Authorization": token,
},
data={
"deviceId": device_id,
"provisionPriority": "2",
"appVersion": "2.7.0",
"device_Type": "iPhone iPhone 6 Plus",
"deviceID": uuid,
"os_Version": "iPhone 12.5.7",
"provisionType": "activate",
},
)
return response.json()
def process(device_id: str):
results = {}
uuid = str(uuid_module.uuid4())
appconfig()
auth_token = login()
version_control(auth_token, uuid)
get_properties(auth_token, uuid)
seq = int(update_device_sat_refresh_with_priority(device_id, auth_token, uuid))
results['crm'] = get_crm_account_plan_information(device_id, auth_token, seq, uuid)
db_update_for_google(device_id, auth_token, seq, uuid)
block_list_device(auth_token, uuid)
results['create'] = create_account(device_id, auth_token, seq, uuid)
results['refresh'] = update_device_sat_refresh_with_priority_cc(device_id, auth_token, uuid)
return results
@app.route("/", methods=['GET', 'POST'])
def index() -> str:
test = 'test' in request.args.keys()
if test:
result = {
'success': True,
'responses': RESPONSES.get('activated'),
}
return render_template('index.html', result=result)
if request.method == 'POST':
radio_id = request.form.get('radio_id').upper().strip()
result = {
'success': False,
'responses': process(radio_id),
}
responses = {k: result.get('responses')[k] for k in result.get('responses').keys()}
if responses.get('crm', {}).get('deviceId'):
responses['crm'].pop('deviceId')
result['success'] = responses == RESPONSES.get('activated') or responses == RESPONSES.get('already_activated')
return render_template('index.html', result=result)
else:
return render_template('index.html')
if __name__ == '__main__':
if len(sys.argv) > 1:
radio_id_input = sys.argv[1].upper().strip()
print(f'Processing for Radio ID "{radio_id_input}"...')
for key, value in process(radio_id_input).items():
print(f"\n{key}:\n{value}")
else:
app.run()