生成X-Bogus的js代码,通过python调用生成

本文涉及的产品
NLP 自学习平台,3个模型定制额度 1个月
视觉智能开放平台,视频资源包5000点
NLP自然语言处理_高级版,每接口累计50万次
简介: 该文本是一个关于如何解析和执行JavaScript代码的步骤说明。主要内容包括:1. 找到JavaScript文件的位置。2. 下载代码并进行格式化。3. 运行代码时会出现缺少变量错误,需要添加模拟环境的代码。4. 指出主要的入口函数是`_0x5a8f25`,将其赋值给`window`。5. 提供了整个JavaScript代码的长串内容。6. 提供了一个Python脚本,用于调用这个JavaScript函数并处理返回的数据。总结:这段文本描述了如何处理和运行一个JavaScript文件,以及使用Python来与这个脚本交互的示例。

1、找到js所在位置,一般这样来找的:
image.png

2、下载下来代码,格式化一下;

3、直接运行代码会报错,提示缺少变量;
添加以下代码(补环境)

window = global
Request = function(){
   
   }
Headers = function(){
   
   }
document = {
   
   }
document.addEventListener =function (){
   
   }

4、 主要入口函数是:_0x5a8f25; 赋值给window

  function _0x5a8f25(_0x48914f, _0xa771aa) {
        return ('undefined' == typeof window ? global : window)['_$webrt_1668687510']('484e4f4a403f52430017211b45bdadd5a9f8450800000000000007fa1b0002012f1d00921b000b191b000b02402217000a1c1b000b1926402217000c1c1b000b190200004017002646000306000e271f001b000200021d00920500121b001b000b031b000b19041d0092071b000b0401220117000b1c1b000b051e01301700131b00201d00741b000b06260a0000101c1b000b07260a0000101c1b001b000b081e01311d00931b001b000b091e00091d00941b0048021d00951b001b000b1d1d009d1b0048401d009e1b001b000b031b000b18041d00d51b001b000b0a221e0132241b000b031b000b0a221e0132241b000b200a000110040a0001101d00d71b001b000b0a221e0132241b000b031b000b0a221e0132241b000b1a0a000110040a0001101d00d91b000b0b1e00161e01330117002d1b000b0b1e001602000025001d11221e006e24131e00530201340200701a020200000a000210001d01331b001b000b0c1e00101d00da1b000b232217000e1c211b000b23430201353e1700151b001b000b23221e0133240a0000101d00da1b001b000b0d261b000b1c1b000b1b0a0002101d00db1b001b000b0e261b000b241b000b230a0002101d00dd1b001b000b0f261b000b250200200a0002101d00e11b001b000b0a221e0132241b000b031b000b26040a0001101d00e21b001b000b101a00221e00dc240a0000104903e82b1d00e31b001b000b11260a0000101d00e41b001b000b1f1d00e71b001b000b1c4901002b1d00e81b001b000b1c4901002c1d00ea1b001b000b1b1d00ee1b001b000b21480e191d00f31b001b000b21480f191d00f91b001b000b22480e191d00fa1b001b000b22480f191d00fc1b001b000b27480e191d00ff1b001b000b27480f191d01011b001b000b284818344900ff2f1d01021b001b000b284810344900ff2f1d01041b001b000b284808344900ff2f1d01361b001b000b284800344900ff2f1d01371b001b000b294818344900ff2f1d01381b001b000b294810344900ff2f1d01391b001b000b294808344900ff2f1d013a1b001b000b294800344900ff2f1d013b1b001b000b2a1b000b2b311b000b2c311b000b2d311b000b2e311b000b2f311b000b30311b000b31311b000b32311b000b33311b000b34311b000b35311b000b36311b000b37311b000b38311b000b39311b000b3a311b000b3b311d013c1b004900ff1d013d1b001b000b12261b000b2a1b000b2c1b000b2e1b000b301b000b321b000b341b000b361b000b381b000b3a1b000b3c1b000b2b1b000b2d1b000b2f1b000b311b000b331b000b351b000b371b000b391b000b3b0a0013101d013e1b001b000b0e261b000b131b000b3d041b000b3e0a0002101d013f1b001b000b14261b000b1e1b000b3d1b000b3f0a0003101d01401b001b000b15261b000b400200240a0002101d01411b000b4100000142000160203333333333333333333333333333333333333333333333333333333333333333016d0e3130333c3b3005273a253027212c023c31061a373f3036210332302108313037203232302707303b23363a313007363a3b263a393007333c27303720320a3a20213027023c31213d0a3c3b3b3027023c31213d0b3a202130271d303c323d210b3c3b3b30271d303c323d2109202630271432303b210b213a193a223027163426300163073c3b31302d1a33083039303621273a3b09203b3130333c3b30310925273a213a212c253008213a0621273c3b3204363439390725273a36302626100e3a373f3036217525273a3630262608063a373f30362105213c213930043b3a31300168016202266541141716111013121d1c1f1e19181b1a05040706010003020d0c0f343736313033323d3c3f3e39383b3a25242726212023222d2c2f65646766616063626d6c7e7a6802266441113e3125323d610f1e2604176d657a1833232266630d1c640767607e02001439103c621b19373a240c011a05202f38133f1f3b272c2d6c1d03123634062116306802266741113e3125323d610f1e2604176d657a1833232266630d1c640767607802001439103c621b19373a240c011a05202f38133f1f3b272c2d6c1d031236340621163068016c0264640639303b32213d0a363d3427163a3130142102646506363d342714210f0e3a373f30362175023c3b313a220808113a362038303b21120e3a373f303621751b34233c3234213a2708053f26313a38100e3a373f303621751d3c26213a272c0807253920323c3b26080a253d343b213a380b36343939053d343b213a380b0a0a3b3c323d2138342730051420313c3a1816343b23342607303b3130273c3b32163a3b21302d2167110922303731273c233027133230211a223b05273a253027212c1b343830260939343b32203432302606363d273a38300727203b213c383007363a3b3b303621140a0a22303731273c2330270a3023343920342130130a0a263039303b3c20380a30233439203421301b0a0a22303731273c2330270a2636273c25210a33203b36213c3a3b170a0a22303731273c2330270a2636273c25210a33203b36150a0a22303731273c2330270a2636273c25210a333b130a0a332d31273c2330270a3023343920342130120a0a31273c2330270a203b22273425253031150a0a22303731273c2330270a203b22273425253031110a0a31273c2330270a3023343920342130140a0a263039303b3c20380a203b22273425253031140a0a332d31273c2330270a203b22273425253031090a263039303b3c20380c36343939063039303b3c2038160a063039303b3c20380a1c11100a0730363a2731302702646708313a362038303b21043e302c2602646602646102646002646305383421363d06073032102d250a09710e34782f0831360a063634363d300a04263a383008363033063d34272508163033063d34272505303a34253c16303a02303717273a22263027113c26253421363d30270f373c3b311a373f30362114262c3b360e3c26101a02303717273a222630270166043a25303b0421302621093c3b363a323b3c213a073a3b3027273a2704363a31301204001a01140a100d1610101110110a1007070e263026263c3a3b06213a27343230072630211c21303810263a38301e302c1d302730172c2130310a2730383a23301c213038093c3b31302d303111170c053a3c3b2130271023303b210e1806053a3c3b2130271023303b210d36273034213010393038303b210636343b23342609213a1134213400071907273025393436300309267f01320a3b34213c2330363a3130140e3a373f30362175053920323c3b142727342c084a0b3d212125266a6f097a097a7d0e65786c082e647966287d097b0e65786c082e647966287c2e6628290e34783365786c082e647961287d6f0e34783365786c082e647961287c2e62287c016108393a3634213c3a3b043d27303304333c3930103d2121256f7a7a393a3634393d3a26210825393421333a273807223c3b313a222603223c3b07343b31273a3c3105393c3b202d026462063c253d3a3b3002646d043c25343102646c043c253a3102676503383436026764093834363c3b213a263d0c3834360a253a22302725367c0436273a26032d64640536273c3a2605332d3c3a2604253c3e3002676702676602676102676002676302676202676d02676c08333c2730333a2d7a063a253027347a05753a25277a05753a25217a07363d273a38307a0821273c31303b217a0438263c300266650266640623303b313a2706123a3a3239300e0a253427343806223c21363d1a3b0a313c27303621063c323b0a363a3b263c2621303b210626223c21363d03313a3807253d343b213a38043d3a3a3e40141716111013121d1c1f1e19181b1a05040706010003020d0c0f343736313033323d3c3f3e39383b3a25242726212023222d2c2f65646766616063626d6c787b03343c31013b01330127092621342721013c383001210934373c393c213c30260a213c3830262134382564133d34273122342730163a3b36202727303b362c0c3130233c36301830383a272c0839343b32203432300a2730263a3920213c3a3b0f3423343c390730263a3920213c3a3b0926362730303b013a250a26362730303b19303321103130233c3630053c2d30390734213c3a0a25273a31203621062037073734212130272c012509213a20363d1c3b333a08213c38302f3a3b300a213c3830262134382567073225201c3b333a0b3f26133a3b2126193c26210b253920323c3b26193c26210a213c38302621343825660a30233027163a3a3e3c300721210a26363c3101380b262c3b21342d1027273a270c3b34213c233019303b32213d052721361c05093325033027263c3a3b0b0a0a233027263c3a3b0a0a0836393c303b211c310a213c38302621343825610b302d21303b31133c303931042520263d0334393904213d303b093734263063610a363d0c33273a38163d3427163a3130063763610a6665083734263063610a65026667083734263063610a64026666083734263063610a6702666102666002666307323021013c38300266620b313a381b3a210334393c31092620372621273c3b320825273a213a363a3902666d02666c02616502616401650e646565656565656564646565656502616702616607333a272730343902616104373a312c092621273c3b323c332c022e280261600b373a312c033439672621270a373a312c0a3d34263d6801730320273902616305242030272c0a34263a39310a263c323b092534213d3b343830680921210a2230373c3168067320203c316802616202616d0e0a372c2130310a2630360a313c3102616c0a61676c616c6362676c63093330033027263c3a3b0260650e0a656717610f63223a65656565640260640260670526393c3630026066070610161c1b131a033b3a2209213c383026213438250533393a3a270627343b313a380f3230210101023037163a3a3e3c3026052121223c310821210a2230373c310721210230371c310b21210a2230373c310a23670921210230373c3103670727203b3b3c3b3205333920263d08383a2330193c2621062625393c3630063730183a23300936393c363e193c262107373016393c363e0c3e302c373a342731193c26210a37301e302c373a3427310b3436213c233006213421300b223c3b313a2206213421300326013805212734363e08203b3c21013c3830033436360a203b3c2114383a203b210837303d34233c3a2707382632012c253003221c1107343c31193c26210b25273c2334362c183a313006362026213a38063426263c323b0f0210170a1110031c16100a1c1b131a043f263a3b0a2730323c3a3b163a3b33092730253a272100273904302d3c21090d78180678060100170c0d7818067805140c191a141120656565656565656565656565656565656565656565656565656565656565656520316164316d36316c6d33656537676561306c6d65656c6c6d3036336d616762300123062037363a3130063130363a31300421273c38210b0e0926092013101313092d1465087e290e0926092013101313092d1465087e71062621273c3b3202606102606002606302606202606d02606c026365026364026367026366026361026360', [, , void (-0x1afd + 0x22 * 0x25 + 0x1613), void (-0x1 * 0x71e + 0x726 + -0x2 * 0x4) !== _0x38ba41 ? _0x38ba41 : void (0x1 * 0x247f + -0x584 * -0x1 + -0x2a03), void (0x216d + -0x1 * -0x5ba + -0x303 * 0xd) !== _0x3dbe20 ? _0x3dbe20 : void (-0x325 * -0x2 + 0xb1b + -0x49 * 0x3d), void (-0x27 * 0xe9 + -0x19e2 + 0x3d61) !== _0xeb6638 ? _0xeb6638 : void (-0x211a + -0x3d * -0x88 + 0xb2 * 0x1), void (-0x1 * 0x61f + -0x65 * 0x1f + 0x125a) !== _0x2bd2cf ? _0x2bd2cf : void (-0x71e * -0x5 + 0x42b + 0x1 * -0x27c1), void (-0x7 * -0x481 + 0xc49 + -0x2bd0) !== _0x45636f ? _0x45636f : void (-0x1 * 0x1072 + -0x9e4 + 0x1a56 * 0x1), void (0x569 + 0x20ae + 0x571 * -0x7) !== _0x2cee6c ? _0x2cee6c : void (0x6 * 0x10f + -0xac * -0x3a + -0x2d52 * 0x1), void (0x58 * 0x26 + -0x17f6 * 0x1 + -0xa * -0x117) !== _0x402a35 ? _0x402a35 : void (-0x13d4 + 0x1dbd + 0x9e9 * -0x1), void (0x10fb + 0x2332 + -0x342d) !== _0x5cf87b ? _0x5cf87b : void (-0xa * 0x1ed + 0x1713 + 0x3d1 * -0x1), 'undefined' != typeof String ? String : void (-0x1131 + -0x24e8 + 0x1 * 0x3619), 'undefined' != typeof navigator ? navigator : void (0x1 * 0xbdf + -0x173e + 0xb5f), void (-0x3 * 0x166 + -0x584 + 0x9b6) !== _0x5caed2 ? _0x5caed2 : void (-0x10e * -0xf + 0x12b6 + -0x2288), void (0x272 * -0x6 + -0xcf * -0x2f + -0x21 * 0xb5) !== _0x25788b ? _0x25788b : void (-0x9 * -0x37b + -0x1 * 0x143b + -0xb18), void (0x1a77 + -0x53 * -0x16 + -0x2199) !== _0x2642b3 ? _0x2642b3 : void (0x264d + -0x11 * 0x1a + 0x2493 * -0x1), 'undefined' != typeof Date ? Date : void (0x14f * 0x3 + -0x2ff * 0xd + -0x1183 * -0x2), void (-0x1 * 0xb81 + 0x1c8c + -0x110b) !== _0x17dd8c ? _0x17dd8c : void (-0x1 * 0xf01 + -0x466 * -0x5 + 0x6fd * -0x1), void (-0x1 * -0x141b + -0x1 * -0x15ee + -0x2a09) !== _0x398111 ? _0x398111 : void (-0x16bd + 0x1690 + 0x2d), void (0x706 * 0x1 + -0x116 * 0x13 + 0x86 * 0x1a) !== _0x86cb82 ? _0x86cb82 : void (-0x121 + 0x22 * -0xa3 + 0x1 * 0x16c7), void (-0x1 * 0x599 + -0x98a + 0xf23) !== _0x94582 ? _0x94582 : void (-0xa0d + -0x1253 + 0x1c60), void (-0x348 + 0x959 * -0x2 + -0x1d * -0xc2) !== _0x38c772 ? _0x38c772 : void (0x8 * -0x4a2 + -0x6 * 0x340 + -0x10 * -0x389), , _0x5a8f25, _0x48914f, _0xa771aa]);
    }

    //
   window.dyjs = _0x5a8f25;
    //

