Merge pull request #361 from VakarisZ/pba_bugfix

PBA handles hostname lookup failure
This commit is contained in:
Daniel Goldberg 2019-07-01 16:30:55 +03:00 committed by GitHub
commit aeb07e1db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -45,12 +45,17 @@ class PBA(object):
""" """
exec_funct = self._execute_default exec_funct = self._execute_default
result = exec_funct() result = exec_funct()
try:
hostname = socket.gethostname() hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
except socket.error:
hostname = "Unknown"
ip = "Unknown"
ControlClient.send_telemetry('post_breach', {'command': self.command, ControlClient.send_telemetry('post_breach', {'command': self.command,
'result': result, 'result': result,
'name': self.name, 'name': self.name,
'hostname': hostname, 'hostname': hostname,
'ip': socket.gethostbyname(hostname)}) 'ip': ip})
def _execute_default(self): def _execute_default(self):
""" """

View File

@ -82,7 +82,7 @@ class TelemetryFeed(flask_restful.Resource):
@staticmethod @staticmethod
def get_post_breach_telem_brief(telem): def get_post_breach_telem_brief(telem):
return '%s post breach action executed on %s (%s) machine' % (telem['data']['name'], return '%s post breach action executed on %s (%s) machine.' % (telem['data']['name'],
telem['data']['hostname'], telem['data']['hostname'],
telem['data']['ip']) telem['data']['ip'])