[Java] 纯文本查看 复制代码
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class StartCrk {
static String basePath = "I:\\Downloads\\crack\\000\\CrackMe_java3\\";
static String tempDir = "F:\\temp\\";
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class<?> crk = Class.forName("lllllllllllllll");
/////
Object obj = crk.newInstance();
/////
Method m = crk.getMethod("loadClass", String.class);
m.setAccessible(true);
Field f0 = crk.getDeclaredField("lll"); //// String[]
f0.setAccessible(true);
Field f1 = crk.getDeclaredField("lIIl"); ///// int[58]
f1.setAccessible(true);
Field f2 = crk.getDeclaredField("llI"); ///// int[34]
f2.setAccessible(true);
//String className1 = f0[f1[1]];
int n1 = 58;
//int i[] = new int[n1];
int ii[] = (int[])f1.get(null);
// System.out.print("int lIIl[] = {");
// for(int j=0; j<n1; j++) {
// System.out.print(ii[j] + ",");
// }
// System.out.println("}");
int n2 = 34;
byte ii2[] = (byte[])f2.get(null);
// System.out.print("int llI[] = {");
// for(int j=0; j<n2; j++) {
// System.out.print(ii2[j] + ",");
// }
// System.out.println("}");
//int n2 = 3;
//String s[] = new String[n2];
String ss[] = (String[])f0.get(null);
System.out.println("0: " + ss[0]);
System.out.println("1: " + ss[1]);
System.out.println("2: " + ss[2]);
String className = ss[ii[1]];
System.out.println("class Name: " + className);
/////
saveClass("cn.loryu.crackme.CrackMe");
saveClass("cn.loryu.crackme.a");
//saveClass("cn.loryu.crackme.Check");
//saveClass("cn.loryu.crackme.Frame");
Object params[] = new String[1];
params[0] = className;
Class<?> claz2 = (Class<?>)m.invoke(obj, params); //// Class: cn.loryu.crackme.CrackMe
if(claz2 != null) {
System.out.println("load class success: " + params[0]);
/////
Object obj2 = (claz2).newInstance();
Method mth[] = claz2.getDeclaredMethods();
for(int k=0; k<mth.length; k++) {
System.out.println("method: " + mth[k]);
}
Field fld[] = claz2.getDeclaredFields();
for(int k=0; k<fld.length; k++) {
System.out.println("field: " + fld[k]);
}
Class param_type_main[] = new Class[1];
param_type_main[0] = String[].class;
Object param_value_main[] = new Object[1];
param_value_main[0] = args;
//// 这里是执行 crackme
// claz2.getDeclaredMethod("main", param_type_main[0]).invoke(null, param_value_main);
long flag1 = 0x274c89061a03L;
long flag2 = flag1 ^ 0x2e660bfc3229L;
//// field
Field f5 = claz2.getDeclaredField("ll"); //// int[]
f5.setAccessible(true);
int n5 = 281;
int ll[] = (int[])f5.get(null);
// System.out.print("int llI[] = {");
// for(int j=0; j<n5; j++) {
// System.out.print(ll[j] + ",");
// }
// System.out.println("}");
//// java.lang.String cn.loryu.crackme.CrackMe.a(int,int,int)
Class<?> type_a[] = new Class[3];
type_a[0] = int.class;
type_a[1] = int.class;
type_a[2] = int.class;
int value_a[] = new int[3];
value_a[0] = ll[2] + ll[3];
value_a[1] = ll[2] + ll[4];
value_a[2] = (int)flag1;
String cls0 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 1: " + cls0); //// java.io.tmpdir
value_a[0] = ll[2] + ll[18];
value_a[1] = ll[2] + ll[19];
value_a[2] = (int)flag1;
String cls1 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 2: " + cls1); //// cn.loryu.crackme.Check
value_a[0] = ll[2] + ll[20];
value_a[1] = ll[8] + ll[21];
value_a[2] = (int)flag1;
String cls2 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 3: " + cls2); //// cn.loryu.crackme.Frame
value_a[0] = ll[2] + ll[5];
value_a[1] = ll[2] + ll[6];
value_a[2] = (int)flag1;
String cls3 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 4: " + cls3); //// Check.class.CrackMe
value_a[0] = ll[2] + ll[7];
value_a[1] = ll[8] + ll[9];
value_a[2] = (int)flag1;
String cls4 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 5: " + cls4); //// Frame.class.CrackMe
value_a[0] = ll[2] + ll[10];
value_a[1] = ll[2] + ll[11];
value_a[2] = (int)flag1;
String cls5 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 6: " + cls5); //// CBEA62C4FB252CEAAE4980645286D6FE2901C8802FC8AB89
value_a[0] = ll[2] + ll[12];
value_a[1] = ll[2] + ll[13];
value_a[2] = (int)flag1;
String cls6 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 7: " + cls6); //// 1F31F140088A5DA2BF202AE3862F206232087A15C4C2C4A1
value_a[0] = ll[2] + ll[14];
value_a[1] = ll[2] - ll[15];
value_a[2] = (int)flag1;
String cls7 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 8: " + cls7); //// cn.loryu.crackme.Check
value_a[0] = ll[2] + ll[16];
value_a[1] = ll[8] + ll[17];
value_a[2] = (int)flag1;
String cls8 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 9: " + cls8); //// cn.loryu.crackme.Frame
value_a[0] = ll[2] + ll[18];
value_a[1] = ll[2] + ll[19];
value_a[2] = (int)flag1;
String cls9 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 10: " + cls9); //// cn.loryu.crackme.Check
value_a[0] = ll[2] + ll[20];
value_a[1] = ll[8] + ll[21];
value_a[2] = (int)flag1;
String cls10 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("obj 11: " + cls10); //// cn.loryu.crackme.Frame
//System.out.println("obj 12: " + ll[22]); //// addListeners
value_a[0] = ll[2] + ll[23];
value_a[1] = ll[8] + ll[24];
value_a[2] = (int)flag1;
String cls11 = (String)claz2.getDeclaredMethod("a", int.class, int.class, int.class).invoke(null, value_a[0], value_a[1], value_a[2]);
System.out.println("method 1: " + cls11); //// addListeners
//// get classloader cn.loryu.crackme.a
String className_a = "cn.loryu.crackme.a";
//Class<?> cls_a = Class.forName(className_a);
Object params_a[] = new String[1];
params_a[0] = className_a;
Class<?> cls_a = (Class<?>)m.invoke(obj, params_a); //// Class: cn.loryu.crackme.a
Object cls_a_obj = cls_a.newInstance();
Method mth2[] = cls_a.getDeclaredMethods();
for(int k=0; k<mth2.length; k++) {
System.out.println("a.method: " + mth2[k]);
}
Field fld2[] = cls_a.getDeclaredFields();
for(int k=0; k<fld2.length; k++) {
System.out.println("a.field: " + fld2[k]);
}
//// loadClass
// Class<?> cls_check = (Class<?>)cls_a.getMethod("loadClass", String.class).invoke(cls_a_obj, "cn.loryu.crackme.Check");
// if(cls_check != null) {
// System.out.println("load class ok: " + cls_check.getName());
// } else {
// System.out.println("load class failure: ");
// }
int i = (int)(flag2 >>> ll[0]);
long l = (flag2 << ll[1]) >>> ll[1];
////// Check.class.CrackMe
File a = new File(tempDir + "Check.class.CrackMe");
byte b1[] = (byte[])cls_a.getDeclaredMethod("a", short.class, File.class, String.class, long.class).invoke(cls_a_obj, (short)i, a.getAbsoluteFile(), "CBEA62C4FB252CEAAE4980645286D6FE2901C8802FC8AB89", l);
System.out.println("cn.loryu.crackme.Check size: " + b1.length);
saveClass("cn.loryu.crackme.Check", b1);
///// Frame.class.CrackMe
File b = new File(tempDir + "Frame.class.CrackMe");
byte b2[] = (byte[])cls_a.getDeclaredMethod("a", short.class, File.class, String.class, long.class).invoke(cls_a_obj, (short)i, b.getAbsoluteFile(), "1F31F140088A5DA2BF202AE3862F206232087A15C4C2C4A1", l);
System.out.println("cn.loryu.crackme.Frame size: " + b2.length);
saveClass("cn.loryu.crackme.Frame", b2);
// System.out.print("b1 = ");
// for(int k=0; k<b1.length; k++) {
// System.out.print(b1[k] + ", ");
// }
// System.out.println("");
// System.out.print("b2 = ");
// for(int k=0; k<b2.length; k++) {
// System.out.print(b2[k] + ", ");
// }
// System.out.println("");
} else {
System.out.println("load class failure: " + params[0]);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static int saveClass(String className, byte[] data) {
String fileName = className.replace('.', File.separatorChar).concat(".class");
try {
String fullPath = basePath + fileName;
int i = fullPath.lastIndexOf(File.separatorChar);
String path = fullPath.substring(0, i);
File f = new File(path);
f.mkdirs(); /// Create directory
FileOutputStream fos = new FileOutputStream(fullPath);
OutputStream os = new BufferedOutputStream(fos);
os.write(data);
System.out.println("save " + className +".class OK");
os.flush();
os.close();
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return data.length;
}
public static int saveClass(String className) {
int size = 0;
try {
Class<?> crk = Class.forName("lllllllllllllll");
/////
//Object obj = crk.newInstance();
Method decrypt = crk.getDeclaredMethod("lllll", String.class);
decrypt.setAccessible(true);
Method decode = crk.getDeclaredMethod("lllIl", byte[].class, byte[].class);
decode.setAccessible(true);
////
Field f2 = crk.getDeclaredField("llI"); ///// int[34]
f2.setAccessible(true);
byte ii2[] = (byte[])f2.get(null);
Object params1[] = new Object[2];
params1[0] = className.getBytes("UTF-8");
params1[1] = ii2;
String s = new String((byte[])decode.invoke(null, params1));
Object params2[] = new Object[1];
params2[0] = s;
byte bytes1[] = (byte[])decrypt.invoke(null, params2);
params1[0] = bytes1;
byte bytes2[] = (byte[])decode.invoke(null, params1);
size = bytes2.length;
System.out.println(className +".class length " + bytes2.length);
String fileName = className.replace('.', File.separatorChar).concat(".class");
String fullPath = basePath + fileName;
int i = fullPath.lastIndexOf(File.separatorChar);
String path = fullPath.substring(0, i);
File f = new File(path);
f.mkdirs(); /// Create directory
FileOutputStream fos = new FileOutputStream(fullPath);
OutputStream os = new BufferedOutputStream(fos);
os.write(bytes2);
System.out.println("save " + className +".class OK");
os.flush();
os.close();
fos.flush();
fos.close();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return size;
}
}