This commit is contained in:
Yutousama 2019-12-31 17:36:28 +08:00
parent 6c74920d5a
commit 81db19fd4b
33 changed files with 3907 additions and 0 deletions

12
AndroidTools.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="apktool_2.3.3" level="project" />
</component>
</module>

150
ad_config.cfg Normal file
View File

@ -0,0 +1,150 @@
{
"array": [
{
"title": "广点通",
"ltName": "GDTUnionSDK_QY.lt",
"manifest": [
"<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.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\" />"
],
"class": [
"com.qq.e.ads.ADActivity",
"com.qq.e.ads.PortraitADActivity",
"com.qq.e.ads.LandscapeADActivity",
"com.qq.e.comm.DownloadService"
],
"random": [
"com",
"ww",
"dt"
],
"rename": {
"ADActivity": "Activity",
"PortraitADActivity": "PortraitActivity",
"LandscapeADActivity": "LandscapeActivity",
"DownloadService": "DownloadService"
},
"isAllPackage":false,
"isReName": true,
"isJarLib":false,
"packagerlimit": 3,
"isManual": false,
"manual": [
{
"class": "com.qq.e.comm.a",
"find": "com/qq/e/ads/ADActivity"
}
]
},
{
"title": "聚量",
"ltName": "jla",
"manifest": [
"<activity android:name=\"com.uniplay.adsdk.AdActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\">/>",
"<activity android:name=\"com.uniplay.adsdk.InterstitialAdActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" android:theme=\"@android:style/Theme.Translucent\"/>",
"<activity android:name=\"com.uniplay.adsdk.NetworkChangeActivity\" android:screenOrientation=\"portrait\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
"<activity android:name=\"com.joomob.activity.AdVideoActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
"<service android:name=\"com.uniplay.adsdk.DownloadService\"/>"
],
"class": [
"com.uniplay.adsdk.AdActivity",
"com.uniplay.adsdk.InterstitialAdActivity",
"com.uniplay.adsdk.NetworkChangeActivity",
"com.joomob.activity.AdVideoActivity",
"com.uniplay.adsdk.DownloadService"
],
"random": [
"com",
"ww",
"ut"
],
"rename": {
"AdActivity": "Activity",
"InterstitialAdActivity": "InterstitialActivity",
"NetworkChangeActivity": "NetworkChangeActivity",
"AdVideoActivity": "VideoActivity",
"DownloadService": "DownloadService"
},
"isAllPackage":false,
"isReName": true,
"isJarLib":false,
"packagerlimit": 3,
"isManual": true,
"manual": [
{
"class":"com.uniplay.adsdk.basic.RuleManage",
"find":".method public configRight",
"msg":"仅保留const-string v0, \"\" return-object v0"
}
]
},
{
"title": "万维",
"ltName": "OnewaySDK_QY.lt",
"manifest": [
"<activity android:name=\"mobi.oneway.export.AdShowActivity\" android:configChanges=\"fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen\" android:hardwareAccelerated=\"true\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\" />",
],
"class": [
"mobi.oneway.sdk.AdShowActivity"
],
"random": [
"com",
"ww",
"wt"
],
"rename": {
"AdShowActivity": "ShowActivity"
},
"isAllPackage":false,
"isReName": true,
"isJarLib":false,
"packagerlimit": 3,
"isManual": true,
"manual": [
{
"class":"mobi.oneway.sdk.port.Unit",
"find":"const-string v0, \"mobi.oneway.export.AdShowActivity\""
},
{
"class":"mobi.oneway.sdk.b.c",
"find":"const-string v1, \"mobi.oneway.export.OWProvider\""
}
]
},
{
"title": "趣赢SDK",
"ltName": "qysdk.jar",
"manifest": [
"<activity android:name=\"com.qy.sdk.views.MyActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" />",
"<receiver android:name=\"com.qy.sdk_rx.listeners.QyReceiver\"> <intent-filter> <action android:name=\"android.net.conn.CONNECTIVITY_CHANGE\" /></intent-filter> <intent-filter><action android:name=\"android.intent.action.PACKAGE_ADDED\" /><data android:scheme=\"package\" /></intent-filter><intent-filter><action android:name=\"android.intent.action.DOWNLOAD_COMPLETE\" /></intent-filter></receiver>",
"<provider android:name=\"com.qy.sdk.TMProvider\" android:authorities=\"${applicationId}.TTMultProvider\" android:exported=\"false\" android:grantUriPermissions=\"true\"> <meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/file_paths\" /></provider>"
],
"class": [
"com.qy.sdk.views.MyActivity",
"com.qy.sdk_rx.listeners.QyReceiver",
"com.qy.sdk.TMProvider"
],
"random": [
"com",
"wq",
"rx"
],
"rename": {
"MyActivity": "Activity",
"QyReceiver":"Receiver",
"TMProvider":"TProvider"
},
"isAllPackage":true,
"isReName": true,
"isJarLib":true,
"packagerlimit": 3,
"isManual": false,
"manual": [
],
"dex2jar":"/media/yutou/_dde_data/反编译/dex2jar-2.0/_d2j-dex2jar.sh"
}
]
}

BIN
apktool_2.3.4.jar Executable file

Binary file not shown.

20
config.cfg Executable file
View File

@ -0,0 +1,20 @@
{
"switch":"1",
"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/",
"input":"/media/yutou/_dde_data/AndroidStudio_Data/buildTools/com.zip",
"out":"/media/yutou/_dde_data/AndroidStudio_Data/buildTools/",
"dx":"/media/yutou/_dde_data/AndroidStudio_Data/buildTools/dx.jar",
"array":[
"rd_rx",
"qy_rx",
"rx",
"rd_rx",
"qy_rx",
"atest"
]
}

BIN
dx.jar Executable file

Binary file not shown.

BIN
libs/apktool_2.3.3.jar Executable file

Binary file not shown.

BIN
libs/apktool_2.3.4.jar Executable file

Binary file not shown.

BIN
libs/json-20180130.jar Executable file

Binary file not shown.

BIN
libs/zip4j-1.3.2.jar Executable file

Binary file not shown.

View File

@ -0,0 +1,5 @@
package com.qy.Interfaces;
public abstract class DalogAbs {
public abstract void onSuccess();
}

View File

@ -0,0 +1,5 @@
package com.qy.Interfaces;
public interface SmaliApkToolsPath {
void smaliPath(String path);
}

418
src/com/qy/sms/SDKTools.java Executable file
View File

@ -0,0 +1,418 @@
package com.qy.sms;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import com.qy.utils.Tools;
import com.qy.utils.WorldTools;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.util.Zip4jConstants;
public class SDKTools {
public static String a, b, c;
public static String packName;
public static String srcPackName = "com.jobs.sdk";
public static String sdkDatapath;
public static String GameSDKManageName = "GameSDKManage";
public static Map<String, String> sdkfunction;
private static String dataFolder = "data";
public static String version = "2.24";
public static void start(String descDir) {
SDKTools tools = new SDKTools();
tools.initName();
tools.unSDKzip(descDir);
tools.resdk();
tools.reCode(SDKTools.sdkDatapath);
tools.reGameSDKManage();
tools.classPath.add(new File(dataFolder).getAbsolutePath() + "\\android.jar");
tools.classPath.add(new File(dataFolder).getAbsolutePath() + "\\androidv4.jar");
tools.saveJavaPath(sdkDatapath);
tools.javaToClass(sdkDatapath);
System.out.println("清理文件:" + sdkDatapath);
tools.deleteJava(sdkDatapath);
tools.toJarforJar();
WorldTools.start(packName, GameSDKManageName, sdkfunction);
}
private void initName() {
sdkfunction = new HashMap<>();
sdkfunction.put("getSDKManage", "get" + Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("init", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("regMethod", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("stop", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("pay", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("authority", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("getTextAlpha", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("setLog", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("getVersion", Tools.getRandomString(Tools.getRandomInt(5, 12)));
sdkfunction.put("getPermission", Tools.getRandomString(Tools.getRandomInt(5, 12)));
}
public void unSDKzip_(String descDir) {
try {
File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/");
System.out.println(sdkPath + " " + sdkPath.exists());
if (sdkPath.exists()) {
Tools.deleteFiles(sdkPath.getAbsolutePath());
}
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
ZipFile zip = new ZipFile(zipFile);
for (Enumeration<?> entries = zip.entries(); entries.hasMoreElements();) {
ZipEntry entry = (ZipEntry) entries.nextElement();
String zipEntryName = entry.getName();
InputStream in = zip.getInputStream(entry);
String outPath = (descDir + "/" + zipEntryName).replace("\\", "/");
// 判断路径是否存在,不存在则创建文件路径
File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));
if (!file.exists()) {
file.mkdirs();
}
// 判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压
if (new File(outPath).isDirectory()) {
continue;
}
// 输出文件路径信息
System.out.println(outPath);
OutputStream out = new FileOutputStream(outPath);
byte[] buf1 = new byte[1024];
int len;
while ((len = in.read(buf1)) > 0) {
out.write(buf1, 0, len);
}
in.close();
out.close();
}
zip.close();
System.out.println("******************解压完毕********************");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private void unSDKzip(String descDir) {
try {
File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/");
System.out.println(sdkPath + " " + sdkPath.exists());
if (sdkPath.exists()) {
Tools.deleteFiles(sdkPath.getAbsolutePath());
}
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
net.lingala.zip4j.core.ZipFile zip=new net.lingala.zip4j.core.ZipFile(zipFile);
zip.setFileNameCharset("GBK");
zip.extractAll(new File("").getAbsolutePath());
System.out.println("******************解压完毕********************");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void resdk() {
File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/");
if (!sdkPath.exists()) {
System.out.println("SDK目录不存在 " + sdkPath.getAbsolutePath());
return;
}
a = Tools.getRandomString(3);
b = Tools.getRandomString(4);
c = Tools.getRandomString(4);
packName = a + "." + b + "." + c;
System.out.println("SDK包名" + packName);
rename(sdkPath);
}
private void rename(File folder) {
String tmp = "", tmp2 = "";
if (folder.exists() && folder.isDirectory()) {
switch (folder.getName()) {
case "com":
tmp = "com";
folder.renameTo(new File(new File("smsdk").getAbsolutePath() + File.separator + a));
tmp2 = a;
break;
case "jobs":
tmp = "jobs";
folder.renameTo(new File(new File("smsdk/" + a).getAbsolutePath() + File.separator + b));
tmp2 = b;
break;
case "sdk":
tmp = "sdk";
tmp2 = c;
sdkDatapath = new File("smsdk/" + a + "/" + b).getAbsolutePath() + File.separator + c;
folder.renameTo(new File(sdkDatapath));
break;
default:
break;
}
System.out.println(sdkDatapath + " " + folder.getAbsolutePath() + " " + tmp + " " + tmp2);
folder = new File(folder.getAbsolutePath().replace(File.separator + tmp, File.separator + tmp2));
System.out.println(folder.getAbsolutePath());
for (File fold : folder.listFiles()) {
if (fold.isDirectory()) {
rename(fold);
}
}
}
}
public void reCode(String path) {
File file = new File(path);
for (File f : file.listFiles()) {
if (f.isDirectory()) {
reCode(f.getAbsolutePath());
} else if (f.getName().contains(".java")) {
reJava(f);
}
}
}
private void reJava(File java) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(java), "UTF-8"));
String str = "", tmp;
while ((tmp = reader.readLine()) != null) {
if (tmp.contains(srcPackName)) {
tmp = tmp.contains(srcPackName + "_rx") ? tmp : tmp.replace(srcPackName, packName);
}
str += tmp + "\n";
}
reader.close();
PrintWriter writer = new PrintWriter(java);
writer.write(str);
writer.flush();
writer.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private void reGameSDKManage() {
File java = new File(sdkDatapath + "/GameSDKManage.java");
if (!java.exists()) {
System.out.println("GameSDKManage.java不存在");
return;
}
GameSDKManageName = Tools.getRandomString(Tools.getRandomInt(4, 8));
File javaName = new File(java.getAbsolutePath().replace(java.getName(), GameSDKManageName + ".java"));
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(java)));
String str = "", tmp;
while ((tmp = reader.readLine()) != null) {
tmp = tmp.replace("GameSDKManage", GameSDKManageName);
tmp = tmp.replace("getSDKManage", sdkfunction.get("getSDKManage"));
tmp = tmp.replace("init", sdkfunction.get("init"));
tmp = tmp.replace("regMethod", sdkfunction.get("regMethod"));
tmp = tmp.replace("stop", sdkfunction.get("stop"));
tmp = tmp.replace("pay", sdkfunction.get("pay"));
tmp = tmp.replace("authority", sdkfunction.get("authority"));
tmp = tmp.replace("getTextAlpha", sdkfunction.get("getTextAlpha"));
tmp = tmp.replace("setLog", sdkfunction.get("setLog"));
tmp = tmp.replace("getVersion", sdkfunction.get("getVersion"));
tmp = tmp.replace("getPermission", sdkfunction.get("getPermission"));
str += tmp + "\n";
}
reader.close();
PrintWriter writer = new PrintWriter(javaName);
writer.write(str);
writer.flush();
writer.close();
java.delete();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private List<String> classPath = new ArrayList<>();
private List<String> javaPath = new ArrayList<>();
private void saveJavaPath(String path) {
File file = new File(path);
for (File f : file.listFiles()) {
if (f.isDirectory()) {
saveJavaPath(f.getAbsolutePath());
} else if (f.getName().contains(".java")) {
javaPath.add(f.getAbsolutePath());
}
}
}
private void javaToClass(String path) {
File file = new File(path);
for (File f : file.listFiles()) {
if (f.isDirectory()) {
javaToClass(f.getAbsolutePath());
} else if (f.getName().contains(".java")) {
try {
String exec = "javac -classpath " + getClassPath() + "; -sourcepath " + getSourcePath() + " "
+ f.getAbsolutePath() + "\n";
System.out.println(exec);
Process process = Runtime.getRuntime().exec(exec);
process.waitFor();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private void deleteJava(String path) {
File file = new File(path);
for (File f : file.listFiles()) {
System.out.println("---->" + f.getAbsolutePath());
if (f.isDirectory()) {
deleteJava(f.getAbsolutePath());
}
if (f.getName().contains(".java")) {
File ft = new File(f.getAbsolutePath().replace(".java", ".class"));
if (ft.exists()) {
f.delete();
// System.out.println("删除java"+f.getAbsolutePath()+" "+t);
}
}
}
}
private String getSourcePath() {
String classpath = new File("smsdk").getAbsolutePath() + ";.";
System.out.println("classpath: " + classpath);
return classpath;
}
private String getClassPath() {
String classPath = "";
for (String str : this.classPath) {
classPath += str + ";";
}
return classPath.substring(0, classPath.length() - 1);
}
public static void buildSDK(File sdkzip) {
try {
List<File> files = new ArrayList<>();
List<ZipEntry> zips = new ArrayList<>();
Map<String, File> fileNames = new HashMap<>();
if (sdkzip == null)
sdkzip = new File("计费sdk" + version + ".zip");
if (sdkzip.exists())
sdkzip.delete();
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(sdkzip));
output.setLevel(Deflater.DEFLATED);
File sdk = new File("sdk.jar");
File word = new File("文档.txt");
File rx = new File("data/rx.lt");
File v4 = new File("data/androidv4.jar");
File manifest = new File("data/manifest清单.txt");
File permission = new File("data/权限列表.txt");
files.add(sdk);
files.add(word);
files.add(rx);
files.add(manifest);
files.add(permission);
files.add(v4);
for (File file : files) {
ZipEntry zip = new ZipEntry(file.getName());
zips.add(zip);
fileNames.put(zip.getName(), file);
}
for (ZipEntry zipEntry : zips) {
output.putNextEntry(zipEntry);
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(fileNames.get(zipEntry.getName())));
byte[] buffer = new byte[1024];
int count;
while ((count = bis.read(buffer)) != -1) {
output.write(buffer, 0, count);
}
output.flush();
bis.close();
}
output.closeEntry();
output.close();
sdk.delete();
word.delete();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private void toJarforJar() {
try {
Process process=Runtime.getRuntime().exec("jar cvf sdk.jar -C smsdk/ .");
process.waitFor();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
@Deprecated
private void toJar() {
try {
File dir = new File("smsdk"+File.separator+a);
ZipParameters par = new ZipParameters();
par.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
par.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
net.lingala.zip4j.core.ZipFile zipFile=new net.lingala.zip4j.core.ZipFile(new File("sdk.zip"));
jar(zipFile,dir, par);
File zip=new File("sdk.zip");
zip.renameTo(new File("sdk.jar"));
zip.delete();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private void jar(net.lingala.zip4j.core.ZipFile zipFile, File file,ZipParameters par) throws Exception {
toJar();
for (File f : file.listFiles()) {
System.out.println("压缩文件:"+f.getAbsolutePath());
if(f.isDirectory()) {
par.setCompressionMethod(Zip4jConstants.COMP_STORE);
File t=new File(f.getName());
t.mkdirs();
zipFile.addFolder(t, par);
jar(zipFile, f, par);
}else {
par.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
par.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
zipFile.addFile(f, par);
}
}
/*if(file.isDirectory()) {
zipFile.addFolder(file, par);
}else {
zipFile.addFile(file, par);
}*/
}
}

73
src/com/qy/ui/AESUi.java Executable file
View File

@ -0,0 +1,73 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.JEditorPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import com.qy.utils.AESTools;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class AESUi extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
public AESUi() {
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setTitle("AES\u5DE5\u5177");
// TODO Auto-generated constructor stub
initView();
}
private JEditorPane output,input;
private void initView() {
setSize(807, 493);
getContentPane().setLayout(null);
output = new JEditorPane();
output.setBounds(48, 250, 691, 168);
getContentPane().add(output);
input = new JEditorPane();
input.setBounds(48, 38, 691, 144);
getContentPane().add(input);
JButton button = new JButton("\u52A0\u5BC6");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String inStr=input.getText();
String out=new String(AESTools.aesEncrypt(inStr, AESTools.key));
output.setText(out);
}
});
button.setBounds(499, 195, 113, 27);
getContentPane().add(button);
JButton button_1 = new JButton("\u89E3\u5BC6");
button_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String inStr=input.getText();
String out=AESTools.aesDecrypt(inStr, AESTools.key);
output.setText(out);
}
});
button_1.setBounds(626, 195, 113, 27);
getContentPane().add(button_1);
JLabel label = new JLabel("\u8F93\u5165");
label.setBounds(48, 13, 72, 18);
getContentPane().add(label);
JLabel label_1 = new JLabel("\u8F93\u51FA");
label_1.setBounds(48, 219, 72, 18);
getContentPane().add(label_1);
setVisible(true);
}
}

180
src/com/qy/ui/AndroidKey.java Executable file
View File

@ -0,0 +1,180 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.AbstractListModel;
import javax.swing.event.ListSelectionListener;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.KeyTools;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
public class AndroidKey extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField md5;
private JTextField sha1;
private JTextField sha256;
private JTextPane textPane;
private List<Map<String,String>> keys;
public static void main(String[] args) {
// TODO Auto-generated method stub
new AndroidKey();
}
public AndroidKey() {
setResizable(false);
setTitle("\u7B7E\u540D\u67E5\u770B\u5668");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initkeys();
initView();
}
private void initkeys() {
keys=new ArrayList<>();
Map<String,String> secretKey=new HashMap<>();//amw.keystroe.jks
secretKey.put("md5", "5D:E3:53:48:3A:48:1C:B7:56:BF:DA:FE:41:6F:10:69");
secretKey.put("sha1", "34:5F:75:56:6E:EF:D4:73:CA:62:88:B8:3F:D2:AE:EE:35:1D:03:0A");
secretKey.put("sha256", "42:CD:68:62:EC:D4:EE:56:BC:3E:1A:6B:54:0C:B4:38:2C:F6:F8:8A:2D:66:F5:3C:DB:56:E0:71:D1:0E:2F:4A");
keys.add(secretKey);
secretKey=new HashMap<>();//langtian.jks
secretKey.put("md5", "23:69:26:CD:3E:A8:74:CF:5D:9C:32:77:EE:AF:65:AB");
secretKey.put("sha1", "F5:19:13:91:70:05:B0:FE:3F:8B:56:99:4B:48:F3:73:4A:22:F2:5D");
secretKey.put("sha256", "5C:BD:49:16:5B:3D:5F:26:6B:99:4A:10:1C:E5:DB:8F:A7:09:26:B5:6B:46:69:2D:12:9D:39:21:AF:24:75:7E");
keys.add(secretKey);
secretKey=new HashMap<>();//my.keystore
secretKey.put("md5", "3B:F8:BA:42:7C:B3:91:A4:5C:3C:E0:1D:67:D6:17:49");
secretKey.put("sha1", "3F:B3:26:07:13:84:BF:12:1A:41:E7:04:4E:63:7D:4F:F4:ED:FA:FA");
secretKey.put("sha256", "C5:5C:4F:F7:5A:C3:5C:5A:A9:B5:8C:29:ED:AD:CE:CB:9E:62:DF:9C:12:94:39:3B:88:CF:5C:3F:0E:B6:96:29");
keys.add(secretKey);
}
private JList<String> list;
private void initView() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
setSize(849, 536);
getContentPane().setLayout(null);
list = new JList<String>();
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Map<String,String> map=keys.get(list.getSelectedIndex());
if(map!=null) {
md5.setText(map.get("md5"));
sha1.setText(map.get("sha1"));
sha256.setText(map.get("sha256"));
}
}
});
list.setModel(new AbstractListModel<String>() {
/**
*
*/
private static final long serialVersionUID = 1L;
String[] values = new String[] {"amw.keystroe.jks", "langtian.jks", "my.keystore"};
public int getSize() {
return values.length;
}
public String getElementAt(int index) {
return values[index];
}
});
list.setBounds(35, 87, 167, 167);
getContentPane().add(list);
JLabel lblMd = new JLabel("MD5:");
lblMd.setBounds(269, 100, 72, 18);
getContentPane().add(lblMd);
JLabel lblSha = new JLabel("SHA1:");
lblSha.setBounds(262, 131, 72, 18);
getContentPane().add(lblSha);
JLabel lblSha_1 = new JLabel("SHA256:");
lblSha_1.setBounds(245, 162, 72, 18);
getContentPane().add(lblSha_1);
md5 = new JTextField();
md5.setBounds(315, 99, 466, 24);
getContentPane().add(md5);
md5.setColumns(10);
sha1 = new JTextField();
sha1.setBounds(315, 132, 466, 24);
getContentPane().add(sha1);
sha1.setColumns(10);
sha256 = new JTextField();
sha256.setBounds(317, 170, 464, 24);
getContentPane().add(sha256);
sha256.setColumns(10);
JButton btnSelectrsa = new JButton("\u9009\u62E9RSA\u6587\u4EF6");
btnSelectrsa.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser=new JFileChooser(new File("").getAbsolutePath());
chooser.showOpenDialog(null);
File rsa=chooser.getSelectedFile();
String data=KeyTools.getRSAkey(rsa, null, true);
textPane.setText(data);
}
});
btnSelectrsa.setBounds(254, 225, 140, 27);
getContentPane().add(btnSelectrsa);
JButton btnSelectkey = new JButton("\u9009\u62E9\u79D8\u94A5\u6587\u4EF6");
btnSelectkey.addMouseListener(new MouseAdapter() {
File rsa;
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser=new JFileChooser(new File("").getAbsolutePath());
chooser.showOpenDialog(null);
rsa=chooser.getSelectedFile();
new EditToDalog("Ìáʾ", "ÇëÊäÈëÃÜÔ¿", null, new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
String data=KeyTools.getRSAkey(rsa, path, false);
textPane.setText(data);
}
});
}
});
btnSelectkey.setBounds(450, 225, 148, 27);
getContentPane().add(btnSelectkey);
textPane = new JTextPane();
JScrollPane scrollBar = new JScrollPane(textPane);
scrollBar.setBounds(35, 289, 750, 187);
getContentPane().add(scrollBar);
setVisible(true);
}
}

