diff --git a/ad_config.cfg b/ad_config.cfg
index 87783db..f70524b 100644
--- a/ad_config.cfg
+++ b/ad_config.cfg
@@ -7,12 +7,14 @@
"",
"",
"",
- ""
+ "",
+ ""
],
"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,
diff --git a/config.cfg b/config.cfg
index 0cf3182..d1fa4b1 100755
--- a/config.cfg
+++ b/config.cfg
@@ -41,5 +41,6 @@
]
}
},
- "sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5"
+ "sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5",
+ "csjPackageName":"com.riboq.qazrj"
}
\ No newline at end of file
diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java
index 9b626a6..ed9db1b 100755
--- a/src/com/qy/ui/AppMain.java
+++ b/src/com/qy/ui/AppMain.java
@@ -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();
diff --git a/src/com/qy/utils/AutoPackageSDK.java b/src/com/qy/utils/AutoPackageSDK.java
index ae49436..a04c03f 100644
--- a/src/com/qy/utils/AutoPackageSDK.java
+++ b/src/com/qy/utils/AutoPackageSDK.java
@@ -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++) {
diff --git a/src/com/qy/utils/AutoPackageSDKMust.java b/src/com/qy/utils/AutoPackageSDKMust.java
index 8dac912..b63e5bb 100644
--- a/src/com/qy/utils/AutoPackageSDKMust.java
+++ b/src/com/qy/utils/AutoPackageSDKMust.java
@@ -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")) {
diff --git a/src/com/qy/utils/CsjTools.java b/src/com/qy/utils/CsjTools.java
index 5f74842..9d00a9a 100644
--- a/src/com/qy/utils/CsjTools.java
+++ b/src/com/qy/utils/CsjTools.java
@@ -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() {
- @Override
- public void smaliPath(String path) {
- System.out.println("打包完成:"+path);
- }
- });
+ 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);
+ tools.out(log.replace("已出包", ""),
+ new File("csj").getAbsolutePath() + File.separator + "csc",
+ Integer.parseInt(path));
+ }
+ });
+ }
+ }
+ });
+
+ // tools.outManifest();
+ // tools.start();
}
}
diff --git a/src/com/qy/utils/SmaliUtils.java b/src/com/qy/utils/SmaliUtils.java
index 6e1fc0f..bc2ed68 100755
--- a/src/com/qy/utils/SmaliUtils.java
+++ b/src/com/qy/utils/SmaliUtils.java
@@ -15,235 +15,248 @@ import com.qy.Interfaces.SmaliApkToolsPath;
import brut.apktool.Main;
public class SmaliUtils {
- //private String str = "";
- public String mainPath =null;
- private int mix = 1000;
- // private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
- private Map clazzList = new HashMap<>();
- private List files = new ArrayList<>();
+ //private String str = "";
+ public String mainPath = null;
+ private int mix = 1000;
+ // private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
+ private Map clazzList;
+ private List files = new ArrayList<>();
- public static void main(String[] args) {
- new SmaliUtils();
- }
- public SmaliUtils() {
- }
-
- public void setPath(String uPath) {
- mainPath=uPath;
-
- }
- private SmaliApkToolsPath inter;
- public void start(SmaliApkToolsPath inter) {
- 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);
+ public static void main(String[] args) {
+ new SmaliUtils();
+ }
- }
- inter.smaliPath("ok");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private int writerIndex=0;
- private void test(){
- writerIndex++;
- if(files.size()==writerIndex){
- inter.smaliPath("ok");
- }
- }
- private void recursive(File file) {
- String packname = null;
- if (file.isFile()) {
- if (!files.contains(file)) {
- files.add(file);
- }
- String path = file.getAbsolutePath();
- path = path.replace(mainPath, "");
- path = path.replace(file.getName(), "");
- if(path.substring(0, 1).equals("/")||path.substring(0, 1).equals("\\")) {
- packname = path.replace("\\", "/").substring(1, path.length() - 1);
- }else {
- packname = path.replace("\\", "/").substring(0, path.length() - 1);
- }
+ public SmaliUtils() {
+ clazzList = new HashMap<>();
+ }
- try {
- readFile(file, packname);
- /*
- * System.out.println("开始 :"+file.getName()); show();
- * System.out.println("结束 :"+file.getName());
- */
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- //System.out.println(file.getAbsolutePath()+" > "+file.exists());
- for (int i = 0; i < file.listFiles().length; i++) {
- recursive(file.listFiles()[i]);
- }
- }
+ public void setPath(String uPath) {
+ mainPath = uPath;
+ }
- }
+ private SmaliApkToolsPath inter;
- 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)){
- return;
- }
- }
- BufferedReader reader = new BufferedReader(new FileReader(file));
- //String str = "";
- String tmp = null;
- while ((tmp = reader.readLine()) != null) {
- if (isOneLine) {
- String newName = null;
- if (tmp.contains(".class public L")) {
- newName = tmp.replace(".class public L", "");
- } else if (tmp.contains(".class public interface abstract L")) {
- newName = tmp.replace(".class public interface abstract L", "");
- } else if (tmp.contains(".class public final enum L")) {
- newName = tmp.replace(".class public final enum L", "");
- } else if (tmp.contains(".class public abstract L")) {
- newName = tmp.replace(".class public abstract L", "");
- } else if (tmp.contains(".class public final L")) {
- newName = tmp.replace(".class public final L", "");
- } else if (tmp.contains(".class final L")) {
- newName = tmp.replace(".class final L", "");
- } else if (tmp.contains(".class L")) {
- 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","");
- }
- if (newName != null) {
- newName = newName.replace(";", "");
- //System.out.println("获取到老包名:" + newName + "新包名:" + (packName + "/" + file.getName().replace(".smali", "")));
- clazzList.put(newName, (packName + "/"+ file.getName()
- .replace(".smali", "")
- .replace("#","")));
- if (clazzList.get(newName).length() < mix) {
- mix = clazzList.get(newName).length();
- }
- }
- isOneLine = false;
- }
- // tmp = changeLine(tmp);
- // str += tmp + "\n";
- }
- reader.close();
+ public void start(SmaliApkToolsPath inter) {
+ 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);
- }
+ }
+ inter.smaliPath("ok");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- private String loadFile(File file) throws Exception {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String str = "";
- String tmp = null;
- while ((tmp = reader.readLine()) != null) {
- str += tmp + "\n";
- }
- reader.close();
- return str;
- }
+ private int writerIndex = 0;
- 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)){
- return;
- }
- }
- String[] datas = str.split("\n");
- String save = "";
- i = 1;
+ private void test() {
+ writerIndex++;
+ if (files.size() == writerIndex) {
+ inter.smaliPath("ok");
+ }
+ }
- for (String string : datas) {
- save += changeLine(string) + "\n";
- }
+ private void recursive(File file) {
+ String packname = null;
+ if (file.isFile()) {
+ if (!files.contains(file)) {
+ files.add(file);
+ }
+ String path = file.getAbsolutePath();
+ path = path.replace(mainPath, "");
+ path = path.replace(file.getName(), "");
+ if (path.substring(0, 1).equals("/") || path.substring(0, 1).equals("\\")) {
+ packname = path.replace("\\", "/").substring(1, path.length() - 1);
+ } else {
+ packname = path.replace("\\", "/").substring(0, path.length() - 1);
+ }
- PrintWriter writer = new PrintWriter(file);
- if (save.trim().length() != 0) {
- writer.write(save);
- writer.flush();
- }
- writer.close();
+ try {
+ readFile(file, packname);
+ /*
+ * System.out.println("开始 :"+file.getName()); show();
+ * System.out.println("结束 :"+file.getName());
+ */
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+ //System.out.println(file.getAbsolutePath()+" > "+file.exists());
+ for (int i = 0; i < file.listFiles().length; i++) {
+ recursive(file.listFiles()[i]);
+ }
+ }
- }
+ }
- int i = 1;
- private String changeLine(String old) {
- Set keySet = clazzList.keySet();
- for (String clazz : keySet) {
- if (old.contains(clazz+";")) {
- old= old.replace(clazz, clazzList.get(clazz));
- }
- }
- return old;
- }
- private boolean isEncryption=true;
- public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) {
- 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"};
- }
- try {
- for (String arg : args) {
- System.out.print(arg+" ");
- }
- Main.main(args);
- 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();
- }
- //jarFile.delete();
- 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 smaliPath,String path,SmaliApkToolsPath inter) {
- String[] args =new String[] {"b","-f",smaliPath,"-o",path};
- for (String string : args) {
- System.out.print(string+" ");
- }
- try {
- Main.main(args);
- if(inter!=null) {
- inter.smaliPath(path);
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- if(inter!=null) {
- inter.smaliPath("error");
- }
- }
- }
- List list;
- public void setFilter(List list){
- this.list=list;
- }
+ 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)) {
+ return;
+ }
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ //String str = "";
+ String tmp = null;
+ while ((tmp = reader.readLine()) != null) {
+ if (isOneLine) {
+ String newName = null;
+ if (tmp.contains(".class public L")) {
+ newName = tmp.replace(".class public L", "");
+ } else if (tmp.contains(".class public interface abstract L")) {
+ newName = tmp.replace(".class public interface abstract L", "");
+ } else if (tmp.contains(".class public final enum L")) {
+ newName = tmp.replace(".class public final enum L", "");
+ } else if (tmp.contains(".class public abstract L")) {
+ newName = tmp.replace(".class public abstract L", "");
+ } else if (tmp.contains(".class public final L")) {
+ newName = tmp.replace(".class public final L", "");
+ } else if (tmp.contains(".class final L")) {
+ newName = tmp.replace(".class final L", "");
+ } else if (tmp.contains(".class L")) {
+ 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", "");
+ }
+ if (newName != null) {
+ newName = newName.replace(";", "");
+ //System.out.println("获取到老包名:" + newName + "新包名:" + (packName + "/" + file.getName().replace(".smali", "")));
+ clazzList.put(newName, (packName + "/" + file.getName()
+ .replace(".smali", "")
+ .replace("#", "")));
+ if (clazzList.get(newName).length() < mix) {
+ mix = clazzList.get(newName).length();
+ }
+ }
+ isOneLine = false;
+ }
+ // tmp = changeLine(tmp);
+ // str += tmp + "\n";
+ }
+ reader.close();
+
+ }
+
+ private String loadFile(File file) throws Exception {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String str = "";
+ String tmp = null;
+ while ((tmp = reader.readLine()) != null) {
+ str += tmp + "\n";
+ }
+ reader.close();
+ return str;
+ }
+
+ 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)) {
+ return;
+ }
+ }
+ String[] datas = str.split("\n");
+ String save = "";
+ i = 1;
+
+ for (String string : datas) {
+ save += changeLine(string) + "\n";
+ }
+
+ PrintWriter writer = new PrintWriter(file);
+ if (save.trim().length() != 0) {
+ writer.write(save);
+ writer.flush();
+ }
+ writer.close();
+
+ }
+
+ int i = 1;
+
+ private String changeLine(String old) {
+ Set keySet = clazzList.keySet();
+ for (String clazz : keySet) {
+ if (old.contains(clazz + ";")) {
+ old = old.replace(clazz, clazzList.get(clazz));
+ }
+ }
+ return old;
+ }
+
+ private boolean isEncryption = true;
+
+ public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) {
+ 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"};
+ }
+ try {
+ for (String arg : args) {
+ System.out.print(arg + " ");
+ }
+ Main.main(args);
+ 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();
+ }
+ //jarFile.delete();
+ 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 smaliPath, String path, SmaliApkToolsPath inter) {
+ String[] args = new String[]{"b", "-f", smaliPath, "-o", path};
+ for (String string : args) {
+ System.out.print(string + " ");
+ }
+ try {
+ Main.main(args);
+ if (inter != null) {
+ inter.smaliPath(path);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ if (inter != null) {
+ inter.smaliPath("error");
+ }
+ }
+ }
+
+ List list;
+
+ public void setFilter(List list) {
+ this.list = list;
+ }
}
diff --git a/src/com/qy/utils/Tools.java b/src/com/qy/utils/Tools.java
index f8aca60..a63a8cd 100755
--- a/src/com/qy/utils/Tools.java
+++ b/src/com/qy/utils/Tools.java
@@ -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());