Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于破解某电商网站页面的尝试-主播主页跳转篇 #22

Open
Ph0enixxx opened this issue Apr 29, 2020 · 0 comments
Open

关于破解某电商网站页面的尝试-主播主页跳转篇 #22

Ph0enixxx opened this issue Apr 29, 2020 · 0 comments

Comments

@Ph0enixxx
Copy link
Owner

0x00 起因

朋友找我做一个国内某知名电商直播网站(*DD)刷粉的脚本,在过程中碰到了一些比较有价值的问题,写出来分享

脚本的流程大致是这样的

加载Token->打开主播主页->点击关注->成功后重复第一步

0x01 主播主页跳转

在进行侦查时,碰到了第一个比较棘手的问题----网页会在加载进入后1~2秒内,跳转到电商APP的下载页,在尝试破解时,发现其前端代码经过混淆,无法追踪清晰的逻辑

0x02 尝试断点

在Google Chrome中,没有找到能够打Navigate跳转断点或者类似Hooklocation.href的方法,不信邪的我自己尝试改location对象也失败了,猜测可能是为了安全(一个网页在关闭或者跳出时,自己就重新蹦出来,想想都刺激),经查阅相关资料后,发现可以打unload断点(类似于某些网站在离开前的弹窗提示)

在使用Chrome->审查->Source->Breakpoint EventListener->load->unload加入断点后,是能够拦截各个加载项目,但是无法拦截最后的跳转到应用市场,猜测是使用了类似replacelocation等方式来反调试,PASS

0x03 尝试改源码

在使用审查->network查看跳转地址xxx_download.html后,尝试在源码中搜索,找到了如下代码:

    window.leoConfig = {"__NAVIGATION_MAP__":{"download.html":"matthew_download.html","market_download.html":"undefined.html","down_market_download.html":"undefined.html","comm_order_snapshot.html":"undefined.html","miff_transplantation_pretence.html":"refresh_slew_forlorn.html","group185.html":"group186.html","pjlkvgcf.html":"ddplteec.html","svideo_personal.html":"fyxmkief.html?page_key=1"},"__CMT_AMPLIFY_RATE__":1,"domainConfig":{"__CMT_HOST__":"cmtw.pinduoduo.com"},"isOnlyShowIndexTab":true};
    window.__NAVIGATION_MAP__ = window.leoConfig.__NAVIGATION_MAP__ || {};
    window.__CMT_AMPLIFY_RATE__ = window.leoConfig.__CMT_AMPLIFY_RATE__;
    window.__CMT_HOST__ = window.leoConfig.domainConfig && window.leoConfig.domainConfig.__CMT_HOST__;

看来leoConfig存储的就是跳转信息,找到后打load断点,打一个window.leoConfig = {},放开断点,可以了,网页没有跳转

0x04 再次遇到问题

然而如果放给朋友去用的话,是要打包成软件或者脚本的,这样的话总不能将断点的打法等动作录入进去,在尝试注入向网页以下脚本时,办法似乎行不通了

window.onload=function(){
    window.leoConfig = {};  // 加载完后立刻跳转
}

仔细观察后,发现正在加载中的主播主页,即使没有加载完,也会进行跳转,也就是说,网页并没有运行到重置window.leoConfig的代码就已经跳转了,此刻我已经有了一个大点的想法

0x05 删除定时任务

既然不是加载完成后判断的,那么也只能是加载完某个对象,或者使用了定时1~2s的任务来做的了,先从定时任务下手,尝试hook定时任务的钩子:

(function(w) {
    var oldST = w.setTimeout;
    var oldSI = w.setInterval;
    var oldCI = w.clearInterval;
    var timers = [];  // 将定时任务的id都放在一个数组中
    w.timers = timers;
    w.setTimeout = function(fn, delay) {
        var id = oldST(function() {
            fn && fn();
            removeTimer(id);
        }, delay);
        timers.push(id);
        return id;
    };
    w.setInterval = function(fn, delay) {
        var id = oldSI(fn, delay);
        timers.push(id);
        return id;
    };
    w.clearInterval = function(id) {
        oldCI(id);
        removeTimer(id);
    };
    w.clearTimeout = w.clearInterval;

    function removeTimer(id) {
        var index = timers.indexOf(id);
        if (index >= 0)
            timers.splice(index, 1);
    }
}(window));

打load断点进行调试,发现里面一共加载了三个定时任务,用clearInterval清除后,网页没有跳转
成功了!接下来就是将clearInterval进行自动化

同样启动一个timeout,来清除其他的定时任务:

function a(){
for(var i = timers.length; i--;)
    clearInterval(timers[i]);
}

setTimeout(a, 1500)

放在油猴脚本中,测试通过
目前一个在此类脚本中,比较棘手的问题就已经解决了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant