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

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

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