diff --git a/cme/protocols/mssql.py b/cme/protocols/mssql.py index ace89ea38..c346dbb86 100755 --- a/cme/protocols/mssql.py +++ b/cme/protocols/mssql.py @@ -26,6 +26,12 @@ def __init__(self, args, db, host): self.os_arch = None self.nthash = '' + if ":" in host: + self.specific_port = host.split(":")[1] + host = host.split(":")[0] + else: + self.specific_port = None + connection.__init__(self, args, db, host) @staticmethod @@ -69,10 +75,11 @@ def proto_flow(self): self.call_cmd_args() def proto_logger(self): + port = self.specific_port if self.specific_port else self.args.port self.logger = CMEAdapter(extra={ 'protocol': 'MSSQL', 'host': self.host, - 'port': self.args.port, + 'port': port, 'hostname': 'None' }) @@ -135,7 +142,8 @@ def print_host_info(self): def create_conn_obj(self): try: - self.conn = tds.MSSQL(self.host, self.args.port, rowsPrinter=self.logger) + port = self.specific_port if self.specific_port else self.args.port + self.conn = tds.MSSQL(self.host, port, rowsPrinter=self.logger) self.conn.connect() except socket.error: return False