PySQLRecon: Offensive MSSQL toolkit written in Python

PySQLRecon

PySQLRecon is a Python port of the awesome SQLRecon project by @sanjivkawa. See the commands section for a list of capabilities.

Commands

All of the main modules from SQLRecon have equivalent commands. Commands noted with [PRIV] require elevated privileges or sysadmin rights to run. Alternatively, commands marked with [NORM] can likely be run by normal users and do not require elevated privileges.

Support for impersonation ([I]) or execution on linked servers ([L]) are denoted at the end of the command description.

[pastacode lang=”markup” message=”” highlight=”” provider=”manual” manual=”adsi%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Obtain%20ADSI%20creds%20from%20ADSI%20linked%20server%20%5BI%2CL%5D%0Aagentcmd%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Execute%20a%20system%20command%20using%20agent%20jobs%20%5BI%2CL%5D%0Aagentstatus%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Enumerate%20SQL%20agent%20status%20and%20jobs%20%5BI%2CL%5D%0Acheckrpc%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20RPC%20status%20of%20linked%20servers%20%5BI%2CL%5D%0Aclr%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Load%20and%20execute%20.NET%20assembly%20in%20a%20stored%20procedure%20%5BI%2CL%5D%0Acolumns%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20columns%20within%20a%20table%20%5BI%2CL%5D%0Adatabases%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20databases%20on%20a%20server%20%5BI%2CL%5D%0Adisableclr%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Disable%20CLR%20integration%20%5BI%2CL%5D%0Adisableole%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Disable%20OLE%20automation%20procedures%20%5BI%2CL%5D%0Adisablerpc%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Disable%20RPC%20and%20RPC%20Out%20on%20linked%20server%20%5BI%5D%0Adisablexp%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Disable%20xp_cmdshell%20%5BI%2CL%5D%0Aenableclr%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Enable%20CLR%20integration%20%5BI%2CL%5D%0Aenableole%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Enable%20OLE%20automation%20procedures%20%5BI%2CL%5D%0Aenablerpc%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Enable%20RPC%20and%20RPC%20Out%20on%20linked%20server%20%5BI%5D%0Aenablexp%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Enable%20xp_cmdshell%20%5BI%2CL%5D%0Aimpersonate%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20users%20that%20can%20be%20impersonated%0Ainfo%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Gather%20information%20about%20the%20SQL%20server%0Alinks%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20linked%20servers%20%5BI%2CL%5D%0Aolecmd%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Execute%20a%20system%20command%20using%20OLE%20automation%20procedures%20%5BI%2CL%5D%0Aquery%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Execute%20a%20custom%20SQL%20query%20%5BI%2CL%5D%0Arows%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Get%20the%20count%20of%20rows%20in%20a%20table%20%5BI%2CL%5D%0Asearch%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Search%20a%20table%20for%20a%20column%20name%20%5BI%2CL%5D%0Asmb%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Coerce%20NetNTLM%20auth%20via%20xp_dirtree%20%5BI%2CL%5D%0Atables%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20tables%20within%20a%20database%20%5BI%2CL%5D%0Ausers%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Enumerate%20users%20with%20database%20access%20%5BI%2CL%5D%0Awhoami%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BNORM%5D%20Gather%20logged%20in%20user%2C%20mapped%20user%20and%20roles%20%5BI%2CL%5D%0Axpcmd%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BPRIV%5D%20Execute%20a%20system%20command%20using%20xp_cmdshell%20%5BI%2CL%5D%20%20%20%20%20″/]

Install

git clone https://github.com/tw1sm/pysqlrecon
cd pysqlrecon
poetry install
poetry run pysqlrecon –help

Use

PySQLRecon has global options (available to any command), with some commands introducing additional flags. All global options must be specified before the command name:

pysqlrecon [GLOBAL_OPTS] COMMAND [COMMAND_OPTS]

View global options:

pysqlrecon –help

View command-specific options:

pysqlrecon [GLOBAL_OPTS] COMMAND –help

Change the database authenticated to, or used in certain PySQLRecon commands (query, tables, columns rows), with the –database flag.

Target execution of a PySQLRecon command on a linked server (instead of the SQL server being authenticated to) using the –link flag.

Impersonate a user account while running a PySQLRecon command with the –impersonate flag.

–link and –impersonate and incompatible.

Source: https://github.com/Tw1sm/

Support Our Threat Intelligence

If you find our technology report and cybersecurity news helpful, consider supporting our work.

Crypto QR Code
USDT (TRC20):
TN8BdV8cp4T1Cd28gK9qTAnZknzzuwyUtm
USDT (ERC20):
0x3725e1a7d3bc5765499fa6aaafe307fabcd75bce

Leave a Reply