Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Commit c9ba4c5

Browse files
Add files via upload
1 parent 4ef6fc1 commit c9ba4c5

File tree

2 files changed

+190
-171
lines changed

2 files changed

+190
-171
lines changed

NumbusterAPI.py

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import requests
22
import signatures
3-
3+
import time
4+
requests.adapters.DEFAULT_RETRIES = 500
45

56
class Numbuster:
67
def __init__(self,access_token=None):
@@ -35,7 +36,7 @@ def v6_comment_delete(self,phone:str):
3536
data = requests.get(url,headers=self.headers)
3637
return data.json()
3738

38-
def v6_old_phone(self,phone,locale='RU'):
39+
def v6_old_phone(self,phone,locale='ru'):
3940
timestamp = signatures.get_timestamp()
4041
cnonce = signatures.get_cnonce()
4142
signature = signatures.signature_v6_old_phone(phone,self.access_token,cnonce,timestamp,locale)
@@ -51,7 +52,7 @@ def v6_notice_delete(self,phone):
5152
data = requests.post(url,headers=self.headers)
5253
return data.json()
5354

54-
def v6_old_sms(self,phone,locale='RU'):
55+
def v6_old_sms(self,phone,locale='ru'):
5556
timestamp = signatures.get_timestamp()
5657
cnonce = signatures.get_cnonce()
5758
signature = signatures.signature_v6_old_sms(phone,self.access_token,cnonce,timestamp,locale)
@@ -72,16 +73,26 @@ def v6_numcy_subscription_comment_renewal(self,comment_id:int):
7273
data = requests.post(url,headers=self.headers)
7374
return data.json()
7475

75-
def v6_auth_get(self,platform='Android',lang='RU'):
76+
def v6_auth_get(self,platform='Android',lang='ru'):
7677
#Allows to get misterious code
7778
timestamp = signatures.get_timestamp()
7879
cnonce = signatures.get_cnonce()
7980
signature = signatures.signature_v6_auth_get(cnonce,timestamp,lang,platform)
8081
url = self.api_url+f'v6/auth/get?platform={platform}&lang={lang}&timestamp={timestamp}&signature={signature}&cnonce={cnonce}'
8182
data = requests.get(url,headers=self.headers)
8283
return data.json()
84+
85+
def v6_auth_precheck(self,code:str,phone:str):
86+
headers = self.headers.copy()
87+
headers['Content-Type'] = 'application/x-www-form-urlencoded'
88+
timestamp = signatures.get_timestamp()
89+
cnonce = signatures.get_cnonce()
90+
signature = signatures.signature_v6_auth_precheck(cnonce,code,phone,timestamp)
91+
url = self.api_url+f'v6/auth/precheck?timestamp={timestamp}&signature={signature}&cnonce={cnonce}'
92+
data = requests.post(url,headers=headers,data=bytes(f'code={code}&phone={phone}','utf-8'))
93+
return data.json()
8394

84-
def v6_old_search(self,phone:str,locale='RU'):
95+
def v6_old_search(self,phone:str,locale='ru'):
8596
timestamp = signatures.get_timestamp()
8697
cnonce = signatures.get_cnonce()
8798
signature = signatures.signature_v6_old_search(phone,self.access_token,cnonce,timestamp,locale)
@@ -113,7 +124,7 @@ def v6_auth_facebook(self,facebook_token,code):
113124
data = requests.post(url,headers=self.headers)
114125
return data.json()
115126

116-
def v6_old_profiles_by_phone(self,phone:str,locale='RU'):
127+
def v6_old_profiles_by_phone(self,phone:str,locale='ru'):
117128
timestamp = signatures.get_timestamp()
118129
cnonce = signatures.get_cnonce()
119130
signature = signatures.signature_v6_old_profiles_by_phone(phone,self.access_token,cnonce,timestamp,locale)
@@ -253,35 +264,39 @@ def another_profiles_without_code(self,phone:str):
253264
return data.json()
254265