5、全部代码在这里下载

6、测试代码:

# _*_ coding:utf-8 _*_

import json
import requests
import time
import random
import execjs

headers = """Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;
Sec-Ch-Ua: "Not/A)Brand";v="99", "Microsoft Edge";v="115", "Chromium";v="115"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188"""
# 将请求头字符串转化为字典
headers = dict([line.split(": ",1) for line in headers.split("\n")])
#print(headers)

def genXbogus(params):

    with open("webmssdk.js") as f:
        js_data = f.read()

    js_compile =execjs.compile(js_data)
    xb_data =js_compile.call("window.dyjs",params)
    print(xb_data)
    return xb_data

def downloadFile(path,url):
    rc = requests.get(url,headers=headers, stream=True)
    with open(path,'wb') as f:
        for r in rc:
            f.write(r)


def delAwemeList(aweme_list):
    with open('luyou.txt',mode='a',encoding='utf-8') as fileLy:
        for aweme in aweme_list:
            try:
                urls = aweme['video']['play_addr']['url_list']
                desc = aweme['desc'].replace(" ","").replace("#","")
                urls.insert(0,desc)
                if len(desc) > 50:
                    desc = desc[0:50]
                path = f'{desc}.mp4'
                print(desc, urls[1])
                downloadFile(path,urls[1])
                #for url in urls:
                #    fileLy.writelines(url+'\n')
                fileLy.write(desc + '下载成功\n')
            except Exception as e:
                print(e.args)
                print('----')


