forked from p15670423/monkey
Agent: Make Hadoop interruptable
This commit is contained in:
parent
ed817feaf2
commit
8921ed77ac
|
@ -65,6 +65,10 @@ class HadoopExploiter(WebRCE):
|
|||
return self.exploit_result
|
||||
|
||||
def exploit(self, url, command):
|
||||
if self._is_interrupted():
|
||||
self._set_interrupted()
|
||||
return False
|
||||
|
||||
# Get the newly created application id
|
||||
resp = requests.post(
|
||||
posixpath.join(url, "ws/v1/cluster/apps/new-application"), timeout=LONG_REQUEST_TIMEOUT
|
||||
|
@ -78,6 +82,11 @@ class HadoopExploiter(WebRCE):
|
|||
[random.choice(string.ascii_lowercase) for _ in range(self.RAN_STR_LEN)] # noqa: DUO102
|
||||
)
|
||||
payload = self._build_payload(app_id, rand_name, command)
|
||||
|
||||
if self._is_interrupted():
|
||||
self._set_interrupted()
|
||||
return False
|
||||
|
||||
resp = requests.post(
|
||||
posixpath.join(url, "ws/v1/cluster/apps/"), json=payload, timeout=LONG_REQUEST_TIMEOUT
|
||||
)
|
||||
|
|
|
@ -23,6 +23,7 @@ from infection_monkey.network.tools import tcp_port_to_service
|
|||
from infection_monkey.telemetry.attack.t1197_telem import T1197Telem
|
||||
from infection_monkey.telemetry.attack.t1222_telem import T1222Telem
|
||||
from infection_monkey.utils.commands import build_monkey_commandline
|
||||
from infection_monkey.utils.threading import interruptable_iter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
# Command used to check if monkeys already exists
|
||||
|
@ -232,7 +233,7 @@ class WebRCE(HostExploiter):
|
|||
is found (bool)
|
||||
:return: None (we append to class variable vulnerable_urls)
|
||||
"""
|
||||
for url in urls:
|
||||
for url in interruptable_iter(urls, self.interrupt):
|
||||
if self.check_if_exploitable(url):
|
||||
self.add_vuln_url(url)
|
||||
self.vulnerable_urls.append(url)
|
||||
|
|
Loading…
Reference in New Issue