测试穿山甲资源包工具
This commit is contained in:
parent
81db19fd4b
commit
9fa2eb3a02
@ -94,7 +94,6 @@ public class AppMain extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initView() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
@ -118,36 +117,37 @@ public class AppMain extends JFrame {
|
||||
zipToJar.addMouseListener(new MouseAdapter() {
|
||||
File file;
|
||||
Timer timer;
|
||||
String name,path;
|
||||
String name, path;
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(configList.getSelectedIndex()<0) {
|
||||
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())
|
||||
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 = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
log.setText("已生成" + name);
|
||||
timer.cancel();
|
||||
}else {
|
||||
} else {
|
||||
log.setText("正在生成");
|
||||
}
|
||||
}
|
||||
}, 0,100);
|
||||
}, 0, 100);
|
||||
|
||||
}
|
||||
});
|
||||
@ -159,28 +159,29 @@ public class AppMain extends JFrame {
|
||||
jarToBase.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(configList.getSelectedIndex()<0) {
|
||||
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) {
|
||||
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")
|
||||
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")
|
||||
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());
|
||||
@ -259,6 +260,7 @@ public class AppMain extends JFrame {
|
||||
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()));
|
||||
@ -266,11 +268,12 @@ public class AppMain extends JFrame {
|
||||
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) {
|
||||
version = path;
|
||||
if (version == null) {
|
||||
return;
|
||||
}
|
||||
new EditToDalog("资源类型", "请输入资源类型\n0=内核\n4=自主广告\n1=广点通\n5=聚量\n11=万维\n13=穿山甲", "", new SmaliApkToolsPath() {
|
||||
@ -278,9 +281,12 @@ public class AppMain extends JFrame {
|
||||
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)
|
||||
File fileOut = new EncryptJar().encrypt(new File(file.getAbsolutePath().replace(file.getName(), "dexTmp.jar")), file.getAbsolutePath() + "_encrypt.jar", Integer.valueOf(path)
|
||||
, Integer.valueOf(version));
|
||||
System.out.println("data路径为:" + fileOut.getAbsolutePath());
|
||||
if (log != null)
|
||||
log.setText("data路径为:" + fileOut.getAbsolutePath());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -298,13 +304,13 @@ public class AppMain extends JFrame {
|
||||
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";
|
||||
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);
|
||||
EncryptJar.FileData data = new EncryptJar().decrypt(file, fileName);
|
||||
new TextToDalog("解码提示", data.toString());
|
||||
//JarToBase.start(file.getAbsolutePath(), false);
|
||||
log.setText("已解码");
|
||||
@ -370,7 +376,7 @@ public class AppMain extends JFrame {
|
||||
chooser.showOpenDialog(null);
|
||||
File java = chooser.getSelectedFile();
|
||||
JarToAJar.toAJar(json.getString("dx"), java.getAbsolutePath(),
|
||||
new File("").getAbsolutePath() + File.separator+java.getName()+"_jar.jar");
|
||||
new File("").getAbsolutePath() + File.separator + java.getName() + "_jar.jar");
|
||||
if (AppMain.isOpenWindows) {
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(new File("").getAbsolutePath()));
|
||||
|
111
src/com/qy/utils/CsjTools.java
Normal file
111
src/com/qy/utils/CsjTools.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.qy.utils;
|
||||
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import com.qy.ui.TextToDalog;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CsjTools {
|
||||
private String csj_R_path="E:\\idea\\android_sdk_tools\\demo_2.8.0.1\\smali\\com\\bytedance\\sdk\\openadsdk";
|
||||
private String csj_demo_path="E:\\idea\\android_sdk_tools\\demo_2.8.0.1";
|
||||
private String apk_R_path="E:\\idea\\android_sdk_tools\\app-release-1\\smali\\com\\luckyboy\\mmxing";
|
||||
private List<String> r_list;
|
||||
public CsjTools() {
|
||||
}
|
||||
public void setR() {
|
||||
r_list=new ArrayList<>();
|
||||
File apk_R=new File(csj_R_path+File.separator+"R.smali");
|
||||
if(!apk_R.exists()){
|
||||
new TextToDalog("找不到文件","穿山甲R文件不存在:"+apk_R);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(apk_R));
|
||||
String tmp;
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
if(tmp.contains("/R$")){
|
||||
r_list.add(tmp.split("/")[tmp.split("/").length-1].replace(";,","").replace(";",""));
|
||||
}
|
||||
}
|
||||
/*for (String fileName : r_list) {
|
||||
setRData(fileName);
|
||||
}*/
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void setRData(String fileName){
|
||||
File apkR=new File(apk_R_path+File.separator+fileName+".smali");
|
||||
|
||||
List<String> header=new ArrayList<>();
|
||||
List<String> end=new ArrayList<>();
|
||||
|
||||
boolean isHeader=true;
|
||||
long id=-1;
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(apkR));
|
||||
String tmp;
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
if(tmp.trim().equals("# direct methods")){
|
||||
isHeader=false;
|
||||
}
|
||||
if(isHeader){
|
||||
header.add(tmp);
|
||||
if(tmp.contains(":I = 0x")){
|
||||
id=Long.parseLong(tmp.split("0x")[1],16);
|
||||
}
|
||||
}else{
|
||||
end.add(tmp);
|
||||
}
|
||||
}
|
||||
header.addAll(getCSJR(fileName,id));
|
||||
header.addAll(end);
|
||||
FileWriter writer=new FileWriter(apkR);
|
||||
for (String str : header) {
|
||||
writer.write(str+"\n");
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private List<String> getCSJR(String fileName,long id){
|
||||
File csjR=new File(csj_R_path+File.separator+fileName+".smali");
|
||||
List<String> csj=new ArrayList<>();
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(csjR));
|
||||
String tmp;
|
||||
long nextId=id;
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
if(tmp.trim().startsWith(".field public")){
|
||||
csj.add(tmp.replace(".field public static",".field public static final")+" = 0x"+Long.toHexString(++nextId));
|
||||
}
|
||||
}
|
||||
csj.add("\n");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return csj;
|
||||
}
|
||||
private void copyFile(){
|
||||
setR();
|
||||
for (String s : r_list) {
|
||||
Tools.copyFile(apk_R_path+File.separator+s+".smali",csj_R_path+File.separator+s+".smali",true);
|
||||
}
|
||||
|
||||
}
|
||||
private void out(){
|
||||
EncryptJar encryptJar=new EncryptJar();
|
||||
encryptJar.encrypt(new File("E:\\idea\\android_sdk_tools\\csj.apk"),"E:\\idea\\android_sdk_tools\\csj_",13,5600);
|
||||
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
CsjTools tools=new CsjTools();
|
||||
tools.out();
|
||||
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class EncryptJar {
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
fos.write(int2byte(filetype));
|
||||
|
||||
System.out.println("资源包版本号:" + ver);
|
||||
System.out.println("资源包版本号:" + ver);
|
||||
fos.write(int2byte(ver));
|
||||
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
@ -124,7 +124,7 @@ public class EncryptJar {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "资源类型:"+type + " 版本号:" + version + " 文件路径:" + file.getAbsolutePath();
|
||||
return "资源类型:"+type + " 版本号:" + version + " 文件路径:" + file.getAbsolutePath();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ public class Tools {
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼ʧ<EFBFBD><EFBFBD>
|
||||
return false;
|
||||
}
|
||||
destFile.delete();
|
||||
|
||||
}
|
||||
|
||||
@ -82,7 +83,7 @@ public class Tools {
|
||||
fileName=srcFile.getName();
|
||||
}
|
||||
in = new FileInputStream(srcFile);
|
||||
out = new FileOutputStream(destFile + "/" +fileName );
|
||||
out = new FileOutputStream(destFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
while ((byteread = in.read(buffer)) != -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user