update
This commit is contained in:
@@ -26,6 +26,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
public class AppMain extends JFrame {
|
||||
private JList<String> configList;
|
||||
@@ -55,6 +56,7 @@ public class AppMain extends JFrame {
|
||||
private JMenuItem mntmBase;
|
||||
|
||||
private static String cscPath = null;
|
||||
private static String savePath=null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*args = new String[]{"-package=com.test.abc"
|
||||
@@ -71,6 +73,11 @@ public class AppMain extends JFrame {
|
||||
String apkPath = null;
|
||||
String csjPath = null;
|
||||
String model = "csj";
|
||||
String jarPath = null;
|
||||
String jarType = null;
|
||||
String config=null;
|
||||
|
||||
int index = -1;
|
||||
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith("-package")) {
|
||||
@@ -91,6 +98,21 @@ public class AppMain extends JFrame {
|
||||
if (arg.startsWith("-model")) {
|
||||
model = arg.replace("-model=", "");
|
||||
}
|
||||
if (arg.startsWith("-jar")) {
|
||||
jarPath = arg.replace("-jar=", "");
|
||||
}
|
||||
if (arg.startsWith("-type")) {
|
||||
jarType = arg.replace("-type=", "");
|
||||
}
|
||||
if (arg.startsWith("-index")) {
|
||||
index = Integer.parseInt(arg.replace("-index=", "").trim());
|
||||
}
|
||||
if(arg.startsWith("-save")){
|
||||
savePath= arg.replace("-save=", "");
|
||||
}
|
||||
if(arg.startsWith("-config")){
|
||||
config=arg.replace("-config=", "");
|
||||
}
|
||||
if (arg.trim().equals("-h")) {
|
||||
outHelp();
|
||||
return;
|
||||
@@ -98,7 +120,7 @@ public class AppMain extends JFrame {
|
||||
}
|
||||
if (model.equals("csj")) {
|
||||
if (packageName != null && version != null && apkPath != null && csjPath != null) {
|
||||
new CsjTools(apkPath, csjPath, packageName, version, new SmaliApkToolsPath() {
|
||||
new CsjTools(apkPath, csjPath, packageName, version,config, new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
if (cscPath != null) {
|
||||
@@ -111,19 +133,35 @@ public class AppMain extends JFrame {
|
||||
} else {
|
||||
outHelp();
|
||||
}
|
||||
}else if(model.equals("sdk")){
|
||||
|
||||
} else if (model.equals("jar")) {
|
||||
System.out.println(jarPath);
|
||||
System.out.println(version);
|
||||
System.out.println(jarType);
|
||||
System.out.println(index);
|
||||
System.out.println(savePath);
|
||||
if (jarPath != null)
|
||||
new AutoRandomAdSDK(new File(jarPath), version, jarType, index, new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
new File(path).renameTo(new File(savePath));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void outHelp() {
|
||||
System.err.println("-package packageName " +
|
||||
"\n-version CsjVersion" +
|
||||
"\n-apk apkFilePath" +
|
||||
"\n-csj csjDemoApkFilePath" +
|
||||
"\n-csc csc save Path");
|
||||
System.err.println("-package packageName 包名" +
|
||||
"\n-version CsjVersion 打包穿山甲资源版本号" +
|
||||
"\n-apk apkFilePath 需要生产资源文件的apk路径" +
|
||||
"\n-csj csjDemoApkFilePath 穿山甲demo的路径" +
|
||||
"\n-csc csc save Path csc保存路径" +
|
||||
"\n-jar adsdk.jar path 需要被修改的sdk路径" +
|
||||
"\n-type sdk type sdk类型" +
|
||||
"\n-index ad_config.cfg index 在ad_config.cfg配置中的array下标"+
|
||||
"\n-save save jar path 保存jar的路径"
|
||||
);
|
||||
}
|
||||
|
||||
public AppMain() {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ChuanShanJiaUi {
|
||||
public void smaliPath(String path) {
|
||||
append(path);
|
||||
if(path.startsWith("已出包")) {
|
||||
new EditToDalog("成功", "打包完成,请输入版本号", "5600", new SmaliApkToolsPath() {
|
||||
new EditToDalog("成功", "打包完成,请输入版本号", "5801", new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String out) {
|
||||
System.out.println(">>" + out);
|
||||
@@ -96,7 +96,7 @@ public class ChuanShanJiaUi {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
JFrame frame = new JFrame("穿山甲资源包生成v1.0");
|
||||
JFrame frame = new JFrame("穿山甲资源包生成v1.1");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setContentPane(new ChuanShanJiaUi().mainPanel);
|
||||
frame.pack();
|
||||
|
||||
@@ -1,33 +1,55 @@
|
||||
package com.qy.ui;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import com.qy.utils.AutoRandomAdSDK;
|
||||
import com.qy.utils.SmaliUtils;
|
||||
import com.qy.utils.Tools;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class OneWayTools {
|
||||
private JSONObject config;
|
||||
private String home;
|
||||
private String packageName=null;
|
||||
private File sdk,core;
|
||||
public static void main(String[] args) {
|
||||
new OneWayTools(new File("OnewaySdk.jar"));
|
||||
}
|
||||
|
||||
|
||||
public OneWayTools(File onwsdk) {
|
||||
// TODO Auto-generated constructor stub
|
||||
start(onwsdk);
|
||||
config= Tools.loadConfig(new File("ad_config.cfg"));
|
||||
sdk=new File("Oneway-2.4.3-release.jar");
|
||||
JSONArray array=new JSONArray();
|
||||
JSONObject gdt = new JSONObject();
|
||||
gdt.put("file", "D:\\IDEA\\android_sdk_tools\\Oneway-2.4.3-release.jar");
|
||||
gdt.put("version", "5800");
|
||||
gdt.put("type", "11");
|
||||
gdt.put("index", 2);
|
||||
gdt.put("packageName", "com.riboq.qazrj.oo");
|
||||
array.put(gdt);
|
||||
new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
System.out.println(">>:!sdk:"+path);
|
||||
start(onwsdk);
|
||||
}
|
||||
});
|
||||
}
|
||||
File onejar;
|
||||
private void start(File onewayjar) {
|
||||
onejar=onewayjar;
|
||||
core=onewayjar;
|
||||
SmaliUtils smali = new SmaliUtils();
|
||||
smali.unPack(onewayjar.getAbsolutePath(), new SmaliApkToolsPath() {
|
||||
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
// TODO Auto-generated method stub
|
||||
home=path;
|
||||
update(path);
|
||||
|
||||
}
|
||||
@@ -38,7 +60,7 @@ public class OneWayTools {
|
||||
File activity = new File(path + File.separator + "smali" + File.separator + "mobi" + File.separator + "oneway"
|
||||
+ File.separator + "sdk" + File.separator + "port" + File.separator + "Unit.smali");
|
||||
File provider = new File(path + File.separator + "smali" + File.separator + "mobi" + File.separator + "oneway"
|
||||
+ File.separator + "sdk" + File.separator + "b" + File.separator + "c.smali");
|
||||
+ File.separator + "sdk" + File.separator + "c" + File.separator + "c.smali");
|
||||
if (!activity.exists()) {
|
||||
System.out.println(activity.getAbsolutePath());
|
||||
new TextToDalog("警告", "Unit.smali文件不存在!");
|
||||
@@ -49,14 +71,79 @@ public class OneWayTools {
|
||||
return;
|
||||
}
|
||||
|
||||
updateActivity(activity.getAbsolutePath());
|
||||
updateProvider(provider.getAbsolutePath());
|
||||
/*updateActivity(activity.getAbsolutePath());
|
||||
updateProvider(provider.getAbsolutePath());*/
|
||||
config();
|
||||
SmaliUtils smali = new SmaliUtils();
|
||||
smali.setPath(path);
|
||||
smali.bale(path, path+File.separator+onejar.getName());
|
||||
smali.bale(path, path+File.separator+"new_"+core.getName());
|
||||
System.out.println(path+File.separator+"new_"+core.getName());
|
||||
|
||||
}
|
||||
private void config(){
|
||||
JSONArray pluginsManual=config.getJSONArray("array").getJSONObject(2).getJSONArray("pluginsManual");
|
||||
for (Object o : pluginsManual) {
|
||||
changeSmali((JSONObject) o);
|
||||
}
|
||||
}
|
||||
private String getPackageName(){
|
||||
if(packageName!=null){
|
||||
return packageName;
|
||||
}
|
||||
JSONArray array=config.getJSONArray("array").getJSONObject(2).getJSONArray("random");
|
||||
packageName="";
|
||||
for (Object o : array) {
|
||||
packageName+=o+".";
|
||||
}
|
||||
packageName=packageName.substring(0,packageName.length()-1);
|
||||
return packageName;
|
||||
}
|
||||
private void changeSmali(JSONObject json){
|
||||
File smali=new File(home+File.separator+"smali"+File.separator+json.getString("class").replace(".",File.separator)+".smali");
|
||||
if(!smali.exists()){
|
||||
System.err.println("smali文件不存在 :"+json.getString("class"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(smali));
|
||||
String tmp,str="";
|
||||
boolean find = false;
|
||||
boolean end = false;
|
||||
boolean write = false;
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
if(tmp.contains(json.getString("find"))){
|
||||
System.out.println("yes!");
|
||||
find=true;
|
||||
}
|
||||
if(find&&!write){
|
||||
tmp=json.getString("data");
|
||||
tmp=tmp.replace("${packagename}",getPackageName());
|
||||
System.out.println(tmp);
|
||||
str+=tmp;
|
||||
write=true;
|
||||
}
|
||||
if(find&&tmp.contains(json.getString("end"))){
|
||||
end = true;
|
||||
find = false;
|
||||
}
|
||||
if (!find) {
|
||||
str+=tmp+"\n";
|
||||
if (end) {
|
||||
end = false;
|
||||
write = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
FileWriter writer=new FileWriter(smali);
|
||||
writer.write(str);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
private void updateActivity(String path) {
|
||||
try {
|
||||
File file = new File(path);
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -13,6 +14,7 @@ public class AutoPackageSDKMust {
|
||||
private SmaliApkToolsPath path;
|
||||
private JSONObject config;
|
||||
private String sdkCode = " String RDCpplictPath=Decode.getData(\"RDCpplictPath\");";
|
||||
private boolean isAddRandomCode = false;
|
||||
|
||||
private AutoPackageSDKMust(String key, SmaliApkToolsPath path) {
|
||||
this.key = key;
|
||||
@@ -103,13 +105,61 @@ public class AutoPackageSDKMust {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(java));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String tmp = null;
|
||||
int braceCount = 0;
|
||||
boolean isMethod = false;
|
||||
boolean isUserDecode = false;
|
||||
String endWriter = "";
|
||||
String endImport = "";
|
||||
String oldCode = "";
|
||||
String packagePath = "";
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
tmp = encrypt(tmp);
|
||||
if (isAddRandomCode) {
|
||||
if (tmp.startsWith("package")) {
|
||||
packagePath = tmp;
|
||||
}
|
||||
oldCode = tmp;
|
||||
if (tmp.contains("import com.qy.sdk.Utils.Decode;")) {
|
||||
isUserDecode = true;
|
||||
}
|
||||
if (tmp.startsWith("import")) {
|
||||
endImport = tmp;
|
||||
}
|
||||
if (tmp.replace(" ", "").contains("){")) {
|
||||
isMethod = true;
|
||||
}
|
||||
if (tmp.contains("{")) {
|
||||
braceCount++;
|
||||
}
|
||||
if (tmp.contains("}")) {
|
||||
braceCount--;
|
||||
if (braceCount == 0) {
|
||||
isMethod = false;
|
||||
}
|
||||
}
|
||||
if (isMethod) {
|
||||
if (new Random().nextDouble() > 0.7d && (oldCode.contains(";") && !oldCode.contains("return")
|
||||
&& !oldCode.contains("=") && !oldCode.endsWith(")") && !oldCode.contains("continue")
|
||||
&& !oldCode.contains("break") && !oldCode.contains("public")
|
||||
&& !oldCode.contains("private") && !oldCode.contains("static"))) {
|
||||
endWriter = "Decode.log(\"" + Tools.getRandomString(16) + "\");";
|
||||
tmp += "\n" + endWriter;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.append(tmp).append("\n");
|
||||
}
|
||||
tmp = builder.toString();
|
||||
if (!isUserDecode&&isAddRandomCode) {
|
||||
if (endImport.trim().length() == 0) {
|
||||
endImport = packagePath;
|
||||
}
|
||||
tmp = tmp.replace(endImport, endImport + "\nimport com.qy.sdk.Utils.Decode;\n");
|
||||
}
|
||||
tmp = tmp.replace(endWriter, "");
|
||||
reader.close();
|
||||
FileWriter writer = new FileWriter(java);
|
||||
writer.write(builder.toString());
|
||||
writer.write(tmp);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.qy.ui.EditToDalog;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -211,22 +212,61 @@ public class AutoRandomAdSDK {
|
||||
}
|
||||
|
||||
boolean isPackage = true;
|
||||
private String csj_packagename = null;
|
||||
private String csj_path = null;
|
||||
private String csj_config = null;
|
||||
|
||||
public void startNotUnPackage(String path, String packagename, SmaliApkToolsPath inster) {
|
||||
public void startNotUnPackage(String path, String packagename, SmaliApkToolsPath inster, boolean showUi, String csj_config) {
|
||||
this.inter = inster;
|
||||
this.csj_config = csj_config;
|
||||
isPackage = false;
|
||||
adClass = new HashMap<String, File>();
|
||||
nowAdClass = new HashMap<String, File>();
|
||||
nowAdFile = new HashMap<String, String>();
|
||||
smalitools = new SmaliUtils();
|
||||
JSONObject cfg = Tools.loadConfig(new File("ad_config.cfg"));
|
||||
this.csj_path = path;
|
||||
if (showUi) {
|
||||
new EditToDalog("输入穿山甲包名", "穿山甲包名", packagename, new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
csj_packagename = path;
|
||||
showCsjVersionDialog();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
csj_packagename = packagename;
|
||||
showCsjVersionDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showCsjVersionDialog() {
|
||||
File configs = new File("csjConfig");
|
||||
String fileName = "";
|
||||
for (File file : configs.listFiles()) {
|
||||
fileName += file.getName() + "\n";
|
||||
}
|
||||
if (csj_config == null) {
|
||||
new EditToDalog("请输入穿山甲版本号", "可选:" + fileName, "5801", new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
toStart(path);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toStart(csj_config);
|
||||
}
|
||||
}
|
||||
|
||||
private void toStart(String version) {
|
||||
JSONObject cfg = Tools.loadConfig(new File("csjConfig" + File.separator + "ad_config_" + version + ".cfg"));
|
||||
config = cfg.getJSONArray("array").getJSONObject(4);
|
||||
JSONArray array = new JSONArray();
|
||||
for (String str : packagename.split("\\.")) {
|
||||
for (String str : csj_packagename.split("\\.")) {
|
||||
array.put(str);
|
||||
}
|
||||
config.put("random", array);
|
||||
rootPath = path;
|
||||
rootPath = csj_path;
|
||||
sdktype = "13";
|
||||
alter();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@ public class CsjTools {
|
||||
private static String csj_Path = "D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2";
|
||||
private List<String> r_list;
|
||||
private String packageName = null;
|
||||
private String csj_config=null;
|
||||
|
||||
public CsjTools() {
|
||||
}
|
||||
|
||||
public CsjTools(String apkFile, String csjFile, String packageName, String version, SmaliApkToolsPath toolsPath) {
|
||||
public CsjTools(String apkFile, String csjFile, String packageName, String version,String csj_config, SmaliApkToolsPath toolsPath) {
|
||||
setUserPackageName(false);
|
||||
this.packageName = packageName;
|
||||
this.csj_config=csj_config;
|
||||
build(csjFile, apkFile, new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
@@ -332,7 +334,7 @@ public class CsjTools {
|
||||
csjManifest = true;
|
||||
runStart();
|
||||
}
|
||||
});
|
||||
},packageName==null,csj_config);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user