Fix errors

main
godylockz 2023-08-11 18:05:50 -04:00
parent 12e259970d
commit f5187f6761
1 changed files with 23 additions and 6 deletions

View File

@ -301,12 +301,29 @@ class mssql(connection):
return False
def mssql_query(self):
result = self.conn.sql_query(self.args.mssql_query)
self.logger.debug(f"SQL Query Result: {result}")
for line in StringIO(self.conn._MSSQL__rowsPrinter.getMessage()).readlines():
if line.strip() != "":
self.logger.highlight(line.strip())
return self.conn._MSSQL__rowsPrinter.getMessage()
if self.conn.lastError:
# Invalid connection
return None
query = self.args.mssql_query
self.logger.info(f"Query to run:\n{query}")
try:
raw_output = self.conn.sql_query(query)
self.logger.info("Executed MSSQL query")
self.logger.debug(f"Raw output: {raw_output}")
for data in raw_output:
if isinstance(data, dict):
for key, value in data.items():
if key:
self.logger.highlight(f"{key}:{value}")
else:
self.logger.highlight(f"{value}")
else:
self.logger.fail("Unexpected output")
except Exception as e:
self.logger.exception(e)
return None
return raw_output
@requires_admin
def execute(self, payload=None, print_output=False):