This commit is contained in:
VakarisZ 2019-05-28 14:14:35 +03:00
parent f4a47f3cb3
commit c4e384205c
4 changed files with 21 additions and 18 deletions

View File

@ -23,6 +23,8 @@ DOWNLOAD_CHUNK = 1024
# to prevent the monkey from just waiting forever to try and connect to an island before going elsewhere.
TIMEOUT = 15
PBA_FILE_DOWNLOAD = "https://%s/api/pba/download/%s"
class ControlClient(object):
proxies = {}
@ -306,3 +308,13 @@ class ControlClient(object):
target_addr, target_port = None, None
return tunnel.MonkeyTunnel(proxy_class, target_addr=target_addr, target_port=target_port)
@staticmethod
def get_pba_file(filename):
try:
return requests.get(PBA_FILE_DOWNLOAD %
(WormConfiguration.current_server, filename),
verify=False,
proxies=ControlClient.proxies)
except requests.exceptions.RequestException:
return False

View File

@ -41,15 +41,9 @@ class UsersPBA(PBA):
:return: True if successful, false otherwise
"""
try:
pba_file_contents = requests.get("https://%s/api/pba/download/%s" %
(WormConfiguration.current_server, filename),
verify=False,
proxies=ControlClient.proxies)
except requests.exceptions.RequestException:
return False
if not pba_file_contents.content:
pba_file_contents = ControlClient.get_pba_file(filename)
if not pba_file_contents or not pba_file_contents.content:
LOG.error("Island didn't respond with post breach file.")
return False
try:

View File

@ -1,9 +1,8 @@
import logging
import subprocess
import socket
from infection_monkey.control import ControlClient
from infection_monkey.utils import is_windows_os
from infection_monkey.config import WormConfiguration
from infection_monkey.config import WormConfiguration, GUID
LOG = logging.getLogger(__name__)
@ -53,13 +52,11 @@ class PBA(object):
Runs post breach action command
"""
exec_funct = self._execute_default
hostname = socket.gethostname()
result = exec_funct()
ControlClient.send_telemetry('post_breach', {'command': self.command,
'result': exec_funct(),
'result': result,
'name': self.name,
'hostname': hostname,
'ip': socket.gethostbyname(hostname)
})
'guid': GUID})
def _execute_default(self):
"""

View File

@ -2,7 +2,7 @@ import React from 'react';
import ReactTable from 'react-table'
let renderArray = function(val) {
return <span>{val.map(x => <span> {x}</span>)}</span>;
return <span>{val.map(x => <span key={x}> {x}</span>)}</span>;
};
let renderIpAddresses = function (val) {
@ -36,7 +36,7 @@ let renderDetails = function (data) {
columns={subColumns}
defaultPageSize={defaultPageSize}
showPagination={showPagination}
style={{"background-color": "#ededed"}}
style={{"backgroundColor": "#ededed"}}
/>
};