Android——浙理体育(飞翔的红蜻蜓)训练记录上传与查询测试DEMO解决方案

 解决方案

package io.shentuzhigang.demo.text;

import io.shentuzhigang.demo.http.okhttp3.HttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.apache.http.client.entity.EntityBuilder;
import org.apache.http.client.entity.GzipCompressingEntity;
import org.apache.http.client.entity.GzipDecompressingEntity;

import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @date 2020-10-26 14:54
 */
public class HongQingTingTest {

    public static void main(String[] args) throws IOException {
        byte[] arrOutput = {  };  #抓包数据
        System.out.println(new String(uncompress(arrOutput)));
        String s=new String(uncompress(arrOutput)).replace("16034",String.valueOf((long)( System.currentTimeMillis() / 1e8)));
        System.out.println(s);
        Request.Builder builder = new Request.Builder();
        Request build = builder.url("http://10.11.246.182:8029/DragonFlyServ/Api/webserver/uploadRunData")
                .header("Charset", "UTF-8")
                .header("Connection", "Keep-Alive")
                .header("Content-Type", "application/x-www-form-urlencoded")
                .post(RequestBody.create(compress(s,"UTF-8")))
                .build();
        String s1= "{'studentno':'2018329621200'," +
                "'uid':'a26baf4e-a27a-424c-9d58-f04b700114a1faf4352521394a859275687a47b786721602508814$9d7370a8eb0c1286ce3c949c0c53469e'}";
        Request.Builder builder1 = new Request.Builder();
        Request build1 = builder1.url("http://10.11.246.182:8029/DragonFlyServ/Api/webserver/getRunDataSummary")
                .header("Charset", "UTF-8")
                .header("Connection", "Keep-Alive")
                .header("Content-Type", "application/x-www-form-urlencoded")
                .post(RequestBody.create(compress(s1,"UTF-8")))
                .build();
        System.out.println(new HttpClient().newCall(build1).execute().body().string());
    }
    public static byte[] compress(String str, String encoding) {
        if (str == null || str.length() == 0) {
            return null;
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip;
        try {
            gzip = new GZIPOutputStream(out);
            gzip.write(str.getBytes(encoding));
            gzip.close();
        } catch ( Exception e) {
            e.printStackTrace();
        }
        return out.toByteArray();
    }


    public static byte[] uncompress(byte[] bytes) {
        if (bytes == null || bytes.length == 0) {
            return null;
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        try {
            GZIPInputStream ungzip = new GZIPInputStream(in);
            byte[] buffer = new byte[256];
            int n;
            while ((n = ungzip.read(buffer)) >= 0) {
                out.write(buffer, 0, n);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return out.toByteArray();
    }
}

参考文章

Android——浙理体育(飞翔的红蜻蜓)反编译分析

“红蜻蜓”跑步APP逆向分析与数据伪造思路

©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页