From 561177d0f40e1b2ca756f8a6b5eaac06861b9575 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Tue, 10 Mar 2020 17:24:19 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BF=E5=B1=B1=E7=94=B2de?=
=?UTF-8?q?mo=E5=AD=98=E5=9C=A8=E6=97=B6=E4=B8=8D=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84BUG=20=E8=87=AA=E5=8A=A8=E6=89=93?=
=?UTF-8?q?=E5=8C=85=E7=A8=8B=E5=BA=8F=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F?=
=?UTF-8?q?=E6=89=93=E5=8C=85=E5=B9=BF=E5=91=8A=E6=BA=90SDK=20=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6manual=E5=AD=97=E6=AE=B5=E6=96=B0?=
=?UTF-8?q?=E5=A2=9Edata=E5=92=8Cend=E5=AD=97=E6=AE=B5=EF=BC=8Cdata?=
=?UTF-8?q?=E4=B8=BA=E6=B7=BB=E5=8A=A0=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=8C?=
=?UTF-8?q?end=E4=B8=BA=E6=A3=80=E6=B5=8B=E5=88=B0=E7=BB=93=E6=9D=9F?=
=?UTF-8?q?=E7=9A=84=E8=A1=A8=E7=A4=BA=EF=BC=8C=E6=84=8F=E6=80=9D=E6=98=AF?=
=?UTF-8?q?=E4=BB=8Efind=E5=88=B0end=E8=BF=99=E4=B8=80=E6=AE=B5=E7=94=B1da?=
=?UTF-8?q?ta=E6=9B=BF=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ad_config.cfg | 6 +-
config.cfg | 24 ++--
src/com/qy/utils/AutoRandomAdSDK.java | 154 ++++++++++++++++++++------
src/com/qy/utils/CsjTools.java | 2 +
4 files changed, 134 insertions(+), 52 deletions(-)
diff --git a/ad_config.cfg b/ad_config.cfg
index 01f648b..9ca1675 100644
--- a/ad_config.cfg
+++ b/ad_config.cfg
@@ -2,7 +2,7 @@
"array": [
{
"title": "广点通",
- "ltName": "GDTUnionSDK_QY.lt",
+ "ltName": "tgd",
"manifest": [
"",
"",
@@ -76,7 +76,9 @@
{
"class": "com.uniplay.adsdk.basic.RuleManage",
"find": ".method public configRight",
- "msg": "仅保留const-string v0, \"\" return-object v0"
+ "msg": "仅保留const-string v0, \"\" return-object v0",
+ "data":".method public configRight(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;\n.locals 3\n.prologue\nconst-string v0, \"\" \nreturn-object v0\n",
+ "end":".end method"
}
]
},
diff --git a/config.cfg b/config.cfg
index 14dedfa..84d35b2 100755
--- a/config.cfg
+++ b/config.cfg
@@ -1,21 +1,13 @@
{
- "1": "/home/yutou/AndroidStudioProjects/ADSDK_v5/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
- "2": "/home/yutou/AndroidStudioProjects/ADSDK_v5/qyadsdk/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
- "3": "F:/AndroidStudio_Data/GameSDK/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
- "4": "/home/yutou/AndroidStudioProjects/ADSDK_v5/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
- "5": "/home/yutou/AndroidStudioProjects/ADSDK_v5/qyadsdk/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
- "6": "/home/yutou/AndroidStudioProjects/ADSDK_v5/Test/build/intermediates/javac/debug/classes/com/",
+ "1": "D:\\AndroidStudio_Data\\ADSDK_v5\\sdk_rx\\build\\intermediates\\javac\\debug\\classes\\com",
+ "2": "D:\\AndroidStudio_Data\\ADSDK_v5\\qyadsdk\\build\\intermediates\\javac\\debug\\classes\\com",
"switch": "1",
- "input": "/media/yutou/_dde_data/AndroidStudio_Data/buildTools/com.zip",
- "out": "/media/yutou/_dde_data/AndroidStudio_Data/buildTools/",
+ "input": "com.zip",
+ "out": "",
"dx": "dx.jar",
"array": [
- "rd_rx",
- "qy_rx",
- "rx",
- "rd_rx",
- "qy_rx",
- "atest"
+ "aa",
+ "tl"
],
"csjConfig": {
"xml": {
@@ -43,8 +35,8 @@
"name": "${demoRoot}/res/raw/*"
},
{
- "command":"delete",
- "name":"${demoRoot}/lib/*"
+ "command": "delete",
+ "name": "${demoRoot}/lib/*"
}
]
}
diff --git a/src/com/qy/utils/AutoRandomAdSDK.java b/src/com/qy/utils/AutoRandomAdSDK.java
index 0683cf9..a5b24ee 100644
--- a/src/com/qy/utils/AutoRandomAdSDK.java
+++ b/src/com/qy/utils/AutoRandomAdSDK.java
@@ -1,12 +1,7 @@
package com.qy.utils;
import java.awt.Desktop;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.*;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.HashMap;
@@ -69,16 +64,67 @@ public class AutoRandomAdSDK {
public static void main(String[] args) {
// TODO Auto-generated method stub
- new AutoRandomAdSDK(new File("JooMobAdSDK_6.1.8.jar"), "5600", "5", 1, null);
+ // new AutoRandomAdSDK(new File("JooMobAdSDK_6.1.8.jar"), "5600", "5", 1, null);
// new AutoRandomAdSDK(new File("GDTSDK.unionNormal.4.100.970.jar"), 0, null);
+ JSONArray array = new JSONArray();
+
+ JSONObject gdt = new JSONObject();
+ gdt.put("file", "D:\\IDEA\\android_sdk_tools\\GDTSDK.unionNormal.4.170.1040.jar");
+ gdt.put("version", "5700");
+ gdt.put("type", "1");
+ gdt.put("index", 0);
+ gdt.put("packageName", "com.gzlt.tgttaxc.lmd1.tgd");
+ array.put(gdt);
+
+ JSONObject unplay = new JSONObject();
+ unplay.put("file", "D:\\IDEA\\android_sdk_tools\\JooMobAdSDK_6.1.8.jar");
+ unplay.put("version", "5700");
+ unplay.put("type", "5");
+ unplay.put("index", 1);
+ unplay.put("packageName", "com.gzlt.tgttaxc.lmd1.up");
+ array.put(unplay);
+
+ JSONObject qy = new JSONObject();
+ qy.put("file", "D:\\IDEA\\android_sdk_tools\\classes.jar");
+ qy.put("version", "5700");
+ qy.put("type", "0");
+ qy.put("packageName", "com.gzlt.tgttaxc.lmd1.ww");
+ qy.put("index", 3);
+ array.put(qy);
+ new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
+ @Override
+ public void smaliPath(String path) {
+ System.out.println("完成:"+path);
+ }
+ });
}
public AutoRandomAdSDK() {
}
- public AutoRandomAdSDK(File sdk, String version, String type, int cfgIndex, SmaliApkToolsPath inster) {
+ public AutoRandomAdSDK(JSONArray batch, SmaliApkToolsPath inter) {
+ final JSONArray array = new JSONArray();
+ for (Object o : batch) {
+ final JSONObject item = (JSONObject) o;
+ autoRandomAdSDK(new File(item.getString("file")), item.getString("version"), item
+ .getString("type"), item.getString("packageName"), item.getInt("index"), new SmaliApkToolsPath() {
+ public void smaliPath(String path) {
+ item.put("path", path);
+ array.put(item);
+ }
+ });
+ }
+ inter.smaliPath(array.toString());
+ }
+
+ public void autoRandomAdSDK(File sdk, String version, String type, String packageName, int cfgIndex, SmaliApkToolsPath inster) {
// TODO Auto-generated constructor stub
+ if (inster == null) {
+ inster = path -> {
+
+ };
+ }
this.inter = inster;
this.version = version;
this.sdktype = type;
@@ -88,9 +134,21 @@ public class AutoRandomAdSDK {
}
this.sdk = sdk;
config = cfg.getJSONArray("array").getJSONObject(cfgIndex);
+ if (packageName != null) {
+ String[] pname = packageName.split("\\.");
+ JSONArray random = new JSONArray();
+ for (String pn : pname) {
+ random.put(pn);
+ }
+ this.config.put("random", random);
+ }
start();
}
+ public AutoRandomAdSDK(File sdk, String version, String type, int cfgIndex, SmaliApkToolsPath inster) {
+ autoRandomAdSDK(sdk, version, type, null, cfgIndex, inster);
+ }
+
public void start() {
adClass = new HashMap();
nowAdClass = new HashMap();
@@ -219,7 +277,7 @@ public class AutoRandomAdSDK {
if (file.exists()) {
- JSONArray array = config.isNull("filter")?null:config.getJSONArray("filter");
+ JSONArray array = config.isNull("filter") ? null : config.getJSONArray("filter");
if (array != null) {
List list = new ArrayList<>();
for (int i = 0; i < array.length(); i++) {
@@ -253,20 +311,46 @@ public class AutoRandomAdSDK {
BufferedReader reader = new BufferedReader(new FileReader(file));
String tmp;
int index = 1;
+ boolean find = false;
+ boolean end = false;
+ boolean write = false;
+ StringBuilder buffer = new StringBuilder();
while ((tmp = reader.readLine()) != null) {
if (tmp.contains(json.getString("find"))) {
list.add(index);
+ find = true;
+ }
+ if (find && !write) {
+ buffer.append(json.getString("data"));
+ write = true;
+ }
+ if (find && tmp.contains(json.getString("end"))) {
+ end = true;
+ find = false;
+ }
+ if (!find) {
+ buffer.append(tmp).append("\n");
+ if (end) {
+ end = false;
+ write = false;
+ }
}
index++;
}
reader.close();
- Desktop.getDesktop().open(file);
+ FileWriter writer = new FileWriter(file);
+ writer.write(buffer.toString());
+ writer.flush();
+ writer.close();
+ out();
+ reader.close();
+ // Desktop.getDesktop().open(file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("请手动打开:" + file.getAbsolutePath() + " 文件");
}
- String index = "";
+ /* String index = "";
for (Integer integer : list) {
System.out.println("请修改第:" + integer + " 行附近的代码");
index += integer + ",";
@@ -278,21 +362,23 @@ public class AutoRandomAdSDK {
// TODO Auto-generated method stub
out();
}
- });
+ });*/
}
}
}
- private void show(File file){
+
+ private void show(File file) {
for (File listFile : file.listFiles()) {
- if(listFile.isDirectory()){
+ if (listFile.isDirectory()) {
show(listFile);
- }else{
- System.out.println(">?"+listFile.getAbsolutePath());
+ } else {
+ System.out.println(">?" + listFile.getAbsolutePath());
}
}
}
+
private void out() {
if (!isPackage) {
if (inter != null) {
@@ -334,19 +420,19 @@ public class AutoRandomAdSDK {
} else {
System.out.println(sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName());
- String exec=config.getString("dex2jar") + " " + sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName();
- System.out.println("exec:"+exec);
+ String exec = config.getString("dex2jar") + " " + sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName();
+ System.out.println("exec:" + exec);
Process process = Runtime.getRuntime().exec(exec);
process.waitFor();
Thread.sleep(100);
- process=Runtime.getRuntime().exec(exec);
+ process = Runtime.getRuntime().exec(exec);
process.waitFor();
lt = new File(sdk.getAbsolutePath().split(sdk.getName())[0], sdk.getName().replace(".jar", "-dex2jar.jar"));
}
System.out.println(">>>:" + lt.getAbsolutePath());
if (lt.exists()) {
nLt = new File(config.getString("ltName"));
- if(nLt.exists()){
+ if (nLt.exists()) {
nLt.delete();
}
lt.renameTo(nLt);
@@ -376,21 +462,21 @@ public class AutoRandomAdSDK {
File filePath = new File(file.getAbsolutePath().replace(file.getName(), ""));
for (File fs : filePath.listFiles()) {
- System.out.println(fs.getAbsolutePath().replace(new File("").getAbsolutePath(),""));
- if(fs.isDirectory()){
+ System.out.println(fs.getAbsolutePath().replace(new File("").getAbsolutePath(), ""));
+ if (fs.isDirectory()) {
continue;
}
- if(!fs.getName().startsWith(fileName)){
+ if (!fs.getName().startsWith(fileName)) {
continue;
}
String nName = getNewName(fs.getName());
if (fs.getName().startsWith(fileName + "$")) {
if (getNewName(fs.getName()).endsWith("[notmover]")) {
- Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(),
- nName + "$" + fs.getName().split("\\$")[1], true);
+ Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), fs
+ .getName().replace(fs.getName().split("\\$")[0], nName), true);
} else {
- moveFile(fs, key, nName + "$" + fs.getName().split("\\$")[1],false);
+ moveFile(fs, key, fs.getName().replace(fs.getName().split("\\$")[0], nName), false);
}
fs.delete();
}
@@ -400,12 +486,12 @@ public class AutoRandomAdSDK {
Tools.copyFileToName(file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), ""),
getNewName(file.getName()) + ".smali", true);
} else {
- moveFile(file, key, getNewName(file.getName()) + ".smali",true);
+ moveFile(file, key, getNewName(file.getName()) + ".smali", true);
}
file.delete();
}
- System.out.println("配置:"+config.getBoolean("isAllPackage"));
+ System.out.println("配置:" + config.getBoolean("isAllPackage"));
if (config.getBoolean("isAllPackage")) {
String tmp = nowAdClass.keySet().iterator().next();
File path = new File((nowAdClass.get(tmp)).getAbsolutePath());
@@ -426,7 +512,7 @@ public class AutoRandomAdSDK {
tmp = tmp.replace("/", File.separator);
String t = tmp.substring(0, 1);
if (t.equals("+")) {
- path = nowAdClass.get(key).getAbsolutePath() + tmp.replace("+","");
+ path = nowAdClass.get(key).getAbsolutePath() + tmp.replace("+", "");
} else {
path = rootPath + File.separator + "smali" + tmp;
}
@@ -466,8 +552,8 @@ public class AutoRandomAdSDK {
new File(rootPath + File.separator + tmp).mkdirs();
movesdk(file, tmp);
} else {
- boolean data=file.renameTo(new File(rootPath + File.separator + toPath, file.getName()));
- // System.out.println("移动文件:"+file.getAbsolutePath().replace(rootPath, "")+" 到"+(rootPath + File.separator + toPath)+" "+data);
+ boolean data = file.renameTo(new File(rootPath + File.separator + toPath, file.getName()));
+ // System.out.println("移动文件:"+file.getAbsolutePath().replace(rootPath, "")+" 到"+(rootPath + File.separator + toPath)+" "+data);
}
}
}
@@ -516,9 +602,9 @@ public class AutoRandomAdSDK {
tmpName = name;
}
String nName;
- if(config.getJSONObject("rename").isNull(tmpName.contains("$") ? tmpName.split("\\$")[0] : tmpName)){
- nName=name;
- }else{
+ if (config.getJSONObject("rename").isNull(tmpName.contains("$") ? tmpName.split("\\$")[0] : tmpName)) {
+ nName = name;
+ } else {
nName = config.getJSONObject("rename")
.getString(tmpName.contains("$") ? tmpName.split("\\$")[0] : tmpName);
}
diff --git a/src/com/qy/utils/CsjTools.java b/src/com/qy/utils/CsjTools.java
index 87e285f..a761d8a 100644
--- a/src/com/qy/utils/CsjTools.java
+++ b/src/com/qy/utils/CsjTools.java
@@ -231,6 +231,8 @@ public class CsjTools {
if (new File(csjFile.getName().replace(".apk", "")).exists()) {
System.out.println(">?>>"+new File(csjFile.getName().replace(".apk", "")).getAbsolutePath());
unPackageCSJ = true;
+ csj_Path = new File(csjFile.getName().replace(".apk", "")).getAbsolutePath();
+ csj_res = csj_Path + File.separator + "res" + File.separator + "values";
}
SmaliUtils utils = new SmaliUtils();
// Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator));