This commit is contained in:
Yutousama 2020-06-03 09:41:10 +08:00
parent 9c41ab000b
commit afe1407825
8 changed files with 328 additions and 264 deletions

View File

@ -7,12 +7,14 @@
"<service android:name=\"com.qq.e.comm.DownloadService\" android:exported=\"false\" />",
"<activity android:name=\"com.qq.e.ads.ADActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
"<activity android:name=\"com.qq.e.ads.PortraitADActivity\" android:screenOrientation=\"portrait\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
"<activity android:name=\"com.qq.e.ads.LandscapeADActivity\" android:screenOrientation=\"landscape\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />"
"<activity android:name=\"com.qq.e.ads.LandscapeADActivity\" android:screenOrientation=\"landscape\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
"<activity android:name=\"com.qq.e.ads.RewardvideoPortraitADActivity\" android:screenOrientation=\"landscape\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />"
],
"class": [
"com.qq.e.ads.ADActivity",
"com.qq.e.ads.PortraitADActivity",
"com.qq.e.ads.LandscapeADActivity",
"com.qq.e.ads.RewardvideoPortraitADActivity",
"com.qq.e.comm.DownloadService"
],
"random": [
@ -24,6 +26,7 @@
"ADActivity": "Activity",
"PortraitADActivity": "PortraitActivity",
"LandscapeADActivity": "LandscapeActivity",
"RewardvideoPortraitADActivity": "RPDActivity",
"DownloadService": "DownloadService"
},
"isAllPackage": false,
@ -133,11 +136,7 @@
"class": [
"com.qy.sdk.views.MyActivity",
"com.qy.sdk_rx.listeners.QyReceiver",
"com.qy.sdk.TMProvider",
"com.qy.sdk.rds.BannerView",
"com.qy.sdk.rds.NativeUnifiedsView",
"com.qy.sdk.rds.RewardView",
"com.qy.sdk.rds.SplashView"
"com.qy.sdk.TMProvider"
],
"random": [
"com",
@ -145,12 +144,9 @@
"bh"
],
"rename": {
"MyActivity": "{>+}Activity",
"MyActivity": "{>+}MActivity",
"QyReceiver": "{>+}Receiver",
"BannerView": "{>+}BView",
"NativeUnifiedsView": "{>+}NUView",
"RewardView": "{>+}RView",
"SplashView": "{>+}OpenView"
"TMProvider":"{>+}TProvider"
},
"isAllPackage": true,
@ -212,8 +208,8 @@
],
"random":[
"com",
"nusqu",
"gzxem"
"riboq",
"qazrj"
],
"isAllPackage":false,
"isReName":true,

View File

@ -41,5 +41,6 @@
]
}
},
"sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5"
"sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5",
"csjPackageName":"com.riboq.qazrj"
}

View File

