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) {
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 SmaliUtils() {
inter.smaliPath("ok"); clazzList = new HashMap<>();
} 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 setPath(String uPath) {
readFile(file, packname); mainPath = uPath;
/* }
* 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]);
}
}
} private SmaliApkToolsPath inter;
private void readFile(File file, String packName) throws Exception { public void start(SmaliApkToolsPath inter) {
boolean isOneLine = true; this.inter = inter;
for (String filter : list) { list = new ArrayList<>();
filter=filter.replace(".",File.separator); System.out.println("开始修改:" + mainPath);
if(file.getAbsolutePath().contains(File.separator+filter+File.separator)){ File path = new File(mainPath);
return; recursive(path);
} try {
} System.out.println(clazzList.size());
BufferedReader reader = new BufferedReader(new FileReader(file)); for (File file : files) {
//String str = ""; String str = loadFile(file);
String tmp = null; writerFile(file, str);
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();
} }
inter.smaliPath("ok");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String loadFile(File file) throws Exception { private int writerIndex = 0;
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 { private void test() {
for (String filter : list) { writerIndex++;
filter=filter.replace(".",File.separator); if (files.size() == writerIndex) {
if(file.getAbsolutePath().contains(File.separator+filter+File.separator)){ inter.smaliPath("ok");
return; }
} }
}
String[] datas = str.split("\n");
String save = "";
i = 1;
for (String string : datas) { private void recursive(File file) {
save += changeLine(string) + "\n"; 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); try {
if (save.trim().length() != 0) { readFile(file, packname);
writer.write(save); /*
writer.flush(); * System.out.println("开始 :"+file.getName()); show();
} * System.out.println("结束 :"+file.getName());
writer.close(); */
} 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 void readFile(File file, String packName) throws Exception {
private String changeLine(String old) { boolean isOneLine = true;
Set<String> keySet = clazzList.keySet(); for (String filter : list) {
for (String clazz : keySet) { filter = filter.replace(".", File.separator);
if (old.contains(clazz+";")) { if (file.getAbsolutePath().contains(File.separator + filter + File.separator)) {
old= old.replace(clazz, clazzList.get(clazz)); return;
} }
} }
return old; BufferedReader reader = new BufferedReader(new FileReader(file));
} //String str = "";
private boolean isEncryption=true; String tmp = null;
public void unPack(String jarPath, SmaliApkToolsPath smaliApkToolsPath) { while ((tmp = reader.readLine()) != null) {
File path=new File(jarPath+".out"); if (isOneLine) {
if(path.exists()&&path.isDirectory()) { String newName = null;
Tools.deleteFiles(path.getAbsolutePath()); if (tmp.contains(".class public L")) {
} newName = tmp.replace(".class public L", "");
String[] args =new String[] {"d","-f",jarPath}; } else if (tmp.contains(".class public interface abstract L")) {
if(isEncryption){ newName = tmp.replace(".class public interface abstract L", "");
args =new String[] {"d","-f",jarPath,"--only-main-classes"}; } else if (tmp.contains(".class public final enum L")) {
} newName = tmp.replace(".class public final enum L", "");
try { } else if (tmp.contains(".class public abstract L")) {
for (String arg : args) { newName = tmp.replace(".class public abstract L", "");
System.out.print(arg+" "); } else if (tmp.contains(".class public final L")) {
} newName = tmp.replace(".class public final L", "");
Main.main(args); } else if (tmp.contains(".class final L")) {
File jarFile=new File(jarPath); newName = tmp.replace(".class final L", "");
String name; } else if (tmp.contains(".class L")) {
if(jarFile.getName().contains(".jar")) { newName = tmp.replace(".class L", "");
name=jarFile.getName()+".out"; } else if (tmp.contains(".class synthetic L")) {
}else if(jarFile.getName().contains(".apk")) { newName = tmp.replace(".class synthetic L", "");
name=jarFile.getName().replace(".apk",""); } else if (tmp.contains(".class final enum L")) {
}else { newName = tmp.replace(".class final enum L", "");
name=jarFile.getName(); }
} if (newName != null) {
//jarFile.delete(); newName = newName.replace(";", "");
smaliApkToolsPath.smaliPath(new File("").getAbsolutePath()+File.separator+name); //System.out.println("获取到老包名:" + newName + "新包名:" + (packName + "/" + file.getName().replace(".smali", "")));
} catch (Exception e) { clazzList.put(newName, (packName + "/" + file.getName()
// TODO Auto-generated catch block .replace(".smali", "")
e.printStackTrace(); .replace("#", "")));
} if (clazzList.get(newName).length() < mix) {
} mix = clazzList.get(newName).length();
public void bale(String path,String smaliPath) { }
bale(path,smaliPath,null); }
} isOneLine = false;
public void bale(String smaliPath,String path,SmaliApkToolsPath inter) { }
String[] args =new String[] {"b","-f",smaliPath,"-o",path}; // tmp = changeLine(tmp);
for (String string : args) { // str += tmp + "\n";
System.out.print(string+" "); }
} reader.close();
try {
Main.main(args); }
if(inter!=null) {
inter.smaliPath(path); private String loadFile(File file) throws Exception {
} BufferedReader reader = new BufferedReader(new FileReader(file));
} catch (Exception e) { String str = "";
// TODO: handle exception String tmp = null;
e.printStackTrace(); while ((tmp = reader.readLine()) != null) {
if(inter!=null) { str += tmp + "\n";
inter.smaliPath("error"); }
} reader.close();
} return str;
} }
List<String> list;
public void setFilter(List<String> list){ private void writerFile(File file, String str) throws Exception {
this.list=list; 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<String> 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<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());