dex动态自修改demo题解


本文为看雪论坛优秀文章
看雪论坛作者ID:Simp1er
前言
正文

package com.kanxue.test;
import android.util.Base64;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class Utils {
public static String cipher;
static {
Utils.cipher = "sGpdX0nDoRPWnonSt0SQQXOk/0wID0jvtAqb2QxJoW4=";
}
public Utils() {
super();
}
public static String aaaaa(String arg7, String arg8) throws Exception {
String v0 = null;
if(arg8 == null) {
return v0;
}
if(arg8.length() != 16) {
return v0;
}
SecretKeySpec v2 = new SecretKeySpec(arg8.getBytes("utf-8"), "AES");
Cipher v3 = Cipher.getInstance("AES/ECB/PKCS5Padding");
v3.init(1, ((Key)v2));
return new String(Base64.encode(v3.doFinal(arg7.getBytes("utf-8")), 0));
}
static String bbbbb(String arg14, String arg15) {
int v0 = 0x100;
char[] v1 = new char[v0];
char[] v2 = new char[v0];
int v3;
for(v3 = 0; v3 < v0; ++v3) {
v1[v3] = arg14.charAt(v3 % arg14.length());
v2[v3] = ((char)v3);
}
v3 = 0;
int v4;
for(v4 = 0; v4 < v0; ++v4) {
v3 = v2[v4] + v3 + v1[v4] & 0xFF;
char v5 = v2[v4];
v2[v4] = v2[v3];
v2[v3] = v5;
}
v0 = 0;
v3 = 0;
String v4_1 = "";
int v5_1;
for(v5_1 = 0; v5_1 < arg15.length(); ++v5_1) {
v0 = v0 + 1 & 0xFF;
char v6 = v2[v0];
v3 = v3 + v6 & 0xFF;
char v7 = ((char)(v2[v3] + v6 & 0xFF));
v2[v0] = v2[v3];
v2[v3] = v6;
try {
v4_1 = v4_1 + new String(new char[]{((char)(arg15.charAt(v5_1) ^ v2[v7]))});
}
catch(Exception v8) {
v8.printStackTrace();
}
}
return v4_1;
}
public static boolean test(String arg6) {
boolean v0 = false;
new Utils();
String v2 = Utils.bbbbb("kanxue", arg6);
try {
if(!Utils.aaaaa(v2, "0123456789abcdef").replace("\n", "").equals(Utils.cipher)) {
return v0;
}
}
catch(Exception v3) {
v3.printStackTrace();
return v0;
}
return true;
}
}




function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return bytes;
}
var jsBytes = hexToBytes("c3bfc29fc3b3c3a335c2a803c294c38c4c670ac39cc3a6c29229005176216dc38d1773");
var buffer = Java.array('byte', jsBytes);
var inputStr = string.$new(buffer);
var test = Utils.bbbbb("kanxue", inputStr);
console.log("Src ->",test);
public class main {
static String bbbbb(String key, String input) {
int len = 256;
char[] k = new char[len];
char[] S = new char[len];
int i;
for(i = 0; i < len; ++i) {
k[i] = key.charAt(i % key.length());
S[i] = ((char)i);
}
i = 0;
int j;
for(j = 0; j < len; ++j) {
i = S[j] + i + k[j] & 0xFF;
char tmp = S[j];
S[j] = S[i];
S[i] = tmp;
}
len = 0;
i = 0;
String v4_1 = "";
int t;
for(t = 0; t < input.length(); ++t) {
len = len + 1 & 0xFF;
char v6 = S[len];
i = i + v6 & 0xFF;
char v7 = ((char)(S[i] + v6 & 0xFF));
S[len] = S[i];
S[i] = v6;
try {
v4_1 = v4_1 + new String(new char[]{((char)(input.charAt(t) ^ S[v7]))});
}
catch(Exception v8) {
v8.printStackTrace();
}
}
return v4_1;
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
public static void main(String[] args) {
String hex = "c3bfc29fc3b3c3a335c2a803c294c38c4c670ac39cc3a6c29229005176216dc38d1773";
byte[] bytes_input = hexStringToByteArray(hex);
String result = bbbbb("kanxue",new String(bytes_input));
System.out.println(result);
/*
byte[] bytes = result.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(String.format("%02x", bytes[i] & 0xff));
}*/
}
}

后记

看雪ID:Simp1er
https://bbs.pediy.com/user-home-715334.htm

# 往期推荐


球分享

球点赞

球在看

点击“阅读原文”,了解更多!
[广告]赞助链接:
关注数据与安全,洞悉企业级服务市场:https://www.ijiandao.com/
让资讯触达的更精准有趣:https://www.0xu.cn/

随时掌握互联网精彩
- 自增id和uuid的优劣 为什么要用自增ID
- Lemon8再次APP Store霸榜,或作为TikTok在美国的替代方案
- 高通推出面向下一代可穿戴设备的骁龙W5+和骁龙W5平台,实现全面跃升
- 【今天 14 点】又拍云联合腾讯云、Flyfish、轻流,带你走进低代码
- 华为邀UNESCO和教育领袖畅谈数字人才建设
- 维持原判,链家程序员删除9TB数据二审判7年;AirPods或将换用USB-C接口;马斯克被推特指责违反保密协议|极客头条
- 小编疯了吗?这次“愚”快的活动,Switch、Airpods 任性送
- 在Z|禾赛科技(高至60w/年)诚招信息安全审计、数据安全经理等人才
- 数据安全“暴增”2450.04%后,中孚信息凭什么做“领军企业”?
- Objective-C 之父 Brad Cox 逝世,创建过乐队、推动苹果软件生态
- 剑指云内存数据库,阿里云在下一盘大棋
- 由于根证书故障 Let's Encrypt证书转换将在2021年发生问题
赞助链接