@ -80,15 +80,15 @@ public class AppMain extends JFrame {
private void initAdbData() {
adbMap = new HashMap<>(9);
adbMap.put("开屏", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"open\"");
adbMap.put("插屏", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"inter\"");
adbMap.put("banner", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"banner\"");
adbMap.put("视频", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"video\"");
adbMap.put("激励视频", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"reward\"");
adbMap.put("SDK信息", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"systemTest\"");
adbMap.put("重载网络", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"reloadApi\"");
adbMap.put("获取广告参数", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"adBean\"");
adbMap.put("查看日志", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"logcat\"");
adbMap.put("开屏", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"open\"");
adbMap.put("插屏", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"inter\"");
adbMap.put("banner", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"banner\"");
adbMap.put("视频", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"video\"");
adbMap.put("激励视频", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"reward\"");
adbMap.put("SDK信息", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"systemTest\"");
adbMap.put("重载网络", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"reloadApi\"");
adbMap.put("获取广告参数", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"adBean\"");
adbMap.put("查看日志", "adb shell am broadcast -a com.android.model.debug --es package \"[packname]\" --es type \"logcat\"");
}
private void initPhonePackageList() {
@ -536,7 +536,8 @@ public class AppMain extends JFrame {
new EditToDalog("提示", "请输入版本号", "", path -> {
if (!Tools.stringIsNull(path)) {
version = path;
new EditToDalog("提示", "请输入包名", "com.prujwk.jdyphn", path1 -> {
packageName="com."+Tools.getRandomString(5).toLowerCase()+"."+ Tools.getRandomString(5).toLowerCase();
new EditToDalog("提示", "请输入包名", packageName, path1 -> {
if (!Tools.stringIsNull(path1)) {
packageName = path1;
autoPackageSdk();

View File

@ -15,18 +15,30 @@ public class AutoPackageSDK {
private AutoRandomAdSDK randomAdSDK;
private String version;
private String packageName;
File gdtsdk, uniplaysdk, qysdk;
private SmaliApkToolsPath inter;
File gdtsdk, uniplaysdk, qysdk,baiduSdk;
private AutoPackageSDK() {
}
public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) {
this.version = version;
this.packageName = packageName;
private void encryptSDK() {
AutoPackageSDKMust.start(Tools.getRandomString(16), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
if (path != null) {
Tools.copyFile(path, new File("input" + File.separator + "qySDK").getAbsolutePath(), true);
}
init();
}
});
}
private void init() {
File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator);
File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator);
File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator);
File baiduPath = new File("input" + File.separator + "baiduSDK" + File.separator);
if (!gdtPath.exists() || Objects.requireNonNull(gdtPath.listFiles()).length == 0) {
inter.smaliPath("广点通SDK不存在请放置到input" + File.separator + "gdtSDK文件夹中");
return;
@ -43,6 +55,12 @@ public class AutoPackageSDK {
}
qysdk = Objects.requireNonNull(qysdkPath.listFiles())[0];
if (!baiduPath.exists() || Objects.requireNonNull(baiduPath.listFiles()).length == 0) {
inter.smaliPath("百青藤SDK不存在请放置到input" + File.separator + "baiduSDK文件夹中");
return;
}
baiduSdk= Objects.requireNonNull(baiduPath.listFiles())[0];
JSONArray array = new JSONArray();
JSONObject gdt = new JSONObject();
@ -61,6 +79,14 @@ public class AutoPackageSDK {
unplay.put("packageName", packageName + ".up");
array.put(unplay);
JSONObject baidu = new JSONObject();
baidu.put("file", baiduSdk.getAbsolutePath());
baidu.put("version", version);
baidu.put("type", "2");
baidu.put("packageName", packageName + ".bsb");
baidu.put("index", 5);
array.put(baidu);
JSONObject qy = new JSONObject();
qy.put("file", qysdk.getAbsolutePath());
qy.put("version", version);
@ -102,8 +128,13 @@ public class AutoPackageSDK {
}
}
});
}
public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) {
this.version = version;
this.packageName = packageName;
this.inter=inter;
encryptSDK();
}
private void outAssetsQY(int index, String type) {
@ -255,9 +286,9 @@ public class AutoPackageSDK {
}
public static void main(String[] args) {
int[] nums = new int[]{-1,-1,-1,1,-1,-1};
int[] nums = new int[]{-1, -1, -1, 1, -1, -1};
for (int j = 1; j < nums.length; j++) {
int index =j;
int index = j;
int tmp = 0;
int tmp2 = 0;
for (int i = 0; i < index; i++) {

View File

@ -4,6 +4,7 @@ import com.qy.Interfaces.SmaliApkToolsPath;
import org.json.JSONObject;
import java.io.*;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -66,7 +67,7 @@ public class AutoPackageSDKMust {
}
private void loadFile(File path) {
for (File file : path.listFiles()) {
for (File file : Objects.requireNonNull(path.listFiles())) {
if (file.isDirectory()) {
loadFile(file);
} else if (file.getName().endsWith(".java")) {

View File

@ -1,6 +1,7 @@
package com.qy.utils;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.ui.EditToDalog;
import org.json.JSONArray;
import org.json.JSONObject;
@ -27,7 +28,7 @@ public class CsjTools {
@Override
public void smaliPath(String path) {
System.out.println(path);
if(path.startsWith("已出包")) {
if (path.startsWith("已出包")) {
out(path.replace("已出包", ""),
new File("csj").getAbsolutePath() + File.separator + "csc",
Integer.parseInt(version));
@ -100,7 +101,11 @@ public class CsjTools {
reader.close();
return getXMLValue("package", tmp);
} else {
return "com.prujwk.jdyphn";
if (packageName == null) {
return Tools.loadConfig(new File("config.cfg")).getString("csjPackageName");
} else {
return packageName;
}
}
} catch (Exception e) {
e.printStackTrace();
@ -128,6 +133,7 @@ public class CsjTools {
writer.write(manifest);
writer.flush();
writer.close();
reader.close();
} catch (Exception e) {
e.printStackTrace();
@ -254,6 +260,7 @@ public class CsjTools {
public void smaliPath(String path) {
_log.smaliPath("已出包" + csjRes.getAbsolutePath());
_log.smaliPath("耗时:" + (System.currentTimeMillis() - time) / 1000 + "");
System.gc();
}
});
@ -346,16 +353,30 @@ public class CsjTools {
//还有最后一个问题穿山甲的Activity没改
public static void main(String[] args) {
new CsjTools("C:\\Users\\58381\\Documents\\WeChat Files\\z583819556\\FileStorage\\File\\2020-04\\CasualGame-release.apk"
, "E:\\idea\\android_sdk_tools\\input\\csjDemo\\demo_2.9.0.0.apk"
, "com.abc.test"
, "5700"
, new SmaliApkToolsPath() {
CsjTools tools = new CsjTools();
tools.build("D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2.apk",
"D:\\IdeaProjects\\android_sdk_tools\\app-release.apk",
new SmaliApkToolsPath() {
@Override
public void smaliPath(String log) {
System.out.println(log);
if (log.startsWith("已出包")) {
System.out.println("打包完成");
new EditToDalog("成功", "打包完成,请输入版本号", "5600", new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
System.out.println("打包完成:"+path);
System.out.println(">>" + path);
tools.out(log.replace("已出包", ""),
new File("csj").getAbsolutePath() + File.separator + "csc",
Integer.parseInt(path));
}
});
}
}
});
// tools.outManifest();
// tools.start();
}
}

View File

@ -16,34 +16,37 @@ import brut.apktool.Main;
public class SmaliUtils {
//private String str = "";
public String mainPath =null;
public String mainPath = null;
private int mix = 1000;
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
private Map<String, String> clazzList = new HashMap<>();
private Map<String, String> clazzList;
private List<File> files = new ArrayList<>();
public static void main(String[] args) {
new SmaliUtils();
}
public SmaliUtils() {
clazzList = new HashMap<>();
}
public void setPath(String uPath) {
mainPath=uPath;
mainPath = uPath;
}
private SmaliApkToolsPath inter;
public void start(SmaliApkToolsPath inter) {
this.inter=inter;
list=new ArrayList<>();
System.out.println("开始修改:"+mainPath);
this.inter = inter;
list = new ArrayList<>();
System.out.println("开始修改:" + mainPath);
File path = new File(mainPath);
recursive(path);
try {
System.out.println(clazzList.size());
for (File file : files) {
String str = loadFile(file);
writerFile(file,str);
writerFile(file, str);
}
inter.smaliPath("ok");
@ -52,13 +55,16 @@ public class SmaliUtils {
e.printStackTrace();
}
}
private int writerIndex=0;
private void test(){
private int writerIndex = 0;
private void test() {
writerIndex++;
if(files.size()==writerIndex){
if (files.size() == writerIndex) {
inter.smaliPath("ok");
}
}
private void recursive(File file) {
String packname = null;
if (file.isFile()) {
@ -68,9 +74,9 @@ public class SmaliUtils {
String path = file.getAbsolutePath();
path = path.replace(mainPath, "");
path = path.replace(file.getName(), "");
if(path.substring(0, 1).equals("/")||path.substring(0, 1).equals("\\")) {
if (path.substring(0, 1).equals("/") || path.substring(0, 1).equals("\\")) {
packname = path.replace("\\", "/").substring(1, path.length() - 1);
}else {
} else {
packname = path.replace("\\", "/").substring(0, path.length() - 1);
}
@ -96,8 +102,8 @@ public class SmaliUtils {
private void readFile(File file, String packName) throws Exception {
boolean isOneLine = true;
for (String filter : list) {
filter=filter.replace(".",File.separator);
if(file.getAbsolutePath().contains(File.separator+filter+File.separator)){
filter = filter.replace(".", File.separator);
if (file.getAbsolutePath().contains(File.separator + filter + File.separator)) {
return;
}
}
@ -123,15 +129,15 @@ public class SmaliUtils {
newName = tmp.replace(".class L", "");
} else if (tmp.contains(".class synthetic L")) {
newName = tmp.replace(".class synthetic L", "");
} else if(tmp.contains(".class final enum L")){
newName=tmp.replace(".class final enum L","");
} else if (tmp.contains(".class final enum L")) {
newName = tmp.replace(".class final enum L", "");
}
if (newName != null) {
newName = newName.replace(";", "");
//System.out.println("获取到老包名:" + newName + "新包名:" + (packName + "/" + file.getName().replace(".smali", "")));
clazzList.put(newName, (packName + "/"+ file.getName()
clazzList.put(newName, (packName + "/" + file.getName()
.replace(".smali", "")
.replace("#","")));
.replace("#", "")));
if (clazzList.get(newName).length() < mix) {
mix = clazzList.get(newName).length();
}
@ -156,10 +162,10 @@ public class SmaliUtils {
return str;
}
private void writerFile(File file,String str) throws Exception {
private void writerFile(File file, String str) throws Exception {
for (String filter : list) {
filter=filter.replace(".",File.separator);
if(file.getAbsolutePath().contains(File.separator+filter+File.separator)){
filter = filter.replace(".", File.separator);
if (file.getAbsolutePath().contains(File.separator + filter + File.separator)) {
return;
}
}
@ -181,69 +187,76 @@ public class SmaliUtils {
}
int i = 1;
private String changeLine(String old) {
Set<String> keySet = clazzList.keySet();
for (String clazz : keySet) {
if (old.contains(clazz+";")) {
old= old.replace(clazz, clazzList.get(clazz));
if (old.contains(clazz + ";")) {
old = old.replace(clazz, clazzList.get(clazz));
}
}
return old;
}
private boolean isEncryption=true;
private boolean isEncryption = true;
public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) {
File path=new File(jarPath+".out");
if(path.exists()&&path.isDirectory()) {
File path = new File(jarPath + ".out");
if (path.exists() && path.isDirectory()) {
Tools.deleteFiles(path.getAbsolutePath());
}
String[] args =new String[] {"d","-f",jarPath};
if(isEncryption){
args =new String[] {"d","-f",jarPath,"--only-main-classes"};
String[] args = new String[]{"d", "-f", jarPath};
if (isEncryption) {
args = new String[]{"d", "-f", jarPath, "--only-main-classes"};
}
try {
for (String arg : args) {
System.out.print(arg+" ");
System.out.print(arg + " ");
}
Main.main(args);
File jarFile=new File(jarPath);
File jarFile = new File(jarPath);
String name;
if(jarFile.getName().contains(".jar")) {
name=jarFile.getName()+".out";
}else if(jarFile.getName().contains(".apk")) {
name=jarFile.getName().replace(".apk","");
}else {
name=jarFile.getName();
if (jarFile.getName().contains(".jar")) {
name = jarFile.getName() + ".out";
} else if (jarFile.getName().contains(".apk")) {
name = jarFile.getName().replace(".apk", "");
} else {
name = jarFile.getName();
}
//jarFile.delete();
smaliApkToolsPath.smaliPath(new File("").getAbsolutePath()+File.separator+name);
smaliApkToolsPath.smaliPath(new File("").getAbsolutePath() + File.separator + name);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void bale(String path,String smaliPath) {
bale(path,smaliPath,null);
public void bale(String path, String smaliPath) {
bale(path, smaliPath, null);
}
public void bale(String smaliPath,String path,SmaliApkToolsPath inter) {
String[] args =new String[] {"b","-f",smaliPath,"-o",path};
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
String[] args = new String[]{"b", "-f", smaliPath, "-o", path};
for (String string : args) {
System.out.print(string+" ");
System.out.print(string + " ");
}
try {
Main.main(args);
if(inter!=null) {
if (inter != null) {
inter.smaliPath(path);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
if(inter!=null) {
if (inter != null) {
inter.smaliPath("error");
}
}
}
List<String> list;
public void setFilter(List<String> list){
this.list=list;
public void setFilter(List<String> list) {
this.list = list;
}
}

View File

@ -55,7 +55,7 @@ public class Tools {
File srcFile = new File(srcFileName);
// 判断源文件是否存在
if (!srcFile.exists()) {
System.err.println("源文件不存在:"+srcFile.getAbsolutePath());
System.err.println("源文件不存在:"+srcFile.getAbsolutePath()+" > "+destFileName);
return false;
} else if (!srcFile.isFile()) {
System.err.println("源文件是目录:"+srcFile.getAbsolutePath());