255266
def another_ping(self,device_build='9b1ef3ef32be6596',device_imei='000000000000000',device_os='Android',deviceToken='0',device_locale='en_US',device_version='60600'):
256-
dt = f'device%5Buid%5D={device_build}&device%5Bimei%5D={device_build}&device%5Bos%5D={device_os}&device%5BdeviceToken%5D={deviceToken}&device%5Blocale%5D={device_locale}&device%5Bversion%5D={device_version}'
257-
headers = self.headers.copy()
258-
headers['Content-Type'] = 'application/x-www-form-urlencoded'
259-
url = self.api_url+f'old4a27f7a4025447ee5560a49bc5bcde34/ping?access_token={self.access_token}'
260-
data = requests.post(url,headers=headers,data=bytes(dt,'utf-8'))
261-
return data.json()
267+
dt = f'device%5Buid%5D={device_build}&device%5Bimei%5D={device_build}&device%5Bos%5D={device_os}&device%5BdeviceToken%5D={deviceToken}&device%5Blocale%5D={device_locale}&device%5Bversion%5D={device_version}'
268+
headers = self.headers.copy()
269+
headers['Content-Type'] = 'application/x-www-form-urlencoded'
270+
url = self.api_url+f'old4a27f7a4025447ee5560a49bc5bcde34/ping?access_token={self.access_token}'
271+
data = requests.post(url,headers=headers,data=bytes(dt,'utf-8'))
272+
return data.json()
262273

263274
def v2_ping(self,version = '60600'):
264-
headers = self.headers.copy()
265-
headers['Content-Type'] = 'application/x-www-form-urlencoded'
266-
url = self.api_url+f'v2/ping?access_token={self.access_token}'
267-
data = requests.post(url,headers=headers,data=bytes(f'package_name=com.numbuster.android&version={version}&check=false','utf-8'))
268-
return data.json()
275+
headers = self.headers.copy()
276+
headers['Content-Type'] = 'application/x-www-form-urlencoded'
277+
url = self.api_url+f'v2/ping?access_token={self.access_token}'
278+
data = requests.post(url,headers=headers,data=bytes(f'package_name=com.numbuster.android&version={version}&check=false','utf-8'))
279+
return data.json()
269280

270281
def v2_contacts_sync(self):
271-
headers = self.headers.copy()
272-
headers['Content-Type'] = 'application/json; charset=UTF-8'
273-
url = self.api_url+f'v2/contacts/sync?access_token={self.access_token}'
274-
data = requests.post(url,headers=headers,data='[]')
275-
return data.json()
282+
headers = self.headers.copy()
283+
headers['Content-Type'] = 'application/json; charset=UTF-8'
284+
url = self.api_url+f'v2/contacts/sync?access_token={self.access_token}'
285+
data = requests.post(url,headers=headers,data='[]')
286+
return data.json()
276287

277288
def request_sms_code(self,phonenumber:str):
278-
code = self.v6_auth_get()['data']['code'] #Can be deleted
279-
self.v6_auth_agreement_code(code) #Can be deleted
280-
self.another_profiles_without_code(phonenumber)
281-
self.another_profiles(phonenumber) #Can be deleted
289+
code = self.v6_auth_get(platform='iOS')['data']['code']
290+
self.v6_auth_agreement_code(code)
291+
self.v6_auth_precheck(code,phonenumber)
292+
self.another_profiles_without_code(phonenumber)
293+
self.another_profiles(phonenumber) #Can be deleted, but meh...
294+
282295

283296
def send_sms_code(self,phonenumber:str,code:str):
297+
284298
self.access_token = api.another_profiles_confirm(phonenumber,code)['access_token']
299+
self.another_ping()
285300
self.v2_ping()
286301
self.v6_auth_agreement(phonenumber)
287302
self.v2_contacts_sync()
@@ -291,7 +306,10 @@ def send_sms_code(self,phonenumber:str,code:str):
291306

292307
if __name__ == '__main__':
293308

294-
api = Numbuster()
309+
api = Numbuster('')
310+
api.request_sms_code('')
311+
code = input('Code: ')
312+
api.send_sms_code('',code)
313+
print(api.access_token)
295314
print(api.v6_old_phone('79202600211'))
296-
297-
315+

0 commit comments

Comments
 (0)