diff --git a/ad_config.cfg b/ad_config.cfg index d500a53..7e97a95 100644 --- a/ad_config.cfg +++ b/ad_config.cfg @@ -31,6 +31,7 @@ "isJarLib": false, "packagerlimit": 3, "isManual": false, + "dex2jar": "D:\\反编译\\dex2jar-2.0\\_d2j-dex2jar.bat", "manual": [ { "class": "com.qq.e.comm.a", @@ -72,6 +73,7 @@ "isJarLib": false, "packagerlimit": 3, "isManual": true, + "dex2jar": "D:\\反编译\\dex2jar-2.0\\_d2j-dex2jar.bat", "manual": [ { "class": "com.uniplay.adsdk.basic.RuleManage", @@ -202,8 +204,8 @@ ], "random":[ "com", - "ww", - "za", + "prujwk", + "jdyphn", ], "isAllPackage":false, "isReName":true, diff --git a/src/com/qy/utils/AutoRandomAdSDK.java b/src/com/qy/utils/AutoRandomAdSDK.java index aa82341..3a04dc3 100644 --- a/src/com/qy/utils/AutoRandomAdSDK.java +++ b/src/com/qy/utils/AutoRandomAdSDK.java @@ -225,11 +225,12 @@ public class AutoRandomAdSDK { + clazzs.getString(i).replace(".", File.separator) + ".smali"); if (clz.exists()) { + // System.out.println("key="+clazzs.getString(i)+" value="+clz); adClass.put(clazzs.getString(i), clz); } } for (String key : adClass.keySet()) { - //System.out.println("注入的值:" + key); + // System.out.println("注入的值:" + key); } mkdirs(); update(); @@ -296,7 +297,6 @@ public class AutoRandomAdSDK { smalitools.setPath(rootPath + File.separator + "smali"); file = new File(rootPath + File.separator + "smali"); - //System.out.println(file.getAbsolutePath() + " " + file.exists()); try { Thread.sleep(200); //System.out.println(smalitools.mainPath); @@ -506,13 +506,14 @@ public class AutoRandomAdSDK { System.out.println("key=" + key + " file=" + nowAdClass.get(key) + " oldFile=" + adClass.get(key)); }*/ for (String key : adClass.keySet()) { + File file = new File(adClass.get(key).getAbsolutePath()); String fileName = file.getName().replace(".smali", ""); File filePath = new File(nowAdClass.get(key).getAbsolutePath().replace(file.getName(), "").replace(".smali", "")); if (!config.getBoolean("isAllPackage")) { filePath = new File(file.getAbsolutePath().replace(file.getName(), "")); } - //System.out.println(nowAdClass.get(key)+" "+file.getName()+" "+filePath.getAbsolutePath()); + // System.out.println(nowAdClass.get(key)+" "+file.getName()+" "+filePath.getAbsolutePath()); //System.out.println(key + " | " + file.getAbsolutePath() + " | " + fileName + " | " + filePath.getAbsolutePath()); if (filePath.listFiles() == null) { //System.out.println("filePath为空:" + filePath.getAbsolutePath()); @@ -520,7 +521,7 @@ public class AutoRandomAdSDK { } //moveFile(filePath,key); for (File fs : filePath.listFiles()) { - // //System.out.println(fs.getAbsolutePath().replace(rootPath, "")); + // System.out.println(fs.getAbsolutePath()); if (fs.isDirectory()) { continue; } @@ -529,25 +530,28 @@ public class AutoRandomAdSDK { } String nName = getNewName(fs.getAbsolutePath()); + //System.out.println(fs.getAbsolutePath().replace(rootPath,"")+" > "+nName); if (fs.getName().startsWith(fileName.split("\\$")[0] + "$")) { if (getNewName(fs.getAbsolutePath()).endsWith("[notmover]")) { Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), fs .getName().replace(fs.getName().split("\\$")[0], nName), true); + file.delete(); } else { - moveFile(fs, key, fs.getName().replace(fs.getName().split("\\$")[0], nName), false); + + moveFile(fs, key, nName+fs.getName().substring(fileName.length()), false); } - fs.delete(); } } if (getNewNameForSrc(file.getName()).endsWith("[notmover]")) { nowAdFile.put(key, file.getAbsolutePath()); Tools.copyFileToName(file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), ""), getNewName(file.getAbsolutePath()) + ".smali", true); + file.delete(); } else { moveFile(file, key, getNewName(file.getAbsolutePath()) + ".smali", true); } - file.delete(); + } if (root != null) removeNullFile(root); @@ -640,8 +644,10 @@ public class AutoRandomAdSDK { } - boolean data = file.renameTo(new File(rootPath + toPath, file.getName())); - //System.out.println("移动文件:" + file.getAbsolutePath().replace(rootPath, "") + " 到 " + (rootPath + toPath) + " > " + fileName + " " + nowAdClass.get(fileName) + " >! " + data); + //boolean data = file.renameTo(new File(rootPath + toPath, file.getName())); + boolean data=Tools.copyFile(file.getAbsolutePath(),rootPath + toPath,true); + file.delete(); + // System.out.println("移动文件:" + file.getAbsolutePath().replace(rootPath, "") + " 到 " + (rootPath + toPath) + " > " + fileName + " " + nowAdClass.get(fileName) + " >! " + data); if (nowAdClass.containsKey(fileName)) { // System.err.println("移动文件:"+file.getAbsolutePath().replace(rootPath, "")+" 到 "+toPath+" > "+fileName+" "+nowAdClass.get(fileName)); // //System.out.println(file.getAbsolutePath().replace(rootPath,"")+" "+toPath); diff --git a/src/com/qy/utils/SmaliUtils.java b/src/com/qy/utils/SmaliUtils.java index 806de2a..b9d9c6b 100755 --- a/src/com/qy/utils/SmaliUtils.java +++ b/src/com/qy/utils/SmaliUtils.java @@ -123,6 +123,8 @@ public class SmaliUtils { newName = tmp.replace(".class L", ""); } else if (tmp.contains(".class synthetic L")) { newName = tmp.replace(".class synthetic L", ""); + } else if(tmp.contains(".class final enum L")){ + newName=tmp.replace(".class final enum L",""); } if (newName != null) { newName = newName.replace(";", ""); @@ -164,6 +166,7 @@ public class SmaliUtils { String[] datas = str.split("\n"); String save = ""; i = 1; + for (String string : datas) { save += changeLine(string) + "\n"; } @@ -178,13 +181,11 @@ public class SmaliUtils { } int i = 1; - private String changeLine(String old) { Set keySet = clazzList.keySet(); for (String clazz : keySet) { - if (old.contains(clazz)) { - old = old.replace(clazz, clazzList.get(clazz)); - //System.out.println((i++) + " 修改:" + t + " 到:" + old + " " + clazz); + if (old.contains(clazz+";")) { + old= old.replace(clazz, clazzList.get(clazz)); } } return old; diff --git a/src/com/qy/utils/Tools.java b/src/com/qy/utils/Tools.java index 0b7e625..5987167 100755 --- a/src/com/qy/utils/Tools.java +++ b/src/com/qy/utils/Tools.java @@ -89,12 +89,14 @@ public class Tools { fileName=srcFile.getName(); } in = new FileInputStream(srcFile); - out = new FileOutputStream(destFile + "/" +fileName ); + out = new FileOutputStream(destFile + File.separator +fileName ); byte[] buffer = new byte[1024]; while ((byteread = in.read(buffer)) != -1) { out.write(buffer, 0, byteread); } + out.close(); + in.close(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); @@ -102,15 +104,6 @@ public class Tools { } catch (IOException e) { e.printStackTrace(); return false; - } finally { - try { - if (out != null) - out.close(); - if (in != null) - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } } } /**