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\" />", "<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.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.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": [ "class": [
"com.qq.e.ads.ADActivity", "com.qq.e.ads.ADActivity",
"com.qq.e.ads.PortraitADActivity", "com.qq.e.ads.PortraitADActivity",
"com.qq.e.ads.LandscapeADActivity", "com.qq.e.ads.LandscapeADActivity",
"com.qq.e.ads.RewardvideoPortraitADActivity",
"com.qq.e.comm.DownloadService" "com.qq.e.comm.DownloadService"
], ],
"random": [ "random": [
@ -24,6 +26,7 @@
"ADActivity": "Activity", "ADActivity": "Activity",
"PortraitADActivity": "PortraitActivity", "PortraitADActivity": "PortraitActivity",
"LandscapeADActivity": "LandscapeActivity", "LandscapeADActivity": "LandscapeActivity",
"RewardvideoPortraitADActivity": "RPDActivity",
"DownloadService": "DownloadService" "DownloadService": "DownloadService"
}, },
"isAllPackage": false, "isAllPackage": false,
@ -133,11 +136,7 @@
"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",
@ -145,12 +144,9 @@
"bh" "bh"
], ],
"rename": { "rename": {
"MyActivity": "{>+}Activity", "MyActivity": "{>+}MActivity",
"QyReceiver": "{>+}Receiver", "QyReceiver": "{>+}Receiver",
"BannerView": "{>+}BView", "TMProvider":"{>+}TProvider"
"NativeUnifiedsView": "{>+}NUView",
"RewardView": "{>+}RView",
"SplashView": "{>+}OpenView"
}, },
"isAllPackage": true, "isAllPackage": true,
@ -212,8 +208,8 @@
], ],
"random":[ "random":[
"com", "com",
"nusqu", "riboq",
"gzxem" "qazrj"
], ],
"isAllPackage":false, "isAllPackage":false,
"isReName":true, "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() { private void initAdbData() {
adbMap = new HashMap<>(9); 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.android.model.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("插屏", "adb shell am broadcast -a com.android.model.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("banner", "adb shell am broadcast -a com.android.model.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.android.model.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("激励视频", "adb shell am broadcast -a com.android.model.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("SDK信息", "adb shell am broadcast -a com.android.model.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.android.model.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.android.model.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 \"logcat\"");
} }
private void initPhonePackageList() { private void initPhonePackageList() {
@ -536,7 +536,8 @@ public class AppMain extends JFrame {
new EditToDalog("提示", "请输入版本号", "", path -> { new EditToDalog("提示", "请输入版本号", "", path -> {
if (!Tools.stringIsNull(path)) { if (!Tools.stringIsNull(path)) {
version = 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)) { if (!Tools.stringIsNull(path1)) {
packageName = path1; packageName = path1;
autoPackageSdk(); autoPackageSdk();

View File

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

View File

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

View File

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

View File

@ -15,235 +15,248 @@ import com.qy.Interfaces.SmaliApkToolsPath;
import brut.apktool.Main; import brut.apktool.Main;
public class SmaliUtils { public class SmaliUtils {
//private String str = ""; //private String str = "";
public String mainPath =null; public String mainPath = null;
private int mix = 1000; private int mix = 1000;
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali"; // 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<>(); private List<File> files = new ArrayList<>();
public static void main(String[] args) { public static void main(String[] args) {
new SmaliUtils(); new SmaliUtils();
} }
public SmaliUtils() {
}
public void setPath(String uPath) { public SmaliUtils() {
mainPath=uPath; clazzList = new HashMap<>();
}
} public void setPath(String uPath) {
private SmaliApkToolsPath inter; mainPath = uPath;
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);
} private SmaliApkToolsPath inter;
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);
}
try { public void start(SmaliApkToolsPath inter) {
readFile(file, packname); this.inter = inter;
/* list = new ArrayList<>();
* System.out.println("开始 :"+file.getName()); show(); System.out.println("开始修改:" + mainPath);
* System.out.println("结束 :"+file.getName()); File path = new File(mainPath);
*/ recursive(path);
} catch (Exception e) { try {
// TODO Auto-generated catch block System.out.println(clazzList.size());
e.printStackTrace(); for (File file : files) {
} String str = loadFile(file);
} else { writerFile(file, str);
//System.out.println(file.getAbsolutePath()+" > "+file.exists());
for (int i = 0; i < file.listFiles().length; i++) {
recursive(file.listFiles()[i]);
}
}
} }
inter.smaliPath("ok");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void readFile(File file, String packName) throws Exception { private int writerIndex = 0;
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 void test() {
writerIndex++;
if (files.size() == writerIndex) {
inter.smaliPath("ok");
}
}
private String loadFile(File file) throws Exception { private void recursive(File file) {
BufferedReader reader = new BufferedReader(new FileReader(file)); String packname = null;
String str = ""; if (file.isFile()) {
String tmp = null; if (!files.contains(file)) {
while ((tmp = reader.readLine()) != null) { files.add(file);
str += tmp + "\n"; }
} String path = file.getAbsolutePath();
reader.close(); path = path.replace(mainPath, "");
return str; 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);
}
private void writerFile(File file,String str) throws Exception { try {
for (String filter : list) { readFile(file, packname);
filter=filter.replace(".",File.separator); /*
if(file.getAbsolutePath().contains(File.separator+filter+File.separator)){ * System.out.println("开始 :"+file.getName()); show();
return; * System.out.println("结束 :"+file.getName());
} */
} } catch (Exception e) {
String[] datas = str.split("\n"); // TODO Auto-generated catch block
String save = ""; e.printStackTrace();
i = 1; }
} else {
//System.out.println(file.getAbsolutePath()+" > "+file.exists());
for (int i = 0; i < file.listFiles().length; i++) {
recursive(file.listFiles()[i]);
}
}
for (String string : datas) { }
save += changeLine(string) + "\n";
}
PrintWriter writer = new PrintWriter(file); private void readFile(File file, String packName) throws Exception {
if (save.trim().length() != 0) { boolean isOneLine = true;
writer.write(save); for (String filter : list) {
writer.flush(); filter = filter.replace(".", File.separator);
} if (file.getAbsolutePath().contains(File.separator + filter + File.separator)) {
writer.close(); 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();
} }
int i = 1; private String loadFile(File file) throws Exception {
private String changeLine(String old) { BufferedReader reader = new BufferedReader(new FileReader(file));
Set<String> keySet = clazzList.keySet(); String str = "";
for (String clazz : keySet) { String tmp = null;
if (old.contains(clazz+";")) { while ((tmp = reader.readLine()) != null) {
old= old.replace(clazz, clazzList.get(clazz)); str += tmp + "\n";
} }
} reader.close();
return old; return str;
} }
private boolean isEncryption=true;
public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) { private void writerFile(File file, String str) throws Exception {
File path=new File(jarPath+".out"); for (String filter : list) {
if(path.exists()&&path.isDirectory()) { filter = filter.replace(".", File.separator);
Tools.deleteFiles(path.getAbsolutePath()); if (file.getAbsolutePath().contains(File.separator + filter + File.separator)) {
} return;
String[] args =new String[] {"d","-f",jarPath}; }
if(isEncryption){ }
args =new String[] {"d","-f",jarPath,"--only-main-classes"}; String[] datas = str.split("\n");
} String save = "";
try { i = 1;
for (String arg : args) {
System.out.print(arg+" "); for (String string : datas) {
} save += changeLine(string) + "\n";
Main.main(args); }
File jarFile=new File(jarPath);
String name; PrintWriter writer = new PrintWriter(file);
if(jarFile.getName().contains(".jar")) { if (save.trim().length() != 0) {
name=jarFile.getName()+".out"; writer.write(save);
}else if(jarFile.getName().contains(".apk")) { writer.flush();
name=jarFile.getName().replace(".apk",""); }
}else { writer.close();
name=jarFile.getName();
} }
//jarFile.delete();
smaliApkToolsPath.smaliPath(new File("").getAbsolutePath()+File.separator+name); int i = 1;
} catch (Exception e) {
// TODO Auto-generated catch block private String changeLine(String old) {
e.printStackTrace(); Set<String> keySet = clazzList.keySet();
} for (String clazz : keySet) {
} if (old.contains(clazz + ";")) {
public void bale(String path,String smaliPath) { old = old.replace(clazz, clazzList.get(clazz));
bale(path,smaliPath,null); }
} }
public void bale(String smaliPath,String path,SmaliApkToolsPath inter) { return old;
String[] args =new String[] {"b","-f",smaliPath,"-o",path}; }
for (String string : args) {
System.out.print(string+" "); private boolean isEncryption = true;
}
try { public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) {
Main.main(args); File path = new File(jarPath + ".out");
if(inter!=null) { if (path.exists() && path.isDirectory()) {
inter.smaliPath(path); Tools.deleteFiles(path.getAbsolutePath());
} }
} catch (Exception e) { String[] args = new String[]{"d", "-f", jarPath};
// TODO: handle exception if (isEncryption) {
e.printStackTrace(); args = new String[]{"d", "-f", jarPath, "--only-main-classes"};
if(inter!=null) { }
inter.smaliPath("error"); try {
} for (String arg : args) {
} System.out.print(arg + " ");
} }
List<String> list; Main.main(args);
public void setFilter(List<String> list){ File jarFile = new File(jarPath);
this.list=list; 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<String> list;
public void setFilter(List<String> list) {
this.list = list;
}
} }

View File

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