This commit is contained in:
Yutousama 2020-06-05 17:24:39 +08:00
parent 80c3f208e3
commit a017fc434d
3 changed files with 194 additions and 21 deletions

View File

@ -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);

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.qy.ui.TestAdSrc">
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="7457" class="javax.swing.JCheckBox" binding="checkBox">
<constraints border-constraint="North"/>
<properties>
<enabled value="false"/>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="4"/>
<text value="深度分析"/>
<visible value="false"/>
</properties>
</component>
<component id="fe66d" class="javax.swing.JLabel" binding="jLable">
<constraints border-constraint="Center"/>
<properties>
<horizontalAlignment value="0"/>
<text value="拖拽APK到此处分析"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -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<String> 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<? extends ZipEntry> 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();
}
}