This is the 10th day of my participation in the August Text Challenge.More challenges in August

Preparation of a tool

1. Fiddler package capture tool, Nighthian simulator 2. Python environment, Java environment 3. 4. Java decompiler tool

Ii Project Ideas

Configure the package capture tool and download the comic applink. Install the comic applink into the Nighthian emulator

Capture APP data

Parse captured data:

A post request

Changed parameters client-time and client-sign

Client-time is obviously a timestamp

Client-sign encrypts data

client_type = 'android'
app_devicetoken = "e571dd8bd67803995b9bdcfefb58662b"
phone_mark = "58D83850AA58CCB094954B30F9C4D3C4"
client_time = str(int(time.time() * 1000))
Copy the code

Parsing the app

Change the apK installation package suffix to RAR. Decompress the package to obtain the corresponding app file

Get the Java classes file

The obtained classes.dex is decompiled, and the tool can either find it itself or communicate with the group to retrieve it

Move classes.dex to the resolved folder

Enter the Windows PowerShell CD into the decompiled folder

Run the.\ d2j-dex2jar.bat.classes.dex command

You get the classes-dex2jar.jar file and this is the source code for Java

Drag the code to your Java decomcompiler JD-GUI

You get all the Java code

Search for the corresponding encryption parameter: client-sign

Make sure client-sign is generated to open the corresponding file for B.class

Find the encryption rules for the data

The original encryption method is MD5

The encrypted data is determined by a timestamp

Content = '3.0.1' + client_type + STR (client_time) + app_deviceToken + phone_mark + "0" + "" + "{54563A97-2BBA-7F31-D4C1-8EF72F4A98E6}" client_sign = hashlib.md5(content.encode("utf-8")).hexdigest()Copy the code

Determine all the parameters of the request header

Headers = {'client-ver': '3.0.1', 'client-type': client_type, 'client-time': STR (client_time), 'phone-mark': phone_mark, 'app-devicetoken': app_devicetoken, 'sina-uid': '0', 'sina-token': '', 'VREADREFER': 'vmh_client', 'client-sign': client_sign, 'Cache-Control': 'no-cache', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Content-Length': '223', 'Host': 'api.manhua.weibo.com', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'the user-agent' : 'okhttp / 3.8.0'}Copy the code

Parameters to be passed

data = "Client_ver = 3.0.1 & client_type = {} & client_time = {} & phone_mark = {} & app_devicetoken = {} & sina_uid = 0 & sina_token = & client_sign = {}". format(client_type, client_time, phone_mark, app_devicetoken, client_sign)Copy the code

Simple code for reference

Content related to the APP, only technical discussion [compilation tools can be accessed by visiting my home page and following my public account]

import requests import time import hashlib import os client_type = 'android' app_devicetoken = "e571dd8bd67803995b9bdcfefb58662b" phone_mark = "58D83850AA58CCB094954B30F9C4D3C4" client_time = str(int(time.time() * 1000)) content = '3.0.1' + client_type + STR (client_time) + app_deviceToken + phone_mark + "0" + "" + "{54563A97-2BBA-7F31-D4C1-8EF72F4A98E6}" client_sign = hashlib.md5(content.encode("utf-8")).hexdigest() headers = { 'client-ver': '3.0.1', 'client-type': client_type, 'client-time': STR (client_time), 'phone-mark': phone_mark, 'app-devicetoken': app_devicetoken, 'sina-uid': '0', 'sina-token': '', 'VREADREFER': 'vmh_client', 'client-sign': client_sign, 'Cache-Control': 'no-cache', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Content-Length': '223', 'Host': 'api.manhua.weibo.com', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'User-Agent': 'okhttp / 3.8.0', } data = "Client_ver = 3.0.1 & client_type = {} & client_time = {} & phone_mark = {} & app_devicetoken = {} & sina_uid = 0 & sina_token = & client_sign = {}". format(client_type, client_time, phone_mark, app_devicetoken, client_sign) def parse_data(url): response = requests.post(url, headers=headers, data=data).json() page_list = response["data"]["chapter_list"] for x in page_list: page_url = "http://api.weibo.com/client/comic/show?comic_id=68236/client/comic/play?chapter_id={}".format(x["chapter_id"]) dir_name + x["chapter_name"] page_data = requests. Post (page_url, headers=headers, data=data).json()["data"]["json_content"]["page"] y = 0 for i in page_data: if not os.path.exists(dir_name): os.makedirs(dir_name) result = requests.get(i["mobileImgUrl"]).content path = dir_name + "\\" + str(y) + ".jpg" with Open (path, "wb")as f: f: print(result) y += 1 def main(): url = "http://api.weibo.com/client/comic/show?comic_id=68236" parse_data(url) if __name__ == '__main__': main()Copy the code

I am Bai You Bai I, a program yuan who likes to share knowledge ❤️ [This article was written by my colleague Bai 汌 and published with permission in Nuggets]

If you don’t know anything about Python or want to learn Python, you can leave a comment on this blog. Thank you very much for your liking, bookkeeping, following and commenting.