Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cme/protocols/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
})

Expand Down Expand Up @@ -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
Expand Down