apktool改为动态加载形式
打包使用2.3.4版本,拆包使用2.4.1版本
This commit is contained in:
parent
c8a82d2ba8
commit
ca4518724a
BIN
libs/apktool_2.3.4.jar
Normal file
BIN
libs/apktool_2.3.4.jar
Normal file
Binary file not shown.
@ -3,8 +3,8 @@ package com.qy.ui;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import com.qy.utils.ApkSignTools;
|
import com.qy.utils.ApkSignTools;
|
||||||
|
import com.qy.utils.StringUtils;
|
||||||
import com.qy.utils.Tools;
|
import com.qy.utils.Tools;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
@ -50,7 +50,7 @@ public class AppMain extends JFrame {
|
|||||||
private JMenuItem mntmBase;
|
private JMenuItem mntmBase;
|
||||||
|
|
||||||
private static String cscPath = null;
|
private static String cscPath = null;
|
||||||
private static String savePath=null;
|
private static String savePath = null;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
/*args = new String[]{"-package=com.test.abc"
|
/*args = new String[]{"-package=com.test.abc"
|
||||||
@ -69,7 +69,7 @@ public class AppMain extends JFrame {
|
|||||||
String model = "csj";
|
String model = "csj";
|
||||||
String jarPath = null;
|
String jarPath = null;
|
||||||
String jarType = null;
|
String jarType = null;
|
||||||
String config=null;
|
String config = null;
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
@ -101,11 +101,11 @@ public class AppMain extends JFrame {
|
|||||||
if (arg.startsWith("-index")) {
|
if (arg.startsWith("-index")) {
|
||||||
index = Integer.parseInt(arg.replace("-index=", "").trim());
|
index = Integer.parseInt(arg.replace("-index=", "").trim());
|
||||||
}
|
}
|
||||||
if(arg.startsWith("-save")){
|
if (arg.startsWith("-save")) {
|
||||||
savePath= arg.replace("-save=", "");
|
savePath = arg.replace("-save=", "");
|
||||||
}
|
}
|
||||||
if(arg.startsWith("-config")){
|
if (arg.startsWith("-config")) {
|
||||||
config=arg.replace("-config=", "");
|
config = arg.replace("-config=", "");
|
||||||
}
|
}
|
||||||
if (arg.trim().equals("-h")) {
|
if (arg.trim().equals("-h")) {
|
||||||
outHelp();
|
outHelp();
|
||||||
@ -114,7 +114,7 @@ public class AppMain extends JFrame {
|
|||||||
}
|
}
|
||||||
if (model.equals("csj")) {
|
if (model.equals("csj")) {
|
||||||
if (packageName != null && version != null && apkPath != null && csjPath != null) {
|
if (packageName != null && version != null && apkPath != null && csjPath != null) {
|
||||||
new CsjTools(apkPath, csjPath, packageName, version,config, new SmaliApkToolsPath() {
|
new CsjTools(apkPath, csjPath, packageName, version, config, new SmaliApkToolsPath() {
|
||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
if (cscPath != null) {
|
if (cscPath != null) {
|
||||||
@ -140,7 +140,7 @@ public class AppMain extends JFrame {
|
|||||||
new File(path).renameTo(new File(savePath));
|
new File(path).renameTo(new File(savePath));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else if(model.equals("sdk")){
|
} else if (model.equals("sdk")) {
|
||||||
new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName);
|
new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ public class AppMain extends JFrame {
|
|||||||
"\n-csc csc save Path csc保存路径" +
|
"\n-csc csc save Path csc保存路径" +
|
||||||
"\n-jar adsdk.jar path 需要被修改的sdk路径" +
|
"\n-jar adsdk.jar path 需要被修改的sdk路径" +
|
||||||
"\n-type sdk type sdk类型" +
|
"\n-type sdk type sdk类型" +
|
||||||
"\n-index ad_config.cfg index 在ad_config.cfg配置中的array下标"+
|
"\n-index ad_config.cfg index 在ad_config.cfg配置中的array下标" +
|
||||||
"\n-save save jar path 保存jar的路径"
|
"\n-save save jar path 保存jar的路径"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -198,7 +198,8 @@ public class AppMain extends JFrame {
|
|||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
String tmp;
|
String tmp;
|
||||||
while ((tmp = reader.readLine()) != null) {
|
while ((tmp = reader.readLine()) != null) {
|
||||||
phonePackageList.add(tmp.substring(8));
|
if (!StringUtils.isEmpty(tmp))
|
||||||
|
phonePackageList.add(tmp.substring(8));
|
||||||
}
|
}
|
||||||
Collections.sort(phonePackageList);
|
Collections.sort(phonePackageList);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -223,7 +224,7 @@ public class AppMain extends JFrame {
|
|||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setTitle("\u8F6C\u6362\u5668v2.2");
|
setTitle("\u8F6C\u6362\u5668v2.3");
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
setSize(900, 456);
|
setSize(900, 456);
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
@ -657,7 +658,7 @@ public class AppMain extends JFrame {
|
|||||||
autoOutApk.addActionListener(new ActionListener() {
|
autoOutApk.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
new AutoOutAPKUi();
|
new AutoOutAPKUi();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(autoOutApk);
|
menu.add(autoOutApk);
|
||||||
|
@ -4,8 +4,8 @@ import com.qy.Interfaces.DialogInterface;
|
|||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
import com.qy.utils.ApkSignTools;
|
import com.qy.utils.ApkSignTools;
|
||||||
import com.qy.utils.AutoOutAPKTools;
|
import com.qy.utils.AutoOutAPKTools;
|
||||||
|
import com.qy.utils.StringUtils;
|
||||||
import com.qy.utils.Tools;
|
import com.qy.utils.Tools;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -20,7 +20,7 @@ import com.qy.Interfaces.DialogInterface;
|
|||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
import com.qy.utils.ApkSignTools;
|
import com.qy.utils.ApkSignTools;
|
||||||
import com.qy.utils.SmaliUtils;
|
import com.qy.utils.SmaliUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import com.qy.utils.StringUtils;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class SmaliUi extends JFrame {
|
public class SmaliUi extends JFrame {
|
||||||
@ -95,7 +95,7 @@ public class SmaliUi extends JFrame {
|
|||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.3");
|
setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.4");
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
setSize(900, 673);
|
setSize(900, 673);
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
|
@ -38,6 +38,7 @@ public class ApkSignTools {
|
|||||||
System.out.println(tmp);
|
System.out.println(tmp);
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
process.destroy();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -34,6 +34,7 @@ public class AutoOutAPKTools {
|
|||||||
outLog("复制游戏文件夹");
|
outLog("复制游戏文件夹");
|
||||||
String newAppPath=appPath+"_"+gameId+"_"+Tools.getRandomString(6);
|
String newAppPath=appPath+"_"+gameId+"_"+Tools.getRandomString(6);
|
||||||
Tools.copy_dir(appPath,newAppPath);
|
Tools.copy_dir(appPath,newAppPath);
|
||||||
|
String oldPath=appPath;
|
||||||
outLog("游戏游戏文件夹复制完成");
|
outLog("游戏游戏文件夹复制完成");
|
||||||
appPath=newAppPath;
|
appPath=newAppPath;
|
||||||
outLog("修改Manifest");
|
outLog("修改Manifest");
|
||||||
@ -41,10 +42,10 @@ public class AutoOutAPKTools {
|
|||||||
outLog("Manifest修改完成,开始生成assets");
|
outLog("Manifest修改完成,开始生成assets");
|
||||||
outAssets();
|
outAssets();
|
||||||
outLog("生成完毕");
|
outLog("生成完毕");
|
||||||
new SmaliUtils().bale(appPath, appPath + File.separator + "game_.apk", new SmaliApkToolsPath() {
|
new SmaliUtils().bale(appPath, appPath + File.separator + new File(oldPath).getName()+gameId, new SmaliApkToolsPath() {
|
||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
inter.smaliPath(appPath + File.separator + "game_.apk");
|
inter.smaliPath(appPath + File.separator + new File(oldPath).getName()+gameId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.qy.utils;
|
package com.qy.utils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -8,15 +10,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import brut.androlib.Androlib;
|
|
||||||
import brut.androlib.res.xml.ResXmlPatcher;
|
|
||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
|
|
||||||
import brut.apktool.Main;
|
|
||||||
import com.qy.ui.TextToDialog;
|
import com.qy.ui.TextToDialog;
|
||||||
import com.sun.javaws.exceptions.ExitException;
|
import com.sun.javaws.exceptions.ExitException;
|
||||||
|
|
||||||
@ -27,6 +23,9 @@ public class SmaliUtils {
|
|||||||
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
|
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
|
||||||
private Map<String, String> clazzList;
|
private Map<String, String> clazzList;
|
||||||
private List<File> files = new ArrayList<>();
|
private List<File> files = new ArrayList<>();
|
||||||
|
private static ClassLoader apktool_234;
|
||||||
|
private static ClassLoader apktool_241;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SmaliUtils();
|
new SmaliUtils();
|
||||||
@ -34,6 +33,17 @@ public class SmaliUtils {
|
|||||||
|
|
||||||
public SmaliUtils() {
|
public SmaliUtils() {
|
||||||
clazzList = new HashMap<>();
|
clazzList = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if(apktool_234==null){
|
||||||
|
apktool_234=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.3.4.jar")});
|
||||||
|
}
|
||||||
|
if(apktool_241==null){
|
||||||
|
apktool_241=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.4.1.jar")});
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPath(String uPath) {
|
public void setPath(String uPath) {
|
||||||
@ -219,7 +229,9 @@ public class SmaliUtils {
|
|||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
System.out.print(arg + " ");
|
System.out.print(arg + " ");
|
||||||
}
|
}
|
||||||
Main.main(args);
|
System.out.println("\n");
|
||||||
|
//Main.main(args);
|
||||||
|
apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
||||||
File jarFile = new File(jarPath);
|
File jarFile = new File(jarPath);
|
||||||
String name;
|
String name;
|
||||||
if (jarFile.getName().contains(".jar")) {
|
if (jarFile.getName().contains(".jar")) {
|
||||||
@ -246,7 +258,7 @@ public class SmaliUtils {
|
|||||||
public boolean run = false;
|
public boolean run = false;
|
||||||
public static StringBuffer error=new StringBuffer();
|
public static StringBuffer error=new StringBuffer();
|
||||||
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
|
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
|
||||||
String[] args = new String[]{"b", "-f", smaliPath, "-o", path};
|
String[] args = new String[]{"-r","b", "-f", smaliPath, "-o", path};
|
||||||
for (String string : args) {
|
for (String string : args) {
|
||||||
System.out.print(string + " ");
|
System.out.print(string + " ");
|
||||||
}
|
}
|
||||||
@ -269,15 +281,17 @@ public class SmaliUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.setErr(old);
|
System.setErr(old);
|
||||||
|
outputStream.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
System.setSecurityManager(new NoExitSecurityManager());
|
//System.setSecurityManager(new NoExitSecurityManager());
|
||||||
|
|
||||||
Main.main(args);
|
//Main.main(args);
|
||||||
|
apktool_234.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
||||||
if (inter != null) {
|
if (inter != null) {
|
||||||
inter.smaliPath(path);
|
inter.smaliPath(path);
|
||||||
}
|
}
|
||||||
|
10
src/com/qy/utils/StringUtils.java
Normal file
10
src/com/qy/utils/StringUtils.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.qy.utils;
|
||||||
|
|
||||||
|
public class StringUtils {
|
||||||
|
public static boolean isEmpty(String str) {
|
||||||
|
if(str==null||str.trim().length()==0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -196,10 +196,10 @@ public class Tools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FileWriter writer=new FileWriter(file);
|
OutputStream outputStream=new FileOutputStream(file);
|
||||||
writer.write(data);
|
outputStream.write(new String(data.getBytes(),StandardCharsets.UTF_8).getBytes());
|
||||||
writer.flush();
|
outputStream.flush();
|
||||||
writer.close();
|
outputStream.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user