View File

@ -0,0 +1,129 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.qy.utils.ApkSignTools;
import java.awt.event.ActionListener;
import java.io.File;
import java.awt.event.ActionEvent;
public class ApkSignUi extends JFrame {
public static void main(String[] args) {
new ApkSignUi();
}
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField txtPass;
private JTextField txtSpass;
private JTextField txtName;
private ApkSignTools tools;
private JLabel lblApkpath ;
private JLabel lblSginpath;
public ApkSignUi() {
setTitle("\u7B7E\u540D\u5DE5\u5177");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// TODO Auto-generated constructor stub
tools=new ApkSignTools();
setSize(448, 355);
getContentPane().setLayout(null);
lblApkpath = new JLabel("APKPath");
JButton btnapk = new JButton("\u9009\u62E9APK");
btnapk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(null);
File file = jFile.getSelectedFile();
if(file!=null&&file.exists()) {
tools.setApkFile(file);
lblApkpath.setText(file.getAbsolutePath());
}
}
});
btnapk.setBounds(36, 28, 105, 27);
getContentPane().add(btnapk);
lblApkpath.setBounds(46, 67, 289, 17);
getContentPane().add(lblApkpath);
JButton button = new JButton("\u9009\u62E9\u7B7E\u540D");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(null);
File file = jFile.getSelectedFile();
if(file!=null&&file.exists()) {
tools.setSignFile(file);
lblSginpath.setText(file.getAbsolutePath());
}
}
});
button.setBounds(36, 96, 105, 27);
getContentPane().add(button);
JButton button_1 = new JButton("\u4F7F\u7528\u9ED8\u8BA4\u7B7E\u540D");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File sign=new File("/media/yutou/_dde_data/AndroidKeys/langtian.jks");
lblSginpath.setText(sign.getAbsolutePath());
tools.setSignFile(sign);
txtName.setText("langtian");
txtPass.setText("134679");
txtSpass.setText("134679");
}
});
button_1.setBounds(220, 96, 130, 27);
getContentPane().add(button_1);
lblSginpath = new JLabel("sginPath");
lblSginpath.setBounds(46, 142, 260, 17);
getContentPane().add(lblSginpath);
txtPass = new JTextField();
txtPass.setText("\u5BC6\u7801");
txtPass.setBounds(27, 173, 114, 21);
getContentPane().add(txtPass);
txtPass.setColumns(10);
txtSpass = new JTextField();
txtSpass.setText("\u522B\u540D\u5BC6\u7801");
txtSpass.setBounds(27, 206, 114, 21);
getContentPane().add(txtSpass);
txtSpass.setColumns(10);
txtName = new JTextField();
txtName.setText("\u522B\u540D");
txtName.setBounds(27, 239, 114, 21);
getContentPane().add(txtName);
txtName.setColumns(10);
JButton btnSign = new JButton("\u7B7E\u540D");
btnSign.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tools.setName(txtName.getText());
tools.setKeyStorePassword(txtSpass.getText());
tools.setSignKey(txtPass.getText());
if(tools.chack()) {
tools.sign();
new TextToDalog("成功", "签名完成");
}else {
new TextToDalog("错误", "APK文件或签名文件不存在");
}
}
});
btnSign.setBounds(263, 246, 105, 27);
getContentPane().add(btnSign);
setVisible(true);
}
}

524
src/com/qy/ui/AppMain.java Executable file
View File

@ -0,0 +1,524 @@
package com.qy.ui;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import org.json.JSONArray;
import org.json.JSONObject;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.EncryptJar;
import com.qy.utils.JarToAJar;
import com.qy.utils.JarToBase;
import com.qy.utils.Tools;
public class AppMain extends JFrame {
private JList<String> configList;
private JButton zipToJar, jarToBase, reload, btnAdbPull;
private JTextField log;
public static JSONObject json;
private Vector<String> vector;
public static boolean isOpenWindows = false;
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField txtCom;
private JButton btnUserBase;
private JTextField textPackName;
private JButton btnRestartapp;
private JLabel lblactivity;
private JTextField textActivity;
private JMenuBar menuBar;
private JTextField uFilePath;
private JSeparator separator;
private JMenuItem menuItem_1;
private JCheckBox openWindows;
private JMenu mnBasetools;
private JMenuItem mntmbase;
private JMenuItem mntmBase;
public static void main(String[] args) {
// TODO Auto-generated method stub
new AppMain();
}
public AppMain() {
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
json = Tools.loadConfig(new File("config.cfg"));
initView();
initData();
log.setText("已载入配置文件");
separator = new JSeparator();
separator.setBounds(247, 149, 158, 2);
getContentPane().add(separator);
repaint();
}
private void initData() {
JSONArray array = json.getJSONArray("array");
vector = new Vector<>();
for (int i = 0; i < array.length(); i++) {
vector.add(array.getString(i));
}
configList.setListData(vector);
}
private void initView() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
setTitle("\u8F6C\u6362\u5668v2.7");
// TODO Auto-generated constructor stub
setSize(900, 456);
getContentPane().setLayout(null);
configList = new JList<String>();
configList.setBounds(0, 0, 1, 1);
JScrollPane scrollBar = new JScrollPane(configList);
scrollBar.setBounds(51, 49, 147, 215);
getContentPane().add(scrollBar);
zipToJar = new JButton("\u8F6Cjar");
zipToJar.addMouseListener(new MouseAdapter() {
File file;
Timer timer;
String name,path;
@Override
public void mouseClicked(MouseEvent e) {
if(configList.getSelectedIndex()<0) {
new TextToDalog("警告", "列表未选择");
return;
}
json.put("switch", configList.getSelectedIndex() + 1 + "");
path = json.getString("out");
name = json.getJSONArray("array").getString(Integer.valueOf(json.getString("switch")) - 1)+".jar";
file=new File(path+name);
if(file.exists())
file.delete();
JarToAJar.start(json);
timer=new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
if(file.exists()) {
log.setText("已生成" + name);
timer.cancel();
}else {
log.setText("正在生成");
}
}
}, 0,100);
}
});
zipToJar.setBounds(247, 72, 158, 27);
getContentPane().add(zipToJar);
jarToBase = new JButton("\u52A0\u5BC6Jar");
jarToBase.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(configList.getSelectedIndex()<0) {
new TextToDalog("警告", "列表未选择");
return;
}
json.put("switch", configList.getSelectedIndex() + 1 + "");
new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
String version;
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
version=path;
if(version==null) {
return;
}
new EditToDalog("资源类型", "请输入资源类型\n0=内核\n4=自主广告\n1=广点通\n5=聚量\n11=万维\n13=穿山甲", "", new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
File input=new File(json.getString("out")
+ json.getJSONArray("array").getString(Integer.valueOf(json.getString("switch")) - 1) + ".jar");
JarToAJar.toAJar(json.getString("dx"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar"));
File outFile=new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.getString("out")
+ json.getJSONArray("array").getString(Integer.valueOf(json.getString("switch")) - 1) + "_encrypt.jar", Integer.valueOf(path)
, Integer.valueOf(version));
log.setText("data路径为:" + outFile.getAbsolutePath());
}
});
}
});
/*
* JarToBase.start(json.getString("out") +
* json.getJSONArray("array").getString(Integer.valueOf(json.getString("switch")
* ) - 1) + ".jar", true);
*/
}
});
jarToBase.setBounds(247, 109, 158, 27);
getContentPane().add(jarToBase);
reload = new JButton("\u91CD\u8F7D\u914D\u7F6E\u6587\u4EF6");
reload.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
initData();
json = Tools.loadConfig(new File("config.cfg"));
log.setText("已重置");
}
});
reload.setBounds(51, 13, 153, 27);
getContentPane().add(reload);
log = new JTextField("\u521D\u59CB\u5316");
log.setBorder(new LineBorder(Color.BLACK, 0));
log.setHorizontalAlignment(SwingConstants.LEFT);
log.setForeground(Color.BLACK);
log.setEditable(false);
log.setBounds(51, 340, 766, 31);
getContentPane().add(log);
txtCom = new JTextField();
txtCom.setHorizontalAlignment(SwingConstants.LEFT);
txtCom.setText("adb push \"" + new File("").getAbsolutePath() + "/[jar]/data/data/[packname]/plugs/");
txtCom.setBounds(444, 73, 293, 27);
getContentPane().add(txtCom);
txtCom.setColumns(10);
JLabel lblAdb = new JLabel("adb\u6307\u4EE4");
lblAdb.setBounds(444, 51, 72, 18);
getContentPane().add(lblAdb);
btnAdbPull = new JButton("adb");
btnAdbPull.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String cmd = txtCom.getText();
cmd = cmd.replace("[packname]", textPackName.getText());
cmd = cmd.replace("[jar]", configList.getSelectedValue().toString() + ".jar");
try {
System.out.println(cmd);
Runtime.getRuntime().exec("adb root");
Runtime.getRuntime().exec("adb remount");
Runtime.getRuntime().exec(cmd);
log.setText("执行:" + cmd);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
log.setText("执行失败");
}
}
});
btnAdbPull.setBounds(444, 295, 147, 27);
getContentPane().add(btnAdbPull);
new ButtonGroup();
btnUserBase = new JButton("\u52A0\u5BC6\u6587\u4EF6");
btnUserBase.addMouseListener(new MouseAdapter() {
File file;
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(null);
file = jFile.getSelectedFile();
new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
String version;
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
version=path;
if(version==null) {
return;
}
new EditToDalog("资源类型", "请输入资源类型\n0=内核\n4=自主广告\n1=广点通\n5=聚量\n11=万维\n13=穿山甲", "", new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
JarToAJar.toAJar(json.getString("dx"), file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), "dexTmp.jar"));
File fileOut=new EncryptJar().encrypt(new File(file.getAbsolutePath().replace(file.getName(), "dexTmp.jar")), file.getAbsolutePath() + "_encrypt.jar", Integer.valueOf(path)
, Integer.valueOf(version));
log.setText("data路径为:" + fileOut.getAbsolutePath());
}
});
}
});
//JarToBase.start(file.getAbsolutePath(), true);
}
});
btnUserBase.setBounds(247, 160, 158, 27);
getContentPane().add(btnUserBase);
JButton btnNewButton = new JButton("\u89E3\u5BC6\u6587\u4EF6");
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(null);
File file = jFile.getSelectedFile();
String fileName=file.getAbsolutePath();
if(fileName.endsWith("_encrypt.jar")) {
fileName=fileName.replace("_encrypt.jar", "_decrypt.jar");
}else {
fileName+="_decrypt.jar";
}
EncryptJar.FileData data= new EncryptJar().decrypt(file, fileName);
new TextToDalog("解码提示", data.toString());
//JarToBase.start(file.getAbsolutePath(), false);
log.setText("已解码");
}
});
btnNewButton.setBounds(247, 200, 158, 27);
getContentPane().add(btnNewButton);
openWindows = new JCheckBox("\u6253\u5F00\u7A97\u53E3");
openWindows.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
isOpenWindows = openWindows.isSelected();
}
});
openWindows.setBounds(247, 30, 133, 31);
getContentPane().add(openWindows);
JLabel label = new JLabel("\u5305\u540D");
label.setBounds(444, 113, 72, 18);
getContentPane().add(label);
textPackName = new JTextField();
textPackName.setText("com.luckyboy.mmxing");
textPackName.setBounds(444, 135, 293, 24);
getContentPane().add(textPackName);
textPackName.setColumns(10);
btnRestartapp = new JButton("\u91CD\u542FAPP");
btnRestartapp.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Runtime.getRuntime().exec("adb shell am force-stop " + textPackName.getText());
Runtime.getRuntime()
.exec("adb shell am start " + textPackName.getText() + File.separator + textActivity.getText());
log.setText("重启完毕");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
log.setText("重启失败");
}
}
});
btnRestartapp.setBounds(595, 295, 147, 27);
getContentPane().add(btnRestartapp);
lblactivity = new JLabel("\u4E3BActivity");
lblactivity.setBounds(444, 164, 119, 18);
getContentPane().add(lblactivity);
textActivity = new JTextField();
textActivity.setText(".MainActivity");
textActivity.setBounds(444, 185, 293, 24);
getContentPane().add(textActivity);
textActivity.setColumns(10);
JButton btnJavatoajar = new JButton("Jar\u8F6C\u5B89\u5353Jar");
btnJavatoajar.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
chooser.showOpenDialog(null);
File java = chooser.getSelectedFile();
JarToAJar.toAJar(json.getString("dx"), java.getAbsolutePath(),
new File("").getAbsolutePath() + File.separator+java.getName()+"_jar.jar");
if (AppMain.isOpenWindows) {
try {
Desktop.getDesktop().open(new File(new File("").getAbsolutePath()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
log.setText("已转为Android可用java");
}
});
btnJavatoajar.setBounds(247, 237, 158, 27);
getContentPane().add(btnJavatoajar);
JLabel label_t = new JLabel("\u83B7\u53D6\u81EA\u5B9A\u4E49\u6587\u4EF6\u8DEF\u5F84");
label_t.setBounds(444, 215, 208, 18);
getContentPane().add(label_t);
uFilePath = new JTextField();
uFilePath.setBounds(444, 238, 293, 24);
getContentPane().add(uFilePath);
uFilePath.setColumns(10);
JButton button = new JButton("\u83B7\u53D6");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
uFilePath.setText(file.getAbsolutePath());
log.setText("获取自定义文件路径完成");
}
});
button.setBounds(755, 235, 113, 27);
getContentPane().add(button);
menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("\u83DC\u5355");
menuBar.add(mnNewMenu);
JMenuItem menuItem = new JMenuItem("\u91CD\u542F");
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
new AppMain();
}
});
mnNewMenu.add(menuItem);
JMenu menu = new JMenu("\u5DE5\u5177");
menuBar.add(menu);
JMenuItem mntmAes = new JMenuItem("AES\u5DE5\u5177");
mntmAes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new AESUi();
}
});
menu.add(mntmAes);
JMenuItem mntmSmali = new JMenuItem("Smali\u5DE5\u5177");
mntmSmali.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SmaliUi();
}
});
menu.add(mntmSmali);
JMenuItem mntmsdk = new JMenuItem("\u4E00\u952E\u77ED\u4EE3SDK");
mntmsdk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SMSToolsUi();
}
});
menu.add(mntmsdk);
menuItem_1 = new JMenuItem("\u67E5\u770B\u7B7E\u540D");
menuItem_1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AndroidKey();
}
});
menu.add(menuItem_1);
JMenuItem mntmOnweay = new JMenuItem("\u4FEE\u6539\u4E07\u7EF4\u63D2\u4EF6\u5305");
mntmOnweay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
uFilePath.setText(file.getAbsolutePath());
log.setText("正在修改万维插件包...");
new OneWayTools(file);
log.setText("修改万维成功,成功后文件将生成在反编译文件夹中");
}
});
JMenuItem mntmapk = new JMenuItem("\u7B7E\u540DAPK");
mntmapk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ApkSignUi();
}
});
menu.add(mntmapk);
menu.add(mntmOnweay);
JMenuItem mntmsdk_1 = new JMenuItem("\u4FEE\u6539\u7B2C\u4E09\u65B9SDK");
mntmsdk_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
new ModifySdkUi();
}
});
menu.add(mntmsdk_1);
mnBasetools = new JMenu("Base64\u5DE5\u5177");
menuBar.add(mnBasetools);
mntmbase = new JMenuItem("\u8F6CBase64");
mntmbase.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(null);
File file = jFile.getSelectedFile();
JarToBase.start(file.getAbsolutePath(), true);
}
});
mnBasetools.add(mntmbase);
mntmBase = new JMenuItem("Base64\u89E3\u7801");
mntmBase.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
jFile.showOpenDialog(AppMain.this);
File file = jFile.getSelectedFile();
JarToBase.start(file.getAbsolutePath(), false);
log.setText("已解码");
}
});
mnBasetools.add(mntmBase);
setVisible(true);
}
}

