The strongest project case of Python crawler - JS reverse. This wave of learning is making money.

If you are Xiaobai, this set of information can help you become a big bull. If you have rich development experience, this set of information can help you break through the bottleneck
2022web full set of video tutorial front-end architecture H5 vue node applet Video + data + code + interview questions.

preface

Some time ago, I saw someone js reverse the feedback area of a mobile phone. I also learned it for the first time. After learning, I always wanted to rely on my ability to see if I could complete it alone and win the real first blood of js reverse. Therefore, there is today's victim, the reverse of the mobile phone circle of a blue factory.

Website analysis

Now that you have selected the target, start capturing the package and analyzing the web page.

This is the case after capturing packets. By comparing multiple packets, it is found that the parameters actually changed are lastId, nonce, timestamp and pageNum. Specifically, lastId: tid of the last speaker on the previous page; pageNum: current page number; Timestamp: 13 bit timestamp; Nonce: I don't know what it is, but he has an encrypted face. So far, the goal is very clear, focusing on nonce.

js reverse analysis

Through global search and breakpoint location, the target is finally locked on this line of code.

??e.params.nonce?=?Object(u["md5"])(t?+?""?+?parseInt(1e7?*?Math.random(),?10)?+?1,?32)

Through observation, it is found that the final output of this line of code is our goal today.

Analyze the code:

"t": 13 bit timestamp

"+" "+": convert timestamp to string

"1e7": 10000000, fixed value

"Math.random()": random number

"parseInt": rounding

The meaning of "t +" "+ parseInt(1e7 * Math.random(), 10)+ 1" is obvious here. Timestamp + rounded random number + 1, and the final result is a 21 digit number.

Continue to analyze Object(u ["md5"]) and 32. It is found that the [md5] method of u is called here, and the previous 21 bit string and 32 are passed to md5 as parameters. The web page source code is as follows:

???e.md5?=?function(e,?t)?{
????????????????function?n(e,?t)?{
????????????????????return?e?<<?t?|?e?>>>?32?-?t
????????????????}
????????????????function?i(e,?t)?{
????????????????????var?n,?i,?a,?r,?o;
????????????????????return?a?=?2147483648?&?e,
????????????????????r?=?2147483648?&?t,
????????????????????n?=?1073741824?&?e,
????????????????????i?=?1073741824?&?t,
????????????????????o?=?(1073741823?&?e)?+?(1073741823?&?t),
????????????????????n?&?i???2147483648?^?o?^?a?^?r?:?n?|?i???1073741824?&?o???3221225472?^?o?^?a?^?r?:?1073741824?^?o?^?a?^?r?:?o?^?a?^?r
????????????????}
????............//Omitted here

So far, the idea has been very clear. Here we can realize MD5 encryption through Python or rewrite the source code. In order to ensure 100% error free, I chose to pick the code here.

js code rewriting

The first is the source code:

??e.md5?=?function(e,?t)?{
????????????????function?n(e,?t)?{
????????????????????return?e?<<?t?|?e?>>>?32?-?t
????????????????}
????????????????function?i(e,?t)?{
????????????????????var?n,?i,?a,?r,?o;
????????????????????return?a?=?2147483648?&?e,
????????????????????r?=?2147483648?&?t,
????????????????????n?=?1073741824?&?e,
????????????????????i?=?1073741824?&?t,
????????????????????o?=?(1073741823?&?e)?+?(1073741823?&?t),
????????????????????n?&?i???2147483648?^?o?^?a?^?r?:?n?|?i???1073741824?&?o???3221225472?^?o?^?a?^?r?:?1073741824?^?o?^?a?^?r?:?o?^?a?^?r
????????????????}
????????????????function?a(e,?t,?a,?r,?o,?s,?l)?{
????????????????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
????????????????????????return?e?&?t?|?~e?&?n
????????????????????}(t,?a,?r),?o),?l)),
????????????????????i(n(e,?s),?t)
????????????????}
????????????????function?r(e,?t,?a,?r,?o,?s,?l)?{
????????????????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
????????????????????????return?e?&?n?|?t?&?~n
????????????????????}(t,?a,?r),?o),?l)),
????????????????????i(n(e,?s),?t)
????????????????}
????????????????function?o(e,?t,?a,?r,?o,?s,?l)?{
????????????????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
????????????????????????return?e?^?t?^?n
????????????????????}(t,?a,?r),?o),?l)),
????????????????????i(n(e,?s),?t)
????????????????}
????????????????function?s(e,?t,?a,?r,?o,?s,?l)?{
????????????????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
????????????????????????return?t?^?(e?|?~n)
????????????????????}(t,?a,?r),?o),?l)),
????????????????????i(n(e,?s),?t)
????????????????}
????????????????function?l(e)?{
????????????????????var?t,?n?=?"",?i?=?"";
????????????????????for?(t?=?0;?t?<=?3;?t++)
????????????????????????n?+=?(i?=?"0"?+?(e?>>>?8?*?t?&?255).toString(16)).substr(i.length?-?2,?2);
????????????????????return?n
????????????????}
????????????????var?c,?u,?p,?m,?d,?h,?f,?v,?y,?g?=?e,?b?=?Array();
????????????????for?(b?=?function(e)?{
????????????????????for?(var?t,?n?=?e.length,?i?=?n?+?8,?a?=?16?*?((i?-?i?%?64)?/?64?+?1),?r?=?Array(a?-?1),?o?=?0,?s?=?0;?s?<?n;?)
????????????????????????o?=?s?%?4?*?8,
????????????????????????r[t?=?(s?-?s?%?4)?/?4]?=?r[t]?|?e.charCodeAt(s)?<<?o,
????????????????????????s++;
????????????????????return?t?=?(s?-?s?%?4)?/?4,
????????????????????o?=?s?%?4?*?8,
????????????????????r[t]?=?r[t]?|?128?<<?o,
????????????????????r[a?-?2]?=?n?<<?3,
????????????????????r[a?-?1]?=?n?>>>?29,
????????????????????r
????????????????}(g),
????????????????h?=?1732584193,
????????????????f?=?4023233417,
????????????????v?=?2562383102,
????????????????y?=?271733878,
????????????????c?=?0;?c?<?b.length;?c?+=?16)
????????????????????u?=?h,
????????????????????p?=?f,
????????????????????m?=?v,
????????????????????d?=?y,
????????????????????f?=?s(f?=?s(f?=?s(f?=?s(f?=?o(f?=?o(f?=?o(f?=?o(f?=?r(f?=?r(f?=?r(f?=?r(f?=?a(f?=?a(f?=?a(f?=?a(f,?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?0],?7,?3614090360),?f,?v,?b[c?+?1],?12,?3905402710),?h,?f,?b[c?+?2],?17,?606105819),?y,?h,?b[c?+?3],?22,?3250441966),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?4],?7,?4118548399),?f,?v,?b[c?+?5],?12,?1200080426),?h,?f,?b[c?+?6],?17,?2821735955),?y,?h,?b[c?+?7],?22,?4249261313),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?8],?7,?1770035416),?f,?v,?b[c?+?9],?12,?2336552879),?h,?f,?b[c?+?10],?17,?4294925233),?y,?h,?b[c?+?11],?22,?2304563134),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?12],?7,?1804603682),?f,?v,?b[c?+?13],?12,?4254626195),?h,?f,?b[c?+?14],?17,?2792965006),?y,?h,?b[c?+?15],?22,?1236535329),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?1],?5,?4129170786),?f,?v,?b[c?+?6],?9,?3225465664),?h,?f,?b[c?+?11],?14,?643717713),?y,?h,?b[c?+?0],?20,?3921069994),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?5],?5,?3593408605),?f,?v,?b[c?+?10],?9,?38016083),?h,?f,?b[c?+?15],?14,?3634488961),?y,?h,?b[c?+?4],?20,?3889429448),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?9],?5,?568446438),?f,?v,?b[c?+?14],?9,?3275163606),?h,?f,?b[c?+?3],?14,?4107603335),?y,?h,?b[c?+?8],?20,?1163531501),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?13],?5,?2850285829),?f,?v,?b[c?+?2],?9,?4243563512),?h,?f,?b[c?+?7],?14,?1735328473),?y,?h,?b[c?+?12],?20,?2368359562),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?5],?4,?4294588738),?f,?v,?b[c?+?8],?11,?2272392833),?h,?f,?b[c?+?11],?16,?1839030562),?y,?h,?b[c?+?14],?23,?4259657740),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?1],?4,?2763975236),?f,?v,?b[c?+?4],?11,?1272893353),?h,?f,?b[c?+?7],?16,?4139469664),?y,?h,?b[c?+?10],?23,?3200236656),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?13],?4,?681279174),?f,?v,?b[c?+?0],?11,?3936430074),?h,?f,?b[c?+?3],?16,?3572445317),?y,?h,?b[c?+?6],?23,?76029189),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?9],?4,?3654602809),?f,?v,?b[c?+?12],?11,?3873151461),?h,?f,?b[c?+?15],?16,?530742520),?y,?h,?b[c?+?2],?23,?3299628645),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?0],?6,?4096336452),?f,?v,?b[c?+?7],?10,?1126891415),?h,?f,?b[c?+?14],?15,?2878612391),?y,?h,?b[c?+?5],?21,?4237533241),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?12],?6,?1700485571),?f,?v,?b[c?+?3],?10,?2399980690),?h,?f,?b[c?+?10],?15,?4293915773),?y,?h,?b[c?+?1],?21,?2240044497),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?8],?6,?1873313359),?f,?v,?b[c?+?15],?10,?4264355552),?h,?f,?b[c?+?6],?15,?2734768916),?y,?h,?b[c?+?13],?21,?1309151649),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?4],?6,?4149444226),?f,?v,?b[c?+?11],?10,?3174756917),?h,?f,?b[c?+?2],?15,?718787259),?y,?h,?b[c?+?9],?21,?3951481745),
????????????????????h?=?i(h,?u),
????????????????????f?=?i(f,?p),
????????????????????v?=?i(v,?m),
????????????????????y?=?i(y,?d);
????????????????return?32?==?t???l(h)?+?l(f)?+?l(v)?+?l(y)?:?l(f)?+?l(v)
????????????}

