app逆向练手系列

发布时间 2023-10-12 22:12:39作者: inks

葫芦侠 

jadx反编译 直接找到代码

 照着代码写 完事

 确实挺不错的

import requests
from hashlib import md5
from time import time, sleep


class Hulux:
    def __init__(self, user, passwd):
        self.sess = requests.session()
        self.sess.headers = {
            'Host': 'floor.huluxia.com',
            'User-Agent': 'okhttp/3.8.1',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        self.params = {
            'platform': '2',
            'gkey': '000000',
            'app_version': '4.2.0.8.2',
            'versioncode': '20141486',
            'market_id': 'floor_web',
            '_key': '',
            'device_code': '[d]ebe1c0cb-c8ee-4bdb-be22-980445be3e68',
            'phone_brand_type': 'UN',
        }
        self.user = user
        self.passwd = md5(passwd.encode("utf-8")).hexdigest()
        self.hlist = {}

    def post(self, url, data=None, params=None):
        return self.sess.post(url=url, params=self.params if not params else params, data=data)

    def get(self, url, data=None, params=None):
        return self.sess.get(url=url, params=self.params if not params else params, data=data)

    def cpParams(self, val):
        params = self.params.copy()
        params.update(val)
        return params

    def getSign(self, data, i=0):
        cipTxt = ""
        if i:
            data['voice_code'] = ""
            data['device_code'] = self.params['device_code']
            if data.get("login_type"):
                del data['login_type']
        data_keys = list(data.keys())
        data_keys.sort()
        for key in data_keys:
            cipTxt += key + data[key]
        cipTxt += "fa1c28a5b62e79c3e63d9030b6142e4b"
        enc = md5(cipTxt.encode('utf-8'))
        return enc.hexdigest().upper()

    def login(self):
        data = {
            'account': self.user,
            'login_type': '2',
            'password': self.passwd
        }
        data['sign'] = self.getSign(data.copy(), 1)
        response = self.post(url='http://floor.huluxia.com/account/login/ANDROID/4.1.8', data=data).json()
        if response['status']:
            self.params['_key'] = response['_key']
            print(response['user']['nick'], "登陆成功!!!")
        else:
            print("账号密码错误!!!")

    def plate(self):
        response = self.get(url='http://floor.huluxia.com/category/list/ANDROID/4.2.3').json()
        categories = response['categories']
        num = 0
        for li in categories:
            if li['categoryID'] not in [0, 1, 6, 93, 94]:
                num += 1
                print(++num, li['title'], f"版主: {len(li['moderator'])} 位", f"关注人数:{li['postCount']}",
                      f"累计访问:{li['viewCount']}")
                self.hlist[str(num)] = str(li['categoryID'])
        self.viewplate(self.hlist.get(input('亲输入要访问的板块:')))

    def viewplate(self, cat_id):

        response = self.get('http://floor.huluxia.com/post/list/ANDROID/4.1.8', params=self.cpParams({
            'start': '0',
            'count': '20',
            'cat_id': cat_id,
            'tag_id': '0',
            'sort_by': '0',
        })).json()

        for li in response['posts']:
            title = li['title']
            postID = li['postID']
            print("=" * 70 + title + "文章" + "=" * 70)
            self.getComment(postID)

    def getComment(self, postID):
        response = self.get('http://floor.huluxia.com/post/detail/ANDROID/4.2.2', params=self.cpParams({
            'post_id': postID,
            'page_no': '1',
            'page_size': '20',
            'doc': '1'})).json()
        detail = response['post']['detail']
        title = response['post']['title']
        print(detail)
        for li in response['comments']:
            user = li['user']
            sex = "" if user['gender'] else ""
            print( user['userID'], user['nick'], user['age'], sex, user['ipAddr'],
                  f"Level{user['level']}", li['text'])
        print("=" * 70 + "结束" + "=" * 70)

    def follows(self, start, end):
        for i in range(start, end + 1):
            user_data = {
                'user_id': f'{i}',
                'time': f'{round(time())}043',
            }
            response = self.post('http://floor.huluxia.com/friendship/follow/ANDROID/4.1.8',
                                 params=self.cpParams(user_data), data={'sign': self.getSign(user_data)})
            print(i, response.text)
            sleep(5)  # 关注间隔

    def main(self):
        self.login()  # 登录
        self.plate()  # 看帖子
        # self.follows(100, 1000)  # 关注


if __name__ == '__main__':
    x = Hulux("1324****9", "ink****0")
    x.main()
View Python Code
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@SuppressWarnings("all")
public class Test {
    public static void main(String[] args) throws NoSuchAlgorithmException {
        String token = "e10adc3949ba59abbe56e057f20f883e";
        System.out.println("uuid:" + lF());
        Map encodeMap = new HashMap();
        /*encodeMap.put("device_code", "[d]ebe1c0cb-c8ee-4bdb-be22-980445be3e68");
        encodeMap.put("account", "25*****318@qq.com");
        encodeMap.put("password", token);
        encodeMap.put("voice_code", "");*/
        encodeMap.put("user_id", "9848731");
        encodeMap.put("time", "1697117514327");
        System.out.println("sign:" + v(encodeMap));
    }

    public static String lF() {
        StringBuilder deviceId = new StringBuilder();
        String raddomId = UUID.randomUUID().toString();
        deviceId.append("[d]");
        deviceId.append(raddomId);
        return deviceId.toString();
    }
    public static String v(Map<String, String> params) throws NoSuchAlgorithmException {
        return c(params, "fa1c28a5b62e79c3e63d9030b6142e4b");
    }

    public static String c(Map<String, String> params, String md5) throws NoSuchAlgorithmException {
        String[] keys = (String[]) params.keySet().toArray(new String[0]);
        Arrays.sort(keys);
        StringBuilder builder = new StringBuilder();
        for (String key : keys) {
            builder.append(key).append(params.get(key) == null ? "" : params.get(key));
        }
        builder.append(md5);
        return lq(builder.toString());

    }
    private static String lq(String data) throws NoSuchAlgorithmException {
        System.out.println(data);
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] array = md.digest(data.getBytes());
        StringBuilder sb = new StringBuilder();
        // HexBin
        for (byte a : array) {
            if (a < 0) {
                a += 256;
            }
            String hex = Integer.toHexString(a).toUpperCase();
            if (hex.length() == 1) {
                sb.append("0" + hex);
            } else {
                sb.append(hex.substring((hex.length() - 2)));
            }
        }
        return sb.toString();
    }

}
View Java Code