Focus on official account dry cargo WeChat public: K brother crawler, keep sharing crawler advance, JS/ Android reverse technology dry goods!
statement
All contents in this article are for learning and communication only. The packet capturing content, sensitive website and data interface have been desensitized. It is strictly prohibited to use them for commercial and illegal purposes, otherwise all the consequences have nothing to do with the author. If there is infringement, please contact me and delete them immediately!
Reverse target
- Objective: webmaster anti crawler practice platform question 3: AAEncode encryption
- Link: http://spider.wangluozhe.com/challenge/3
- Introduction: this topic still requires to collect all the numbers of 100 pages and calculate the sum of all data. It needs to dig out the source code for calculation, mainly using AAEncode encryption
Introduction to AAEncode
AAEncode and JJEncode are the same author: Yosuke HASEGAWA of Japan. AAEncode can encode any JavaScript code into Japanese emoticons. Online experience address: https://utf-8.jp/public/aaencode.html .
A normal JS code:
alert("Hello, JavaScript" )
Code after AAEncode confusion:
゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) ('_');
AAEncode's disambiguation method is similar to that of JJEncode. It is very simple. Several common methods are introduced below:
- Directly decrypt using online tools, such as: http://www.hiencode.com/aaencode.html ;
- Remove the last symbol ('') of the code and put it into the browser for direct execution to see the source code;
- Online debugging, break points in the first line of AAEncode code, then execute step by step, and finally see the source code in the virtual machine (VM);
Inverse parameter
The main target of reverse is the page turning interface_ With the signature parameter, the encryption method called is still window get_ Sign (), which is the same as the previous two questions, will not be repeated in this article. If you are unclear, you can see brother K's article in the last issue.
If you continue to follow up, you will find that it is a color AAEncode confusion:
We copy this code, remove the ('') at the end, and run it directly on the browser console (it is recommended to open a traceless window, which may sometimes have an impact). We can see the source code. Click the source code to the virtual machine (VM), and the whole source code is displayed in front of us:
In addition to directly removing the ('' ') operation, we can also set a breakpoint in the first line of the confused code, and then follow up step by step. Finally, we will also get the source code, as shown in the following figure:
Look at the code. There is a hook window The sign operation and delete operation are followed by a DES encrypted function. The following try catch statement sets some parameters such as key, focusing on the try catch statement. The next breakpoint is to see which statement is actually taken:
We don't need to care about other logic. We can copy the try statement directly without exception. DES can directly call crypto JS. After local rewriting, it can be carried with Python code_ signature calculates the data of each page one by one and finally submits it successfully:
Complete code
GitHub pays attention to brother K crawler and continues to share crawler related codes! Welcome, star! https://github.com/kgepachong/
The following only demonstrates part of the key code and cannot be run directly! Full code warehouse address: https://github.com/kgepachong/crawler/
JavaScript encryption code
/* ================================== # @Time : 2021-12-13 # @Author : WeChat official account: K brother crawler # @FileName: challenge_3.js # @Software: PyCharm # ================================== */ var CryptoJS = require('crypto-js') function encryptByDES(message, key) { var keyHex = CryptoJS.enc.Utf8.parse(key); var encrypted = CryptoJS.DES.encrypt(message, keyHex, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); return encrypted.ciphertext.toString(); } function getSign() { var message = "http://spider.wangluozhe.com/challenge/3"; message = message + '|' + Date.parse(new Date()).toString(); var key = Date.parse(new Date()).toString(); return encryptByDES(message, key); } // Test output // console.log(getSign())
Python computing key code
# ================================== # --*-- coding: utf-8 --*-- # @Time : 2021-12-13 # @Author: WeChat official account: K brother crawler # @FileName: challenge_3.py # @Software: PyCharm # ================================== import execjs import requests challenge_api = "http://spider.wangluozhe.com/challenge/api/3" headers = { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Cookie": "take cookie Change the value to your own!", "Host": "spider.wangluozhe.com", "Origin": "http://spider.wangluozhe.com", "Referer": "http://spider.wangluozhe.com/challenge/2", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36", "X-Requested-With": "XMLHttpRequest" } def get_signature(): with open('challenge_3.js', 'r', encoding='utf-8') as f: ppdai_js = execjs.compile(f.read()) signature = ppdai_js.call("getSign") print("signature: ", signature) return signature def main(): result = 0 for page in range(1, 101): data = { "page": page, "count": 10, "_signature": get_signature() } response = requests.post(url=challenge_api, headers=headers, data=data).json() for d in response["data"]: result += d["value"] print("The result is: ", result) if __name__ == '__main__': main()