57
src/com/qy/ui/EditToDalog.java Executable file
View File

@ -0,0 +1,57 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import com.qy.Interfaces.SmaliApkToolsPath;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class EditToDalog extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField textField;
public EditToDalog(String title,String text,String fileName,SmaliApkToolsPath path) {
super(title);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initView(text,fileName,path);
}
public void initView(String text,String fileName,final SmaliApkToolsPath path) {
// TODO Auto-generated constructor stub
setSize(577, 260);
getContentPane().setLayout(null);
JTextArea lblNewLabel = new JTextArea(text);
lblNewLabel.setBackground(UIManager.getColor("Label.background"));
lblNewLabel.setEditable(false);
lblNewLabel.setLineWrap(true);
lblNewLabel.setBounds(47, 12, 438, 119);
getContentPane().add(lblNewLabel);
textField = new JTextField();
textField.setBounds(47, 143, 501, 24);
getContentPane().add(textField);
textField.setColumns(10);
textField.setText(fileName);
JButton btnOk = new JButton("ok");
btnOk.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
path.smaliPath(textField.getText());
EditToDalog.this.dispose();
}
});
btnOk.setBounds(435, 179, 113, 27);
getContentPane().add(btnOk);
setVisible(true);
}
}

View File

@ -0,0 +1,140 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.json.JSONException;
import org.json.JSONObject;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.AutoRandomAdSDK;
import com.qy.utils.Tools;
import javax.swing.JList;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class ModifySdkUi extends JFrame{
private JList<String> list;
private File sdkFile;
private Map<Integer, Boolean> userEncrypt;
/**
*
*/
private static final long serialVersionUID = 1L;
public ModifySdkUi() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setTitle("\u7B2C\u4E09\u65B9SDK\u4FEE\u6539\u5DE5\u5177v1.4");
// TODO Auto-generated constructor stub
userEncrypt=new HashMap<Integer, Boolean>();
initView();
initData();
}
private void initView() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
setSize(473, 356);
getContentPane().setLayout(null);
list = new JList<String>();
list.setBounds(45, 43, 145, 200);
getContentPane().add(list);
JButton btnNewButton = new JButton("\u5F00\u59CB");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(sdkFile!=null&&list.getSelectedIndex()>=0) {
if(userEncrypt.get(list.getSelectedIndex())) {
new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
String version;
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
version=path;
if(version==null) {
return;
}
new EditToDalog("资源类型", "请输入资源类型\n0=内核\n4=自主广告\n1=广点通\n5=聚量\n11=万维\n13=穿山甲", "", new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
new AutoRandomAdSDK(sdkFile,version,path, list.getSelectedIndex(),new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
new TextToDalog("提示", "处理完毕,文件路径:"+path);
}
});
}
});
}
});
}else {
new AutoRandomAdSDK(sdkFile,null,null, list.getSelectedIndex(),new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
new TextToDalog("提示", "处理完毕,文件路径:"+path);
}
});
}
}else {
new TextToDalog("警告", "未选择文件或未选择列表配置");
}
}
});
btnNewButton.setBounds(216, 143, 200, 100);
getContentPane().add(btnNewButton);
JButton btnSelectfile = new JButton("\u9009\u62E9jar\u6587\u4EF6");
btnSelectfile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser(new File("").getAbsolutePath());
chooser.showOpenDialog(null);
sdkFile = chooser.getSelectedFile();
}
});
btnSelectfile.setBounds(260, 70, 105, 27);
getContentPane().add(btnSelectfile);
setVisible(true);
}
void initData() {
JSONObject json=Tools.loadConfig(new File("ad_config.cfg"));
Vector<String> vector = new Vector<>();
for (int i = 0; i < json.getJSONArray("array").length(); i++) {
try {
vector.add(new String(json.getJSONArray("array").getJSONObject(i).getString("title").getBytes(),"UTF-8"));
userEncrypt.put(i
, !json.getJSONArray("array").getJSONObject(i).getBoolean("isJarLib"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
list.setListData(vector);
}
}

131
src/com/qy/ui/OneWayTools.java Executable file
View File

@ -0,0 +1,131 @@
package com.qy.ui;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.SmaliUtils;
public class OneWayTools {
public static void main(String[] args) {
new OneWayTools(new File("OnewaySdk.jar"));
}
public OneWayTools(File onwsdk) {
// TODO Auto-generated constructor stub
start(onwsdk);
}
File onejar;
private void start(File onewayjar) {
onejar=onewayjar;
SmaliUtils smali = new SmaliUtils();
smali.unPack(onewayjar.getAbsolutePath(), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
update(path);
}
});
}
private void update(String path) {
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");
if (!activity.exists()) {
System.out.println(activity.getAbsolutePath());
new TextToDalog("警告", "Unit.smali文件不存在!");
return;
}
if (!provider.exists()) {
new TextToDalog("警告", "c.smali文件不存在!");
return;
}
updateActivity(activity.getAbsolutePath());
updateProvider(provider.getAbsolutePath());
SmaliUtils smali = new SmaliUtils();
smali.setPath(path);
smali.bale(path, path+File.separator+onejar.getName());
}
private void updateActivity(String path) {
try {
File file = new File(path);
BufferedReader reader = new BufferedReader(new FileReader(file));
String tmp, str = "";
boolean write = false;
while ((tmp = reader.readLine()) != null) {
if (tmp.trim().equals("const-string v0, \"mobi.oneway.export.AdShowActivity\"")) {
tmp = " const-string v0, \"com.qy.AdShowActivity\"";
write = true;
}
str += tmp + "\n";
}
reader.close();
if (write) {
FileWriter writer = new FileWriter(file);
writer.write(str);
writer.flush();
writer.close();
return;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
new TextToDalog("错误", "处理unit.smali文件失败" + e.getMessage());
return;
}
new TextToDalog("警告", "Unit.smali文件没有包含指定代码请手动检查");
}
private void updateProvider(String path) {
try {
List<String> list = new ArrayList<>();
File file = new File(path);
BufferedReader reader = new BufferedReader(new FileReader(file));
String tmp, str = "";
boolean write = false;
int index = 0;
while ((tmp = reader.readLine()) != null) {
list.add(tmp);
if (tmp.trim().equals("const-string v1, \"mobi.oneway.export.OWProvider\"")) {
if (list.get(index - 1).trim().equals(":try_start_0")
&& list.get(index - 3).trim().equals("const/4 v0, 0x0")) {
list.set(index - 3, " const/4 v0, 0x1");
write = true;
}
}
index++;
}
for (String string : list) {
str += string + "\n";
}
reader.close();
if (write) {
FileWriter writer = new FileWriter(file);
writer.write(str);
writer.flush();
writer.close();
return;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
new TextToDalog("错误", "处理c.smali文件失败" + e.getMessage());
return;
}
new TextToDalog("警告", "c.smali文件没有包含指定代码请手动检查");
}
}

122
src/com/qy/ui/SMSToolsUi.java Executable file
View File

@ -0,0 +1,122 @@
package com.qy.ui;
import javax.swing.JFrame;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.UIManager;
import com.qy.Interfaces.DalogAbs;
import com.qy.sms.SDKTools;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class SMSToolsUi extends JFrame {
/**
* 更新日志 v1.0 初始版默认热包版本 v2.22
* v1.1 修复Eclipse无法使用的问题
* v1.2 新增对话框回调 热更包更新至2.24
* v1.3 修复Eclipse无法打包的问题 自带jdk降低到1.7版本采用jar.exe打包sdk
*/
private static final long serialVersionUID = 1L;
private JButton btnNewButton;
public static void main(String[] args) {
// TODO Auto-generated method stub
new SMSToolsUi();
}
public SMSToolsUi() {
initView();
}
private void initView() {
// TODO Auto-generated method stub
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
setResizable(false);
setTitle("\u77ED\u4EE3SDK\u81EA\u52A8\u751F\u6210\u5DE5\u5177v1.3");
setSize(425, 336);
getContentPane().setLayout(null);
btnNewButton = new JButton("\u4E00\u952E\u751F\u6210SDK\u53CA\u6587\u6863");
btnNewButton.addMouseListener(new MouseAdapter() {
String path;
@Override
public void mouseClicked(MouseEvent e) {
path = btnNewButton.getText();
btnNewButton.setEnabled(false);
btnNewButton.setText("正在编译SDK,请稍后...");
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
SDKTools.start(new File("").getAbsolutePath());
btnNewButton.setText(path);
btnNewButton.setEnabled(true);
new TextToDalog("提示", "计费SDK生成成功请选择保存位置", new DalogAbs() {
File sdk;
@Override
public void onSuccess() {
// TODO Auto-generated method stub
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showSaveDialog(null);
sdk = chooser.getSelectedFile();
if (sdk != null) {
File sdk_ = new File(
sdk.getAbsolutePath() + "/" + "计费sdk" + SDKTools.version + ".zip");
SDKTools.buildSDK(sdk_);
new TextToDalog("完成", "任务已完成", new DalogAbs() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
try {
Desktop.getDesktop().open(sdk);
System.out.println("\n本窗口可以关掉了");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
} else {
new TextToDalog("错误", "已放弃本次任务");
}
}
});
}
}, 100);
}
});
btnNewButton.setBounds(48, 13, 324, 216);
getContentPane().add(btnNewButton);
JLabel label = new JLabel("(\u5185\u90E8\u4F7F\u7528\uFF0C\u5207\u52FF\u5916\u6F0F\uFF01\uFF09");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBounds(65, 242, 278, 46);
getContentPane().add(label);
setVisible(true);
}
}

446
src/com/qy/ui/SmaliUi.java Executable file
View File

@ -0,0 +1,446 @@
package com.qy.ui;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.SmaliUtils;
public class SmaliUi extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField jarPath, savePath, smaliPath;
private SmaliUtils utils;
private Vector<String> vector;
private JList<String> list;
private List<File> fileList;
private JTextField lblInfo;
private String smaliHome;
private JCheckBox chckbxSavesmalipath;
private Timer timer;
public static void main(String[] args) {
new SmaliUi();
}
public SmaliUi() {
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
utils = new SmaliUtils();
vector = new Vector<>();
fileList = new ArrayList<>();
timer = new Timer();
initView();
}
private void initView() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.2");
// TODO Auto-generated constructor stub
setSize(900, 673);
getContentPane().setLayout(null);
smaliPath = new JTextField();
smaliPath.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
// TODO Auto-generated method stub
changeList();
}
@Override
public void insertUpdate(DocumentEvent e) {
// TODO Auto-generated method stub
changeList();
}
@Override
public void changedUpdate(DocumentEvent e) {
// TODO Auto-generated method stub
changeList();
}
});
smaliPath.setBounds(45, 55, 678, 24);
getContentPane().add(smaliPath);
smaliPath.setColumns(10);
JLabel lblFilepath = new JLabel(
"SmaliPath(\u4FEE\u6539\u8981\u5728smali\u8DEF\u5F84\u91CC\uFF0C\u6253\u5305\u9700\u8981\u5728apktool.yml\u540C\u7EA7)");
lblFilepath.setBounds(45, 24, 544, 18);
getContentPane().add(lblFilepath);
JButton btnFilepath = new JButton("select");
btnFilepath.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = new JFileChooser(new File("").getAbsolutePath());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(null);
smaliPath.setText(chooser.getSelectedFile().getAbsolutePath());
}
});
btnFilepath.setBounds(737, 54, 113, 27);
getContentPane().add(btnFilepath);
list = new JList<String>();
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int index = list.getSelectedIndex();
if (fileList.get(index).isDirectory()) {
smaliPath.setText(fileList.get(index).getAbsolutePath());
}
}
}
});
JScrollPane pane = new JScrollPane(list);
pane.setBounds(45, 118, 335, 449);
getContentPane().add(pane);
JButton btnOpen = new JButton("Edit");
btnOpen.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int index = list.getSelectedIndex();
if (index > 0) {
File file = fileList.get(index);
if (file.isFile()) {
try {
Desktop.getDesktop().open(file);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
});
btnOpen.setBounds(435, 137, 113, 27);
getContentPane().add(btnOpen);
JButton btnRename = new JButton("ReName");
btnRename.addMouseListener(new MouseAdapter() {
File file;
@Override
public void mouseClicked(MouseEvent e) {
int index = list.getSelectedIndex();
if (index > 0) {
file = fileList.get(index);
new EditToDalog("重命名", "希望将文件(夹) " + file.getName() + " 重命名为?", file.getName(),
new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
if (path.trim().length() != 0 && !file.getName().equals(path)) {
File toFile = new File(file.getParentFile().getAbsolutePath() + File.separator + path);
file.renameTo(toFile);
lblInfo.setText("重命名:" + toFile.getName());
changeList();
}
}
});
}
}
});
btnRename.setBounds(435, 177, 113, 27);
getContentPane().add(btnRename);
JButton btnMove = new JButton("Move");
btnMove.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int index = list.getSelectedIndex();
if (index > 0) {
JFileChooser chooser = new JFileChooser(smaliPath.getText());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showSaveDialog(null);
File path = chooser.getSelectedFile();
File file = fileList.get(index);
file.renameTo(new File(path.getAbsolutePath() + File.separator + file.getName()));
lblInfo.setText("移动:" + file.getAbsolutePath());
changeList();
}
}
});
btnMove.setBounds(562, 137, 113, 27);
getContentPane().add(btnMove);
JButton btnDelete = new JButton("Delete");
btnDelete.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int index = list.getSelectedIndex();
if (index > 0) {
File file = fileList.get(index);
file.delete();
changeList();
}
}
});
btnDelete.setBounds(562, 177, 113, 27);
getContentPane().add(btnDelete);
JLabel lblAdb = new JLabel("Tools");
lblAdb.setBounds(404, 241, 72, 18);
getContentPane().add(lblAdb);
JLabel lblFile = new JLabel("File");
lblFile.setBounds(394, 117, 72, 18);
getContentPane().add(lblFile);
JLabel lblSetjarpath = new JLabel("jar/apk\u6587\u4EF6 (jar\u9700\u8981\u662Fdex\u7684\uFF09");
lblSetjarpath.setBounds(414, 284, 321, 18);
getContentPane().add(lblSetjarpath);
jarPath = new JTextField();
jarPath.setBounds(404, 315, 319, 24);
getContentPane().add(jarPath);
JButton btnSelect = new JButton("select");
btnSelect.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = new JFileChooser(new File("").getAbsolutePath());
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
jarPath.setText(file.getAbsolutePath());
}
});
btnSelect.setBounds(737, 315, 113, 27);
getContentPane().add(btnSelect);
JLabel lblSavedexpath = new JLabel("\u4FDD\u5B58\u4F4D\u7F6E");
lblSavedexpath.setBounds(414, 352, 134, 18);
getContentPane().add(lblSavedexpath);
savePath = new JTextField();
savePath.setBounds(404, 383, 319, 24);
getContentPane().add(savePath);
JButton btnSelect_1 = new JButton("select");
btnSelect_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = new JFileChooser(new File("").getAbsolutePath());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(null);
savePath.setText(chooser.getSelectedFile().getAbsolutePath());
}
});
btnSelect_1.setBounds(737, 380, 113, 27);
getContentPane().add(btnSelect_1);
JButton button = new JButton("\u62C6\u5305");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
lblInfo.setText("开始拆包");
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
if(jarPath.getText().trim().length()==0) {
new TextToDalog("警告", "没有选择目标文件");
return;
}
utils.unPack(jarPath.getText(), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
smaliPath.setText(path);
smaliHome = path;
lblInfo.setText("拆包完成");
}
});
}
}, 100);
}
});
button.setBounds(573, 454, 113, 113);
getContentPane().add(button);
JButton button_1 = new JButton("\u6253\u5305");
button_1.addMouseListener(new MouseAdapter() {
private String path;
@Override
public void mouseClicked(MouseEvent e) {
if (chckbxSavesmalipath.isSelected()&&smaliHome!=null)
smaliPath.setText(smaliHome);
if(savePath.getText().trim().length()==0) {
savePath.setText(smaliHome);
lblInfo.setText("没有填写保存路径,默认保存在当前目录");
new TextToDalog("警告", "没有填写保存路径,默认保存在当前目录");
}
if(jarPath.getText().trim().length()==0) {
path="dex.zip";
new TextToDalog("警告", "没有填写保存文件名默认为dex.zip");
}else {
path=new File(jarPath.getText()).getName();
}
lblInfo.setText("开始打包");
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
utils.bale(smaliPath.getText(), savePath.getText() + File.separator+path);
lblInfo.setText("打包完成,保存路径为:" + savePath.getText());
}
}, 100);
}
});
button_1.setBounds(715, 454, 113, 113);
getContentPane().add(button_1);
JButton btnOpenexlprer = new JButton("OpenExlprer");
btnOpenexlprer.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int index = list.getSelectedIndex();
if (index > 0) {
File file = fileList.get(index);
String path;
if (file.isDirectory()) {
path = file.getAbsolutePath();
} else {
path = file.getParentFile().getAbsolutePath();
}
try {
lblInfo.setText("已打开");
Desktop.getDesktop().open(new File(path));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
btnOpenexlprer.setBounds(689, 137, 139, 27);
getContentPane().add(btnOpenexlprer);
JButton btnNewButton = new JButton("\u4FEE\u6539");
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (chckbxSavesmalipath.isSelected())
smaliPath.setText(smaliHome);
File file = new File(smaliPath.getText());
for (File f : file.listFiles()) {
if (f.getName().equals("smali") && f.isDirectory()) {
smaliPath.setText(f.getAbsolutePath());
break;
}
}
lblInfo.setText("开始根据目录结构修改smali 请等待...");
utils.setPath(smaliPath.getText());
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
utils.start();
lblInfo.setText("完成");
}
}, 100);
}
});
btnNewButton.setBounds(435, 454, 113, 113);
getContentPane().add(btnNewButton);
JButton btnNewButton_1 = new JButton("Reload");
btnNewButton_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
changeList();
}
});
btnNewButton_1.setBounds(689, 177, 139, 27);
getContentPane().add(btnNewButton_1);
lblInfo = new JTextField("info");
lblInfo.setBorder(new LineBorder(Color.BLACK, 0));
lblInfo.setHorizontalAlignment(SwingConstants.LEFT);
lblInfo.setForeground(Color.BLACK);
lblInfo.setEditable(false);
lblInfo.setBounds(45, 580, 592, 18);
getContentPane().add(lblInfo);
chckbxSavesmalipath = new JCheckBox("\u8BB0\u5F55\u62C6\u5305\u7684Smali\u8DEF\u5F84");
chckbxSavesmalipath.setSelected(true);
chckbxSavesmalipath.setBounds(562, 9, 196, 37);
getContentPane().add(chckbxSavesmalipath);
JSeparator separator = new JSeparator();
separator.setBounds(394, 220, 453, 2);
getContentPane().add(separator);
JSeparator separator_1 = new JSeparator();
separator_1.setBounds(45, 92, 805, 2);
getContentPane().add(separator_1);
setVisible(true);
}
private void changeList() {
// TODO Auto-generated method stub
try {
File file = new File(smaliPath.getText());
File[] files = file.listFiles();
vector.clear();
fileList.clear();
vector.add("返回上层");
fileList.add(file.getParentFile());
for (File f : files) {
if (!f.isHidden()) {
vector.add(f.getName());
fileList.add(f);
}
}
list.setListData(vector);
lblInfo.setText("刷新界面");
} catch (Exception e) {
// TODO: handle exception
lblInfo.setText("刷新失败");
}
}
}

