测试穿山甲资源包工具
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());
|
||||
@ -119,6 +118,7 @@ public class AppMain extends JFrame {
|
||||
File file;
|
||||
Timer timer;
|
||||
String name, path;
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (configList.getSelectedIndex() < 0) {
|
||||
@ -166,6 +166,7 @@ public class AppMain extends JFrame {
|
||||
json.put("switch", configList.getSelectedIndex() + 1 + "");
|
||||
new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
|
||||
String version;
|
||||
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -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,6 +268,7 @@ 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
|
||||
@ -280,7 +283,10 @@ public class AppMain extends JFrame {
|
||||
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));
|
||||
System.out.println("data路径为:" + fileOut.getAbsolutePath());
|
||||
if (log != null)
|
||||
log.setText("data路径为:" + fileOut.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