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

Commit c140c23

Browse files
authored
Update tapswap.py
1 parent 6aae968 commit c140c23

File tree

1 file changed

+3
-66
lines changed

1 file changed

+3
-66
lines changed

tapswap.py

+3-66
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from BypassTLS import BypassTLSv1_3
1212

1313
class TapSwap:
14-
def __init__(self, url: str, auto_upgrade:bool, max_charge_level:int, max_energy_level:int, max_tap_level:int):
14+
def __init__(self, url: str, chq_bypass, auto_upgrade:bool, max_charge_level:int, max_energy_level:int, max_tap_level:int):
1515
if auto_upgrade:
1616
self.max_charge_level = max_charge_level
1717
self.max_energy_level = max_energy_level
@@ -25,6 +25,7 @@ def __init__(self, url: str, auto_upgrade:bool, max_charge_level:int, max_energy
2525
self.init_data = urllib.parse.unquote(url).split('tgWebAppData=')[1].split('&tgWebAppVersion')[0]
2626
self.x_cv = "617"
2727
self.access_token = ""
28+
self.chq_bypass = chq_bypass
2829
self.headers = {
2930
"accept": "*/*",
3031
"accept-language": "en-US,en;q=0.9,fa;q=0.8",
@@ -59,21 +60,8 @@ def prepare_prerequisites(self):
5960
print("[!] We ran into trouble with the get auth token! 🚫 The script is stopping.")
6061
sys.exit()
6162

62-
def run_code_and_calculate_result(self, code):
63-
x = JSCodeProcessor(code)
64-
return x.execute_js_code()
65-
6663
def extract_chq_result(self, chq):
67-
len_value = len(chq)
68-
bytes_array = bytearray(len_value // 2)
69-
x = 157
70-
71-
for t in range(0, len_value, 2):
72-
bytes_array[t // 2] = int(chq[t:t + 2], 16)
73-
74-
xored = bytearray(t ^ x for t in bytes_array)
75-
decoded = xored.decode('utf-8')
76-
return self.run_code_and_calculate_result(decoded)
64+
return self.chq_bypass(chq)
7765

7866
def get_auth_token(self):
7967
payload = {
@@ -362,54 +350,3 @@ def shares(self):
362350
def time_to_recharge(self):
363351
return self._time_to_recharge + random.randint(60*2, 60*12)
364352

365-
class JSCodeProcessor:
366-
def __init__(self, js_code):
367-
self.js_code = js_code
368-
self.data = None
369-
self.codes = {}
370-
self.code_to_run = ""
371-
372-
def extract_data(self):
373-
data = "h['innerHTML']" + self.js_code.split("h['innerHTML']")[1].split('}()));function a()')[0].replace(';', ';\n\n').replace("'+'", '')
374-
data = data.replace('\\x20', ' ').replace('\\x22', '"')
375-
self.data = data
376-
return data
377-
378-
def parse_html(self):
379-
if self.data is None:
380-
self.extract_data()
381-
soup = BeautifulSoup(self.data, 'html.parser')
382-
div_elements = soup.find_all('div')
383-
for div in div_elements:
384-
if 'id' in div.attrs and '_v' in div.attrs:
385-
self.codes[div['id']] = div['_v']
386-
387-
return self.codes
388-
389-
def build_js_code(self):
390-
if not self.codes:
391-
self.parse_html()
392-
393-
cjk = self.data.split('var i=')[1].split(';')[0].split(',')
394-
code_to_run = "function() {"
395-
for k, v in self.codes.items():
396-
if k in cjk[0]:
397-
i = v
398-
code_to_run += f"i={v};\n"
399-
if k in cjk[1]:
400-
j = v
401-
code_to_run += f"j={v};\n"
402-
403-
code_to_run += cjk[2] + ";\n"
404-
r = 'return ' + self.data.split('return')[1].split(';')[0] + ';}'
405-
code_to_run += r
406-
407-
self.code_to_run = code_to_run
408-
return code_to_run
409-
410-
def execute_js_code(self):
411-
if not self.code_to_run:
412-
self.build_js_code()
413-
414-
r = js2py.eval_js(self.code_to_run)
415-
return r()

0 commit comments

Comments
 (0)