The second is the rewritten code, which follows the principle that the less you change, the better:

???function?MD5?(e,?t)?{
?????function?n(e,?t)?{
?????????return?e?<<?t?|?e?>>>?32?-?t
?????}

?????function?i(e,?t)?{
?????????var?n,?i,?a,?r,?o;
?????????return?a?=?2147483648?&?e,
?????????r?=?2147483648?&?t,
?????????n?=?1073741824?&?e,
?????????i?=?1073741824?&?t,
?????????o?=?(1073741823?&?e)?+?(1073741823?&?t),
?????????n?&?i???2147483648?^?o?^?a?^?r?:?n?|?i???1073741824?&?o???3221225472?^?o?^?a?^?r?:?1073741824?^?o?^?a?^?r?:?o?^?a?^?r
?????}

?????function?a(e,?t,?a,?r,?o,?s,?l)?{
?????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
?????????????return?e?&?t?|?~e?&?n
?????????}(t,?a,?r),?o),?l)),
?????????i(n(e,?s),?t)
?????}

?????function?r(e,?t,?a,?r,?o,?s,?l)?{
?????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
?????????????return?e?&?n?|?t?&?~n
?????????}(t,?a,?r),?o),?l)),
?????????i(n(e,?s),?t)
?????}

?????function?o(e,?t,?a,?r,?o,?s,?l)?{
?????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
?????????????return?e?^?t?^?n
?????????}(t,?a,?r),?o),?l)),
?????????i(n(e,?s),?t)
?????}

?????function?s(e,?t,?a,?r,?o,?s,?l)?{
?????????return?e?=?i(e,?i(i(function(e,?t,?n)?{
?????????????return?t?^?(e?|?~n)
?????????}(t,?a,?r),?o),?l)),
?????????i(n(e,?s),?t)
?????}