61
src/com/qy/ui/TextToDalog.java Executable file
View File

@ -0,0 +1,61 @@
package com.qy.ui;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JTextArea;
import com.qy.Interfaces.DalogAbs;
import javax.swing.JFrame;
import javax.swing.UIManager;
public class TextToDalog extends JFrame {
/**
*
*/
DalogAbs abs;
private static final long serialVersionUID = 1L;
public TextToDalog(String title,String text,DalogAbs abs) {
super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.abs=abs;
initView(text);
}
/**
* @wbp.parser.constructor
*/
public TextToDalog(String title,String text) {
// TODO Auto-generated constructor stub
new TextToDalog(title, text,null);
}
public void initView(String text) {
// TODO Auto-generated constructor stub
setSize(636, 231);
getContentPane().setLayout(null);
JTextArea lblNewLabel = new JTextArea(text);
lblNewLabel.setBackground(UIManager.getColor("Label.background"));
lblNewLabel.setEditable(false);
lblNewLabel.setLineWrap(true);
lblNewLabel.setBounds(42, 37, 438, 106);
getContentPane().add(lblNewLabel);
JButton btnOk = new JButton("ok");
btnOk.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TextToDalog.this.dispose();
if(abs!=null) {
abs.onSuccess();
}
}
});
btnOk.setBounds(491, 144, 113, 27);
getContentPane().add(btnOk);
setVisible(true);
}
}

