新增对壳所有字符串加密的操作(还没做UI)

This commit is contained in:
Yutousama 2020-05-29 17:31:53 +08:00
parent 572a74f97a
commit 85eec17ee6
6 changed files with 306 additions and 73 deletions

View File

@ -133,7 +133,11 @@
"class": [ "class": [
"com.qy.sdk.views.MyActivity", "com.qy.sdk.views.MyActivity",
"com.qy.sdk_rx.listeners.QyReceiver", "com.qy.sdk_rx.listeners.QyReceiver",
"com.qy.sdk.TMProvider" "com.qy.sdk.TMProvider",
"com.qy.sdk.rds.BannerView",
"com.qy.sdk.rds.NativeUnifiedsView",
"com.qy.sdk.rds.RewardView",
"com.qy.sdk.rds.SplashView"
], ],
"random": [ "random": [
"com", "com",
@ -143,7 +147,11 @@
"rename": { "rename": {
"MyActivity": "{>+}Activity", "MyActivity": "{>+}Activity",
"QyReceiver": "{>+}Receiver", "QyReceiver": "{>+}Receiver",
"TMProvider": "TProvider" "BannerView": "{>+}BView",
"NativeUnifiedsView": "{>+}NUView",
"RewardView": "{>+}RView",
"SplashView": "{>+}OpenView"
}, },
"isAllPackage": true, "isAllPackage": true,
"regexPackage":".qy", "regexPackage":".qy",
@ -204,8 +212,8 @@
], ],
"random":[ "random":[
"com", "com",
"prujwk", "nusqu",
"jdyphn", "gzxem"
], ],
"isAllPackage":false, "isAllPackage":false,
"isReName":true, "isReName":true,
@ -223,17 +231,17 @@
},{ },{
"class":"com.bytedance.embedapplog.util.TTEncryptUtils", "class":"com.bytedance.embedapplog.util.TTEncryptUtils",
"find":"const-string v0, \"tobEmbedEncrypt\"", "find":"const-string v0, \"tobEmbedEncrypt\"",
"data":"const-string v0, \"tob\"\n", "data":"const-string v0, \"ttb\"\n",
"end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V" "end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V"
},{ },{
"class":"com.pgl.sys.ces.a", "class":"com.pgl.sys.ces.a",
"find":"const-string v0, \"nms\"", "find":"const-string v0, \"nms\"",
"data":"const-string v0, \"hms\"\n", "data":"const-string v0, \"ees\"\n",
"end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V" "end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V"
},{ },{
"class":"com.pgl.sys.ces.b", "class":"com.pgl.sys.ces.b",
"find":"const-string p1, \"nms\"", "find":"const-string p1, \"nms\"",
"data":"const-string p1, \"hms\"\n", "data":"const-string p1, \"ees\"\n",
"end":"invoke-static {p0, p1}, Lcom/pgl/a/b/e;->a(Landroid/content/Context;Ljava/lang/String;)Z" "end":"invoke-static {p0, p1}, Lcom/pgl/a/b/e;->a(Landroid/content/Context;Ljava/lang/String;)Z"
} }
], ],
@ -269,6 +277,49 @@
"com.androidx" "com.androidx"
] ]
} },
{
"title": "百青藤",
"ltName": "bsb",
"manifest": [
"<activity android:name=\"com.baidu.mobads.AppActivity\" android:configChanges=\"screenSize|keyboard|keyboardHidden|orientation\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" />",
"<activity android:name=\"com.baidu.mobads.production.rewardvideo.MobRewardVideoActivity\" android:configChanges=\"screenSize|orientation|keyboardHidden\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" > </activity>"
],
"class": [
"com.baidu.mobads.AppActivity",
"com.baidu.mobads.production.rewardvideo.MobRewardVideoActivity",
"com.baidu.mobads.AppActivityImp"
],
"random": [
"com",
"nusqu",
"gzxem",
"bsb"
],
"rename": {
"AppActivity": "MyActivity",
"MobRewardVideoActivity":"MyRewardVideoActivity",
"AppActivityImp":"MyActivityImp"
},
"isAllPackage": false,
"isReName": true,
"isJarLib": false,
"packagerlimit": 3,
"isManual": true,
"dex2jar": "D:\\反编译\\dex2jar-2.0\\_d2j-dex2jar.bat",
"manual": [
{
"class":"com.baidu.mobads.utils.r",
"find":"const-string v1, \".bd.provider\"",
"data":"const-string v1, \".fileprovider\"\n",
"end":"invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;"
},{
"class":"com.baidu.mobads.utils.r",
"find":"invoke-static {p0, v0, p1}, Lcom/baidu/mobads/openad/BdFileProvider;->getUriForFile(Landroid/content/Context;Ljava/lang/String;Ljava/io/File;)Landroid/net/Uri;",
"data":"invoke-static {p0, v0, p1}, Landroid/support/v4/content/FileProvider;->getUriForFile(Landroid/content/Context;Ljava/lang/String;Ljava/io/File;)Landroid/net/Uri;\n",
"end":":try_end_0"
}
]
},
] ]
} }

View File

@ -40,5 +40,6 @@
} }
] ]
} }
} },
"sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5"
} }

View File

@ -20,7 +20,7 @@ public class AESTools {
/** /**
* 字节数组转化为大写16进制字符串 * 字节数组转化为大写16进制字符串
* *
* @param b * @param b
* @return * @return
@ -40,7 +40,7 @@ public class AESTools {
} }
/** /**
* 16进制字符串转字节数组 * 16进制字符串转字节数组
* *
* @param s * @param s
* @return * @return
@ -59,12 +59,12 @@ public class AESTools {
/** /**
* AES 加密 * AES 加密
* *
* @param content * @param content
* 明文 * 明文
* @param password * @param password
* 生成秘钥的关键字 * 生成秘钥的关键字
* @return * @return
*/ */
@ -76,22 +76,9 @@ public class AESTools {
cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv); cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
byte[] encryptedData = cipher.doFinal(content.getBytes(bm)); byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
// return Base64.encode(encryptedData); // return Base64.encode(encryptedData);
return byte2HexStr(encryptedData); return byte2HexStr(encryptedData);
} catch (NoSuchAlgorithmException e) { } catch (Exception 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
e.printStackTrace(); e.printStackTrace();
} }
@ -99,19 +86,19 @@ public class AESTools {
} }
/** /**
* AES 解密 * AES 解密
* *
* @param content * @param content
* 密文 * 密文
* @param password * @param password
* 生成秘钥的关键字 * 生成秘钥的关键字
* @return * @return
*/ */
public static String aesDecrypt(String content, String password) { public static String aesDecrypt(String content, String password) {
try { try {
// byte[] byteMi = Base64.decode(content); // byte[] byteMi = Base64.decode(content);
byte[] byteMi= str2ByteArray(content); byte[] byteMi= str2ByteArray(content);
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes()); IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES"); SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

View File

@ -6,6 +6,7 @@ import org.json.JSONObject;
import sun.applet.Main; import sun.applet.Main;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Objects; import java.util.Objects;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -16,6 +17,10 @@ public class AutoPackageSDK {
private String packageName; private String packageName;
File gdtsdk, uniplaysdk, qysdk; File gdtsdk, uniplaysdk, qysdk;
private AutoPackageSDK() {
}
public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) { public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) {
this.version = version; this.version = version;
this.packageName = packageName; this.packageName = packageName;
@ -79,18 +84,19 @@ public class AutoPackageSDK {
@Override @Override
public void smaliPath(String path) { public void smaliPath(String path) {
System.out.println("打包完成:" + path); System.out.println("打包完成:" + path);
delete(gdtPath,gdtsdk); delete(gdtPath, gdtsdk);
delete(unplayPath,uniplaysdk); delete(unplayPath, uniplaysdk);
delete(qysdkPath,qysdk); delete(qysdkPath, qysdk);
outAssetsADS(path); outAssetsADS(path);
copy(); copy();
File sdk=zip(); File sdk = zip();
System.out.println("制作SDK完成:"); 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()) { for (File file : path.listFiles()) {
if(!file.getName().equals(sdk.getName())){ if (!file.getName().equals(sdk.getName())) {
file.delete(); file.delete();
} }
} }
@ -176,50 +182,56 @@ public class AutoPackageSDK {
str.append(tmp.replace("{packagename}", packageName)).append("\n"); str.append(tmp.replace("{packagename}", packageName)).append("\n");
} }
reader.close(); reader.close();
FileWriter writer = new FileWriter(manifest); byte[] uft8bom = {(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
writer.write(str.toString()); OutputStream os = new FileOutputStream(manifest);
writer.flush();
writer.close(); 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) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private File zip(File file) throws Exception { private File zip(File file) throws Exception {
String cd = "cd " + new File("packageSDK").getAbsolutePath(); String cd = "cd " + new File("packageSDK").getAbsolutePath();
File sdk = new File("packageSDK" + File.separator + "sdk.aar"); File sdk = new File("packageSDK" + File.separator + "sdk.aar");
File files=new File("packageSDK"); File files = new File("packageSDK");
String aapt=new File("aapt.exe").exists()?new File("aapt.exe").getAbsolutePath():"aapt"; String aapt = new File("aapt.exe").exists() ? new File("aapt.exe").getAbsolutePath() : "aapt";
for (File listFile : file.listFiles()) { for (File listFile : file.listFiles()) {
if(listFile.isDirectory()){ if (listFile.isDirectory()) {
zip(listFile); zip(listFile);
}else if(!listFile.getName().equals("sdk.aar")){ } else if (!listFile.getName().equals("sdk.aar")) {
String path=listFile.getAbsolutePath().replace(files.getAbsolutePath(),""); String path = listFile.getAbsolutePath().replace(files.getAbsolutePath(), "");
String exec=aapt+" r "+sdk.getAbsolutePath()+" "+path.substring(1)+"\n"; String exec = aapt + " r " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec); Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
Thread.sleep(100); Thread.sleep(100);
exec =aapt+ " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n"; exec = aapt + " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec); Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
Thread.sleep(100); Thread.sleep(100);
} }
} }
return sdk; return sdk;
} }
private File zip() { private File zip() {
File sdk=null; File sdk = null;
try { try {
Tools.copyFile(new File("input" + File.separator + "Documents" + File.separator + "sdk.aar").getAbsolutePath(), Tools.copyFile(new File("input" + File.separator + "Documents" + File.separator + "sdk.aar").getAbsolutePath(),
new File("packageSDK").getAbsolutePath(), true); new File("packageSDK").getAbsolutePath(), true);
String cd = "cd " + new File("packageSDK").getAbsolutePath() + "\n\r"; String cd = "cd " + new File("packageSDK").getAbsolutePath() + "\n\r";
Process process=Runtime.getRuntime().exec(new String[]{"cmd"}); Process process = Runtime.getRuntime().exec(new String[]{"cmd"});
OutputStream stream =process.getOutputStream(); OutputStream stream = process.getOutputStream();
stream.write(cd.getBytes()); stream.write(cd.getBytes());
stream.flush(); stream.flush();
stream.close(); stream.close();
process.destroy(); process.destroy();
sdk=zip(new File("packageSDK")); sdk = zip(new File("packageSDK"));
File copy=new File("packageSDK"+File.separator+"copy"); File copy = new File("packageSDK" + File.separator + "copy");
if(copy.exists()){ if (copy.exists()) {
zip(copy); zip(copy);
} }
stream.close(); stream.close();
@ -230,24 +242,37 @@ public class AutoPackageSDK {
} }
return sdk; return sdk;
} }
private void copy(){
try{ private void copy() {
File copyPath=new File("input"+File.separator+"Documents"+File.separator+"copy"); try {
if(copyPath.exists()){ File copyPath = new File("input" + File.separator + "Documents" + File.separator + "copy");
Tools.copyFile(copyPath.getAbsolutePath(),new File("packageSDK").getAbsolutePath(),true); if (copyPath.exists()) {
Tools.copyFile(copyPath.getAbsolutePath(), new File("packageSDK").getAbsolutePath(), true);
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
int a=1; int[] nums = new int[]{-1,-1,-1,1,-1,-1};
new AutoPackageSDK(new SmaliApkToolsPath() { for (int j = 1; j < nums.length; j++) {
@Override int index =j;
public void smaliPath(String path) { int tmp = 0;
//com.tanggttaxc.langtt.mi int tmp2 = 0;
System.out.println(">"+path); 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);
} }
} }

View 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);
}
});
}
}

View File

@ -298,7 +298,15 @@ public class Tools {
String exec="java -jar "+dx+" --dex --output="+outName+" "+inName+""; String exec="java -jar "+dx+" --dex --output="+outName+" "+inName+"";
System.out.println("java to dex:"+exec); System.out.println("java to dex:"+exec);
Process process=Runtime.getRuntime().exec(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(); process.waitFor();
System.out.println("打包完成");
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();