抖音a_bogus

干货分享 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:小璐学编程

  • 8
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值