diff --git a/config.cfg b/config.cfg index 2ac7095..ec44c66 100755 --- a/config.cfg +++ b/config.cfg @@ -41,6 +41,9 @@ ] } }, - "sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5", - "csjPackageName":"com.iaalz.tzjyg" + "sdkPath":"D:\\Android_src\\kuku-android-sdk", + "csjPackageName":"com.iaalz.tzjyg", + "packageApkTool":"libs/apktool_2.4.1.jar", + "unPackageApkTool":"libs/apktool_2.4.1.jar", + "encryption":true } \ No newline at end of file diff --git a/libs/SparseBitSet-1.2.jar b/libs/SparseBitSet-1.2.jar new file mode 100644 index 0000000..bdb6771 Binary files /dev/null and b/libs/SparseBitSet-1.2.jar differ diff --git a/libs/activation-1.1.1.jar b/libs/activation-1.1.1.jar new file mode 100644 index 0000000..1b703ab Binary files /dev/null and b/libs/activation-1.1.1.jar differ diff --git a/libs/commons-codec-1.13.jar b/libs/commons-codec-1.13.jar new file mode 100644 index 0000000..bf6ccb3 Binary files /dev/null and b/libs/commons-codec-1.13.jar differ diff --git a/libs/commons-collections4-4.4.jar b/libs/commons-collections4-4.4.jar new file mode 100644 index 0000000..da06c3e Binary files /dev/null and b/libs/commons-collections4-4.4.jar differ diff --git a/libs/commons-compress-1.19.jar b/libs/commons-compress-1.19.jar new file mode 100644 index 0000000..5c9f52a Binary files /dev/null and b/libs/commons-compress-1.19.jar differ diff --git a/libs/commons-logging-1.2.jar b/libs/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/libs/commons-logging-1.2.jar differ diff --git a/libs/commons-math3-3.6.1.jar b/libs/commons-math3-3.6.1.jar new file mode 100644 index 0000000..0ff582c Binary files /dev/null and b/libs/commons-math3-3.6.1.jar differ diff --git a/libs/dom4j-2.1.3.jar b/libs/dom4j-2.1.3.jar new file mode 100644 index 0000000..9a4f5d2 Binary files /dev/null and b/libs/dom4j-2.1.3.jar differ diff --git a/libs/jaxb-api-2.3.1.jar b/libs/jaxb-api-2.3.1.jar new file mode 100644 index 0000000..4565865 Binary files /dev/null and b/libs/jaxb-api-2.3.1.jar differ diff --git a/libs/jaxb-core-2.3.0.1.jar b/libs/jaxb-core-2.3.0.1.jar new file mode 100644 index 0000000..431e143 Binary files /dev/null and b/libs/jaxb-core-2.3.0.1.jar differ diff --git a/libs/jaxb-impl-2.3.2.jar b/libs/jaxb-impl-2.3.2.jar new file mode 100644 index 0000000..58035e8 Binary files /dev/null and b/libs/jaxb-impl-2.3.2.jar differ diff --git a/libs/junit-4.12.jar b/libs/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/libs/junit-4.12.jar differ diff --git a/libs/log4j-1.2.17.jar b/libs/log4j-1.2.17.jar new file mode 100644 index 0000000..1d425cf Binary files /dev/null and b/libs/log4j-1.2.17.jar differ diff --git a/libs/poi-4.1.2.jar b/libs/poi-4.1.2.jar new file mode 100644 index 0000000..3803353 Binary files /dev/null and b/libs/poi-4.1.2.jar differ diff --git a/libs/poi-excelant-4.1.2.jar b/libs/poi-excelant-4.1.2.jar new file mode 100644 index 0000000..eeef301 Binary files /dev/null and b/libs/poi-excelant-4.1.2.jar differ diff --git a/libs/poi-ooxml-4.1.2.jar b/libs/poi-ooxml-4.1.2.jar new file mode 100644 index 0000000..6038a51 Binary files /dev/null and b/libs/poi-ooxml-4.1.2.jar differ diff --git a/libs/poi-ooxml-schemas-4.1.2.jar b/libs/poi-ooxml-schemas-4.1.2.jar new file mode 100644 index 0000000..74d3cd5 Binary files /dev/null and b/libs/poi-ooxml-schemas-4.1.2.jar differ diff --git a/libs/poi-scratchpad-4.1.2.jar b/libs/poi-scratchpad-4.1.2.jar new file mode 100644 index 0000000..bc0a3d5 Binary files /dev/null and b/libs/poi-scratchpad-4.1.2.jar differ diff --git a/libs/xmlbeans-3.1.0.jar b/libs/xmlbeans-3.1.0.jar new file mode 100644 index 0000000..18e568f Binary files /dev/null and b/libs/xmlbeans-3.1.0.jar differ diff --git a/src/com/qy/sms/SDKTools.java b/src/com/qy/sms/SDKTools.java index 8f06b73..1e72436 100755 --- a/src/com/qy/sms/SDKTools.java +++ b/src/com/qy/sms/SDKTools.java @@ -46,7 +46,7 @@ public class SDKTools { tools.classPath.add(new File(dataFolder).getAbsolutePath() + "\\androidv4.jar"); tools.saveJavaPath(sdkDatapath); tools.javaToClass(sdkDatapath); - System.out.println("清理文件:" + sdkDatapath); + System.out.println("娓呯悊鏂囦欢:" + sdkDatapath); tools.deleteJava(sdkDatapath); tools.toJarforJar(); WorldTools.start(packName, GameSDKManageName, sdkfunction); @@ -75,23 +75,23 @@ public class SDKTools { Tools.deleteFiles(sdkPath.getAbsolutePath()); } File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip"); - System.out.println("解压sdk源码:"+zipFile.getAbsolutePath()); + System.out.println("瑙e帇sdk婧愮爜:"+zipFile.getAbsolutePath()); ZipFile zip = new ZipFile(zipFile); for (Enumeration entries = zip.entries(); entries.hasMoreElements();) { ZipEntry entry = (ZipEntry) entries.nextElement(); String zipEntryName = entry.getName(); InputStream in = zip.getInputStream(entry); String outPath = (descDir + "/" + zipEntryName).replace("\\", "/"); - // 判断路径是否存在,不存在则创建文件路径 + // 鍒ゆ柇璺緞鏄惁瀛樺湪,涓嶅瓨鍦ㄥ垯鍒涘缓鏂囦欢璺緞 File file = new File(outPath.substring(0, outPath.lastIndexOf('/'))); if (!file.exists()) { file.mkdirs(); } - // 判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压 + // 鍒ゆ柇鏂囦欢鍏ㄨ矾寰勬槸鍚︿负鏂囦欢澶,濡傛灉鏄笂闈㈠凡缁忎笂浼,涓嶉渶瑕佽В鍘 if (new File(outPath).isDirectory()) { continue; } - // 输出文件路径信息 + // 杈撳嚭鏂囦欢璺緞淇℃伅 System.out.println(outPath); OutputStream out = new FileOutputStream(outPath); byte[] buf1 = new byte[1024]; @@ -103,7 +103,7 @@ public class SDKTools { out.close(); } zip.close(); - System.out.println("******************解压完毕********************"); + System.out.println("******************瑙e帇瀹屾瘯********************"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); @@ -117,11 +117,11 @@ public class SDKTools { Tools.deleteFiles(sdkPath.getAbsolutePath()); } File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip"); - System.out.println("解压sdk源码:"+zipFile.getAbsolutePath()); + System.out.println("瑙e帇sdk婧愮爜:"+zipFile.getAbsolutePath()); net.lingala.zip4j.core.ZipFile zip=new net.lingala.zip4j.core.ZipFile(zipFile); zip.setFileNameCharset("GBK"); zip.extractAll(new File("").getAbsolutePath()); - System.out.println("******************解压完毕********************"); + System.out.println("******************瑙e帇瀹屾瘯********************"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); @@ -131,14 +131,14 @@ public class SDKTools { public void resdk() { File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/"); if (!sdkPath.exists()) { - System.out.println("SDK目录不存在 " + sdkPath.getAbsolutePath()); + System.out.println("SDK鐩綍涓嶅瓨鍦 " + sdkPath.getAbsolutePath()); return; } a = Tools.getRandomString(3); b = Tools.getRandomString(4); c = Tools.getRandomString(4); packName = a + "." + b + "." + c; - System.out.println("SDK包名:" + packName); + System.out.println("SDK鍖呭悕锛" + packName); rename(sdkPath); } @@ -211,7 +211,7 @@ public class SDKTools { private void reGameSDKManage() { File java = new File(sdkDatapath + "/GameSDKManage.java"); if (!java.exists()) { - System.out.println("GameSDKManage.java不存在"); + System.out.println("GameSDKManage.java涓嶅瓨鍦"); return; } GameSDKManageName = Tools.getRandomString(Tools.getRandomInt(4, 8)); @@ -290,7 +290,7 @@ public class SDKTools { File ft = new File(f.getAbsolutePath().replace(".java", ".class")); if (ft.exists()) { f.delete(); - // System.out.println("删除java:"+f.getAbsolutePath()+" "+t); + // System.out.println("鍒犻櫎java锛"+f.getAbsolutePath()+" "+t); } } } @@ -318,18 +318,18 @@ public class SDKTools { List zips = new ArrayList<>(); Map fileNames = new HashMap<>(); if (sdkzip == null) - sdkzip = new File("计费sdk" + version + ".zip"); + sdkzip = new File("璁¤垂sdk" + version + ".zip"); if (sdkzip.exists()) sdkzip.delete(); ZipOutputStream output = new ZipOutputStream(new FileOutputStream(sdkzip)); output.setLevel(Deflater.DEFLATED); File sdk = new File("sdk.jar"); - File word = new File("文档.txt"); + File word = new File("鏂囨。.txt"); File rx = new File("data/rx.lt"); File v4 = new File("data/androidv4.jar"); - File manifest = new File("data/manifest清单.txt"); - File permission = new File("data/权限列表.txt"); + File manifest = new File("data/manifest娓呭崟.txt"); + File permission = new File("data/鏉冮檺鍒楄〃.txt"); files.add(sdk); files.add(word); @@ -359,7 +359,7 @@ public class SDKTools { output.closeEntry(); output.close(); - sdk.delete(); + sdk.delete(); word.delete(); } catch (Exception e) { // TODO: handle exception @@ -396,7 +396,7 @@ public class SDKTools { private void jar(net.lingala.zip4j.core.ZipFile zipFile, File file,ZipParameters par) throws Exception { toJar(); for (File f : file.listFiles()) { - System.out.println("压缩文件:"+f.getAbsolutePath()); + System.out.println("鍘嬬缉鏂囦欢锛"+f.getAbsolutePath()); if(f.isDirectory()) { par.setCompressionMethod(Zip4jConstants.COMP_STORE); File t=new File(f.getName()); diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java index c796251..5489c40 100755 --- a/src/com/qy/ui/AppMain.java +++ b/src/com/qy/ui/AppMain.java @@ -61,89 +61,6 @@ public class AppMain extends JFrame { // TODO Auto-generated method stub if (args.length == 0) { new AppMain(); - } else { - String packageName = null; - String version = null; - String apkPath = null; - String csjPath = null; - String model = "csj"; - String jarPath = null; - String jarType = null; - String config = null; - - int index = -1; - - for (String arg : args) { - if (arg.startsWith("-package")) { - packageName = arg.replace("-package=", ""); - } - if (arg.startsWith("-version")) { - version = arg.replace("-version=", ""); - } - if (arg.startsWith("-apk")) { - apkPath = arg.replace("-apk=", ""); - } - if (arg.startsWith("-csj")) { - csjPath = arg.replace("-csj=", ""); - } - if (arg.startsWith("-csc")) { - cscPath = arg.replace("-csc=", ""); - } - if (arg.startsWith("-model")) { - model = arg.replace("-model=", ""); - } - if (arg.startsWith("-jar")) { - jarPath = arg.replace("-jar=", ""); - } - if (arg.startsWith("-type")) { - jarType = arg.replace("-type=", ""); - } - if (arg.startsWith("-index")) { - index = Integer.parseInt(arg.replace("-index=", "").trim()); - } - if (arg.startsWith("-save")) { - savePath = arg.replace("-save=", ""); - } - if (arg.startsWith("-config")) { - config = arg.replace("-config=", ""); - } - if (arg.trim().equals("-h")) { - outHelp(); - return; - } - } - if (model.equals("csj")) { - if (packageName != null && version != null && apkPath != null && csjPath != null) { - new CsjTools(apkPath, csjPath, packageName, version, config, 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("jar")) { - System.out.println(jarPath); - System.out.println(version); - System.out.println(jarType); - System.out.println(index); - System.out.println(savePath); - if (jarPath != null) - new AutoRandomAdSDK(new File(jarPath), version, jarType, index, new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - new File(path).renameTo(new File(savePath)); - } - }); - } else if (model.equals("sdk")) { - new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName); - } - } } @@ -249,8 +166,8 @@ public class AppMain extends JFrame { return; } json.put("switch", configList.getSelectedIndex() + 1 + ""); - path = json.getString("out"); - name = json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar"; + path = json.optString("out",""); + name = json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + ".jar"; file = new File(path + name); if (file.exists()) file.delete(); @@ -301,11 +218,11 @@ public class AppMain extends JFrame { @Override public void smaliPath(String path) { // TODO Auto-generated method stub - File input = new File(json.getString("out") - + json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar"); - Tools.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.parseInt(json.getString("switch")) - 1) + "_encrypt.jar", Integer.parseInt(path) + File input = new File(json.optString("out","") + + json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + ".jar"); + Tools.toAJar(json.optString("dx","dx.jar"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")); + File outFile = new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.optString("out","") + + json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + "_encrypt.jar", Integer.parseInt(path) , Integer.parseInt(version)); log.setText("data璺緞涓:" + outFile.getAbsolutePath()); } @@ -403,8 +320,8 @@ public class AppMain extends JFrame { @Override public void smaliPath(String path) { // TODO Auto-generated method stub - Tools.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) + Tools.toAJar(json.optString("dx","dx.jar"), 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.parseInt(path) , Integer.parseInt(version)); System.out.println("data璺緞涓:" + fileOut.getAbsolutePath()); if (log != null) @@ -497,7 +414,7 @@ public class AppMain extends JFrame { JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath())); chooser.showOpenDialog(null); File java = chooser.getSelectedFile(); - Tools.toAJar(json.getString("dx"), java.getAbsolutePath(), + Tools.toAJar(json.optString("dx","dx.jar"), java.getAbsolutePath(), new File("").getAbsolutePath() + File.separator + java.getName() + "_jar.jar"); if (AppMain.isOpenWindows) { try { @@ -649,7 +566,7 @@ public class AppMain extends JFrame { } public void autoPackageSdk() { - new AutoPackageSDK(path -> new TextToDialog("鎻愮ず", String.format("鎵撳寘瀹屾垚%s", path)), version, packageName); + } }); menu.add(autoSDK); @@ -690,6 +607,17 @@ public class AppMain extends JFrame { }); mnBasetools.add(mntmBase); + /*JMenu config=new JMenu("璁剧疆"); + JMenuItem systemConfig=new JMenuItem("涓昏缃"); + systemConfig.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + } + }); + config.add(systemConfig); + menuBar.add(config); +*/ setVisible(true); } } diff --git a/src/com/qy/ui/AutoOutAPKAddChannelUi.java b/src/com/qy/ui/AutoOutAPKAddChannelUi.java index c8461e1..24d4b45 100644 --- a/src/com/qy/ui/AutoOutAPKAddChannelUi.java +++ b/src/com/qy/ui/AutoOutAPKAddChannelUi.java @@ -9,6 +9,8 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import java.io.File; import java.util.*; import java.util.List; @@ -80,6 +82,25 @@ public class AutoOutAPKAddChannelUi { textField.setText(data); textField.setToolTipText(data); textField.setSize(100,20); + textField.addKeyListener(new KeyListener() { + int oldKey=0; + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if(oldKey==17&&e.getKeyCode()==86){ + textField.setText(textField.getText().replace("=","{=}")); + }else{ + oldKey=e.getKeyCode(); + } + } + }); list.add(textField); inputPanel.add(textField); } diff --git a/src/com/qy/ui/AutoOutAPKUi.form b/src/com/qy/ui/AutoOutAPKUi.form index a9d7ecc..e21cd0e 100644 --- a/src/com/qy/ui/AutoOutAPKUi.form +++ b/src/com/qy/ui/AutoOutAPKUi.form @@ -7,7 +7,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -113,17 +113,18 @@ - + + - + @@ -131,6 +132,20 @@ + + + + + + + + + + + + + + diff --git a/src/com/qy/ui/AutoOutAPKUi.java b/src/com/qy/ui/AutoOutAPKUi.java index 8b977df..0cf4321 100644 --- a/src/com/qy/ui/AutoOutAPKUi.java +++ b/src/com/qy/ui/AutoOutAPKUi.java @@ -2,16 +2,16 @@ package com.qy.ui; import com.qy.Interfaces.DialogInterface; import com.qy.Interfaces.SmaliApkToolsPath; -import com.qy.utils.ApkSignTools; -import com.qy.utils.AutoOutAPKTools; -import com.qy.utils.StringUtils; -import com.qy.utils.Tools; +import com.qy.utils.*; +import org.json.JSONArray; import org.json.JSONObject; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -30,10 +30,12 @@ public class AutoOutAPKUi { private JButton start; private JButton selectAppPath; private JLabel appPath; + private JComboBox selectAppid; private LinkedHashMap map = new LinkedHashMap<>(); private LinkedHashMap channel = new LinkedHashMap<>(); private Vector vector = new Vector(); + private JSONObject changeImage=null; public AutoOutAPKUi() { @@ -43,7 +45,7 @@ public class AutoOutAPKUi { // TODO: handle exception e.printStackTrace(); } - JFrame frame = new JFrame("椹敳鍖呭嚭鍖呭伐鍏1.0"); + JFrame frame = new JFrame("椹敳鍖呭嚭鍖呭伐鍏2.0"); frame.setContentPane(panel1); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); @@ -102,49 +104,52 @@ public class AutoOutAPKUi { } } AutoOutAPKTools tools = new AutoOutAPKTools(gid, cmap); - JSONObject json=new JSONObject(); - JSONObject pa=new JSONObject(); - JSONObject ji=new JSONObject(); - pa.put("key","${packagename}"); - pa.put("value",pid); - ji.put("key","${JPUSH_KEY}"); - ji.put("value",jid); - json.put("${packagename}",pa); - json.put("JPUSH_APPKEY",ji); + JSONObject json = new JSONObject(); + JSONObject pa = new JSONObject(); + JSONObject ji = new JSONObject(); + pa.put("key", "${packagename}"); + pa.put("value", pid); + ji.put("key", "${JPUSH_KEY}"); + ji.put("value", jid); + json.put("${packagename}", pa); + json.put("JPUSH_APPKEY", ji); tools.setAppPath(path); tools.setManifestMap(json); + if(changeImage!=null){ + tools.setChangeFile(changeImage); + } tools.start(new SmaliApkToolsPath() { @Override public void smaliPath(String path) { - LinkedHashMap keyMap=ApkSignUi.loadKeys(); + LinkedHashMap keyMap = ApkSignUi.loadKeys(); Vector adbList = new Vector(keyMap.keySet()); - JComboBox keysList=new JComboBox(adbList); + JComboBox keysList = new JComboBox(adbList); keysList.setBounds(157, 50, 200, 27); new TextToDialog("閫夋嫨绛惧悕", keysList, new DialogInterface() { @Override public void onSuccess() { - String key=adbList.get(keysList.getSelectedIndex()); - String tmp=keyMap.get(key); - if(!StringUtils.isEmpty(tmp)){ - JSONObject json=new JSONObject(tmp); - ApkSignTools signTools=new ApkSignTools(); + String key = adbList.get(keysList.getSelectedIndex()); + String tmp = keyMap.get(key); + if (!StringUtils.isEmpty(tmp)) { + JSONObject json = new JSONObject(tmp); + ApkSignTools signTools = new ApkSignTools(); signTools.setSignFile(new File(json.getString("file"))); signTools.setApkFile(new File(path)); signTools.setKeyStorePassword(json.getString("alias_password")); signTools.setName(json.getString("alias")); signTools.setSignKey(json.getString("password")); - if(signTools.sign()){ + if (signTools.sign()) { try { - String apkName="./apk_out/game_"+System.currentTimeMillis()+".apk"; - Tools.copyFile(signTools.getApkFile().getAbsolutePath()+"_sign.apk",apkName,true); + String apkName = "./apk_out/game_" + System.currentTimeMillis() + ".apk"; + Tools.copyFile(signTools.getApkFile().getAbsolutePath() + "_sign.apk", apkName, true); Desktop.getDesktop().open(new File(apkName).getParentFile()); System.out.println("绛惧悕瀹屾垚"); } catch (IOException ioException) { ioException.printStackTrace(); } - tools.clear(); - }else { - new TextToDialog("璀﹀憡","绛惧悕澶辫触"); + //tools.clear(); + } else { + new TextToDialog("璀﹀憡", "绛惧悕澶辫触"); } } } @@ -164,6 +169,75 @@ public class AutoOutAPKUi { appPath.setText(path.getAbsolutePath()); } }); + selectAppid.addItem("鏃"); + for (String appid : ExcelTools.getAllAppId()) { + selectAppid.addItem(appid); + } + selectAppid.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if (e.getItem().toString().equals("鏃")) { + return; + } + JSONObject json = ExcelTools.queryParamByAppId(Integer.parseInt(e.getItem().toString())); + if (json != null) { + channel.clear(); + vector.clear(); + list1.updateUI(); + setData(json); + } + } + } + }); + } + + private void addChannel(JSONObject json) { + JSONObject config = Tools.loadConfig(new File("gameConfig.json")); + for (String key : config.keySet()) { + JSONArray array = config.getJSONArray(key); + Map map = null; + for (Object o : array) { + if (!json.isNull(o.toString())) { + if (map == null) + map = new HashMap<>(); + map.put(o.toString(), json.getString((o.toString()))); + } + } + if (map != null) { + channel.put(key,map); + vector.add(key); + list1.setListData(vector); + list1.updateUI(); + } + } + } + + private void setData(JSONObject json) { + System.out.println(json); + gameId.setText(json.getInt("appId") + ""); + packageName.setText(json.getString("packageName")); + jiguang.setText(json.getString("jiguang")); + addChannel(json); + if(json.optString("isChageImage","鍚").equals("鏄")){ + changeImage=new JSONObject(); + changeImage.put("srcPath",json.getString("srcimagePath")); + changeImage.put("oldPath",json.getString("oldImagePath")); + changeImage.put("filePath",json.getString("filePath")); + }else{ + changeImage=null; + } + /* AutoOutAPKAddChannelUi.newInstance(new DialogInterface() { + @Override + public void onOut(Object data) { + super.onOut(data); + Map map = (Map) data; + for (Object o : map.keySet()) { + System.out.println(o.toString() + " > " + map.get(o)); + + } + } + });*/ } private void createUIComponents() { diff --git a/src/com/qy/utils/AESTools.java b/src/com/qy/utils/AESTools.java index c23e59c..d564966 100755 --- a/src/com/qy/utils/AESTools.java +++ b/src/com/qy/utils/AESTools.java @@ -1,14 +1,13 @@ package com.qy.utils; +import org.apache.commons.codec.binary.Base64; + import java.io.UnsupportedEncodingException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; +import javax.crypto.*; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; diff --git a/src/com/qy/utils/AutoOutAPKTools.java b/src/com/qy/utils/AutoOutAPKTools.java index be1e04e..c45ee24 100644 --- a/src/com/qy/utils/AutoOutAPKTools.java +++ b/src/com/qy/utils/AutoOutAPKTools.java @@ -18,6 +18,7 @@ public class AutoOutAPKTools { private JSONObject manifestMap; private String appPath; private SmaliApkToolsPath inter; + private JSONObject copyJson; public AutoOutAPKTools(String gameId, Map channel) { this.gameId = gameId; @@ -49,10 +50,20 @@ public class AutoOutAPKTools { @Override public void smaliPath(String path) { inter.smaliPath(appPath + File.separator + new File(oldPath).getName() + gameId); + if (copyJson != null) { + File copyPath = new File(copyJson.getString("oldPath")); + for (File file : Objects.requireNonNull(copyPath.listFiles())) { + Tools.copyFile(file.getAbsolutePath(), appPath + File.separator + copyJson.getString("filePath"), true); + } + } } }); } + public void setChangeFile(JSONObject json) { + copyJson = json; + } + public void clear() { Tools.deleteFiles(appPath); } @@ -63,7 +74,7 @@ public class AutoOutAPKTools { try { List keys = new ArrayList<>(manifestMap.keySet()); - BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(manifest), StandardCharsets.UTF_8)); + BufferedReader reader = new BufferedReader(new FileReader(manifest)); while ((tmp = reader.readLine()) != null) { for (String key : keys) { if (tmp.contains(key)) { @@ -91,6 +102,12 @@ public class AutoOutAPKTools { } Tools.saveConfig(new File(appPath + File.separator + "assets" + File.separator + "kusdkconf.ini"), builder.toString()); + if (copyJson != null) { + File path = new File(copyJson.getString("srcPath")); + for (File file : Objects.requireNonNull(path.listFiles())) { + Tools.copyFile(file.getAbsolutePath(), appPath + File.separator + copyJson.getString("filePath"), true); + } + } } private void outLog(String log) { diff --git a/src/com/qy/utils/AutoPackageSDK.java b/src/com/qy/utils/AutoPackageSDK.java index a8fceb7..87a66a8 100644 --- a/src/com/qy/utils/AutoPackageSDK.java +++ b/src/com/qy/utils/AutoPackageSDK.java @@ -1,311 +1,66 @@ package com.qy.utils; -import com.qy.Interfaces.SmaliApkToolsPath; -import org.json.JSONArray; -import org.json.JSONObject; -import sun.applet.Main; - import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.Timer; -import java.util.TimerTask; public class AutoPackageSDK { - private AutoRandomAdSDK randomAdSDK; - private String version; - private String packageName; - private SmaliApkToolsPath inter; - File gdtsdk, uniplaysdk, qysdk,baiduSdk; - - private AutoPackageSDK() { + /* + 1銆佸湪SDK鐩綍璋冪敤.\gradlew assembleKusdk 鐢熸垚SDK + 2銆佸湪EmptyDemo椤圭洰鍚屾gradle + 3銆佺敓鎴怐emo.apk + public void init() { } - private void encryptSDK() { - AutoPackageSDKMust.start(Tools.getRandomString(16), new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - if (path != null) { - Tools.copyFile(path, new File("input" + File.separator + "qySDK").getAbsolutePath(), true); - } - init(); - } - }); + 4銆佸鍒禷pk鍒颁复鏃剁洰褰曞苟鍙嶇紪璇 + 5銆佸鍒跺弽缂栬瘧鐩綍鍒皊dk鐩綍 鈫愬埌杩欎竴姝ュ凡缁忓畬鎴怱DK鐨勫鐞 + 鐢熸垚姣嶅寘鐨勬柟妗堬細 + 1銆佸弽缂栬瘧CP鍖 + 2銆佹嫹璐漵dk鐩綍鐨刟ssets銆乻mali鍒癈P鍖 + 3銆佹牴鎹瓹P鍖呭凡鏈夌殑lib搴撴嫹璐濆搴旂殑sdk lib + 4銆佸悎骞秙dk鍜宑p鐨剅es锛岃緭鍑哄埌cp鐩綍 + 5銆侀噸鏂版墦鍖卌p鍖 + */ + + public AutoPackageSDK() { } - private void init() { - System.out.println("鍑嗗鎵撳寘"); - File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator); - File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator); - File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator); - File baiduPath = new File("input" + File.separator + "baiduSDK" + File.separator); - if (!gdtPath.exists() || Objects.requireNonNull(gdtPath.listFiles()).length == 0) { - inter.smaliPath("骞跨偣閫歋DK涓嶅瓨鍦紝璇锋斁缃埌input" + File.separator + "gdtSDK鏂囦欢澶逛腑"); - return; - } - gdtsdk = Objects.requireNonNull(gdtPath.listFiles())[0]; - if (!unplayPath.exists() || Objects.requireNonNull(unplayPath.listFiles()).length == 0) { - inter.smaliPath("鑱氶噺SDK涓嶅瓨鍦紝璇锋斁缃埌input" + File.separator + "gdtSDK鏂囦欢澶逛腑"); - return; - } - uniplaysdk = Objects.requireNonNull(unplayPath.listFiles())[0]; - if (!qysdkPath.exists() || Objects.requireNonNull(qysdkPath.listFiles()).length == 0) { - inter.smaliPath("瓒h耽SDK涓嶅瓨鍦紝璇锋斁缃埌input" + File.separator + "gdtSDK鏂囦欢澶逛腑"); - return; - } - qysdk = Objects.requireNonNull(qysdkPath.listFiles())[0]; - - if (!baiduPath.exists() || Objects.requireNonNull(baiduPath.listFiles()).length == 0) { - inter.smaliPath("鐧鹃潚钘DK涓嶅瓨鍦紝璇锋斁缃埌input" + File.separator + "baiduSDK鏂囦欢澶逛腑"); - return; - } - baiduSdk= Objects.requireNonNull(baiduPath.listFiles())[0]; - - JSONArray array = new JSONArray(); - - JSONObject gdt = new JSONObject(); - gdt.put("file", gdtsdk.getAbsolutePath()); - gdt.put("version", version); - gdt.put("type", "1"); - gdt.put("index", 0); - gdt.put("packageName", packageName + ".tgd"); - array.put(gdt); - - JSONObject unplay = new JSONObject(); - unplay.put("file", uniplaysdk.getAbsolutePath()); - unplay.put("version", version); - unplay.put("type", "5"); - unplay.put("index", 1); - unplay.put("packageName", packageName + ".up"); - array.put(unplay); - - JSONObject baidu = new JSONObject(); - baidu.put("file", baiduSdk.getAbsolutePath()); - baidu.put("version", version); - baidu.put("type", "2"); - baidu.put("packageName", packageName + ".bsb"); - baidu.put("index", 5); - array.put(baidu); - - JSONObject qy = new JSONObject(); - qy.put("file", qysdk.getAbsolutePath()); - qy.put("version", version); - qy.put("type", "0"); - qy.put("packageName", packageName + ".ww"); - qy.put("index", 3); - array.put(qy); - - File sdk = new File("packageSDK"); - - Tools.deleteFiles(sdk.getAbsolutePath()); - if (!sdk.exists()) { - sdk.mkdirs(); - } - - System.out.println("澶嶅埗璧勬簮鏂囦欢"); - outAssetsQY(0, "0"); - outAssetsQY(1, "4"); - outRes(); - System.out.println("寮濮嬫墦鍖"); - new AutoRandomAdSDK(array, new SmaliApkToolsPath() { - @Override - public void smaliPath(String path) { - System.out.println("鎵撳寘瀹屾垚:" + path); - delete(gdtPath, gdtsdk); - delete(unplayPath, uniplaysdk); - delete(qysdkPath, qysdk); - outAssetsADS(path); - copy(); - File sdk = zip(); - System.out.println("鍒朵綔SDK瀹屾垚:"); - inter.smaliPath(sdk == null ? "sdk鎵撳寘澶辫触" : sdk.getAbsolutePath()); - } - - private void delete(File path, File sdk) { - for (File file : path.listFiles()) { - if (!file.getName().equals(sdk.getName())) { - file.delete(); - } - } - } - }); - } - - public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) { - this.version = version; - this.packageName = packageName; - this.inter=inter; - encryptSDK(); - } - - private void outAssetsQY(int index, String type) { - JSONObject json = Tools.loadConfig(new File("config.cfg")); - - json.put("switch", index + 1 + ""); - String path = json.getString("out"); - String name = json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar"; - File file = new File(path + name); - if (file.exists()) - file.delete(); - - JarToAJar.start(json); - - Timer timer = new Timer(); - timer.schedule(new TimerTask() { - - @Override - public void run() { - // TODO Auto-generated method stub - if (file.exists()) { - File input = new File(json.getString("out") - + json.getJSONArray("array").getString(index) + ".jar"); - Tools.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(index), Integer.parseInt(type) - , Integer.parseInt(version)); - System.out.println(outFile.getAbsolutePath()); - File assets = new File("packageSDK" + File.separator + "assets"); - Tools.copyFile(outFile.getAbsolutePath(), assets.getAbsolutePath(), true); - outFile.delete(); - input.delete(); - timer.cancel(); - } - } - }, 0, 100); - - - } - - private void outAssetsADS(String path) { - JSONArray array = new JSONArray(path); - File assets = new File("packageSDK" + File.separator + "assets"); - File libs = new File("packageSDK" + File.separator); - assets.mkdirs(); - libs.mkdirs(); - for (int i = 0; i < array.length(); i++) { - JSONObject item = array.getJSONObject(i); - System.out.println(">>" + item.toString()); - if (item.getString("type").equals("0")) { - Tools.copyFileToName(item.getString("path"), libs.getAbsolutePath(), "classes.jar", true); - } else { - Tools.copyFile(item.getString("path"), assets.getAbsolutePath(), true); - } - File file = new File(item.getString("path")); - file.delete(); - } - - } - - private void outRes() { - //new File("packageSDK" + File.separator + "jni").mkdirs(); - File xmlFolder = new File("packageSDK" + File.separator + "res" + File.separator + "xml"); - xmlFolder.mkdirs(); - File manifest = new File("packageSDK" + File.separator + "AndroidManifest.xml"); - File srcManifest = new File("input" + File.separator + "Documents" + File.separator + "AndroidManifest.xml"); - Tools.copyFile("input" + File.separator + "Documents" + File.separator + "file_paths_5.xml", - xmlFolder.getAbsolutePath(), true); - Tools.copyFile("input" + File.separator + "Documents" + File.separator + "network_security_config.xml", - xmlFolder.getAbsolutePath(), true); + public void packageSdk() { + String sdkPath = Tools.loadConfig(new File("config.cfg")).getString("sdkPath"); try { - BufferedReader reader = new BufferedReader(new FileReader(srcManifest)); - String tmp; - StringBuilder str = new StringBuilder(); - while ((tmp = reader.readLine()) != null) { - str.append(tmp.replace("{packagename}", packageName)).append("\n"); - } - reader.close(); - byte[] uft8bom = {(byte) 0xef, (byte) 0xbb, (byte) 0xbf}; - OutputStream os = new FileOutputStream(manifest); - - OutputStreamWriter outputStream = new OutputStreamWriter(os, StandardCharsets.UTF_8); - outputStream.write(new String(str.toString().getBytes(), StandardCharsets.UTF_8)); + Process process = Runtime.getRuntime().exec(new String[]{"cmd"}); + OutputStream outputStream = process.getOutputStream(); + outputStream.write(("cd '" + sdkPath + "'").getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + outputStream.write(("gradlew assembleKusdk").getBytes(StandardCharsets.UTF_8)); outputStream.flush(); outputStream.close(); - os.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private File zip(File file) throws Exception { - String cd = "cd " + new File("packageSDK").getAbsolutePath(); - File sdk = new File("packageSDK" + File.separator + "sdk.aar"); - File files = new File("packageSDK"); - String aapt = new File("aapt.exe").exists() ? new File("aapt.exe").getAbsolutePath() : "aapt"; - for (File listFile : file.listFiles()) { - if (listFile.isDirectory()) { - zip(listFile); - } else if (!listFile.getName().equals("sdk.aar")) { - String path = listFile.getAbsolutePath().replace(files.getAbsolutePath(), ""); - String exec = aapt + " r " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n"; - Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec); - Thread.sleep(100); - exec = aapt + " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n"; - Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec); - Thread.sleep(100); - } - - } - return sdk; - } - - private File zip() { - File sdk = null; - try { - Tools.copyFile(new File("input" + File.separator + "Documents" + File.separator + "sdk.aar").getAbsolutePath(), - new File("packageSDK").getAbsolutePath(), true); - String cd = "cd " + new File("packageSDK").getAbsolutePath() + "\n\r"; - Process process = Runtime.getRuntime().exec(new String[]{"cmd"}); - OutputStream stream = process.getOutputStream(); - stream.write(cd.getBytes()); - stream.flush(); - stream.close(); - process.destroy(); - sdk = zip(new File("packageSDK")); - File copy = new File("packageSDK" + File.separator + "copy"); - if (copy.exists()) { - zip(copy); - } - stream.close(); - process.destroy(); - } catch (Exception e) { - e.printStackTrace(); - - } - return sdk; - } - - private void copy() { - try { - File copyPath = new File("input" + File.separator + "Documents" + File.separator + "copy"); - if (copyPath.exists()) { - Tools.copyFile(copyPath.getAbsolutePath(), new File("packageSDK").getAbsolutePath(), true); - } } catch (Exception e) { e.printStackTrace(); } } + private void printOut(InputStream inputStream) { + new Thread(new Runnable() { + @Override + public void run() { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String str = "", tmp; + while ((tmp = reader.readLine()) != null) { + str += tmp; + System.out.println(tmp); + } + reader.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + }).start(); + } + public static void main(String[] args) { - int[] nums = new int[]{-1, -1, -1, 1, -1, -1}; - for (int j = 1; j < nums.length; j++) { - int index = j; - int tmp = 0; - int tmp2 = 0; - for (int i = 0; i < index; i++) { - tmp += nums[i]; - } - for (int i = index + 1; i < nums.length; i++) { - tmp2 += nums[i]; - } - System.out.println(tmp); - System.out.println(tmp2); - if (tmp == tmp2) { - System.out.println("return:" + index); - return; - } - } - System.out.println("return:" + -1); + new AutoPackageSDK().packageSdk(); } } diff --git a/src/com/qy/utils/ExcelTools.java b/src/com/qy/utils/ExcelTools.java new file mode 100644 index 0000000..4972418 --- /dev/null +++ b/src/com/qy/utils/ExcelTools.java @@ -0,0 +1,96 @@ +package com.qy.utils; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.json.JSONObject; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class ExcelTools { + + private ExcelTools() { + + } + private static Workbook getWorkbook(){ + try { + return new XSSFWorkbook(new File("浜у搧鍙傛暟.xlsx")); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + private static void close(Workbook workbook){ + try { + workbook.close(); + } catch (Exception ignored) { + } + } + public static JSONObject queryParamByAppId(int appId) { + Workbook workbook=getWorkbook(); + if (workbook == null) { + return null; + } + JSONObject json = new JSONObject(); + Sheet sheet = workbook.getSheetAt(0); + Row param = null; + for (Row row : sheet) { + if (row.getCell(0).getCellType() == CellType.NUMERIC && row.getCell(0).getNumericCellValue() == appId) { + param = row; + break; + } + } + if (param == null) { + close(workbook); + return null; + } + json.put("appId", param.getCell(0).getNumericCellValue()); + json.put("packageName", param.getCell(1).getStringCellValue()); + json.put("jiguang", param.getCell(2).getStringCellValue()); + json.put("TOUTIAO_APP_ID", getValue(param.getCell(3))); + for (Cell cell : sheet.getRow(0)) { + String title = getValue(cell); + if (!StringUtils.isEmpty(title) && title.contains("|")) { + String value = getValue(param.getCell(cell.getColumnIndex())); + if (value != null) + json.put(title.split("\\|")[1],value); + } + } + close(workbook); + return json; + } + public static List getAllAppId(){ + List list=new ArrayList<>(); + Workbook workbook=getWorkbook(); + if (workbook == null) { + return list; + } + Sheet sheet = workbook.getSheetAt(0); + for (Row row : sheet) { + Cell cell=row.getCell(0); + String value=getValue(cell); + if(value!=null&&!value.equals("appid")){ + list.add(value); + } + } + close(workbook); + return list; + } + + private static String getValue(Cell cell) { + switch (cell.getCellType()) { + case NUMERIC: + return ((int) cell.getNumericCellValue()) + ""; + case STRING: + return cell.getStringCellValue(); + default: + return null; + } + } + + public static void main(String[] args) { + + } +} diff --git a/src/com/qy/utils/HeiHeiTools.java b/src/com/qy/utils/HeiHeiTools.java new file mode 100644 index 0000000..0db9f24 --- /dev/null +++ b/src/com/qy/utils/HeiHeiTools.java @@ -0,0 +1,182 @@ +package com.qy.utils; + +import com.qy.Interfaces.SmaliApkToolsPath; +import com.qy.ui.ApkSignUi; +import org.json.JSONObject; + +import java.io.File; +import java.util.LinkedHashMap; +import java.util.Vector; + +public class HeiHeiTools { + private File apk; + private File pluginPath; + + public HeiHeiTools() { + + } + + public void setSdkPlugin(File pluginPath) { + this.pluginPath = pluginPath; + } + + public void setApk(File apk) { + this.apk = apk; + } + + public void start() { + SmaliUtils utils = new SmaliUtils(); + utils.unPack(apk.getAbsolutePath(), new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + copyLibs(new File(path)); + } + }); + } + + private SmaliApkToolsPath packaInter; + + private void copyLibs(File smaliPath) { + if (!new File(pluginPath.getAbsolutePath() + File.separator + "libs").exists()) { + copyAssets(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "assets")); + } + unpackLibs(new File(pluginPath.getAbsolutePath() + File.separator + "libs"), new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + File libs = new File(path); + for (File file : libs.listFiles()) { + if (file.isDirectory() && !"original".equals(file.getName())&& !"unknown".equals(file.getName())) { + Tools.copy_dir(file.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "smali"); + } + if(file.isDirectory()&& "assets".equals(file.getName())){ + Tools.copy_dir(file.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "assets"); + } + + } + packaInter = new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + XMLTools.mergeManifestXML(new File(smaliPath.getAbsolutePath() + File.separator + "AndroidManifest.xml"), + new File(pluginPath.getAbsolutePath() + File.separator + "AndroidManifest.xml"), + new File(smaliPath.getAbsolutePath() + File.separator + "AndroidManifest.xml")); + SmaliUtils utils = new SmaliUtils(); + utils.bale(smaliPath.getAbsolutePath(), smaliPath.getAbsolutePath()+File.separator+"game.apk", new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + + LinkedHashMap keyMap= ApkSignUi.loadKeys(); + Vector adbList = new Vector(keyMap.keySet()); + String key=adbList.get(1); + String tmp=keyMap.get(key); + System.out.println("閫夋嫨绛惧悕:"+key); + JSONObject json=new JSONObject(tmp); + ApkSignTools tools=new ApkSignTools(); + tools.setSignFile(new File(json.getString("file"))); + tools.setApkFile(new File(path)); + tools.setKeyStorePassword(json.getString("alias_password")); + tools.setName(json.getString("alias")); + tools.setSignKey(json.getString("password")); + System.out.println("寮濮嬬鍚"); + tools.sign(); + System.out.println("鎵撳寘瀹屾垚:" + path); + } + }); + } + }; + copyAssets(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "assets")); + } + }); + } + + private void copyAssets(File smaliPath, File assets) { + Tools.copy_dir(assets.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "assets"); + copyJniLibs(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "JniLibs")); + } + + private void copyJniLibs(File smaliPath, File jniLibs) { + File libs = new File(smaliPath.getAbsolutePath() + File.separator + "lib"); + if(libs.exists()) { + for (File file : libs.listFiles()) { + Tools.copy_dir(jniLibs.getAbsolutePath() + File.separator + file.getName(), file.getAbsolutePath()); + } + } + copyRes(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "res")); + } + + private void copyRes(File smaliPath, File res) { + Tools.copy_dir(res.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "res"); + copyCode(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "code")); + + } + + private void copyCode(File smaliPath, File code) { + File sboran = null; + for (File file : smaliPath.listFiles()) { + if (file.getName().startsWith("smali")) { + if (new File(file.getAbsolutePath() + File.separator + + "com" + File.separator + + "sboran" + File.separator + + "game" + File.separator + + "sdk").exists()) { + sboran = new File(file.getAbsolutePath() + File.separator + + "com" + File.separator + + "sboran" + File.separator + + "game" + File.separator + + "sdk"); + break; + } + } + } + if (sboran != null) { + Tools.copyFile(code.listFiles()[0].getAbsolutePath() + File.separator + "SboRanApplication.smali" + , sboran.getAbsolutePath(), true); + Tools.copy_dir(code.getAbsolutePath(), sboran.getAbsolutePath() + File.separator + "platform"); + Tools.deleteFile(sboran.getAbsolutePath() + File.separator + "platform" + File.separator + code.listFiles()[0].getName() + File.separator + "SboRanApplication.smali"); + } + packaInter.smaliPath("ok"); + } + + private static void unpackLibs(File libs, SmaliApkToolsPath smaliApkToolsPath) { + String dx = Tools.loadConfig(new File("config.cfg")).getString("dx"); + if (new File("tmp" + File.separator + "dex").exists()) { + Tools.deleteFiles(new File("tmp" + File.separator + "dex").getAbsolutePath()); + } + if (new File("tmp" + File.separator + "dx_smali").exists()) { + Tools.deleteFiles(new File("tmp" + File.separator + "dx_smali").getAbsolutePath()); + } + new File("tmp" + File.separator + "dxs").mkdirs(); + System.out.println(libs.getAbsolutePath()); + for (File file : libs.listFiles()) { + Tools.toAJar(dx, file.getAbsolutePath(), "tmp" + File.separator + "dxs" + File.separator + file.getName()); + } + libs = new File("tmp" + File.separator + "dxs"); + unpackLibsDx(libs.listFiles(), 0); + smaliApkToolsPath.smaliPath(new File("tmp" + File.separator + "dx_smali").getAbsolutePath()); + } + + public static void unpackLibsDx(File[] files, int index) { + if (index < files.length) { + new SmaliUtils().unPack(files[index].getAbsolutePath(), new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + Tools.copy_dir(path, "tmp" + File.separator + "dx_smali"); + unpackLibsDx(files, index + 1); + } + }); + } + } + + + public static void main(String[] args) { + /* HeiHeiTools tools = new HeiHeiTools(); + tools.setApk(new File("D:\\ieda\\android_sdk_tools\\澶╁懡浼犺锛堝樋鍢挎父鎴忎笓鏈嶏級_鍢垮樋娓告垙_8.1.4_202106070951.apk")); + tools.setSdkPlugin(new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\zssdk")); + tools.start();*/ + unpackLibs(new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\69you\\libs"), new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + System.out.println("over = "+path); + } + }); + } +} diff --git a/src/com/qy/utils/SmaliUtils.java b/src/com/qy/utils/SmaliUtils.java index 3c31289..4d2e12a 100755 --- a/src/com/qy/utils/SmaliUtils.java +++ b/src/com/qy/utils/SmaliUtils.java @@ -3,7 +3,6 @@ package com.qy.utils; import java.io.*; import java.net.URL; import java.net.URLClassLoader; -import java.nio.ByteBuffer; import java.security.Permission; import java.util.ArrayList; import java.util.HashMap; @@ -14,7 +13,7 @@ import java.util.Set; import com.qy.Interfaces.SmaliApkToolsPath; import com.qy.ui.TextToDialog; -import com.sun.javaws.exceptions.ExitException; +import org.json.JSONObject; public class SmaliUtils { //private String str = ""; @@ -23,8 +22,8 @@ public class SmaliUtils { // private String mainPath = "D:\\鍙嶇紪璇慭\APK\\rx.jar.out\\smali"; private Map clazzList; private List files = new ArrayList<>(); - private static ClassLoader apktool_234; - private static ClassLoader apktool_241; + private ClassLoader package_apktool; + private ClassLoader un_apktool; public static void main(String[] args) { @@ -34,11 +33,21 @@ public class SmaliUtils { public SmaliUtils() { clazzList = new HashMap<>(); try { - if(apktool_234==null){ - apktool_234=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.3.4.jar")}); + JSONObject json =Tools.loadConfig(new File("config.cfg")); + if(package_apktool ==null){ + String path="libs/apktool_2.4.1.jar"; + if(json!=null){ + path=json.optString("packageApkTool","libs/apktool_2.4.1.jar"); + } + System.out.println(path); + package_apktool =new URLClassLoader(new URL[]{new URL("file:"+path)}); } - if(apktool_241==null){ - apktool_241=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.4.1.jar")}); + if(un_apktool ==null){ + String path="libs/apktool_2.4.1.jar"; + if(json!=null){ + path=json.optString("unPackageApkTool","libs/apktool_2.4.1.jar"); + } + un_apktool =new URLClassLoader(new URL[]{new URL("file:"+path)}); } }catch (Exception e){ e.printStackTrace(); @@ -222,6 +231,10 @@ public class SmaliUtils { Tools.deleteFiles(path.getAbsolutePath()); } String[] args = new String[]{"d", "-f", jarPath}; + JSONObject json=Tools.loadConfig(new File("config.cfg")); + if(json!=null){ + isEncryption=json.optBoolean("encryption",false); + } if (isEncryption) { args = new String[]{"d", "-f", jarPath, "--only-main-classes"}; } @@ -231,7 +244,7 @@ public class SmaliUtils { } System.out.println("\n"); //Main.main(args); - apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); + un_apktool.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); File jarFile = new File(jarPath); String name; if (jarFile.getName().contains(".jar")) { @@ -260,7 +273,7 @@ public class SmaliUtils { public void bale(String smaliPath, String path, SmaliApkToolsPath inter) { String[] args = new String[]{"-r","b", "-f", smaliPath, "-o", path}; for (String string : args) { - System.out.print(string + " "); + System.err.print(string + " "); } try { run = true; @@ -291,7 +304,7 @@ public class SmaliUtils { System.setSecurityManager(new NoExitSecurityManager()); //Main.main(args); - apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); + package_apktool.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); if (inter != null) { inter.smaliPath(path); } diff --git a/src/com/qy/utils/Tools.java b/src/com/qy/utils/Tools.java index 0cc48ad..1cf7f14 100755 --- a/src/com/qy/utils/Tools.java +++ b/src/com/qy/utils/Tools.java @@ -128,7 +128,11 @@ public class Tools { } public static void copy_dir(String src,String desc){ try { + //System.out.println("鎷疯礉鏂囦欢:"+src+" -> "+desc); File dirSrc=new File(src); + if(!dirSrc.exists()){ + return; + } for (File file : dirSrc.listFiles()) { if(file.isDirectory()){ new File(desc+File.separator+file.getName()).mkdirs(); @@ -413,4 +417,9 @@ public class Tools { } System.out.println("[鍩熷悕]" + url + " = [body]" + body.toString() + " -> [鎺ユ敹] " + str); } + + public static void deleteFile(String s) { + System.out.println("鍒犻櫎鏂囦欢:"+s); + new File(s).delete(); + } } diff --git a/src/com/qy/utils/XMLTools.java b/src/com/qy/utils/XMLTools.java new file mode 100644 index 0000000..2db344c --- /dev/null +++ b/src/com/qy/utils/XMLTools.java @@ -0,0 +1,216 @@ +package com.qy.utils; + + +import org.dom4j.*; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.SAXReader; +import org.dom4j.io.XMLWriter; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class XMLTools { + private XMLTools() { + } + public static void mergeManifestXML(File src,File src2,File outFile){ + try { + SAXReader reader = new SAXReader(); + Document manifestDocument = reader.read(src); + Document manifestDocument2 = reader.read(src2); + Element manifestElement = manifestDocument.getRootElement(); + Element manifestElement2 = manifestDocument2.getRootElement(); + for (Element element : manifestElement2.elements("uses-permission")) { + if(manifestElement.asXML().contains((CharSequence) element.attribute("name").getData())){ + continue; + } + manifestElement.add((Element) element.clone()); + } + Element application=manifestElement.element("application"); + Element application2=manifestElement2.element("application"); + for (Element element : application2.elements()) { + if(application.asXML().contains((CharSequence) element.attribute("name").getData())){ + continue; + } + application.add((Element) element.clone()); + } + manifestElement.remove(application); + manifestElement.add((Element) application.clone()); + manifestDocument.remove(manifestElement); + manifestDocument.add((Element) manifestElement.clone()); + writeFile4Pretty(outFile,manifestDocument); + System.out.println("AndroidManifest澶勭悊瀹屾垚"); + } catch (Exception e) { + e.printStackTrace(); + } + } + private static void writeFile4Pretty(File file, Document document) throws IOException { + OutputFormat format = OutputFormat.createPrettyPrint(); + format.setEncoding(document.getXMLEncoding()); + XMLWriter writer = new XMLWriter(new FileWriter(file), format); + writer.write(document); + writer.flush(); + writer.close(); + } + /** + * 鍚堝苟涓嶅悓xml鏂囦欢锛岃鏂规硶涓嶈兘鐢ㄤ簬鍚堝苟public.xml + * @param file1 鏂囦欢1 + * @param file2 琚悎骞剁殑鏂囦欢2 + * @param outFile 杈撳嚭鏂囦欢 + */ + public static void mergeResXML(File file1, File file2, File outFile) { + try { + List list = new ArrayList<>(); + List list1 = readXML(file1); + List list2 = readXML(file2); + list.add(""); + list.add(""); + list.addAll(list1); + for (String element : list2) { + if (!list.contains(element)) { + list.add(element); + } + + } + list.add(""); + FileWriter writer = new FileWriter(outFile); + for (String s : list) { + writer.append(s).append("\n"); + } + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 鍚堝苟public.xml + * + * @param file1 琚悎骞舵枃浠讹紝浠ヨ鏂囦欢id涓轰富 + * @param file2 鍚堝苟绱犳潗 + * @param outFile 杈撳嚭鏂囦欢 + */ + public static void mergePublicXML(File file1, File file2, File outFile) { + try { + //file1涓殑鍙傛暟锛屽湪閬嶅巻file2鏃剁敤鏉ュ垽鏂槸鍚﹂噸澶 + List list = new ArrayList<>(); + //鏈鍚庤緭鍑虹殑xml鏂囦欢锛屼笉鐩存帴asXML鏄洜涓篴sXML涓嶆牸寮忓寲鏂囦欢锛屼笉濂界湅 + List main = new ArrayList<>(); + SAXReader reader = new SAXReader(); + Document document = reader.read(file1); + Document document2 = reader.read(file2); + Element element = document.getRootElement(); + Element element2 = document2.getRootElement(); + //閬嶅巻file1锛屽苟璁板綍鍏冪礌 + for (Element el : element.elements()) { + list.add(el.attributeValue("type") + "|" + el.attributeValue("name")); + } + //鍚堝苟file2锛屽幓閲 + for (Element el : element2.elements()) { + String tmp = el.attributeValue("type") + "|" + el.attributeValue("name"); + if (!list.contains(tmp)) { + element.add((Element) el.clone()); + } + } + //鍒嗛棬鍒被锛屼繚瀛樹笉鍚宼ype涓嬬殑鍏冪礌鍒癿ap + Map> map=new HashMap<>(); + for (Element el : element.elements()) { + List elements; + if(map.containsKey(el.attributeValue("type"))){ + elements=map.get(el.attributeValue("type")); + }else{ + elements=new ArrayList<>(); + } + if(!elements.contains(el)){ + elements.add(el); + map.put(el.attributeValue("type"),elements); + } + } + main.add(""); + main.add(""); + int index=0x7f00;//涓嶅悓type鐨勫 + int nowIndex=Integer.parseInt( Integer.toHexString(index)+"0000",16);//鍗曚釜鍏冪礌鐨勫硷紝渚嬶細0x7f000000 + String nowKey=""; + //閲嶆柊璁剧疆id + for (String key : map.keySet()) { + if(!key.equals(nowKey)){ + nowKey=key; + index++; + nowIndex=Integer.parseInt( Integer.toHexString(index)+"0000",16); + } + for (Element el : map.get(key)) { + main.add(el.addAttribute("id","0x"+Integer.toHexString(nowIndex++)).asXML()); + } + } + main.add(""); + FileWriter writer = new FileWriter(outFile); + for (String s : main) { + writer.append(s).append("\n"); + } + //writer.append(element.asXML()); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static List readXML(File file) { + List list = new ArrayList<>(); + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(file); + Element element = document.getRootElement(); + for (Element el : element.elements()) { + list.add(el.asXML()); + } + return list; + } catch (Exception e) { + e.printStackTrace(); + System.out.println(file.exists()); + } + return list; + } + + public static void out() { + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(new File("input\\xml\\tmp.xml")); + Element element = document.getRootElement(); + int i = 0x7f0b0026; + for (Element el : element.elements()) { + i++; + String value = "0x" + Integer.toHexString(i); + el = el.addAttribute("id", value); + System.out.println(el.asXML()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + boolean isPublic=true; + if(isPublic) { + mergePublicXML(new File("D:\\ieda\\android_sdk_tools\\EmptyDemo\\res\\values\\public.xml") + , new File("D:\\ieda\\android_sdk_tools\\app-game_op2-release\\res\\values\\public.xml") + , new File("D:\\ieda\\android_sdk_tools\\app-game_op2-release\\res\\values\\public.xml")); + }else { + String fileName = "styles.xml"; + mergeResXML(new File("D:\\ieda\\android_sdk_tools\\qztx_agent_115847_baoliang_11027_1003.0.0_20210128_48301\\res\\values\\" + fileName), + new File("D:\\ieda\\android_sdk_tools\\EmptyDemo\\res\\values\\" + fileName), + new File("D:\\ieda\\android_sdk_tools\\qztx_agent_115847_baoliang_11027_1003.0.0_20210128_48301\\res\\values\\" + fileName)); + } + /*mergeManifestXML(new File("D:\\ieda\\android_sdk_tools\\涓夌敓璇\\AndroidManifest.xml"), + new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\binghu\\AndroidManifest.xml"), + new File("D:\\ieda\\android_sdk_tools\\涓夌敓璇\\Manifest.xml"));*/ + + } +}