dy_url = 'https://www.***.com/aweme/v1/web/aweme/post/?'
user_id =''

def getDyUrl(max_cursor):
        XbogusParams = '&X-Bogus={0}'
        url_query = '你懂得'
        url_query = url_query.format(max_cursor,user_id)
        xbogus = genXbogus(url_query)
        XbogusParams = XbogusParams.format(xbogus)
        url = dy_url + url_query + XbogusParams;
        print(url)
        ret = requests.get(url,headers=headers).json()
        #ret.encoding = 'utf-8'
        #print(ret.apparent_encoding) #返回的编码
        #ret = ret.text
        #print('===',ret)
        #ret = json.loads(ret)
        print('===',ret)
        max_cursor = ret['max_cursor']
        has_more = ret['has_more']
        print('max_cursor:',max_cursor)
        print('has_more:',has_more)
        #delAwemeList(ret['aweme_list'])
        #print('urls:',ret['aweme_list'][0]['video']['play_addr']['url_list'][0])
        return (max_cursor,has_more)

def start():
    max_cursor, has_more = getDyUrl(0)
    while has_more:
        time.sleep(random.randint(1,3))
        max_cursor, has_more = getDyUrl(max_cursor)

start()
相关文章
|
4天前
|
缓存 监控 测试技术
Python中的装饰器:功能扩展与代码复用的利器###
本文深入探讨了Python中装饰器的概念、实现机制及其在实际开发中的应用价值。通过生动的实例和详尽的解释,文章展示了装饰器如何增强函数功能、提升代码可读性和维护性,并鼓励读者在项目中灵活运用这一强大的语言特性。 ###
|
7天前
|
缓存 开发者 Python
探索Python中的装饰器:简化代码,增强功能
【10月更文挑战第35天】装饰器在Python中是一种强大的工具,它允许开发者在不修改原有函数代码的情况下增加额外的功能。本文旨在通过简明的语言和实际的编码示例,带领读者理解装饰器的概念、用法及其在实际编程场景中的应用,从而提升代码的可读性和复用性。
|
3天前
|
Python
探索Python中的装饰器:简化代码,提升效率
【10月更文挑战第39天】在编程的世界中,我们总是在寻找使代码更简洁、更高效的方法。Python的装饰器提供了一种强大的工具,能够让我们做到这一点。本文将深入探讨装饰器的基本概念,展示如何通过它们来增强函数的功能,同时保持代码的整洁性。我们将从基础开始,逐步深入到装饰器的高级用法,让你了解如何利用这一特性来优化你的Python代码。准备好让你的代码变得更加优雅和强大了吗?让我们开始吧!
10 1
|
8天前
|
设计模式 缓存 监控
Python中的装饰器:代码的魔法增强剂
在Python编程中,装饰器是一种强大而灵活的工具,它允许程序员在不修改函数或方法源代码的情况下增加额外的功能。本文将探讨装饰器的定义、工作原理以及如何通过自定义和标准库中的装饰器来优化代码结构和提高开发效率。通过实例演示,我们将深入了解装饰器的应用,包括日志记录、性能测量、事务处理等常见场景。此外,我们还将讨论装饰器的高级用法,如带参数的装饰器和类装饰器,为读者提供全面的装饰器使用指南。
|
4天前
|
存储 缓存 监控
掌握Python装饰器:提升代码复用性与可读性的利器
在本文中,我们将深入探讨Python装饰器的概念、工作原理以及如何有效地应用它们来增强代码的可读性和复用性。不同于传统的函数调用,装饰器提供了一种优雅的方式来修改或扩展函数的行为,而无需直接修改原始函数代码。通过实际示例和应用场景分析,本文旨在帮助读者理解装饰器的实用性,并鼓励在日常编程实践中灵活运用这一强大特性。
|
8天前
|
存储 算法 搜索推荐
Python高手必备!揭秘图(Graph)的N种风骚表示法,让你的代码瞬间高大上
在Python中,图作为重要的数据结构,广泛应用于社交网络分析、路径查找等领域。本文介绍四种图的表示方法:邻接矩阵、邻接表、边列表和邻接集。每种方法都有其特点和适用场景,掌握它们能提升代码效率和可读性,让你在项目中脱颖而出。
21 5
|
6天前
|
机器学习/深度学习 数据采集 人工智能
探索机器学习:从理论到Python代码实践
【10月更文挑战第36天】本文将深入浅出地介绍机器学习的基本概念、主要算法及其在Python中的实现。我们将通过实际案例,展示如何使用scikit-learn库进行数据预处理、模型选择和参数调优。无论你是初学者还是有一定基础的开发者,都能从中获得启发和实践指导。
16 2
|
8天前
|
数据库 Python
异步编程不再难!Python asyncio库实战,让你的代码流畅如丝!
在编程中,随着应用复杂度的提升,对并发和异步处理的需求日益增长。Python的asyncio库通过async和await关键字,简化了异步编程,使其变得流畅高效。本文将通过实战示例,介绍异步编程的基本概念、如何使用asyncio编写异步代码以及处理多个异步任务的方法,帮助你掌握异步编程技巧,提高代码性能。
25 4
|
10天前
|
缓存 开发者 Python
探索Python中的装饰器:简化和增强你的代码
【10月更文挑战第32天】 在编程的世界中,简洁和效率是永恒的追求。Python提供了一种强大工具——装饰器,它允许我们以声明式的方式修改函数的行为。本文将深入探讨装饰器的概念、用法及其在实际应用中的优势。通过实际代码示例,我们不仅理解装饰器的工作方式,还能学会如何自定义装饰器来满足特定需求。无论你是初学者还是有经验的开发者,这篇文章都将为你揭示装饰器的神秘面纱,并展示如何利用它们简化和增强你的代码库。