爱意满满的作品展示区。
huyiwei

理论永远不会失效的抖音直播间消息获取工具[狗头]需要的朋友 dd

  •  1
     
  •   huyiwei · Mar 19, 2024 · 3081 views
    This topic created in 785 days ago, the information mentioned may be changed or developed.

    原理就是 hook web 网页 js 哈哈哈

    Supplement 1  ·  Mar 20, 2024

    核心代码就两处

    main.js

    拦截关于websocket的js文件把请求转给本地代理服务器

    // 拦截请求
    this.webContents.session.webRequest.onBeforeRequest((details, callback) => {
    
        // 在这里进行请求处理,例如修改请求 URL、添加请求头等
        if (
            /^https:\/\/.+?webcast\/douyin_live\/\d+.+\.js$/.test(details.url)
        ) {
            callback({ redirectURL: `http://localhost:${replaceWsPort}/${details.url}` });
            return
        }
        
        // 继续请求
        callback({ cancel: false });
    });
    

    replaceWs.js

    本地代理服务拿到js文件,对js文件修改加hook

    // http拿到js文件内容
    return fetch(url).then(res => res.text()).then(text => {
        // 是否有ws字样
        if (!text.includes('new WebSocket')) return text
        // 开始替换数据
        // 替换onError
        text = text.replaceAll(/(\{.+?\("socket error",(.+?)\),)/g, '$1typeof window.emitClose == \'function\' && window.emitClose(\'error\',$2),')
        // 替换onClose
        text = text.replace(/(\{.+?\("socket closed",(.+?)\),)/, '$1typeof window.emitClose == \'function\' && window.emitClose(\'close\',$2),')
        // 替换onOpen td("socket established"),
        text = text.replace(/(\{.+?\("socket established"\),)/, '$1typeof window.emitOpen == \'function\' && window.emitOpen(),')
        // 替换onMessage ;eu || tM("no payload can be decoded, maybe cannot find idl", eo);
        text = text.replace(/;([a-zA-Z]+)?\|\|.+?\("no payload can be decoded, maybe cannot find idl",[a-zA-Z]+\);/, ';if(typeof window.emitMessage == \'function\'){window.emitMessage($1);}return {method:\'\'};')
        // 替换stop函数
        // text = text.replace(/\{[a-zA-Z]+?\("socket terminating"\),/, '{return;')
        text = text.replaceAll(/stop\(\)\s*\{/g, 'stop(){return;')
        // 替换 "visible"
        text = text.replaceAll(/"visible"/g, '"_visible_"')
        // 替换暂停 pause() {
        text = text.replaceAll(/pause\(\)\s*\{/g, 'pause() {return;')
        return text
    })
    

    然后你懂得...

    Supplement 2  ·  Mar 20, 2024
    github 懒得上了,很烂的代码,大神略过。 蓝奏地址 https://vsay.lanzoul.com/b02fym2lc
    密码:7ar3
    19 replies    2024-03-20 17:36:00 +08:00
    CodeXx
        1
    CodeXx  
       Mar 19, 2024
    dd
    pancrasxox
        2
    pancrasxox  
       Mar 19, 2024 via Android
    不懂 这个有啥用😵‍💫
    LICC168
        3
    LICC168  
       Mar 19, 2024
    dd
    notot
        4
    notot  
       Mar 19, 2024
    js rpc
    airzhao
        5
    airzhao  
       Mar 19, 2024
    dd
    boris1993Jr
        6
    boris1993Jr  
       Mar 19, 2024 via iPhone
    dd if=/dev/null of=/dev/sda
    loveqianool
        7
    loveqianool  
       Mar 19, 2024 via Android
    有快手的吗
    fbzl
        8
    fbzl  
       Mar 19, 2024 via iPhone
    js 文件会变动,要定期适配
    0x0x
        9
    0x0x  
       Mar 19, 2024 via iPhone
    dd
    doanything
        10
    doanything  
       Mar 20, 2024 via iPhone
    dd
    whoami9426
        11
    whoami9426  
       Mar 20, 2024
    hook 网页直播的 websocket
    huyiwei
        12
    huyiwei  
    OP
       Mar 20, 2024
    @fbzl 不需要,基本不用改代码,自动适配
    huyiwei
        13
    huyiwei  
    OP
       Mar 20, 2024
    github 懒得上了,很烂的代码,大神略过。 蓝奏地址 https://vsay.lanzoul.com/b02fym2lc
    密码:7ar3
    huyiwei
        14
    huyiwei  
    OP
       Mar 20, 2024
    huyiwei
        15
    huyiwei  
    OP
       Mar 20, 2024 via Android
    @loveqianool 快手同理呀
    EmpCold
        16
    EmpCold  
       Mar 20, 2024
    先顶后看。
    dylan593
        17
    dylan593  
       Mar 20, 2024
    谢谢楼主分享
    getcodex
        18
    getcodex  
       Mar 20, 2024
    这个可以干啥,没看懂使用场景
    bkmi
        19
    bkmi  
       Mar 20, 2024 via Android
    发个 gist 呗
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5816 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 156ms · UTC 06:24 · PVG 14:24 · LAX 23:24 · JFK 02:24
    ♥ Do have faith in what you're doing.