140
src/com/qy/utils/AESTools.java Executable file
View File

@ -0,0 +1,140 @@
package com.qy.utils;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class AESTools {
public static final String key="langtianaes20188";
public static final String VIPARA = "1269571569321021";
public static final String bm = "utf-8";
/**
* 字节数组转化为大写16进制字符串
*
* @param b
* @return
*/
private static String byte2HexStr(byte[] b) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < b.length; i++) {
String s = Integer.toHexString(b[i] & 0xFF);
if (s.length() == 1) {
sb.append("0");
}
sb.append(s.toUpperCase());
}
return sb.toString();
}
/**
* 16进制字符串转字节数组
*
* @param s
* @return
*/
private static byte[] str2ByteArray(String s) {
int byteArrayLength = s.length() / 2;
byte[] b = new byte[byteArrayLength];
for (int i = 0; i < byteArrayLength; i++) {
byte b0 = (byte) Integer.valueOf(s.substring(i * 2, i * 2 + 2), 16)
.intValue();
b[i] = b0;
}
return b;
}
/**
* AES 加密
*
* @param content
* 明文
* @param password
* 生成秘钥的关键字
* @return
*/
public static String aesEncrypt(String content, String password) {
try {
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
// return Base64.encode(encryptedData);
return byte2HexStr(encryptedData);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/**
* AES 解密
*
* @param content
* 密文
* @param password
* 生成秘钥的关键字
* @return
*/
public static String aesDecrypt(String content, String password) {
try {
// byte[] byteMi = Base64.decode(content);
byte[] byteMi= str2ByteArray(content);
IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes());
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
byte[] decryptedData = cipher.doFinal(byteMi);
return new String(decryptedData, "utf-8");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,81 @@
package com.qy.utils;
import java.io.File;
import java.io.IOException;
public class ApkSignTools {
public static void main(String[] args) {
File file=new File("/media/yutou/_dde_data/AndroidStudio_Data/buildTools/hezi/test.apk.out/test.apk");
ApkSignTools tools=new ApkSignTools();
tools.setApkFile(file);
tools.setSignFile(new File("/media/yutou/_dde_data/AndroidKeys/langtian.jks"));
tools.setName("langtian");
tools.setKeyStorePassword("134679");
tools.setSignKey("134679");
tools.sign();
}
private File apkFile;
private File signFile;
private String signKey;
private String keyStorePassword;
private String name;
public ApkSignTools() {
// TODO Auto-generated constructor stub
}
public void sign() {
String exec="jarsigner -verbose -keystore " + signFile.getAbsolutePath() + " -keypass " + signKey
+ " -storepass " + keyStorePassword + " -signedjar " + apkFile.getAbsolutePath()+"_sign.apk" + " " + apkFile.getAbsolutePath() + " " + name;
System.out.println(exec);
try {
Runtime.getRuntime().exec(exec);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public File getSignFile() {
return signFile;
}
public void setSignFile(File signFile) {
this.signFile = signFile;
}
public String getSignKey() {
return signKey;
}
public void setSignKey(String signKey) {
this.signKey = signKey;
}
public String getKeyStorePassword() {
return keyStorePassword;
}
public void setKeyStorePassword(String keyStorePassword) {
this.keyStorePassword = keyStorePassword;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public File getApkFile() {
return apkFile;
}
public void setApkFile(File apkFile) {
this.apkFile = apkFile;
}
public boolean chack() {
// TODO Auto-generated method stub
if(apkFile==null||!apkFile.exists()) {
return false;
}
if(signFile==null||!signFile.exists()) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,431 @@
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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.json.JSONArray;
import org.json.JSONObject;
import com.qy.Interfaces.DalogAbs;
/*
配置JSON格式
{
"title": "趣赢SDK", //标题
"ltName": "qysdk.jar", //保存文件名
"manifest": [
//原始清单配置
],
"class": [ //希望变动的类
"com.qy.sdk.views.MyActivity",
],
"random": [//修改包名
"com",//固定包名
"[random]"//随机包名
],
"rename": {//修改类名
"MyActivity": "Activity",//指定类名
"TMProvider":"TProvider[notmover]",//指定包名但不移动路径
"BannerView":"[random]"//随机类名2~6
},
"isAllPackage":true,//修改所有包名false的话只修改class指定的包名
"isReName": true,//重命名类名
"isJarLib":true,//打出成jar包false的话则会进行加密
"packagerlimit": 3,//修改包名长度需小于或等于random数组
"isManual": false,//手动修改类文件
"manual": [
//需要手动修改的类
],
"dex2jar":"/media/yutou/_dde_data/反编译/dex2jar-2.0/_d2j-dex2jar.sh"//指定dex2jar的路径
}
*/
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.ui.TextToDalog;
public class AutoRandomAdSDK {
private File sdk;
private JSONObject config;
private SmaliUtils smalitools;
private Map<String, File> adClass;
private Map<String, File> nowAdClass;
private Map<String, String> nowAdFile;
private String rootPath;
private String dxPath;
private String version;
private String sdktype;
private SmaliApkToolsPath inter;
private boolean isDev = false;
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("GDTSDK.unionNormal.4.100.970.jar"), 0, null);
}
public AutoRandomAdSDK(File sdk,String version,String type, int cfgIndex, SmaliApkToolsPath inster) {
// TODO Auto-generated constructor stub
this.inter = inster;
this.version=version;
this.sdktype=type;
JSONObject cfg = Tools.loadConfig(new File("ad_config.cfg"));
if (cfg == null) {
throw new NullPointerException("没有广告配置文件");
}
this.sdk = sdk;
config = cfg.getJSONArray("array").getJSONObject(cfgIndex);
start();
}
public void start() {
adClass = new HashMap<String, File>();
nowAdClass = new HashMap<String, File>();
nowAdFile = new HashMap<String, String>();
smalitools = new SmaliUtils();
File tmpSdk = new File(sdk.getAbsolutePath().replace(sdk.getName(), "new_" + sdk.getName()));
if (isDev) {
dxPath="/media/yutou/_dde_data/AndroidStudio_Data/buildTools/dx.jar";
sdktype="3";
version="1000";
} else {
JSONObject json = Tools.loadConfig(new File("config.cfg"));
dxPath=json.getString("dx");
}
JarToAJar.toAJar(dxPath, sdk.getAbsolutePath(),
tmpSdk.getAbsolutePath());
sdk = new File(tmpSdk.getAbsolutePath());
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
smalitools.unPack(sdk.getAbsolutePath(), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
rootPath = path;
alter();
}
});
}
private void alter() {
JSONArray clazzs = config.getJSONArray("class");
for (int i = 0; i < clazzs.length(); i++) {
File clz = new File(rootPath + File.separator + "smali" + File.separator
+ clazzs.getString(i).replaceAll("\\.", File.separator) + ".smali");
if (clz.exists()) {
adClass.put(clazzs.getString(i), clz);
}
}
for (String key : adClass.keySet()) {
System.out.println("注入的值:" + key);
}
mkdirs();
update();
change();
}
private void outManifest() {
JSONArray array = new JSONArray();
for (String key : nowAdClass.keySet()) {
JSONArray manifest = config.getJSONArray("manifest");
for (int i = 0; i < manifest.length(); i++) {
if (manifest.getString(i).contains(key)) {
String path = nowAdClass.get(key).getAbsolutePath();
String newManifest = path
.replace(sdk.getAbsolutePath() + ".out" + File.separator + "smali" + File.separator, "");
try {
newManifest = newManifest.replaceAll(File.separator, ".") + "." + adClass.get(key).getName();
array.put(manifest.getString(i).replace(key, newManifest.replace(".smali", "")));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
System.out.println("-------->"+adClass.size());
for(String keys:adClass.keySet()) {
System.out.println(keys+" "+adClass.get(keys));
}
}
break;
}
}
}
File manifest = new File(sdk.getAbsolutePath() + ".out" + File.separator + "manifest.xml");
PrintWriter writer;
try {
writer = new PrintWriter(manifest);
for (int i = 0; i < array.length(); i++) {
writer.write(array.getString(i).toString() + "\n");
writer.flush();
}
writer.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void change() {
smalitools.setPath(sdk.getAbsolutePath() + ".out" + File.separator + "smali");
System.out.println(smalitools.mainPath);
try {
Thread.sleep(200);
System.out.println(smalitools.mainPath);
File file = new File(sdk.getAbsolutePath() + ".out" + File.separator + "smali");
if (file.exists()) {
smalitools.start();
if (config.getBoolean("isManual")) {
manual();
} else {
out();
}
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void manual() {
JSONArray man = config.getJSONArray("manual");
for (int i = 0; i < man.length(); i++) {
JSONObject json = man.getJSONObject(i);
File file = new File(sdk.getAbsolutePath() + ".out" + File.separator + "smali" + File.separator
+ json.getString("class").replace(".", File.separator) + ".smali");
if (file.exists()) {
List<Integer> list = new ArrayList<Integer>();
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String tmp;
int index = 1;
while ((tmp = reader.readLine()) != null) {
if (tmp.contains(json.getString("find"))) {
list.add(index);
}
index++;
}
reader.close();
Desktop.getDesktop().open(file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("请手动打开:" + file.getAbsolutePath() + " 文件");
}
String index="";
for (Integer integer : list) {
System.out.println("请修改第:" + integer + " 行附近的代码");
index+=integer+",";
}
new TextToDalog("提示", "请修改第:" + index + " 行附近的代码,备注:"+json.getString("msg"),new DalogAbs() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
out();
}
});
}
}
}
private void out() {
smalitools.bale(sdk.getAbsolutePath() + ".out",
sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName(),new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
try {
outManifest();
File lt;
if (!config.getBoolean("isJarLib")) {
JarToAJar.toAJar(dxPath, sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName(), sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName()+"_dex.jar");
new EncryptJar().encrypt(new File(sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName())
,sdk.getAbsolutePath() + ".out" + File.separator +"dexTmp.jar", sdktype, version);
lt = new File(sdk.getAbsolutePath() + ".out" + File.separator +"dexTmp.jar");
}else {
System.out.println(sdk.getAbsolutePath()+".out"+File.separator+sdk.getName());
Process process=Runtime.getRuntime().exec(config.getString("dex2jar")+" "+sdk.getAbsolutePath()+".out"+File.separator+sdk.getName());
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()) {
File nLt = new File(config.getString("ltName"));
lt.renameTo(nLt);
if (inter != null)
inter.smaliPath(nLt.getAbsolutePath());
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
}
private void update() {
for (String key : adClass.keySet()) {
File file = adClass.get(key);
String fileName = file.getName().replace(".smali", "");
File filePath = new File(file.getAbsolutePath().replace(file.getName(), ""));
for (File fs : filePath.listFiles()) {
if(fs.getName().equals("BuildConfig.smali")) {
fs.delete();
continue;
}
if (fs.getName().startsWith(fileName + "$")) {
if(getNewName(fs.getName()).endsWith("[notmover]")) {
Tools.copyFileToName(fs.getAbsolutePath(),fs.getAbsolutePath(),
getNewName(fs.getName()) + "$" + fs.getName().split("\\$")[1], true);
}else {
Tools.copyFileToName(fs.getAbsolutePath(), nowAdClass.get(key).getAbsolutePath(),
getNewName(fs.getName()) + "$" + fs.getName().split("\\$")[1], true);
}
fs.delete();
}
}
if(getNewNameForSrc(file.getName()).endsWith("[notmover]")) {
nowAdFile.put(key,file.getAbsolutePath());
Tools.copyFileToName(file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), ""),
getNewName(file.getName()) + ".smali", true);
}else {
nowAdFile.put(key, nowAdClass.get(key).getAbsolutePath());
Tools.copyFileToName(file.getAbsolutePath(), nowAdClass.get(key).getAbsolutePath(),
getNewName(file.getName()) + ".smali", true);
}
file.delete();
}
if(config.getBoolean("isAllPackage")) {
String tmp=nowAdClass.keySet().iterator().next();
File path=new File((nowAdClass.get(tmp)).getAbsolutePath());
String packge=path.getAbsolutePath().replace(rootPath+File.separator+"smali"+File.separator,"");
File root=new File(rootPath+File.separator+"smali");
allpackage(root,packge);
removeNullFile(root);
}
}
private void allpackage(File file,String packge) {
for(File tmp:file.listFiles()) {
String pack=tmp.getAbsolutePath().replace(rootPath+File.separator+"smali"+File.separator,"");
if(!packge.contains(pack)&&tmp.isDirectory()) {
movesdk(tmp, File.separator+"smali"+File.separator+packge);
}
if(tmp.isDirectory()) {
allpackage(tmp, packge);
}
}
}
private void movesdk(File path,String toPath) {
for(File file:path.listFiles()) {
if(file.isDirectory()) {
String tmp=toPath+File.separator+file.getName();
//System.out.println("创建文件夹:"+tmp);
new File(rootPath+File.separator+tmp).mkdirs();
movesdk(file, tmp);
}else {
// System.out.println("移动文件:"+file.getAbsolutePath().replace(rootPath, "")+""+toPath);
file.renameTo(new File(rootPath+File.separator+toPath,file.getName()));
}
}
}
private void removeNullFile(File root) {
for(File file:root.listFiles()) {
if(file.isDirectory()) {
if(file.listFiles().length==0) {
file.delete();
}else {
removeNullFile(file);
if(file.listFiles().length==0) {
file.delete();
}
}
}
}
}
private String getNewName(String name) {
String nName=getNewNameForSrc(name);
if(nName.endsWith("[notmover]")) {
nName=nName.replace("[notmover]", "");
}
return nName;
}
private String getNewNameForSrc(String name) {
// TODO Auto-generated method stub
if (!config.getBoolean("isReName")) {
return name;
}
String tmpName;
String wName = null;
name = name.replace(".smali", "");
if (name.contains("$")) {
tmpName = name.split("$")[0];
for (String t : name.split("$")) {
if (!t.equals(tmpName)) {
wName += t;
}
}
} else {
tmpName = name;
}
String nName = config.getJSONObject("rename")
.getString(tmpName.contains("$") ? tmpName.split("\\$")[0] : tmpName);
if(nName.contains("[random]")) {
String tName=Tools.getRandomString(new Random().nextInt(6)+2);
nName=nName.replace("[random]", tName);
config.getJSONObject("rename").put(tmpName.contains("$") ? tmpName.split("\\$")[0] : tmpName,nName);
}
if (wName != null) {
nName += wName;
}
return nName;
}
private void mkdirs() {
JSONArray clazzs = config.getJSONArray("class");
JSONArray random = config.getJSONArray("random");
for (int i = 0; i < clazzs.length(); i++) {
File path = new File(rootPath + File.separator + "smali");
File mkdir = null;
for (int j = 0; j < config.getInt("packagerlimit"); j++) {
String packageName;
if (random.getString(j).equals("[random]")) {
packageName = Tools.getRandomString(3);
} else {
packageName = random.getString(j);
}
if (mkdir == null) {
mkdir = new File(path.getAbsolutePath() + File.separator + packageName);
} else {
mkdir = new File(mkdir.getAbsolutePath() + File.separator + packageName);
}
if (!mkdir.exists()) {
mkdir.mkdirs();
}
}
nowAdClass.put(clazzs.getString(i), mkdir);
}
}
}

View File

@ -0,0 +1,131 @@
package com.qy.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class EncryptJar {
public static final int rd_rx=0;
public static final int qy_rx=4;
public static final int gdt=1;
public static final int uniplay=5;
public static final int pangllin=13;
public static final int oneway=11;
private static final int factor=0x23;
public static void main(String[] args) {
// TODO Auto-generated method stub
File file=new File("test_classes.jar");
EncryptJar tools=new EncryptJar();
//tools.encrypt(file, "test_classes.jar", rd_rx, 1000);
tools.decrypt(file, "decrypt_classes.jar");
}
public File encrypt(File file,String outputFile,String filetype,String ver) {
return encrypt(file, outputFile, Integer.parseInt(filetype), Integer.parseInt(ver));
}
public File encrypt(File file,String outputFile,int filetype,int ver) {
try {
int size=0;
byte[] buf=new byte[1024];
FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(int2byte(filetype));
System.out.println("资源包版本号:" + ver);
fos.write(int2byte(ver));
FileInputStream is = new FileInputStream(file);
while((size=is.read(buf))>0)
{
for(int i=0;i<size;i++)
{
buf[i] = (byte)(buf[i]&0xff ^ factor);
}
fos.write(buf, 0, size);
}
fos.close();
is.close();
return new File(outputFile);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
public FileData decrypt(File file,String outputFile) {
FileData fileData=new FileData();
try {
int size=0;
byte[] buf=new byte[1024];
byte[] data=new byte[4];
FileOutputStream fos = new FileOutputStream(outputFile);
FileInputStream is = new FileInputStream(file);
is.read(data);
fileData.type=byte2int(data);
is.read(data);
fileData.version=byte2int(data);
while((size=is.read(buf))>0)
{
for(int i=0;i<size;i++)
{
buf[i] = (byte)(buf[i]&0xff ^ factor);
}
fos.write(buf, 0, size);
}
fos.close();
is.close();
fileData.file=new File(outputFile);
return fileData;
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
static byte[] int2byte(int val)
{
byte[] b4 = new byte[4];
for(int i=0;i<b4.length;i++)
{
b4[b4.length-i-1] = (byte) ( (val>>(i*8)) & 0xff);
}
return b4;
}
static int byte2int(byte[] b4){
int val=0;
for(int i=0;i<b4.length;i++)
{
val = (b4[i] & 0xff) + (val<<8);
}
return val;
}
public class FileData{
private int type;
private int version;
private File file;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
@Override
public String toString() {
return "资源类型:"+type + " 版本号:" + version + " 文件路径:" + file.getAbsolutePath();
}
}
}

130
src/com/qy/utils/JarToAJar.java Executable file
View File

@ -0,0 +1,130 @@
package com.qy.utils;
import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.json.JSONArray;
import org.json.JSONObject;
import com.qy.ui.AppMain;
public class JarToAJar {
private static JSONObject json;
private final int BUFFER_SIZE = 2 * 1024;
public static void start(JSONObject json) {
JarToAJar.json=json;
JSONArray array=json.getJSONArray("array");
String inName=json.isNull("input")?"com.zip":json.getString("input");
String outName=json.isNull("out")?"rx.jar":json.getString("out")+array.getString(Integer.valueOf(json.getString("switch"))-1)+".jar";
new JarToAJar(inName,outName);
}
public JarToAJar(String inName,String outName) {
// TODO Auto-generated constructor stub
try {
String dx=json.isNull("dx")?"dx.jar":json.getString("dx");
File outFile=new File(inName);
if(outFile.exists())
outFile.delete();
OutputStream outputStream = new FileOutputStream(
new File(inName));
toZip(json.getString(json.getString("switch")), outputStream, true);
toAJar(dx,inName, outName);
System.out.println(outName);
if(AppMain.isOpenWindows)
Desktop.getDesktop().open(new File(json.getString("out")));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public static void toAJar(String dx,String inName,String outName) {
try {
File file=new File(outName);
if(file.exists()) {
file.delete();
}
String exec="java -jar "+dx+" --dex --output="+outName+" "+inName+"";
System.out.println("java to dex:"+exec);
Process process=Runtime.getRuntime().exec(exec);
process.waitFor();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void toZip(String srcDir, OutputStream out, boolean KeepDirStructure) throws RuntimeException {
long start = System.currentTimeMillis();
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(out);
File sourceFile = new File(srcDir);
compress(sourceFile, zos, sourceFile.getName(), KeepDirStructure);
long end = System.currentTimeMillis();
System.out.println("压缩完成,耗时:" + (end - start) + " ms");
} catch (Exception e) {
throw new RuntimeException("zip error from ZipUtils", e);
} finally {
if (zos != null) {
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private void compress(File sourceFile, ZipOutputStream zos, String name, boolean KeepDirStructure)
throws Exception {
byte[] buf = new byte[BUFFER_SIZE];
if (sourceFile.isFile()) {
// 向zip输出流中添加一个zip实体构造器中name为zip实体的文件的名字
zos.putNextEntry(new ZipEntry(name));
// copy文件到zip输出流中
int len;
FileInputStream in = new FileInputStream(sourceFile);
while ((len = in.read(buf)) != -1) {
zos.write(buf, 0, len);
}
// Complete the entry
zos.closeEntry();
in.close();
} else {
File[] listFiles = sourceFile.listFiles();
if (listFiles == null || listFiles.length == 0) {
// 需要保留原来的文件结构时,需要对空文件夹进行处理
if (KeepDirStructure) {
// 空文件夹的处理
zos.putNextEntry(new ZipEntry(name + File.separator));
// 没有文件不需要文件的copy
zos.closeEntry();
}
} else {
for (File file : listFiles) {
// 判断是否需要保留原来的文件结构
if (KeepDirStructure) {
// 注意file.getName()前面需要带上父文件夹的名字加一斜杠,
// 不然最后压缩包中就不能保留原来的文件结构,所有文件都跑到压缩包根目录下了
compress(file, zos, name + File.separator + file.getName(), KeepDirStructure);
} else {
compress(file, zos, file.getName(), KeepDirStructure);
}
}
}
}
}
}

77
src/com/qy/utils/JarToBase.java Executable file
View File

@ -0,0 +1,77 @@
package com.qy.utils;
import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.PrintWriter;
import com.qy.ui.AppMain;
import com.sun.org.apache.xml.internal.security.utils.Base64;
public class JarToBase {
public static void start(String jarPath,boolean isBase) {
// TODO Auto-generated method stub
try {
new JarToBase(jarPath,isBase);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public JarToBase(String jarPath,boolean isBase) throws Exception {
// TODO Auto-generated constructor stub
if(isBase) {
encode(jarPath);
}else {
decode(jarPath);
}
}
public void decode(String basePath) throws Exception{
File file=new File(basePath);
File out=new File(new File("").getAbsolutePath()+File.separator+file.getName().split("\\.")[0]+".jar");
BufferedReader reader=new BufferedReader(new FileReader(file));
String tmp,str="";
while ((tmp=reader.readLine())!=null) {
str+=tmp;
}
byte[] b=Base64.decode(str);
DataOutputStream outputStream=new DataOutputStream(new FileOutputStream(out));
outputStream.write(b);
outputStream.flush();
outputStream.close();
reader.close();
if(AppMain.isOpenWindows)
Desktop.getDesktop().open(new File(new File("").getAbsolutePath()));
}
public void encode(String jarPath)throws Exception{
File file=new File(jarPath);
DataInputStream inputStream=new DataInputStream(new FileInputStream(file));
byte[] b=new byte[inputStream.available()];
while ((inputStream.read(b))!=-1) {
}
inputStream.close();
String str=new String(Base64.encode(b));
// System.out.println(str);
save(str,file.getName().split("\\.")[0]);
}
public void save(String str,String name )throws Exception {
File file=new File(new File("").getAbsolutePath()+File.separator+name+".lt");
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>:"+file.getAbsolutePath());
file.createNewFile();
PrintWriter writer=new PrintWriter(file);
writer.write(str);
writer.flush();
writer.close();
if(AppMain.isOpenWindows)
Desktop.getDesktop().open(new File(file.getAbsolutePath().substring(0, file.getAbsolutePath().length()-file.getName().length())));
}
}

36
src/com/qy/utils/KeyTools.java Executable file
View File

@ -0,0 +1,36 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class KeyTools {
public static String getRSAkey(File file,String key,boolean isRsa) {
try {
String exec;
if(isRsa) {
exec="keytool -printcert -file "+file.getAbsolutePath();
}else {
exec="keytool -list -v -keystore "+file.getAbsolutePath()+" -storepass "+key;
}
System.out.println(exec);
Process process=Runtime.getRuntime().exec(exec);
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
String str="",tmp;
while ((tmp=reader.readLine())!=null) {
str+=tmp+"\n";
}
reader.close();
System.out.println(str);
return str;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "null";
}
public static void main(String[] args) {
getRSAkey(new File("D:\\AndroidKeys\\langtian.jks"),"134679",false);
}
}

211
src/com/qy/utils/SmaliUtils.java Executable file
View File

@ -0,0 +1,211 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.qy.Interfaces.SmaliApkToolsPath;
import brut.apktool.Main;
public class SmaliUtils {
private String str = "";
public String mainPath =null;
private int mix = 1000;
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
private Map<String, String> clazzList = new HashMap<>();
private List<File> files = new ArrayList<>();
public static void main(String[] args) {
new SmaliUtils();
}
public SmaliUtils() {
}
public void setPath(String uPath) {
mainPath=uPath;
}
public void start() {
System.out.println("开始修改:"+mainPath);
File path = new File(mainPath);
recursive(path);
try {
System.out.println(clazzList.size());
for (File file : files) {
loadFile(file);
writerFile(file);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
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 {
readFile(file, packname);
/*
* 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 void readFile(File file, String packName) throws Exception {
boolean isOneLine = true;
BufferedReader reader = new BufferedReader(new FileReader(file));
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", "");
}
if (newName != null) {
newName = newName.replace(";", "");
//System.out.println("获取到老包名:" + newName + "新包名:" + (packName + "/" + file.getName().replace(".smali", "")));
clazzList.put(newName, (packName + File.separator + file.getName().replace(".smali", "")));
if (clazzList.get(newName).length() < mix) {
mix = clazzList.get(newName).length();
}
}
isOneLine = false;
}
// tmp = changeLine(tmp);
str += tmp + "\n";
}
reader.close();
}
private String loadFile(File file) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(file));
str = "";
String tmp = null;
while ((tmp = reader.readLine()) != null) {
str += tmp + "\n";
}
reader.close();
return str;
}
private void writerFile(File file) throws Exception {
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));
//System.out.println((i++) + " 修改:" + t + " 到:" + old + " " + clazz);
}
}
return old;
}
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};
try {
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().split("\\.")[0];
}else {
name=jarFile.getName();
}
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 path,String smaliPath,SmaliApkToolsPath inter) {
String args[]=new String[] {"b","-f",path,"-o",smaliPath};
for (String string : args) {
System.out.print(string+" ");
}
try {
Main.main(args);
if(inter!=null) {
inter.smaliPath("ok");
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
if(inter!=null) {
inter.smaliPath("error");
}
}
}
}

148
src/com/qy/utils/Tools.java Executable file
View File

@ -0,0 +1,148 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Random;
import org.json.JSONObject;
public class Tools {
public static boolean stringIsNull(String string) {
if (string == null || string.length() == 0) {
return true;
}
return false;
}
public static String getRandomString(int length) {
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(str.length());
sb.append(str.charAt(number));
}
return sb.toString();
}
public static int getRandomInt(int min,int max) {
int i=new Random().nextInt(max);
if(i<min) {
return getRandomInt(min, max);
}
return i;
}
public static void deleteFiles(String path) {
File files = new File(path);
if (files.exists()) {
if (files.isDirectory()) {
for (File file : files.listFiles()) {
deleteFiles(file.getAbsolutePath());
}
}
// System.out.println("ɾ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> "+files.getAbsolutePath());
files.delete();
}
}
public static boolean copyFileToName(String srcFileName,String destFileName,String fileName,boolean overlay) {
File srcFile = new File(srcFileName);
// <EFBFBD>ж<EFBFBD>Դ<EFBFBD>ļ<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (!srcFile.exists()) {
return false;
} else if (!srcFile.isFile()) {
return false;
}
// <EFBFBD>ж<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
File destFile = new File(destFileName);
// <EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>򴴽<EFBFBD>Ŀ¼
if (!destFile.exists()) {
// Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (!destFile.mkdirs()) {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼ʧ<EFBFBD><EFBFBD>
return false;
}
}
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
int byteread = 0; // <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD>
InputStream in = null;
OutputStream out = null;
try {
if(fileName==null) {
fileName=srcFile.getName();
}
in = new FileInputStream(srcFile);
out = new FileOutputStream(destFile + "/" +fileName );
byte[] buffer = new byte[1024];
while ((byteread = in.read(buffer)) != -1) {
out.write(buffer, 0, byteread);
}
return true;
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (out != null)
out.close();
if (in != null)
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* <EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
*
* @param srcFileName <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @param destFileName Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @param overlay <EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>Ƿ񸲸<EFBFBD>
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>false
*/
public static boolean copyFile(String srcFileName, String destFileName,
boolean overlay) {
return copyFileToName(srcFileName, destFileName, null, overlay);
}
public static JSONObject loadConfig(File file) {
JSONObject json = null;
BufferedReader reader;
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
reader = new BufferedReader(new FileReader(file));
String tmp, str = "";
while ((tmp = reader.readLine()) != null) {
str += tmp;
}
json = new JSONObject(str);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return json;
}
}

View File

@ -0,0 +1,37 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.Map;
public class WorldTools {
public static void start(String packName, String managename,Map<String,String> functions) {
try {
BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(new File("data"+File.separator+"½ÓÈëÎĵµ.txt")), "UTF-8"));
String str="",tmp;
while ((tmp=reader.readLine())!=null) {
tmp=tmp.replace("${GameSDK}", managename);
tmp=tmp.replace("${init}", functions.get("init"));
tmp=tmp.replace("${pay}", functions.get("pay"));
tmp=tmp.replace("${getTextAlpha}", functions.get("getTextAlpha"));
tmp=tmp.replace("${getPermission}", functions.get("getPermission"));
tmp=tmp.replace("${authority}", functions.get("authority"));
tmp=tmp.replace("${getSDKManage}", functions.get("getSDKManage"));
str+=tmp+"\n";
}
FileWriter writer=new FileWriter(new File("Îĵµ.txt"));
writer.write(str);
writer.flush();
writer.close();
reader.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}

12
src/com/qy/utils/ZipTest.java Executable file
View File

@ -0,0 +1,12 @@
package com.qy.utils;
public class ZipTest {
public static void main(String[] args) throws Exception {
new ZipTest();
}
public ZipTest()throws Exception {
// TODO Auto-generated constructor stub
}
}