测试穿山甲资源包工具

This commit is contained in:
Yutousama 2020-02-16 21:49:13 +08:00
parent 81db19fd4b
commit 9fa2eb3a02
4 changed files with 563 additions and 445 deletions

View File

@ -39,486 +39,492 @@ import com.qy.utils.JarToBase;
import com.qy.utils.Tools; import com.qy.utils.Tools;
public class AppMain extends JFrame { public class AppMain extends JFrame {
private JList<String> configList; private JList<String> configList;
private JButton zipToJar, jarToBase, reload, btnAdbPull; private JButton zipToJar, jarToBase, reload, btnAdbPull;
private JTextField log; private JTextField log;
public static JSONObject json; public static JSONObject json;
private Vector<String> vector; private Vector<String> vector;
public static boolean isOpenWindows = false; public static boolean isOpenWindows = false;
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JTextField txtCom; private JTextField txtCom;
private JButton btnUserBase; private JButton btnUserBase;
private JTextField textPackName; private JTextField textPackName;
private JButton btnRestartapp; private JButton btnRestartapp;
private JLabel lblactivity; private JLabel lblactivity;
private JTextField textActivity; private JTextField textActivity;
private JMenuBar menuBar; private JMenuBar menuBar;
private JTextField uFilePath; private JTextField uFilePath;
private JSeparator separator; private JSeparator separator;
private JMenuItem menuItem_1; private JMenuItem menuItem_1;
private JCheckBox openWindows; private JCheckBox openWindows;
private JMenu mnBasetools; private JMenu mnBasetools;
private JMenuItem mntmbase; private JMenuItem mntmbase;
private JMenuItem mntmBase; private JMenuItem mntmBase;
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
new AppMain(); new AppMain();
} }
public AppMain() { public AppMain() {
setResizable(false); setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
json = Tools.loadConfig(new File("config.cfg")); json = Tools.loadConfig(new File("config.cfg"));
initView(); initView();
initData(); initData();
log.setText("已载入配置文件"); log.setText("已载入配置文件");
separator = new JSeparator(); separator = new JSeparator();
separator.setBounds(247, 149, 158, 2); separator.setBounds(247, 149, 158, 2);
getContentPane().add(separator); getContentPane().add(separator);
repaint(); repaint();
} }
private void initData() { private void initData() {
JSONArray array = json.getJSONArray("array"); JSONArray array = json.getJSONArray("array");
vector = new Vector<>(); vector = new Vector<>();
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
vector.add(array.getString(i)); vector.add(array.getString(i));
} }
configList.setListData(vector); 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);
private void initView() { configList = new JList<String>();
try { configList.setBounds(0, 0, 1, 1);
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>(); JScrollPane scrollBar = new JScrollPane(configList);
configList.setBounds(0, 0, 1, 1); scrollBar.setBounds(51, 49, 147, 215);
getContentPane().add(scrollBar);
JScrollPane scrollBar = new JScrollPane(configList); zipToJar = new JButton("\u8F6Cjar");
scrollBar.setBounds(51, 49, 147, 215); zipToJar.addMouseListener(new MouseAdapter() {
getContentPane().add(scrollBar); File file;
Timer timer;
String name, path;
zipToJar = new JButton("\u8F6Cjar"); @Override
zipToJar.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) {
File file; if (configList.getSelectedIndex() < 0) {
Timer timer; new TextToDalog("警告", "列表未选择");
String name,path; return;
@Override }
public void mouseClicked(MouseEvent e) { json.put("switch", configList.getSelectedIndex() + 1 + "");
if(configList.getSelectedIndex()<0) { path = json.getString("out");
new TextToDalog("警告", "列表未选择"); name = json.getJSONArray("array").getString(Integer.valueOf(json.getString("switch")) - 1) + ".jar";
return; file = new File(path + name);
} if (file.exists())
json.put("switch", configList.getSelectedIndex() + 1 + ""); file.delete();
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); JarToAJar.start(json);
timer=new Timer(); timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if(file.exists()) { if (file.exists()) {
log.setText("已生成" + name); log.setText("已生成" + name);
timer.cancel(); timer.cancel();
}else { } else {
log.setText("正在生成"); log.setText("正在生成");
} }
} }
}, 0,100); }, 0, 100);
} }
}); });
zipToJar.setBounds(247, 72, 158, 27); zipToJar.setBounds(247, 72, 158, 27);
getContentPane().add(zipToJar); getContentPane().add(zipToJar);
jarToBase = new JButton("\u52A0\u5BC6Jar"); jarToBase = new JButton("\u52A0\u5BC6Jar");
jarToBase.addMouseListener(new MouseAdapter() { jarToBase.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(configList.getSelectedIndex()<0) { if (configList.getSelectedIndex() < 0) {
new TextToDalog("警告", "列表未选择"); new TextToDalog("警告", "列表未选择");
return; return;
} }
json.put("switch", configList.getSelectedIndex() + 1 + ""); json.put("switch", configList.getSelectedIndex() + 1 + "");
new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() { new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
String version; 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);
*/
} @Override
}); public void smaliPath(String path) {
jarToBase.setBounds(247, 109, 158, 27); // TODO Auto-generated method stub
getContentPane().add(jarToBase); 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);
*/
reload = new JButton("\u91CD\u8F7D\u914D\u7F6E\u6587\u4EF6"); }
reload.addMouseListener(new MouseAdapter() { });
@Override jarToBase.setBounds(247, 109, 158, 27);
public void mouseClicked(MouseEvent e) { getContentPane().add(jarToBase);
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"); reload = new JButton("\u91CD\u8F7D\u914D\u7F6E\u6587\u4EF6");
log.setBorder(new LineBorder(Color.BLACK, 0)); reload.addMouseListener(new MouseAdapter() {
log.setHorizontalAlignment(SwingConstants.LEFT); @Override
log.setForeground(Color.BLACK); public void mouseClicked(MouseEvent e) {
log.setEditable(false); initData();
log.setBounds(51, 340, 766, 31); json = Tools.loadConfig(new File("config.cfg"));
getContentPane().add(log); log.setText("已重置");
}
});
reload.setBounds(51, 13, 153, 27);
getContentPane().add(reload);
txtCom = new JTextField(); log = new JTextField("\u521D\u59CB\u5316");
txtCom.setHorizontalAlignment(SwingConstants.LEFT); log.setBorder(new LineBorder(Color.BLACK, 0));
txtCom.setText("adb push \"" + new File("").getAbsolutePath() + "/[jar]/data/data/[packname]/plugs/"); log.setHorizontalAlignment(SwingConstants.LEFT);
txtCom.setBounds(444, 73, 293, 27); log.setForeground(Color.BLACK);
getContentPane().add(txtCom); log.setEditable(false);
txtCom.setColumns(10); log.setBounds(51, 340, 766, 31);
getContentPane().add(log);
JLabel lblAdb = new JLabel("adb\u6307\u4EE4"); txtCom = new JTextField();
lblAdb.setBounds(444, 51, 72, 18); txtCom.setHorizontalAlignment(SwingConstants.LEFT);
getContentPane().add(lblAdb); txtCom.setText("adb push \"" + new File("").getAbsolutePath() + "/[jar]/data/data/[packname]/plugs/");
txtCom.setBounds(444, 73, 293, 27);
getContentPane().add(txtCom);
txtCom.setColumns(10);
btnAdbPull = new JButton("adb"); JLabel lblAdb = new JLabel("adb\u6307\u4EE4");
btnAdbPull.addMouseListener(new MouseAdapter() { lblAdb.setBounds(444, 51, 72, 18);
@Override getContentPane().add(lblAdb);
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 = new JButton("adb");
}); btnAdbPull.addMouseListener(new MouseAdapter() {
btnAdbPull.setBounds(444, 295, 147, 27); @Override
getContentPane().add(btnAdbPull); 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("执行失败");
}
new ButtonGroup(); }
});
btnAdbPull.setBounds(444, 295, 147, 27);
getContentPane().add(btnAdbPull);
btnUserBase = new JButton("\u52A0\u5BC6\u6587\u4EF6"); new ButtonGroup();
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"); btnUserBase = new JButton("\u52A0\u5BC6\u6587\u4EF6");
btnNewButton.addMouseListener(new MouseAdapter() { btnUserBase.addMouseListener(new MouseAdapter() {
@Override File file;
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"); @Override
openWindows.addActionListener(new ActionListener() { public void mouseClicked(MouseEvent e) {
public void actionPerformed(ActionEvent e) { JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
isOpenWindows = openWindows.isSelected(); jFile.showOpenDialog(null);
} file = jFile.getSelectedFile();
}); new EditToDalog("需要版本号", "请输入资源版本号", "", new SmaliApkToolsPath() {
String version;
openWindows.setBounds(247, 30, 133, 31); @Override
getContentPane().add(openWindows); 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));
System.out.println("data路径为:" + fileOut.getAbsolutePath());
if (log != null)
log.setText("data路径为:" + fileOut.getAbsolutePath());
JLabel label = new JLabel("\u5305\u540D"); }
label.setBounds(444, 113, 72, 18); });
getContentPane().add(label); }
});
//JarToBase.start(file.getAbsolutePath(), true);
}
});
btnUserBase.setBounds(247, 160, 158, 27);
getContentPane().add(btnUserBase);
textPackName = new JTextField(); JButton btnNewButton = new JButton("\u89E3\u5BC6\u6587\u4EF6");
textPackName.setText("com.luckyboy.mmxing"); btnNewButton.addMouseListener(new MouseAdapter() {
textPackName.setBounds(444, 135, 293, 24); @Override
getContentPane().add(textPackName); public void mouseClicked(MouseEvent e) {
textPackName.setColumns(10); 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);
btnRestartapp = new JButton("\u91CD\u542FAPP"); openWindows = new JCheckBox("\u6253\u5F00\u7A97\u53E3");
btnRestartapp.addMouseListener(new MouseAdapter() { openWindows.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
public void mouseClicked(MouseEvent e) { isOpenWindows = openWindows.isSelected();
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"); openWindows.setBounds(247, 30, 133, 31);
lblactivity.setBounds(444, 164, 119, 18); getContentPane().add(openWindows);
getContentPane().add(lblactivity);
textActivity = new JTextField(); JLabel label = new JLabel("\u5305\u540D");
textActivity.setText(".MainActivity"); label.setBounds(444, 113, 72, 18);
textActivity.setBounds(444, 185, 293, 24); getContentPane().add(label);
getContentPane().add(textActivity);
textActivity.setColumns(10);
JButton btnJavatoajar = new JButton("Jar\u8F6C\u5B89\u5353Jar"); textPackName = new JTextField();
btnJavatoajar.addMouseListener(new MouseAdapter() { textPackName.setText("com.luckyboy.mmxing");
@Override textPackName.setBounds(444, 135, 293, 24);
public void mouseClicked(MouseEvent e) { getContentPane().add(textPackName);
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath())); textPackName.setColumns(10);
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"); btnRestartapp = new JButton("\u91CD\u542FAPP");
label_t.setBounds(444, 215, 208, 18); btnRestartapp.addMouseListener(new MouseAdapter() {
getContentPane().add(label_t); @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);
uFilePath = new JTextField(); lblactivity = new JLabel("\u4E3BActivity");
uFilePath.setBounds(444, 238, 293, 24); lblactivity.setBounds(444, 164, 119, 18);
getContentPane().add(uFilePath); getContentPane().add(lblactivity);
uFilePath.setColumns(10);
JButton button = new JButton("\u83B7\u53D6"); textActivity = new JTextField();
button.addMouseListener(new MouseAdapter() { textActivity.setText(".MainActivity");
@Override textActivity.setBounds(444, 185, 293, 24);
public void mouseClicked(MouseEvent e) { getContentPane().add(textActivity);
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath())); textActivity.setColumns(10);
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
uFilePath.setText(file.getAbsolutePath());
log.setText("获取自定义文件路径完成");
} JButton btnJavatoajar = new JButton("Jar\u8F6C\u5B89\u5353Jar");
}); btnJavatoajar.addMouseListener(new MouseAdapter() {
button.setBounds(755, 235, 113, 27); @Override
getContentPane().add(button); 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);
menuBar = new JMenuBar(); 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);
setJMenuBar(menuBar); uFilePath = new JTextField();
uFilePath.setBounds(444, 238, 293, 24);
getContentPane().add(uFilePath);
uFilePath.setColumns(10);
JMenu mnNewMenu = new JMenu("\u83DC\u5355"); JButton button = new JButton("\u83B7\u53D6");
menuBar.add(mnNewMenu); 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("获取自定义文件路径完成");
JMenuItem menuItem = new JMenuItem("\u91CD\u542F"); }
menuItem.addActionListener(new ActionListener() { });
public void actionPerformed(ActionEvent e) { button.setBounds(755, 235, 113, 27);
dispose(); getContentPane().add(button);
new AppMain();
}
});
mnNewMenu.add(menuItem); menuBar = new JMenuBar();
JMenu menu = new JMenu("\u5DE5\u5177"); setJMenuBar(menuBar);
menuBar.add(menu);
JMenuItem mntmAes = new JMenuItem("AES\u5DE5\u5177"); JMenu mnNewMenu = new JMenu("\u83DC\u5355");
mntmAes.addActionListener(new ActionListener() { menuBar.add(mnNewMenu);
public void actionPerformed(ActionEvent e) {
new AESUi();
}
});
menu.add(mntmAes);
JMenuItem mntmSmali = new JMenuItem("Smali\u5DE5\u5177"); JMenuItem menuItem = new JMenuItem("\u91CD\u542F");
mntmSmali.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new SmaliUi(); dispose();
} new AppMain();
}); }
menu.add(mntmSmali); });
JMenuItem mntmsdk = new JMenuItem("\u4E00\u952E\u77ED\u4EE3SDK"); mnNewMenu.add(menuItem);
mntmsdk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SMSToolsUi();
}
});
menu.add(mntmsdk);
menuItem_1 = new JMenuItem("\u67E5\u770B\u7B7E\u540D"); JMenu menu = new JMenu("\u5DE5\u5177");
menuItem_1.addActionListener(new ActionListener() { menuBar.add(menu);
@Override
public void actionPerformed(ActionEvent e) {
new AndroidKey();
}
});
menu.add(menuItem_1);
JMenuItem mntmOnweay = new JMenuItem("\u4FEE\u6539\u4E07\u7EF4\u63D2\u4EF6\u5305"); JMenuItem mntmAes = new JMenuItem("AES\u5DE5\u5177");
mntmOnweay.addActionListener(new ActionListener() { mntmAes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath())); new AESUi();
chooser.showOpenDialog(null); }
File file = chooser.getSelectedFile(); });
uFilePath.setText(file.getAbsolutePath()); menu.add(mntmAes);
log.setText("正在修改万维插件包...");
new OneWayTools(file);
log.setText("修改万维成功,成功后文件将生成在反编译文件夹中");
} JMenuItem mntmSmali = new JMenuItem("Smali\u5DE5\u5177");
}); mntmSmali.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SmaliUi();
}
});
menu.add(mntmSmali);
JMenuItem mntmapk = new JMenuItem("\u7B7E\u540DAPK"); JMenuItem mntmsdk = new JMenuItem("\u4E00\u952E\u77ED\u4EE3SDK");
mntmapk.addActionListener(new ActionListener() { mntmsdk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new ApkSignUi(); new SMSToolsUi();
} }
}); });
menu.add(mntmapk); menu.add(mntmsdk);
menu.add(mntmOnweay);
JMenuItem mntmsdk_1 = new JMenuItem("\u4FEE\u6539\u7B2C\u4E09\u65B9SDK"); menuItem_1 = new JMenuItem("\u67E5\u770B\u7B7E\u540D");
mntmsdk_1.addActionListener(new ActionListener() { menuItem_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { @Override
new ModifySdkUi(); public void actionPerformed(ActionEvent e) {
} new AndroidKey();
}); }
menu.add(mntmsdk_1); });
menu.add(menuItem_1);
mnBasetools = new JMenu("Base64\u5DE5\u5177"); JMenuItem mntmOnweay = new JMenuItem("\u4FEE\u6539\u4E07\u7EF4\u63D2\u4EF6\u5305");
menuBar.add(mnBasetools); 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("修改万维成功,成功后文件将生成在反编译文件夹中");
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"); JMenuItem mntmapk = new JMenuItem("\u7B7E\u540DAPK");
mntmBase.addActionListener(new ActionListener() { mntmapk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath())); new ApkSignUi();
jFile.showOpenDialog(AppMain.this); }
File file = jFile.getSelectedFile(); });
JarToBase.start(file.getAbsolutePath(), false); menu.add(mntmapk);
log.setText("已解码"); menu.add(mntmOnweay);
}
});
mnBasetools.add(mntmBase);
setVisible(true); 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);
}
} }