?????function?l(e)?{
?????????var?t,?n?=?"",
?????????????i?=?"";
?????????for?(t?=?0;?t?<=?3;?t++)
?????????n?+=?(i?=?"0"?+?(e?>>>?8?*?t?&?255).toString(16)).substr(i.length?-?2,?2);
?????????return?n
?????}
?????var?c,?u,?p,?m,?d,?h,?f,?v,?y,?g?=?e,
?????????b?=?Array();
?????for?(b?=?function(e)?{
?????????for?(var?t,?n?=?e.length,?i?=?n?+?8,?a?=?16?*?((i?-?i?%?64)?/?64?+?1),?r?=?Array(a?-?1),?o?=?0,?s?=?0;?s?<?n;)
?????????o?=?s?%?4?*?8,
?????????r[t?=?(s?-?s?%?4)?/?4]?=?r[t]?|?e.charCodeAt(s)?<<?o,
?????????s++;
?????????return?t?=?(s?-?s?%?4)?/?4,
?????????o?=?s?%?4?*?8,
?????????r[t]?=?r[t]?|?128?<<?o,
?????????r[a?-?2]?=?n?<<?3,
?????????r[a?-?1]?=?n?>>>?29,
?????????r
?????}(g),
?????h?=?1732584193,
?????f?=?4023233417,
?????v?=?2562383102,
?????y?=?271733878,
?????c?=?0;?c?<?b.length;?c?+=?16)
?????u?=?h,
?????p?=?f,
?????m?=?v,
?????d?=?y,
?????f?=?s(f?=?s(f?=?s(f?=?s(f?=?o(f?=?o(f?=?o(f?=?o(f?=?r(f?=?r(f?=?r(f?=?r(f?=?a(f?=?a(f?=?a(f?=?a(f,?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?0],?7,?3614090360),?f,?v,?b[c?+?1],?12,?3905402710),?h,?f,?b[c?+?2],?17,?606105819),?y,?h,?b[c?+?3],?22,?3250441966),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?4],?7,?4118548399),?f,?v,?b[c?+?5],?12,?1200080426),?h,?f,?b[c?+?6],?17,?2821735955),?y,?h,?b[c?+?7],?22,?4249261313),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?8],?7,?1770035416),?f,?v,?b[c?+?9],?12,?2336552879),?h,?f,?b[c?+?10],?17,?4294925233),?y,?h,?b[c?+?11],?22,?2304563134),?v?=?a(v,?y?=?a(y,?h?=?a(h,?f,?v,?y,?b[c?+?12],?7,?1804603682),?f,?v,?b[c?+?13],?12,?4254626195),?h,?f,?b[c?+?14],?17,?2792965006),?y,?h,?b[c?+?15],?22,?1236535329),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?1],?5,?4129170786),?f,?v,?b[c?+?6],?9,?3225465664),?h,?f,?b[c?+?11],?14,?643717713),?y,?h,?b[c?+?0],?20,?3921069994),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?5],?5,?3593408605),?f,?v,?b[c?+?10],?9,?38016083),?h,?f,?b[c?+?15],?14,?3634488961),?y,?h,?b[c?+?4],?20,?3889429448),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?9],?5,?568446438),?f,?v,?b[c?+?14],?9,?3275163606),?h,?f,?b[c?+?3],?14,?4107603335),?y,?h,?b[c?+?8],?20,?1163531501),?v?=?r(v,?y?=?r(y,?h?=?r(h,?f,?v,?y,?b[c?+?13],?5,?2850285829),?f,?v,?b[c?+?2],?9,?4243563512),?h,?f,?b[c?+?7],?14,?1735328473),?y,?h,?b[c?+?12],?20,?2368359562),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?5],?4,?4294588738),?f,?v,?b[c?+?8],?11,?2272392833),?h,?f,?b[c?+?11],?16,?1839030562),?y,?h,?b[c?+?14],?23,?4259657740),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?1],?4,?2763975236),?f,?v,?b[c?+?4],?11,?1272893353),?h,?f,?b[c?+?7],?16,?4139469664),?y,?h,?b[c?+?10],?23,?3200236656),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?13],?4,?681279174),?f,?v,?b[c?+?0],?11,?3936430074),?h,?f,?b[c?+?3],?16,?3572445317),?y,?h,?b[c?+?6],?23,?76029189),?v?=?o(v,?y?=?o(y,?h?=?o(h,?f,?v,?y,?b[c?+?9],?4,?3654602809),?f,?v,?b[c?+?12],?11,?3873151461),?h,?f,?b[c?+?15],?16,?530742520),?y,?h,?b[c?+?2],?23,?3299628645),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?0],?6,?4096336452),?f,?v,?b[c?+?7],?10,?1126891415),?h,?f,?b[c?+?14],?15,?2878612391),?y,?h,?b[c?+?5],?21,?4237533241),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?12],?6,?1700485571),?f,?v,?b[c?+?3],?10,?2399980690),?h,?f,?b[c?+?10],?15,?4293915773),?y,?h,?b[c?+?1],?21,?2240044497),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?8],?6,?1873313359),?f,?v,?b[c?+?15],?10,?4264355552),?h,?f,?b[c?+?6],?15,?2734768916),?y,?h,?b[c?+?13],?21,?1309151649),?v?=?s(v,?y?=?s(y,?h?=?s(h,?f,?v,?y,?b[c?+?4],?6,?4149444226),?f,?v,?b[c?+?11],?10,?3174756917),?h,?f,?b[c?+?2],?15,?718787259),?y,?h,?b[c?+?9],?21,?3951481745),
?????h?=?i(h,?u),
?????f?=?i(f,?p),
?????v?=?i(v,?m),
?????y?=?i(y,?d);
?????return?32?==?t???l(h)?+?l(f)?+?l(v)?+?l(y)?:?l(f)?+?l(v)
?}

