干货分享 dy–a_bogus ,
def get_chaos(params, ua):
with open(JS_PATH, 'r', encoding='UTF-8') as f:
js_code = f.read()
js_content = execjs.compile(js_code)
return js_content.call('get_fromCharCodeStr1'), js_content.call('get_chaos', params, ua)
def make_str_chaos(chaos_str: str):
t = ''
a = [131]
n, d = 0, 0
e = list(range(256))
for r in range(256):
d = (d + e[r] + a[r % len(a)]) % 256
e[r], e[d] = e[d], e[r]
d = 0
for o in chaos_str:
n += 1
d = (d + e[n % 256]) % 256
e[n], e[d] = e[d], e[n]
t += chr(ord(o) ^ e[(e[n] + e[d]) % 256])
return t
def left_shift(a, b):
"""a << b"""
a, b = ctypes.c_int32(a).value, b % 32
return ctypes.c_int32(a << b).value
def chaos2result(chaos_str: str):
base_str = "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
result = ''
and_list = [16515072, 258048, 4032, 63]
chaos_pad_str = chaos_str + chr(0) + chr(0) + chr(0)
for i in range(0, len(chaos_str), 3):
num0, num1, num2 = ord(chaos_pad_str[i]), ord(chaos_pad_str[i + 1]), ord(chaos_pad_str[i + 2])
number = num2 | left_shift(num1, 8) | left_shift(num0, 16)
for j, and_num in enumerate(and_list):
result += base_str[ctypes.c_int32(number & and_num).value >> (6 * (3 - j))]
return result
def get_a_bogus(params, _ua):
s1, s2 = get_chaos(params, _ua)
s2 = make_str_chaos(s2)
a_bogus = chaos2result(s1 + s2)
return a_bogus
感兴趣的小伙伴可以关注gzh:小璐学编程