AES加密求助各位大佬
本帖最后由 百事可乐呐 于 2021-3-18 12:14 编辑在python爬APP的过程中遇到了密码加密,反编译APP得知是AES/CBC/PKCS5Padding
尝试过反编译从源代码中找密码以及偏移量,但是因为没有安卓基础没找到,请各位大佬帮忙提供一下思路
目前已知明文:Abc961125@
加密之后:ebgcgddjdgdbdbdcdfea
看了源代码似乎是有SHA1以及base、MD5加密的混合
```
package p012cn.jiguang.p024d.p035g.p036a;
import android.support.p008v4.view.ViewCompat;
import android.util.Base64;
import java.lang.reflect.InvocationTargetException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import p012cn.jiguang.p024d.p025a.C0307d;
import p012cn.jiguang.p038e.C0416d;
import p012cn.jiguang.p039f.C0418b;
import p012cn.jiguang.p040g.C0421a;
/* renamed from: cn.jiguang.d.g.a.a */
public final class C0397a {
/* renamed from: a */
private static String f531a = "";
/* renamed from: b */
private static int f532b;
/* renamed from: a */
public static String m832a() {
return f531a;
}
/* renamed from: a */
public static String m833a(long j) {
long j2;
long j3;
switch (((int) j) % 10) {
case 1:
j2 = 5 * j;
j3 = 88;
break;
case 2:
j2 = 23 * j;
j3 = 15;
break;
case 3:
j2 = 3 * j;
j3 = 73;
break;
case 4:
j2 = 13 * j;
j3 = 96;
break;
case 5:
j2 = 17 * j;
j3 = 49;
break;
case 6:
j2 = 7 * j;
j3 = 68;
break;
case 7:
j2 = 31 * j;
j3 = 39;
break;
case 8:
j2 = 29 * j;
j3 = 41;
break;
case 9:
j2 = 37 * j;
j3 = 91;
break;
default:
j2 = 8 * j;
j3 = 74;
break;
}
long j4 = j2 + (j % j3);
return C0421a.m998a("JCKP" + String.valueOf(j4));
}
/* renamed from: a */
public static String m834a(String str) {
String encodeToString;
try {
if ("DFA84B10B7ACDD25".length() != 16) {
encodeToString = null;
} else {
byte[] c = m844c("DFA84B10B7ACDD25", "ASCII");
Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
instance.init(1, new SecretKeySpec(c, "AES"), m836a(c));
encodeToString = Base64.encodeToString(instance.doFinal(str.getBytes()), 2);
}
return encodeToString;
} catch (Exception unused) {
C0416d.m970g("", "Unexpected - failed to AES encrypt.");
return "";
}
}
/* renamed from: a */
public static String m835a(String str, String str2) {
if (str2 == null) {
return null;
}
try {
if (str2.length() != 16) {
return null;
}
byte[] c = m844c(str2, "ASCII");
Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
instance.init(2, new SecretKeySpec(c, "AES"), m836a(c));
return new String(instance.doFinal(Base64.decode(str, 2)));
} catch (Exception unused) {
return null;
}
}
/* renamed from: a */
private static IvParameterSpec m836a(byte[] bArr) {
try {
return (IvParameterSpec) C0418b.m983a(IvParameterSpec.class, new Object[]{bArr}, new Class[]{byte[].class});
} catch (NoSuchMethodException e) {
e.printStackTrace();
return null;
} catch (IllegalAccessException e2) {
e2.printStackTrace();
return null;
} catch (InvocationTargetException e3) {
e3.printStackTrace();
return null;
} catch (InstantiationException e4) {
e4.printStackTrace();
return null;
}
}
/* renamed from: a */
public static void m837a(int i) {
f532b = i;
}
/* renamed from: a */
public static byte[] m838a(String str, byte[] bArr) {
SecretKeySpec secretKeySpec = new SecretKeySpec(m844c(str, "utf-8"), "AES");
Cipher instance = Cipher.getInstance("AES/ECB/PKCS7Padding");
instance.init(1, secretKeySpec);
return instance.doFinal(bArr);
}
/* renamed from: a */
public static byte[] m839a(byte[] bArr, int i) {
Exception e;
byte[] bArr2;
long j;
int length = bArr.length - 24;
byte[] bArr3 = new byte;
byte[] bArr4 = new byte;
System.arraycopy(bArr, 0, bArr3, 0, 24);
System.arraycopy(bArr, 24, bArr4, 0, length);
String str = "";
if (i == 1) {
j = C0307d.m391d(null);
} else {
if (i == 0) {
j = (long) f532b;
}
byte[] a = m838a(str, bArr4);
int length2 = a.length + 24;
bArr2 = new byte;
try {
System.arraycopy(bArr3, 0, bArr2, 0, 24);
System.arraycopy(a, 0, bArr2, 24, a.length);
bArr2 = (byte) ((length2 >>> 8) & 255);
bArr2 = (byte) (length2 & 255);
bArr2 = (byte) (bArr2 | 128);
return bArr2;
} catch (Exception e2) {
e = e2;
e.printStackTrace();
return bArr2;
}
}
str = m841b(j);
try {
byte[] a2 = m838a(str, bArr4);
int length22 = a2.length + 24;
bArr2 = new byte;
System.arraycopy(bArr3, 0, bArr2, 0, 24);
System.arraycopy(a2, 0, bArr2, 24, a2.length);
bArr2 = (byte) ((length22 >>> 8) & 255);
bArr2 = (byte) (length22 & 255);
bArr2 = (byte) (bArr2 | 128);
return bArr2;
} catch (Exception e3) {
e = e3;
bArr2 = null;
e.printStackTrace();
return bArr2;
}
}
/* renamed from: b */
public static int m840b() {
return Math.abs(new SecureRandom().nextInt()) & ViewCompat.MEASURED_SIZE_MASK;
}
/* renamed from: b */
private static String m841b(long j) {
long j2;
long j3;
String valueOf = String.valueOf(j);
int length = valueOf.length();
if (length >= 2) {
valueOf = valueOf.substring(length - 2, length);
}
switch (Integer.parseInt(valueOf) % 10) {
case 1:
j2 = 5 * j;
j3 = 88;
break;
case 2:
j2 = 23 * j;
j3 = 15;
break;
case 3:
j2 = 3 * j;
j3 = 73;
break;
case 4:
j2 = 13 * j;
j3 = 96;
break;
case 5:
j2 = 17 * j;
j3 = 49;
break;
case 6:
j2 = 7 * j;
j3 = 68;
break;
case 7:
j2 = 31 * j;
j3 = 39;
break;
case 8:
j2 = 29 * j;
j3 = 41;
break;
case 9:
j2 = 37 * j;
j3 = 91;
break;
default:
j2 = 8 * j;
j3 = 74;
break;
}
long j4 = j2 + (j % j3);
String a = C0421a.m998a("JCKP" + String.valueOf(j4));
f531a = a;
return a;
}
/* renamed from: b */
public static String m842b(String str, String str2) {
try {
return m835a(str, "DFA84B10B7ACDD25");
} catch (Exception unused) {
C0416d.m970g("", "Unexpected - failed to AES decrypt.");
return str2;
}
}
/* renamed from: b */
public static byte[] m843b(String str, byte[] bArr) {
SecretKeySpec secretKeySpec = new SecretKeySpec(m844c(str, "utf-8"), "AES");
Cipher instance = Cipher.getInstance("AES/ECB/NoPadding");
instance.init(2, secretKeySpec);
return instance.doFinal(bArr);
}
/* renamed from: c */
private static byte[] m844c(String str, String str2) {
byte[] bArr = new byte;
byte[] bytes = str.substring(0, str.length() / 2).getBytes(str2);
byte[] bytes2 = str.substring(str.length() / 2).getBytes(str2);
System.arraycopy(bytes, 0, bArr, 0, bytes.length);
System.arraycopy(bytes2, 0, bArr, bytes.length, bytes2.length);
return bArr;
}
}
```
https://wws.lanzouj.com/i9Bdwn1tsfg
密码:6k27
麻烦各位大佬指点我这个小小白,谢谢! @涛之雨 大佬帮忙看看?{:1_923:} 论坛禁止求脱求破,求助软件分析思路,务必在主题帖中描述清楚你的分析思路与方法,否则当作求破处理,再次发现违规终身禁言!
哪里是关键算法?
就丢个加密前后内容,谁知道哪里加密的 涛之雨 发表于 2021-3-18 22:41
论坛禁止求脱求破,求助软件分析思路,务必在主题帖中描述清楚你的分析思路与方法,否则当作求破处理,再次 ...
已经解决啦,谢谢大佬,加密解密都在webview上做的
页:
[1]