After testing, the code can perfectly achieve the function I want,

Then save the code as js file.

Python code writing

  • Routine operation

    import?requests
    import?random
    import?execjs
    import?json
    import?pandas?as?pd
    import?time

    url?=?'https://bbs.vivo.com.cn/api/community/forum/threads'
    headers?=?{
    ???'accept':?'application/json,?text/plain,?/',
    ???'content-type':?'application/json;charset=UTF-8',
    ???'user-agent':?'Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/95.0.4621.0?Safari/537.36',
    ???'sec-ch-ua':?'"Chromium";v="21",?"?Not;A?Brand";v="99"',
    ???'sec-ch-ua-mobile':?'?0',
    ???'sec-ch-ua-platform':?'"Windows"',
    ???'origin':?'https://bbs.vivo.com.cn',
    ???'referer':?'https://bbs.vivo.com.cn/newbbs/forum/9',
    ???'cookie':?'cookieId=e1c6727a-9b29-1c13-a417-1b74440b9d521639290997482;?KL9d_2132_saltkey=pU2Rr4AV;?KL9d_2132_lastvisit=1639287439;?Hm_lvt_9ef7debb81babe8b94af7f2c274869fd=1639291140,1639713347;?Hm_lvt_a7471116b9007c038d41873ab9121a9e=1639291040,1639713440;?sessionId=b6c66b37-b88e-f74d-fa6b-b7e526d5e5f7'
    }

Although many packages have been imported here, they are actually imported one by one according to the use needs.

  • Parameters required for Python to generate js

    def?get_timestamp():
    ??? timestamp?=?int(time.time()?*?1000)??#? Get 13 bit timestamp
    ???return?timestamp

    def?get_str_():
    ??? num?=?int(float(str(random.random()?*?10000000)[:10]))??#? Get random number
    ??? str_?=?str(get_timestamp())?+?str(num)?+?‘ 1’??#? Get 21 bit random number
    ???return?str_

Here, timestamp and 21 bit concatenated string are generated respectively

  • Import the js file and get the most important parameter nonce

    def?get_cxt():
    ??? with?open(“1.js”)? as?file:??#? Open JS file
    ??? cxt?=?execjs.compile(file.read())??#? Import js file
    ???return?cxt

    def?get_nonce():
    ??? nonce?=?get_cxt().call(‘md5’,?get_str_(),?‘ 32’)??#? Call MD5 function of js file to encrypt and get nonce
    ???return?nonce

  • Get the data. Next, generate the data. Here I choose the first page as the test.

    def?get_data():??#? Get first page data
    ???data?=?{
    ???'forumId':?"9",
    ???'imgSpecs':?["t577x324",?"t577x4096"],
    ???'lastId':?"",
    ???'nonce':?get_nonce(),
    ???'order':?'1',
    ???'pageNum':?'1',
    ???'pageSize':?'10',
    ???'timestamp':?get_timestamp(),
    ???'topicId':?""
    ???}
    ???return?data

  • Initiate a request and get the data

    def?main():
    ??? res?=?requests.post(url,?headers=headers,?data=json.dumps(get_data())).text??#? Request first page data
    ???datss?=?json.loads(res)['data']['list']
    ???data_list?=?[]
    ???for?data?in?datss:
    ???bbsname?=?data['author']['bbsName']
    ???name?=?data['forum']['name']
    ???summary?=?data['summary']
    ???tid?=?data['tid']
    ???data_list.append({
    ???'bbsname':?bbsname,
    ???'name':?name,
    ???'summary':?summary,
    ???'tid':?tid
    ???})
    ???return?data_list

    if?name?==?'main':
    ???df?=?pd.DataFrame(main())
    ???#?df.index?=?df.index?+?1
    ???print(df)
    ??? df.to_excel('mobile circle 0.xlsx ')

