From c58b890c618ecbd4d702a0562ab0ae1064603b6b Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 26 Feb 2020 16:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E7=A9=BF=E5=B1=B1?= =?UTF-8?q?=E7=94=B2=E8=B5=84=E6=BA=90=E5=8C=85=E6=89=93=E5=8C=85=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BB=8EEclipse?= =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E5=AF=BC=E8=87=B4UI=E4=B9=B1=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_config.cfg | 4 +- config.cfg | 2 +- src/com/qy/ui/AndroidKey.java | 36 ++++----- src/com/qy/ui/ApkSignUi.java | 35 ++++---- src/com/qy/ui/AppMain.java | 10 +++ src/com/qy/ui/ChuanShanJiaUi.form | 110 ++++++++++++++++++++++++++ src/com/qy/ui/ChuanShanJiaUi.java | 108 +++++++++++++++++++++++++ src/com/qy/ui/ModifySdkUi.java | 6 +- src/com/qy/ui/OneWayTools.java | 22 +++--- src/com/qy/ui/SMSToolsUi.java | 20 ++--- src/com/qy/ui/SmaliUi.java | 42 +++++----- src/com/qy/utils/ApkSignTools.java | 12 +-- src/com/qy/utils/AutoRandomAdSDK.java | 47 ++++++++--- src/com/qy/utils/CsjTools.java | 96 +++++++++++++--------- 14 files changed, 420 insertions(+), 130 deletions(-) create mode 100644 src/com/qy/ui/ChuanShanJiaUi.form create mode 100644 src/com/qy/ui/ChuanShanJiaUi.java diff --git a/ad_config.cfg b/ad_config.cfg index d8a8e26..01f648b 100644 --- a/ad_config.cfg +++ b/ad_config.cfg @@ -128,8 +128,8 @@ ], "random": [ "com", - "wq", - "rx" + "opx", + "bh" ], "rename": { "MyActivity": "Activity", diff --git a/config.cfg b/config.cfg index 6e15f86..14dedfa 100755 --- a/config.cfg +++ b/config.cfg @@ -8,7 +8,7 @@ "switch": "1", "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", + "dx": "dx.jar", "array": [ "rd_rx", "qy_rx", diff --git a/src/com/qy/ui/AndroidKey.java b/src/com/qy/ui/AndroidKey.java index 3ad5645..c7db226 100755 --- a/src/com/qy/ui/AndroidKey.java +++ b/src/com/qy/ui/AndroidKey.java @@ -29,7 +29,7 @@ import java.io.File; public class AndroidKey extends JFrame{ /** - * + * */ private static final long serialVersionUID = 1L; private JTextField md5; @@ -66,7 +66,7 @@ public class AndroidKey extends JFrame{ 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 list; private void initView() { @@ -78,8 +78,8 @@ public class AndroidKey extends JFrame{ } setSize(849, 536); getContentPane().setLayout(null); - - list = new JList(); + + list = new JList(); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { Map map=keys.get(list.getSelectedIndex()); @@ -92,7 +92,7 @@ public class AndroidKey extends JFrame{ }); list.setModel(new AbstractListModel() { /** - * + * */ private static final long serialVersionUID = 1L; String[] values = new String[] {"amw.keystroe.jks", "langtian.jks", "my.keystore"}; @@ -105,34 +105,34 @@ public class AndroidKey extends JFrame{ }); 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 @@ -146,7 +146,7 @@ public class AndroidKey extends JFrame{ }); 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; @@ -155,8 +155,8 @@ public class AndroidKey extends JFrame{ JFileChooser chooser=new JFileChooser(new File("").getAbsolutePath()); chooser.showOpenDialog(null); rsa=chooser.getSelectedFile(); - new EditToDalog("ʾ", "Կ", null, new SmaliApkToolsPath() { - + new EditToDalog("提示", "请输入密钥", null, new SmaliApkToolsPath() { + @Override public void smaliPath(String path) { // TODO Auto-generated method stub @@ -164,17 +164,17 @@ public class AndroidKey extends JFrame{ 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); - + } } diff --git a/src/com/qy/ui/ApkSignUi.java b/src/com/qy/ui/ApkSignUi.java index 3606943..204875b 100644 --- a/src/com/qy/ui/ApkSignUi.java +++ b/src/com/qy/ui/ApkSignUi.java @@ -18,7 +18,7 @@ public class ApkSignUi extends JFrame { } /** - * + * */ private static final long serialVersionUID = 1L; private JTextField txtPass; @@ -27,9 +27,9 @@ public class ApkSignUi extends JFrame { private ApkSignTools tools; private JLabel lblApkpath ; private JLabel lblSginpath; - + public ApkSignUi() { - setTitle("\u7B7E\u540D\u5DE5\u5177"); + setTitle("\u7B7E\u540D\u5DE5\u5177v1.1"); setResizable(false); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // TODO Auto-generated constructor stub @@ -46,17 +46,17 @@ public class ApkSignUi extends JFrame { 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) { @@ -71,7 +71,7 @@ public class ApkSignUi extends JFrame { }); 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) { @@ -85,29 +85,29 @@ public class ApkSignUi extends JFrame { }); 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) { @@ -115,10 +115,13 @@ public class ApkSignUi extends JFrame { tools.setKeyStorePassword(txtSpass.getText()); tools.setSignKey(txtPass.getText()); if(tools.chack()) { - tools.sign(); - new TextToDalog("ɹ", "ǩ"); + if(tools.sign()) { + new TextToDalog("成功", "签名完成"); + }else{ + new TextToDalog("失败", "签名异常"); + } }else { - new TextToDalog("", "APKļǩļ"); + new TextToDalog("错误", "APK文件或签名文件不存在"); } } }); diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java index b67d51b..3028d1c 100755 --- a/src/com/qy/ui/AppMain.java +++ b/src/com/qy/ui/AppMain.java @@ -503,6 +503,16 @@ public class AppMain extends JFrame { }); menu.add(mntmsdk_1); + JMenuItem csj=new JMenuItem("穿山甲资源包"); + csj.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ChuanShanJiaUi.main(null); + } + }); + menu.add(csj); + + mnBasetools = new JMenu("Base64\u5DE5\u5177"); menuBar.add(mnBasetools); diff --git a/src/com/qy/ui/ChuanShanJiaUi.form b/src/com/qy/ui/ChuanShanJiaUi.form new file mode 100644 index 0000000..b00764a --- /dev/null +++ b/src/com/qy/ui/ChuanShanJiaUi.form @@ -0,0 +1,110 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com/qy/ui/ChuanShanJiaUi.java b/src/com/qy/ui/ChuanShanJiaUi.java new file mode 100644 index 0000000..891c832 --- /dev/null +++ b/src/com/qy/ui/ChuanShanJiaUi.java @@ -0,0 +1,108 @@ +package com.qy.ui; + +import com.qy.Interfaces.SmaliApkToolsPath; +import com.qy.utils.CsjTools; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class ChuanShanJiaUi { + private JPanel mainPanel; + private JButton selectButton; + private JTextArea log; + + public ChuanShanJiaUi() { + selectButton.addActionListener(new ActionListener() { + File apkFile,csjDemo; + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser jfile=new JFileChooser(new File("").getAbsolutePath()); + jfile.showOpenDialog(null); + apkFile=jfile.getSelectedFile(); + if(apkFile!=null){ + append("已选择文件:"+apkFile.getAbsolutePath()); + File csjPath=new File("input"+File.separator+"csjDemo"+File.separator); + if(csjPath.exists()){ + File[] fs=csjPath.listFiles(); + if(fs==null||fs.length==0){ + append("没有找到穿山甲demo,请将穿山甲demo放置在 input"+File.separator+"csjDemo文件夹中"); + }else{ + selectButton.setEnabled(false); + append("穿山甲Demo选择为 "+fs[0].getName()); + csjDemo=fs[0]; + new Thread(new Runnable() { + @Override + public void run() { + CsjTools tools=new CsjTools(); + tools.build(csjDemo.getAbsolutePath(), apkFile.getAbsolutePath(), new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + append(path); + if(path.startsWith("已出包")) { + new EditToDalog("成功", "打包完成,请输入版本号", "5600", new SmaliApkToolsPath() { + @Override + public void smaliPath(String out) { + System.out.println(">>" + out); + tools.out(path.replace("已出包", ""), + new File("csj").getAbsolutePath() + File.separator + "csc", + Integer.parseInt(out)); + append("加密包位置:" + new File("csj").getAbsolutePath() + File.separator + "csc"); + selectButton.setEnabled(true); + } + }); + } + + } + }); + } + }).start(); + + } + }else{ + append("没有找到穿山甲demo,请将穿山甲demo放置在 input"+File.separator+"csjDemo文件夹中"); + csjDemo.mkdirs(); + } + } + } + }); + } + private void append(String log){ + this.log.append("["+new SimpleDateFormat("HH:mm:ss").format(new Date()) +"]"+log+"\n"); + } + private void show(){ + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + JFrame frame = new JFrame("穿山甲资源包生成v1.0"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setContentPane(new ChuanShanJiaUi().mainPanel); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setSize(420,400); + frame.setVisible(true); + } + public static void main(String[] args) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + JFrame frame = new JFrame("穿山甲资源包生成v1.0"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setContentPane(new ChuanShanJiaUi().mainPanel); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setSize(420,400); + frame.setVisible(true); + } + + +} diff --git a/src/com/qy/ui/ModifySdkUi.java b/src/com/qy/ui/ModifySdkUi.java index 6ad5449..d80bec7 100644 --- a/src/com/qy/ui/ModifySdkUi.java +++ b/src/com/qy/ui/ModifySdkUi.java @@ -26,7 +26,7 @@ import java.awt.event.ActionEvent; public class ModifySdkUi extends JFrame{ private JList list; - private File sdkFile; + private File sdkFile=new File("D:\\IdeaProjects\\android_sdk_tools\\classes.jar"); private Map userEncrypt; /** * @@ -137,4 +137,8 @@ public class ModifySdkUi extends JFrame{ } list.setListData(vector); } + + public static void main(String[] args) { + new ModifySdkUi(); + } } diff --git a/src/com/qy/ui/OneWayTools.java b/src/com/qy/ui/OneWayTools.java index 78af4e8..91c0000 100755 --- a/src/com/qy/ui/OneWayTools.java +++ b/src/com/qy/ui/OneWayTools.java @@ -41,27 +41,27 @@ public class OneWayTools { + File.separator + "sdk" + File.separator + "b" + File.separator + "c.smali"); if (!activity.exists()) { System.out.println(activity.getAbsolutePath()); - new TextToDalog("", "Unit.smaliļ!"); + new TextToDalog("警告", "Unit.smali文件不存在!"); return; } if (!provider.exists()) { - new TextToDalog("", "c.smaliļ!"); + 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) { @@ -82,10 +82,10 @@ public class OneWayTools { } catch (Exception e) { // TODO: handle exception e.printStackTrace(); - new TextToDalog("", "unit.smaliļʧܣ" + e.getMessage()); + new TextToDalog("错误", "处理unit.smali文件失败:" + e.getMessage()); return; } - new TextToDalog("", "Unit.smaliļûаָ룬ֶ"); + new TextToDalog("警告", "Unit.smali文件没有包含指定代码,请手动检查"); } private void updateProvider(String path) { @@ -93,7 +93,7 @@ public class OneWayTools { List list = new ArrayList<>(); File file = new File(path); BufferedReader reader = new BufferedReader(new FileReader(file)); - + String tmp, str = ""; boolean write = false; int index = 0; @@ -112,7 +112,7 @@ public class OneWayTools { str += string + "\n"; } reader.close(); - + if (write) { FileWriter writer = new FileWriter(file); writer.write(str); @@ -123,9 +123,9 @@ public class OneWayTools { } catch (Exception e) { // TODO: handle exception e.printStackTrace(); - new TextToDalog("", "c.smaliļʧܣ" + e.getMessage()); + new TextToDalog("错误", "处理c.smali文件失败:" + e.getMessage()); return; } - new TextToDalog("", "c.smaliļûаָ룬ֶ"); + new TextToDalog("警告", "c.smali文件没有包含指定代码,请手动检查"); } } diff --git a/src/com/qy/ui/SMSToolsUi.java b/src/com/qy/ui/SMSToolsUi.java index c72d98b..6a44688 100755 --- a/src/com/qy/ui/SMSToolsUi.java +++ b/src/com/qy/ui/SMSToolsUi.java @@ -23,10 +23,10 @@ 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.exesdk + * 更新日志 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; @@ -62,7 +62,7 @@ public class SMSToolsUi extends JFrame { public void mouseClicked(MouseEvent e) { path = btnNewButton.getText(); btnNewButton.setEnabled(false); - btnNewButton.setText("ڱSDK,Ժ..."); + btnNewButton.setText("正在编译SDK,请稍后..."); new Timer().schedule(new TimerTask() { @Override @@ -71,7 +71,7 @@ public class SMSToolsUi extends JFrame { SDKTools.start(new File("").getAbsolutePath()); btnNewButton.setText(path); btnNewButton.setEnabled(true); - new TextToDalog("ʾ", "ƷSDKɳɹѡ񱣴λ", new DalogAbs() { + new TextToDalog("提示", "计费SDK生成成功,请选择保存位置", new DalogAbs() { File sdk; @Override @@ -83,16 +83,16 @@ public class SMSToolsUi extends JFrame { sdk = chooser.getSelectedFile(); if (sdk != null) { File sdk_ = new File( - sdk.getAbsolutePath() + "/" + "Ʒsdk" + SDKTools.version + ".zip"); + sdk.getAbsolutePath() + "/" + "计费sdk" + SDKTools.version + ".zip"); SDKTools.buildSDK(sdk_); - new TextToDalog("", "", new DalogAbs() { + new TextToDalog("完成", "任务已完成", new DalogAbs() { @Override public void onSuccess() { // TODO Auto-generated method stub try { Desktop.getDesktop().open(sdk); - System.out.println("\nڿԹص"); + System.out.println("\n本窗口可以关掉了"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -101,7 +101,7 @@ public class SMSToolsUi extends JFrame { }); } else { - new TextToDalog("", "ѷ"); + new TextToDalog("错误", "已放弃本次任务"); } } }); diff --git a/src/com/qy/ui/SmaliUi.java b/src/com/qy/ui/SmaliUi.java index 292256c..2fa38c8 100755 --- a/src/com/qy/ui/SmaliUi.java +++ b/src/com/qy/ui/SmaliUi.java @@ -32,7 +32,7 @@ import com.qy.utils.SmaliUtils; public class SmaliUi extends JFrame { /** - * + * */ private static final long serialVersionUID = 1L; private JTextField jarPath, savePath, smaliPath; @@ -160,8 +160,8 @@ public class SmaliUi extends JFrame { public void mouseClicked(MouseEvent e) { int index = list.getSelectedIndex(); if (index > 0) { - file = fileList.get(index); - new EditToDalog("", "ϣļ() " + file.getName() + " Ϊ", file.getName(), + file = fileList.get(index); + new EditToDalog("重命名", "希望将文件(夹) " + file.getName() + " 重命名为?", file.getName(), new SmaliApkToolsPath() { @Override @@ -170,7 +170,7 @@ public class SmaliUi extends JFrame { 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()); + lblInfo.setText("重命名:" + toFile.getName()); changeList(); } } @@ -194,7 +194,7 @@ public class SmaliUi extends JFrame { File path = chooser.getSelectedFile(); File file = fileList.get(index); file.renameTo(new File(path.getAbsolutePath() + File.separator + file.getName())); - lblInfo.setText("ƶ:" + file.getAbsolutePath()); + lblInfo.setText("移动:" + file.getAbsolutePath()); changeList(); } } @@ -271,14 +271,14 @@ public class SmaliUi extends JFrame { button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - lblInfo.setText("ʼ"); + lblInfo.setText("开始拆包"); timer.schedule(new TimerTask() { @Override public void run() { // TODO Auto-generated method stub if(jarPath.getText().trim().length()==0) { - new TextToDalog("", "ûѡĿļ"); + new TextToDalog("警告", "没有选择目标文件"); return; } utils.unPack(jarPath.getText(), new SmaliApkToolsPath() { @@ -288,7 +288,7 @@ public class SmaliUi extends JFrame { // TODO Auto-generated method stub smaliPath.setText(path); smaliHome = path; - lblInfo.setText(""); + lblInfo.setText("拆包完成"); } }); @@ -308,23 +308,23 @@ public class SmaliUi extends JFrame { smaliPath.setText(smaliHome); if(savePath.getText().trim().length()==0) { savePath.setText(smaliHome); - lblInfo.setText("ûд·ĬϱڵǰĿ¼"); - new TextToDalog("", "ûд·ĬϱڵǰĿ¼"); + lblInfo.setText("没有填写保存路径,默认保存在当前目录"); + new TextToDalog("警告", "没有填写保存路径,默认保存在当前目录"); } if(jarPath.getText().trim().length()==0) { path="dex.zip"; - new TextToDalog("", "ûдļĬΪdex.zip"); + new TextToDalog("警告", "没有填写保存文件名,默认为dex.zip"); }else { path=new File(jarPath.getText()).getName(); } - lblInfo.setText("ʼ"); + 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()); + lblInfo.setText("打包完成,保存路径为:" + savePath.getText()); } }, 100); } @@ -346,7 +346,7 @@ public class SmaliUi extends JFrame { path = file.getParentFile().getAbsolutePath(); } try { - lblInfo.setText("Ѵ"); + lblInfo.setText("已打开"); Desktop.getDesktop().open(new File(path)); } catch (IOException e1) { // TODO Auto-generated catch block @@ -371,7 +371,7 @@ public class SmaliUi extends JFrame { break; } } - lblInfo.setText("ʼĿ¼ṹ޸smali ȴ..."); + lblInfo.setText("开始根据目录结构修改smali 请等待..."); utils.setPath(smaliPath.getText()); timer.schedule(new TimerTask() { @@ -379,7 +379,7 @@ public class SmaliUi extends JFrame { public void run() { // TODO Auto-generated method stub utils.start(); - lblInfo.setText(""); + lblInfo.setText("完成"); } }, 100); } @@ -409,11 +409,11 @@ public class SmaliUi extends JFrame { 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); @@ -427,7 +427,7 @@ public class SmaliUi extends JFrame { File[] files = file.listFiles(); vector.clear(); fileList.clear(); - vector.add("ϲ"); + vector.add("返回上层"); fileList.add(file.getParentFile()); for (File f : files) { if (!f.isHidden()) { @@ -436,10 +436,10 @@ public class SmaliUi extends JFrame { } } list.setListData(vector); - lblInfo.setText("ˢ½"); + lblInfo.setText("刷新界面"); } catch (Exception e) { // TODO: handle exception - lblInfo.setText("ˢʧ"); + lblInfo.setText("刷新失败"); } } diff --git a/src/com/qy/utils/ApkSignTools.java b/src/com/qy/utils/ApkSignTools.java index 9a48412..cbd4e97 100644 --- a/src/com/qy/utils/ApkSignTools.java +++ b/src/com/qy/utils/ApkSignTools.java @@ -24,15 +24,17 @@ public class ApkSignTools { 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; + public boolean 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) { + Runtime.getRuntime().exec(exec).waitFor(); + return true; + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); + return false; } } public File getSignFile() { diff --git a/src/com/qy/utils/AutoRandomAdSDK.java b/src/com/qy/utils/AutoRandomAdSDK.java index 580006d..c7742ce 100644 --- a/src/com/qy/utils/AutoRandomAdSDK.java +++ b/src/com/qy/utils/AutoRandomAdSDK.java @@ -146,6 +146,7 @@ public class AutoRandomAdSDK { for (int i = 0; i < clazzs.length(); i++) { File clz = new File(rootPath + File.separator + "smali" + File.separator + clazzs.getString(i).replace(".", File.separator) + ".smali"); + if (clz.exists()) { adClass.put(clazzs.getString(i), clz); } @@ -172,7 +173,7 @@ public class AutoRandomAdSDK { String newManifest = path .replace(sdk.getAbsolutePath() + ".out" + File.separator + "smali" + File.separator, ""); try { - newManifest = newManifest.replaceAll(File.separator, ".") + "." + adClass.get(key).getName(); + newManifest = newManifest.replace(File.separator, ".") + "." + adClass.get(key).getName(); array.put(manifest.getString(i).replace(key, newManifest.replace(".smali", ""))); } catch (Exception e) { // TODO: handle exception @@ -218,7 +219,7 @@ public class AutoRandomAdSDK { if (file.exists()) { - JSONArray array = config.getJSONArray("filter"); + JSONArray array = config.isNull("filter")?null:config.getJSONArray("filter"); if (array != null) { List list = new ArrayList<>(); for (int i = 0; i < array.length(); i++) { @@ -282,7 +283,16 @@ public class AutoRandomAdSDK { } } } + private void show(File file){ + for (File listFile : file.listFiles()) { + if(listFile.isDirectory()){ + show(listFile); + }else{ + System.out.println(">?"+listFile.getAbsolutePath()); + } + } + } private void out() { if (!isPackage) { if (inter != null) { @@ -299,6 +309,11 @@ public class AutoRandomAdSDK { path = sdk.getAbsolutePath() + ".out"; name = sdk.getName(); } + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } smalitools.bale(path, path + File.separator + name, new SmaliApkToolsPath() { @@ -306,6 +321,7 @@ public class AutoRandomAdSDK { public void smaliPath(String path) { // TODO Auto-generated method stub try { + Thread.sleep(2000); outManifest(); File lt; File nLt = null; @@ -317,13 +333,22 @@ public class AutoRandomAdSDK { 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()); + + String exec=config.getString("dex2jar") + " " + sdk.getAbsolutePath() + ".out" + File.separator + sdk.getName(); + System.out.println("exec:"+exec); + Process process = Runtime.getRuntime().exec(exec); + process.waitFor(); + Thread.sleep(100); + process=Runtime.getRuntime().exec(exec); process.waitFor(); lt = new File(sdk.getAbsolutePath().split(sdk.getName())[0], sdk.getName().replace(".jar", "-dex2jar.jar")); } System.out.println(">>>:" + lt.getAbsolutePath()); if (lt.exists()) { nLt = new File(config.getString("ltName")); + if(nLt.exists()){ + nLt.delete(); + } lt.renameTo(nLt); } @@ -351,16 +376,13 @@ public class AutoRandomAdSDK { File filePath = new File(file.getAbsolutePath().replace(file.getName(), "")); for (File fs : filePath.listFiles()) { + System.out.println(fs.getAbsolutePath().replace(new File("").getAbsolutePath(),"")); if(fs.isDirectory()){ continue; } if(!fs.getName().startsWith(fileName)){ continue; } - if (fs.getName().equals("BuildConfig.smali")) { - fs.delete(); - continue; - } String nName = getNewName(fs.getName()); if (fs.getName().startsWith(fileName + "$")) { @@ -383,6 +405,7 @@ public class AutoRandomAdSDK { file.delete(); } + System.out.println("配置:"+config.getBoolean("isAllPackage")); if (config.getBoolean("isAllPackage")) { String tmp = nowAdClass.keySet().iterator().next(); File path = new File((nowAdClass.get(tmp)).getAbsolutePath()); @@ -418,6 +441,7 @@ public class AutoRandomAdSDK { 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); @@ -431,14 +455,19 @@ public class AutoRandomAdSDK { private void movesdk(File path, String toPath) { for (File file : path.listFiles()) { + if (file.getName().equals("BuildConfig.smali")) { + file.delete(); + continue; + } + 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())); + boolean data=file.renameTo(new File(rootPath + File.separator + toPath, file.getName())); + // System.out.println("移动文件:"+file.getAbsolutePath().replace(rootPath, "")+" 到"+(rootPath + File.separator + toPath)+" "+data); } } } diff --git a/src/com/qy/utils/CsjTools.java b/src/com/qy/utils/CsjTools.java index c50a3f9..87e285f 100644 --- a/src/com/qy/utils/CsjTools.java +++ b/src/com/qy/utils/CsjTools.java @@ -77,6 +77,7 @@ public class CsjTools { reader.close(); String apkPackage = getXMLValue("package", tmp); System.out.println(apkPackage); + _log.smaliPath("获取到APK包名:"+apkPackage); reader = new BufferedReader(new FileReader(demoManifest)); tmp = reader.readLine(); String manifest = tmp.replace(getXMLValue("package", tmp), apkPackage) + "\n"; @@ -93,7 +94,7 @@ public class CsjTools { } } - private void out(String srcFile, String encryptFile, int version) { + public void out(String srcFile, String encryptFile, int version) { EncryptJar encryptJar = new EncryptJar(); encryptJar.encrypt(new File(srcFile), encryptFile, 13, version); @@ -168,8 +169,9 @@ public class CsjTools { } } - private void start(SmaliApkToolsPath toolsPath) { - System.out.println("开始制作资源包"); + private void start() { + _log.smaliPath("开始制作资源包"); + commandFile(); String apkXML = loadXml(apk_res + File.separator + "public.xml"); String demoXML = loadXml(csj_res + File.separator + "public.xml"); @@ -206,24 +208,39 @@ public class CsjTools { new File("csj/").mkdirs(); } SmaliUtils utils = new SmaliUtils(); + _log.smaliPath("资源包制作完成,开始打包为apk"); utils.bale(csj_Path, csjRes.getAbsolutePath(), new SmaliApkToolsPath() { @Override public void smaliPath(String path) { - toolsPath.smaliPath("已出包" + csjRes.getAbsolutePath()); - System.out.println("耗时:"+(System.currentTimeMillis()-time)/1000+" 秒"); + _log.smaliPath("已出包" + csjRes.getAbsolutePath()); + _log.smaliPath("耗时:" + (System.currentTimeMillis() - time) / 1000 + " 秒"); + } }); } + private long time; + private boolean unPackageCSJ = false; + private SmaliApkToolsPath _log; + public void build(String csjPath, String apkPath, SmaliApkToolsPath log) { - time=System.currentTimeMillis(); + time = System.currentTimeMillis(); + _log=log; + unPackageCSJ=false; + File csjFile = new File(csjPath); + if (new File(csjFile.getName().replace(".apk", "")).exists()) { + System.out.println(">?>>"+new File(csjFile.getName().replace(".apk", "")).getAbsolutePath()); + unPackageCSJ = true; + } SmaliUtils utils = new SmaliUtils(); - Tools.deleteFiles(new File("").getAbsolutePath()+File.separator+new File(csjPath).getName().replace(".apk",File.separator)); - Tools.deleteFiles(new File("").getAbsolutePath()+File.separator+new File(apkPath).getName().replace(".apk",File.separator)); + // Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator)); + Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(apkPath).getName().replace(".apk", File.separator)); new Thread(new Runnable() { @Override public void run() { - log.smaliPath("开始反编译目标APK"); + _log.smaliPath("开始反编译目标APK"); + + utils.unPack(apkPath, new SmaliApkToolsPath() { @Override public void smaliPath(String path) { @@ -232,35 +249,42 @@ public class CsjTools { System.out.println(path); apk_Path = path; apk_res = apk_Path + File.separator + "res" + File.separator + "values"; - runStart(log); + runStart(); } }); - log.smaliPath("开始反编译穿山甲Demo"); - utils.unPack(csjPath, new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - log.smaliPath("穿山甲Demo反编译完成:" + path); - System.out.println(path); - csj_Path = path; - csj_res = csj_Path + File.separator + "res" + File.separator + "values"; - log.smaliPath("开始修改穿山甲清单"); - new Thread(new Runnable() { - @Override - public void run() { - new AutoRandomAdSDK().startNotUnPackage(path, new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - System.out.println("-------" + path); - csjManifest = true; - runStart(log); - } - }); - } - }).start(); - } - }); + if (unPackageCSJ) { + _log.smaliPath("穿山甲demo已存在,不再反编译"); + csjManifest = true; + runStart(); + } else { + _log.smaliPath("开始反编译穿山甲Demo"); + utils.unPack(csjPath, new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + _log.smaliPath("穿山甲Demo反编译完成:" + path); + System.out.println(path); + csj_Path = path; + csj_res = csj_Path + File.separator + "res" + File.separator + "values"; + _log.smaliPath("开始修改穿山甲"); + new Thread(new Runnable() { + @Override + public void run() { + new AutoRandomAdSDK().startNotUnPackage(path, new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + _log.smaliPath("穿山甲修改完成"); + System.out.println("-------" + path); + csjManifest = true; + runStart(); + } + }); + } + }).start(); + } + }); + } } }).start(); @@ -269,9 +293,9 @@ public class CsjTools { boolean csjManifest = false; boolean apkUnPackage = false; - private void runStart(SmaliApkToolsPath log) { + private void runStart() { if (apkUnPackage && csjManifest) { - start(log); + start(); } }