新增对壳所有字符串加密的操作(还没做UI)
This commit is contained in:
@@ -20,7 +20,7 @@ public class AESTools {
|
||||
|
||||
|
||||
/**
|
||||
* <EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>д16<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* 字节数组转化为大写16进制字符串
|
||||
*
|
||||
* @param b
|
||||
* @return
|
||||
@@ -40,7 +40,7 @@ public class AESTools {
|
||||
}
|
||||
|
||||
/**
|
||||
* 16<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 16进制字符串转字节数组
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
@@ -59,12 +59,12 @@ public class AESTools {
|
||||
|
||||
|
||||
/**
|
||||
* AES <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* AES 加密
|
||||
*
|
||||
* @param content
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 明文
|
||||
* @param password
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>Ĺؼ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* 生成秘钥的关键字
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -76,22 +76,9 @@ public class AESTools {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
|
||||
byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
|
||||
|
||||
// return Base64.encode(encryptedData);
|
||||
return byte2HexStr(encryptedData);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// return Base64.encode(encryptedData);
|
||||
return byte2HexStr(encryptedData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -99,19 +86,19 @@ public class AESTools {
|
||||
}
|
||||
|
||||
/**
|
||||
* AES <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* AES 解密
|
||||
*
|
||||
* @param content
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 密文
|
||||
* @param password
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>Ĺؼ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* 生成秘钥的关键字
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static String aesDecrypt(String content, String password) {
|
||||
try {
|
||||
// byte[] byteMi = Base64.decode(content);
|
||||
byte[] byteMi= str2ByteArray(content);
|
||||
byte[] byteMi= str2ByteArray(content);
|
||||
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
|
||||
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.json.JSONObject;
|
||||
import sun.applet.Main;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -16,6 +17,10 @@ public class AutoPackageSDK {
|
||||
private String packageName;
|
||||
File gdtsdk, uniplaysdk, qysdk;
|
||||
|
||||
private AutoPackageSDK() {
|
||||
|
||||
}
|
||||
|
||||
public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) {
|
||||
this.version = version;
|
||||
this.packageName = packageName;
|
||||
@@ -79,18 +84,19 @@ public class AutoPackageSDK {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
System.out.println("打包完成:" + path);
|
||||
delete(gdtPath,gdtsdk);
|
||||
delete(unplayPath,uniplaysdk);
|
||||
delete(qysdkPath,qysdk);
|
||||
delete(gdtPath, gdtsdk);
|
||||
delete(unplayPath, uniplaysdk);
|
||||
delete(qysdkPath, qysdk);
|
||||
outAssetsADS(path);
|
||||
copy();
|
||||
File sdk=zip();
|
||||
File sdk = zip();
|
||||
System.out.println("制作SDK完成:");
|
||||
inter.smaliPath(sdk==null?"sdk打包失败":sdk.getAbsolutePath());
|
||||
inter.smaliPath(sdk == null ? "sdk打包失败" : sdk.getAbsolutePath());
|
||||
}
|
||||
private void delete(File path,File sdk){
|
||||
|
||||
private void delete(File path, File sdk) {
|
||||
for (File file : path.listFiles()) {
|
||||
if(!file.getName().equals(sdk.getName())){
|
||||
if (!file.getName().equals(sdk.getName())) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
@@ -176,50 +182,56 @@ public class AutoPackageSDK {
|
||||
str.append(tmp.replace("{packagename}", packageName)).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
FileWriter writer = new FileWriter(manifest);
|
||||
writer.write(str.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
byte[] uft8bom = {(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
|
||||
OutputStream os = new FileOutputStream(manifest);
|
||||
|
||||
OutputStreamWriter outputStream = new OutputStreamWriter(os, StandardCharsets.UTF_8);
|
||||
outputStream.write(new String(str.toString().getBytes(), StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private File zip(File file) throws Exception {
|
||||
String cd = "cd " + new File("packageSDK").getAbsolutePath();
|
||||
File sdk = new File("packageSDK" + File.separator + "sdk.aar");
|
||||
File files=new File("packageSDK");
|
||||
String aapt=new File("aapt.exe").exists()?new File("aapt.exe").getAbsolutePath():"aapt";
|
||||
File files = new File("packageSDK");
|
||||
String aapt = new File("aapt.exe").exists() ? new File("aapt.exe").getAbsolutePath() : "aapt";
|
||||
for (File listFile : file.listFiles()) {
|
||||
if(listFile.isDirectory()){
|
||||
if (listFile.isDirectory()) {
|
||||
zip(listFile);
|
||||
}else if(!listFile.getName().equals("sdk.aar")){
|
||||
String path=listFile.getAbsolutePath().replace(files.getAbsolutePath(),"");
|
||||
String exec=aapt+" r "+sdk.getAbsolutePath()+" "+path.substring(1)+"\n";
|
||||
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec);
|
||||
} else if (!listFile.getName().equals("sdk.aar")) {
|
||||
String path = listFile.getAbsolutePath().replace(files.getAbsolutePath(), "");
|
||||
String exec = aapt + " r " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
|
||||
Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
|
||||
Thread.sleep(100);
|
||||
exec =aapt+ " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
|
||||
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec);
|
||||
exec = aapt + " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
|
||||
Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
}
|
||||
return sdk;
|
||||
}
|
||||
|
||||
private File zip() {
|
||||
File sdk=null;
|
||||
File sdk = null;
|
||||
try {
|
||||
Tools.copyFile(new File("input" + File.separator + "Documents" + File.separator + "sdk.aar").getAbsolutePath(),
|
||||
new File("packageSDK").getAbsolutePath(), true);
|
||||
String cd = "cd " + new File("packageSDK").getAbsolutePath() + "\n\r";
|
||||
Process process=Runtime.getRuntime().exec(new String[]{"cmd"});
|
||||
OutputStream stream =process.getOutputStream();
|
||||
Process process = Runtime.getRuntime().exec(new String[]{"cmd"});
|
||||
OutputStream stream = process.getOutputStream();
|
||||
stream.write(cd.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
process.destroy();
|
||||
sdk=zip(new File("packageSDK"));
|
||||
File copy=new File("packageSDK"+File.separator+"copy");
|
||||
if(copy.exists()){
|
||||
sdk = zip(new File("packageSDK"));
|
||||
File copy = new File("packageSDK" + File.separator + "copy");
|
||||
if (copy.exists()) {
|
||||
zip(copy);
|
||||
}
|
||||
stream.close();
|
||||
@@ -230,24 +242,37 @@ public class AutoPackageSDK {
|
||||
}
|
||||
return sdk;
|
||||
}
|
||||
private void copy(){
|
||||
try{
|
||||
File copyPath=new File("input"+File.separator+"Documents"+File.separator+"copy");
|
||||
if(copyPath.exists()){
|
||||
Tools.copyFile(copyPath.getAbsolutePath(),new File("packageSDK").getAbsolutePath(),true);
|
||||
|
||||
private void copy() {
|
||||
try {
|
||||
File copyPath = new File("input" + File.separator + "Documents" + File.separator + "copy");
|
||||
if (copyPath.exists()) {
|
||||
Tools.copyFile(copyPath.getAbsolutePath(), new File("packageSDK").getAbsolutePath(), true);
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int a=1;
|
||||
new AutoPackageSDK(new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
//com.tanggttaxc.langtt.mi
|
||||
System.out.println(">"+path);
|
||||
int[] nums = new int[]{-1,-1,-1,1,-1,-1};
|
||||
for (int j = 1; j < nums.length; j++) {
|
||||
int index =j;
|
||||
int tmp = 0;
|
||||
int tmp2 = 0;
|
||||
for (int i = 0; i < index; i++) {
|
||||
tmp += nums[i];
|
||||
}
|
||||
}, "5800", a==0?"com.luckyboy.mmxing":"com.prujwk.jdyphn");
|
||||
for (int i = index + 1; i < nums.length; i++) {
|
||||
tmp2 += nums[i];
|
||||
}
|
||||
System.out.println(tmp);
|
||||
System.out.println(tmp2);
|
||||
if (tmp == tmp2) {
|
||||
System.out.println("return:" + index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("return:" + -1);
|
||||
}
|
||||
}
|
||||
|
||||
161
src/com/qy/utils/AutoPackageSDKMust.java
Normal file
161
src/com/qy/utils/AutoPackageSDKMust.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.qy.utils;
|
||||
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AutoPackageSDKMust {
|
||||
private String key;
|
||||
private SmaliApkToolsPath path;
|
||||
private JSONObject config;
|
||||
private String sdkCode = " String RDCpplictPath=Decode.getData(\"RDCpplictPath\");";
|
||||
|
||||
private AutoPackageSDKMust(String key, SmaliApkToolsPath path) {
|
||||
this.key = key;
|
||||
this.path = path;
|
||||
config = Tools.loadConfig(new File("config.cfg"));
|
||||
start();
|
||||
}
|
||||
|
||||
public static void start(String key, SmaliApkToolsPath path) {
|
||||
new AutoPackageSDKMust(key, path);
|
||||
}
|
||||
|
||||
private void start() {
|
||||
if (true) {
|
||||
copySDK();
|
||||
File sdk_src = new File("sdk_src" + File.separator + "sdk" + File.separator + "src" + File.separator + "main" + File.separator + "java");
|
||||
loadFile(sdk_src);
|
||||
path.smaliPath(packageSDK());
|
||||
} else {
|
||||
System.out.println(encrypt(sdkCode));
|
||||
System.out.println(AESTools.aesDecrypt("655312476E8F4F12A72E1AB1C3CF8032", key));
|
||||
}
|
||||
}
|
||||
|
||||
private void copySDK() {
|
||||
File sdkPath = new File(config.getString("sdkPath"));
|
||||
if (!sdkPath.exists()) {
|
||||
path.smaliPath(null);
|
||||
return;
|
||||
}
|
||||
File sdk_src = new File("sdk_src");
|
||||
sdk_src.mkdirs();
|
||||
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "build.gradle", sdk_src.getAbsolutePath() + File.separator, true);
|
||||
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "gradlew", sdk_src.getAbsolutePath() + File.separator, true);
|
||||
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "gradlew.bat", sdk_src.getAbsolutePath() + File.separator, true);
|
||||
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "settings.gradle", sdk_src.getAbsolutePath() + File.separator, true);
|
||||
Tools.copyFile(sdkPath.getAbsolutePath() + File.separator + "local.properties", sdk_src.getAbsolutePath() + File.separator, true);
|
||||
try {
|
||||
BufferedReader reader;
|
||||
Process process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "gradle " + sdk_src.getAbsolutePath() + File.separator + "gradle /E /I /Y");
|
||||
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
while (reader.readLine() != null) ;
|
||||
reader.close();
|
||||
process = Runtime.getRuntime().exec("xcopy " + sdkPath.getAbsolutePath() + File.separator + "sdk " + sdk_src.getAbsolutePath() + File.separator + "sdk /E /I /Y");
|
||||
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
while (reader.readLine() != null) ;
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("复制完全");
|
||||
}
|
||||
|
||||
private void loadFile(File path) {
|
||||
for (File file : path.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
loadFile(file);
|
||||
} else if (file.getName().endsWith(".java")) {
|
||||
if (!file.getName().equals("Decode.java")) {
|
||||
loadCode(file);
|
||||
} else {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String tmp = null;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
if (tmp.contains("String key=")) {
|
||||
tmp = tmp.replace("\"\"", "\"" + key + "\"");
|
||||
}
|
||||
builder.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCode(File java) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(java));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String tmp = null;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
tmp = encrypt(tmp);
|
||||
builder.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
FileWriter writer = new FileWriter(java);
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String encrypt(String tmp) {
|
||||
Pattern pattern = Pattern.compile("\\\"([^\\\"]*)\\\"");
|
||||
Matcher matcher = pattern.matcher(tmp);
|
||||
while (matcher.find()) {
|
||||
String code = tmp.substring(matcher.start(), matcher.end());
|
||||
String encrypt = AESTools.aesEncrypt(code.replace("\"", ""), key);
|
||||
if (encrypt != null) {
|
||||
tmp = tmp.replace(code, "$#&" + encrypt + "$#&");
|
||||
}
|
||||
matcher = pattern.matcher(tmp);
|
||||
}
|
||||
tmp = tmp.replace("$#&", "\"");
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private String packageSDK() {
|
||||
File sdk_src = new File("sdk_src");
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(sdk_src.getAbsolutePath() + File.separator + "gradlew.bat assembleRelease -p " + sdk_src.getAbsolutePath() + File.separator + "sdk");//打包sdk
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
System.out.println(tmp);
|
||||
}
|
||||
process.waitFor();
|
||||
reader.close();
|
||||
return sdk_src.getAbsolutePath() + File.separator + "sdk" + File.separator + "build" + File.separator
|
||||
+ "intermediates" + File.separator + "aar_main_jar" + File.separator + "release" + File.separator + "classes.jar";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
start("eZMpiVponpIUV5VO", new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
System.out.println("over=" + path);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,15 @@ public class Tools {
|
||||
String exec="java -jar "+dx+" --dex --output="+outName+" "+inName+"";
|
||||
System.out.println("java to dex:"+exec);
|
||||
Process process=Runtime.getRuntime().exec(exec);
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
System.out.println("read");
|
||||
String tmp=reader.readLine();
|
||||
while (tmp!=null){
|
||||
System.out.println(tmp);
|
||||
tmp=reader.readLine();
|
||||
}
|
||||
process.waitFor();
|
||||
System.out.println("打包完成");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user