吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1402|回复: 2
收起左侧

[Android 求助] 求助app base64解密

[复制链接]
gggqqqxxx 发表于 2020-9-22 12:36
本帖最后由 gggqqqxxx 于 2020-9-22 12:38 编辑

抓包某app数据加密了,脱壳逆向app  找到好像是每次请求回来走到下面的方法解密 调用解密decryptBase64String(respones,"weichats");
这个代码 自己建一个java文件把这个执行一下不知道能运行 base64怎么解密 哪位大佬解答一下
package com.asdfg2.daili.Common.crypt;

import java.io.UnsupportedEncodingException;
import kotlin.UByte;

public final class XXTEA {
    private static final int DELTA = -1640531527;

    /* renamed from: MX */
    private static int m12MX(int i, int i2, int i3, int i4, int i5, int[] iArr) {
        return ((i ^ i2) + (iArr[(i4 & 3) ^ i5] ^ i3)) ^ (((i3 >>> 5) ^ (i2 << 2)) + ((i2 >>> 3) ^ (i3 << 4)));
    }

    private XXTEA() {
    }

    public static final byte[] encrypt(byte[] bArr, byte[] bArr2) {
        if (bArr.length == 0) {
            return bArr;
        }
        return toByteArray(encrypt(toIntArray(bArr, true), toIntArray(fixKey(bArr2), false)), false);
    }

    public static final byte[] encrypt(String str, byte[] bArr) {
        try {
            return encrypt(str.getBytes("UTF-8"), bArr);
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final byte[] encrypt(byte[] bArr, String str) {
        try {
            return encrypt(bArr, str.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final byte[] encrypt(String str, String str2) {
        try {
            return encrypt(str.getBytes("UTF-8"), str2.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final String encryptToBase64String(byte[] bArr, byte[] bArr2) {
        byte[] encrypt = encrypt(bArr, bArr2);
        if (encrypt == null) {
            return null;
        }
        return Base64.encode(encrypt);
    }

    public static final String encryptToBase64String(String str, byte[] bArr) {
        byte[] encrypt = encrypt(str, bArr);
        if (encrypt == null) {
            return null;
        }
        return Base64.encode(encrypt);
    }

    public static final String encryptToBase64String(byte[] bArr, String str) {
        byte[] encrypt = encrypt(bArr, str);
        if (encrypt == null) {
            return null;
        }
        return Base64.encode(encrypt);
    }

    public static final String encryptToBase64String(String str, String str2) {
        byte[] encrypt = encrypt(str, str2);
        if (encrypt == null) {
            return null;
        }
        return Base64.encode(encrypt);
    }

    public static final byte[] decrypt(byte[] bArr, byte[] bArr2) {
        if (bArr.length == 0) {
            return bArr;
        }
        return toByteArray(decrypt(toIntArray(bArr, false), toIntArray(fixKey(bArr2), false)), true);
    }

    public static final byte[] decrypt(byte[] bArr, String str) {
        try {
            return decrypt(bArr, str.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final byte[] decryptBase64String(String str, byte[] bArr) {
        return decrypt(Base64.decode(str), bArr);
    }

    public static final byte[] decryptBase64String(String str, String str2) {
        return decrypt(Base64.decode(str), str2);
    }

    public static final String decryptToString(byte[] bArr, byte[] bArr2) {
        try {
            byte[] decrypt = decrypt(bArr, bArr2);
            if (decrypt == null) {
                return null;
            }
            return new String(decrypt, "UTF-8");
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final String decryptToString(byte[] bArr, String str) {
        try {
            byte[] decrypt = decrypt(bArr, str);
            if (decrypt == null) {
                return null;
            }
            return new String(decrypt, "UTF-8");
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final String decryptBase64StringToString(String str, byte[] bArr) {
        try {
            byte[] decrypt = decrypt(Base64.decode(str), bArr);
            if (decrypt == null) {
                return null;
            }
            return new String(decrypt, "UTF-8");
        } catch (UnsupportedEncodingException unused) {
            return null;
        }
    }

    public static final String decryptBase64StringToString(String str, String str2) {
        try {
            byte[] decrypt = decrypt(Base64.decode(str), str2);
            if (decrypt == null) {
                return null;
            }
            return new String(decrypt, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private static int[] encrypt(int[] iArr, int[] iArr2) {
        int length = iArr.length - 1;
        if (length < 1) {
            return iArr;
        }
        int i = (52 / (length + 1)) + 6;
        int i2 = iArr[length];
        int i3 = 0;
        while (true) {
            int i4 = i - 1;
            if (i <= 0) {
                return iArr;
            }
            int i5 = DELTA + i3;
            int i6 = (i5 >>> 2) & 3;
            int i7 = i2;
            int i8 = 0;
            while (i8 < length) {
                int i9 = i8 + 1;
                i7 = iArr[i8] + m12MX(i5, iArr[i9], i7, i8, i6, iArr2);
                iArr[i8] = i7;
                i8 = i9;
            }
            i2 = iArr[length] + m12MX(i5, iArr[0], i7, i8, i6, iArr2);
            iArr[length] = i2;
            i3 = i5;
            i = i4;
        }
    }

    private static int[] decrypt(int[] iArr, int[] iArr2) {
        int length = iArr.length - 1;
        if (length < 1) {
            return iArr;
        }
        int i = iArr[0];
        for (int i2 = ((52 / (length + 1)) + 6) * DELTA; i2 != 0; i2 -= DELTA) {
            int i3 = (i2 >>> 2) & 3;
            int i4 = i;
            int i5 = length;
            while (i5 > 0) {
                i4 = iArr[i5] - m12MX(i2, i4, iArr[i5 - 1], i5, i3, iArr2);
                iArr[i5] = i4;
                i5--;
            }
            i = iArr[0] - m12MX(i2, i4, iArr[length], i5, i3, iArr2);
            iArr[0] = i;
        }
        return iArr;
    }

    private static byte[] fixKey(byte[] bArr) {
        if (bArr.length == 16) {
            return bArr;
        }
        byte[] bArr2 = new byte[16];
        if (bArr.length < 16) {
            System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
        } else {
            System.arraycopy(bArr, 0, bArr2, 0, 16);
        }
        return bArr2;
    }

    private static int[] toIntArray(byte[] bArr, boolean z) {
        int[] iArr;
        int length = (bArr.length & 3) == 0 ? bArr.length >>> 2 : (bArr.length >>> 2) + 1;
        if (z) {
            iArr = new int[(length + 1)];
            iArr[length] = bArr.length;
        } else {
            iArr = new int[length];
        }
        int length2 = bArr.length;
        for (int i = 0; i < length2; i++) {
            int i2 = i >>> 2;
            iArr[i2] = iArr[i2] | ((bArr[i] & UByte.MAX_VALUE) << ((i & 3) << 3));
        }
        return iArr;
    }

    private static byte[] toByteArray(int[] iArr, boolean z) {
        int i;
        int length = iArr.length << 2;
        if (z) {
            i = iArr[iArr.length - 1];
            int i2 = length - 4;
            if (i < i2 - 3 || i > i2) {
                return null;
            }
        } else {
            i = length;
        }
        byte[] bArr = new byte[i];
        for (int i3 = 0; i3 < i; i3++) {
            bArr[i3] = (byte) (iArr[i3 >>> 2] >>> ((i3 & 3) << 3));
        }
        return bArr;
    }
}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

涛之雨 发表于 2020-9-22 13:26
标准b64吧。直接搜一下就行
jmzqwh 发表于 2020-9-22 13:52
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-16 17:42

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表