Display of all codes

import?requests
import?random
import?execjs
import?json
import?pandas?as?pd
import?time

url?=?'https://bbs.vivo.com.cn/api/community/forum/threads'
headers?=?{
????'accept':?'application/json,?text/plain,?*/*',
????'content-type':?'application/json;charset=UTF-8',
????'user-agent':?'Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/95.0.4621.0?Safari/537.36',
????'sec-ch-ua':?'"Chromium";v="21",?"?Not;A?Brand";v="99"',
????'sec-ch-ua-mobile':?'?0',
????'sec-ch-ua-platform':?'"Windows"',
????'origin':?'https://bbs.vivo.com.cn',
????'referer':?'https://bbs.vivo.com.cn/newbbs/forum/9',
????'cookie':?'cookieId=e1c6727a-9b29-1c13-a417-1b74440b9d521639290997482;?KL9d_2132_saltkey=pU2Rr4AV;?KL9d_2132_lastvisit=1639287439;?Hm_lvt_9ef7debb81babe8b94af7f2c274869fd=1639291140,1639713347;?Hm_lvt_a7471116b9007c038d41873ab9121a9e=1639291040,1639713440;?sessionId=b6c66b37-b88e-f74d-fa6b-b7e526d5e5f7'
}


def?get_timestamp():
????timestamp?=?int(time.time()?*?1000)??#? Get 13 bit timestamp
????return?timestamp


def?get_str_():
????num?=?int(float(str(random.random()?*?10000000)[:10]))??#? Get random number
????str_?=?str(get_timestamp())?+?str(num)?+?'1'??#? Get 21 bit random number
????return?str_


def?get_cxt():
????with?open("1.js")?as?file:??#? Open js file
????????cxt?=?execjs.compile(file.read())??#? Import js file
????????return?cxt


def?get_nonce():
????nonce?=?get_cxt().call('md5',?get_str_(),?'32')??#? Call md5 function of js file to encrypt and get nonce
????return?nonce


def?get_data():??#? Get first page data
????data?=?{
????????'forumId':?"9",
????????'imgSpecs':?["t577x324",?"t577x4096"],
????????'lastId':?"",
????????'nonce':?get_nonce(),
????????'order':?'1',
????????'pageNum':?'1',
????????'pageSize':?'10',
????????'timestamp':?get_timestamp(),
????????'topicId':?""
????}
????return?data


def?main():
????res?=?requests.post(url,?headers=headers,?data=json.dumps(get_data())).text??#? Request first page data
????datss?=?json.loads(res)['data']['list']
????data_list?=?[]
????for?data?in?datss:
????????bbsname?=?data['author']['bbsName']
????????name?=?data['forum']['name']
????????summary?=?data['summary']
????????tid?=?data['tid']
????????data_list.append({
????????????'bbsname':?bbsname,
????????????'name':?name,
????????????'summary':?summary,
????????????'tid':?tid
????????})
????return?data_list


if?__name__?==?'__main__':
????df?=?pd.DataFrame(main())
????#?df.index?=?df.index?+?1
????print(df)
????df.to_excel('Mobile circle 0.xlsx')

Achievement display

Write at the end

  • This is the first time I have completed the js reverse alone in a real sense, and the process is also very tortuous. So far, I have succeeded. Send an article to commemorate it, and I can't help but hear WK in my heart.

  • 2 special thanks to brother Mantou for his help. After all the codes are completed, the "client parameter error" will be reported as long as the request is made. He has been troubled by this problem for a long time. Later, brother Mantou found that the data format is wrong and needs to use JSON Dumps () encodes the data. Thanks again.

  • 3 so far, although the reverse work of js has been completed, there is also a lastid in the data of this website. It is not difficult to obtain the tid of the last user on the previous page. Later, I have time to write a cycle.

  • You need to have full code or video tutorials to look at the official account below.

Keywords: Python Javascript Front-end html Interview

Added by nafarius1357 on Sun, 20 Feb 2022 20:51:09 +0200