1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| public boolean checkPassword(String str) { try { InputStream open = getAssets().open("classes.dex"); byte[] bArr = new byte[open.available()]; open.read(bArr); File file = new File(getDir("data", 0), "1.dex"); FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(bArr); fileOutputStream.close(); open.close(); String str2 = (String) new DexClassLoader(file.getAbsolutePath(), getDir("dex", 0).getAbsolutePath(), null, getClass().getClassLoader()) .loadClass("com.zj.wuaipojie2024_2.C") .getDeclaredMethod("isValidate", Context.class, String.class, int[].class) .invoke(null, this, str, getResources().getIntArray(R.array.A_offset)); if (str2 == null || !str2.startsWith("唉!")) { return false; } this.tvText.setText(str2); this.myunlock.setVisibility(8); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
public static String isValidate(Context context, String str, int[] iArr) throws Exception { try { return (String) getStaticMethod(context, iArr, "com.zj.wuaipojie2024_2.A", "d", Context.class, String.class).invoke(null, context, str); } catch (Exception e) { Log.e(TAG, "咦,似乎是坏掉的dex呢!"); e.printStackTrace(); return ""; } } private static Method getStaticMethod(Context context, int[] iArr, String str, String str2, Class<?>... clsArr) throws Exception { try { File fix = fix(read(context), iArr[0], iArr[1], iArr[2], context);
ClassLoader classLoader = context.getClass().getClassLoader();
File dir = context.getDir("fixed", 0);
Method declaredMethod = new DexClassLoader(fix.getAbsolutePath(), dir.getAbsolutePath(), null, classLoader) .loadClass(str) .getDeclaredMethod(str2, clsArr);
fix.delete(); new File(dir, fix.getName()).delete();
return declaredMethod; } catch (Exception e) { e.printStackTrace(); return null; } } private static File fix(ByteBuffer byteBuffer, int i, int i2, int i3, Context context) throws Exception { try { File dir = context.getDir("data", 0); int intValue = D.getClassDefData(byteBuffer, i).get("class_data_off").intValue(); HashMap<String, int[][]> classData = D.getClassData(byteBuffer, intValue); classData.get("direct_methods")[i2][2] = i3; byte[] encodeClassData = D.encodeClassData(classData); byteBuffer.position(intValue); byteBuffer.put(encodeClassData); byteBuffer.position(32); byte[] bArr = new byte[byteBuffer.capacity() - 32]; byteBuffer.get(bArr); byte[] sha1 = Utils.getSha1(bArr); byteBuffer.position(12); byteBuffer.put(sha1); int checksum = Utils.checksum(byteBuffer); byteBuffer.position(8); byteBuffer.putInt(Integer.reverseBytes(checksum)); byte[] array = byteBuffer.array(); File file = new File(dir, "2.dex"); FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(array); fileOutputStream.close(); return file; } catch (Exception e) { e.printStackTrace(); return null; } } 修复后的代码: public static String d(Context context, String str) { MainActivity.sSS(str); String signInfo = Utils.getSignInfo(context); if (signInfo == null || !signInfo.equals("fe4f4cec5de8e8cf2fca60a4e61f67bcd3036117")) { return ""; } StringBuffer stringBuffer = new StringBuffer(); int i = 0; while (stringBuffer.length() < 9 && i < 40) { int i2 = i + 1; String substring = "0485312670fb07047ebd2f19b91e1c5f".substring(i, i2); if (!stringBuffer.toString().contains(substring)) { stringBuffer.append(substring); } i = i2; }
return !str.equals(stringBuffer.toString().toUpperCase()) ? "" : "唉!哪有什么亿载沉睡的玄天帝,不过是一位被诅咒束缚的旧日之尊,在灯枯之际挣扎的南柯一梦罢了。有缘人,这份机缘就赠予你了。坐标在B.d"; } public static String d(String str) { return "机缘是{" + Utils.md5(Utils.getSha1("password+你的uid".getBytes())) + "}"; }
|