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
result = exec_funct()
hostname = socket.gethostname()
try:
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
except socket.error:
hostname = "Unknown"
ip = "Unknown"
ControlClient.send_telemetry('post_breach', {'command': self.command,
'result': result,
'name': self.name,
'hostname': hostname,
'ip': socket.gethostbyname(hostname)})
'ip': ip})
def _execute_default(self):
"""

View File

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