View 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();
}
}

View File

@ -31,7 +31,7 @@ public class EncryptJar {
FileOutputStream fos = new FileOutputStream(outputFile); FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(int2byte(filetype)); fos.write(int2byte(filetype));
System.out.println("资源包版本号:" + ver); System.out.println("资源包版本号:" + ver);
fos.write(int2byte(ver)); fos.write(int2byte(ver));
FileInputStream is = new FileInputStream(file); FileInputStream is = new FileInputStream(file);
@ -124,7 +124,7 @@ public class EncryptJar {
} }
@Override @Override
public String toString() { public String toString() {
return "资源类型:"+type + " 版本号:" + version + " 文件路径:" + file.getAbsolutePath(); return "资源类型:"+type + " 版本号:" + version + " 文件路径:" + file.getAbsolutePath();
} }
} }

View File

@ -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> // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼ʧ<EFBFBD><EFBFBD>
return false; return false;
} }
destFile.delete();
} }
@ -82,7 +83,7 @@ public class Tools {
fileName=srcFile.getName(); fileName=srcFile.getName();
} }
in = new FileInputStream(srcFile); in = new FileInputStream(srcFile);
out = new FileOutputStream(destFile + "/" +fileName ); out = new FileOutputStream(destFile);
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
while ((byteread = in.read(buffer)) != -1) { while ((byteread = in.read(buffer)) != -1) {