diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java index 053076c..c940022 100755 --- a/src/com/qy/ui/AppMain.java +++ b/src/com/qy/ui/AppMain.java @@ -70,6 +70,7 @@ public class AppMain extends JFrame { String version = null; String apkPath = null; String csjPath = null; + String model = "csj"; for (String arg : args) { if (arg.startsWith("-package")) { @@ -87,36 +88,44 @@ public class AppMain extends JFrame { if (arg.startsWith("-csc")) { cscPath = arg.replace("-csc=", ""); } + if (arg.startsWith("-model")) { + model = arg.replace("-model=", ""); + } if (arg.trim().equals("-h")) { - System.err.println("-package packageName " + - "\n-version CsjVersion" + - "\n-apk apkFilePath" + - "\n-csj csjDemoApkFilePath" + - "\n-csc csc save Path"); + outHelp(); return; } } - if (packageName != null && version != null && apkPath != null && csjPath != null) { - new CsjTools(apkPath, csjPath, packageName, version, new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - if (cscPath != null) { - File file = new File(path); - file.renameTo(new File(cscPath)); - } + if (model.equals("csj")) { + if (packageName != null && version != null && apkPath != null && csjPath != null) { + new CsjTools(apkPath, csjPath, packageName, version, new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + if (cscPath != null) { + File file = new File(path); + file.renameTo(new File(cscPath)); + } + + } + }); + } else { + outHelp(); + } + }else if(model.equals("sdk")){ - } - }); - } else { - System.err.println("-package packageName " + - "\n-version CsjVersion" + - "\n-apk apkFilePath" + - "\n-csj csjDemoApkFilePath" + - "\n-csc csc save Path"); } + } } + private static void outHelp() { + System.err.println("-package packageName " + + "\n-version CsjVersion" + + "\n-apk apkFilePath" + + "\n-csj csjDemoApkFilePath" + + "\n-csc csc save Path"); + } + public AppMain() { setResizable(false); diff --git a/src/com/qy/ui/TestAdSrc.form b/src/com/qy/ui/TestAdSrc.form new file mode 100644 index 0000000..b65844f --- /dev/null +++ b/src/com/qy/ui/TestAdSrc.form @@ -0,0 +1,29 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com/qy/ui/TestAdSrc.java b/src/com/qy/ui/TestAdSrc.java new file mode 100644 index 0000000..36524c7 --- /dev/null +++ b/src/com/qy/ui/TestAdSrc.java @@ -0,0 +1,135 @@ +package com.qy.ui; + +import javax.swing.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.io.File; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class TestAdSrc { + private JCheckBox checkBox; + private JPanel panel1; + private JLabel jLable; + + public TestAdSrc() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + JFrame frame = new JFrame("广告源分析工具1.0"); + frame.setContentPane(panel1); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setSize(420, 400); + frame.setVisible(true); + adSrcList(); + initView(); + } + + public void initView() { + panel1.setTransferHandler(new TransferHandler() { + @Override + public boolean importData(JComponent comp, Transferable t) { + try { + Object obj = t.getTransferData(DataFlavor.javaFileListFlavor); + File file = new File(obj.toString().substring(1, obj.toString().length() - 1)); + System.out.println(file.getAbsolutePath()); + if (!file.getName().endsWith(".apk")) { + new TextToDalog("警告", "并非一个apk文件:" + file.getAbsolutePath()); + return true; + } + if (checkBox.isSelected()) { + completeAnalysis(file); + } else { + analysis(file); + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + + @Override + public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) { + return true; + } + }); + } + + private List gdt, csj, bd, ow, up; + + private void adSrcList() { + gdt = new ArrayList<>(); + csj = new ArrayList<>(); + bd = new ArrayList<>(); + ow = new ArrayList<>(); + up = new ArrayList<>(); + gdt.add("gdt_plugin"); + csj.add("libtobEmbedEncrypt.so"); + bd.add("bdxadsdk.jar"); + ow.add("OnewaySdk.jar"); + up.add("uniplayad_logo.png"); + } + + private void analysis(File file) { + try { + ZipFile zipFile = new ZipFile(file); + Enumeration entries = zipFile.entries(); + String msg = ""; + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + for (String s : gdt) { + if (entry.getName().contains(s)&&!msg.contains("广点通")) { + msg += "广点通 "; + break; + } + } + for (String s : bd) { + if (entry.getName().contains(s)&&!msg.contains("百青藤")) { + msg += "百青藤 "; + break; + } + } + for (String s : csj) { + if (entry.getName().contains(s)&&!msg.contains("穿山甲")) { + msg += "穿山甲 "; + break; + } + } + for (String s : ow) { + if (entry.getName().contains(s)&&!msg.contains("万维")) { + msg += "万维 "; + break; + } + } + for (String s : up) { + if (entry.getName().contains(s)&&!msg.contains("聚量")) { + msg += "聚量 "; + break; + } + } + } + if(msg.equals("")){ + new TextToDalog("提示",file.getName()+"不包含已知广告源"); + }else{ + new TextToDalog("提示","已扫描到:"+msg); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void completeAnalysis(File file) { + + } + + public static void main(String[] args) { + new TestAdSrc(); + } +}