Skip to content

Commit 932153b

Browse files
committed
init
0 parents  commit 932153b

47 files changed

Lines changed: 3570 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.pyc
2+
.pytest_cache/
3+
dist/
4+
.ruff_cache/
5+
resources/dotnet/*.dll

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
repos:
2+
- repo: https://github.com/charliermarsh/ruff-pre-commit
3+
hooks:
4+
- id: ruff

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
## [v0.1.0] - XX/XX/XXXX
3+
- Initial commit

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<h1 align="center">
2+
<img height=250 src=resources/images/snake_logo.png />
3+
<br>
4+
PySQLRecon
5+
<br>
6+
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
7+
![PyPi](https://img.shields.io/pypi/v/pysqlrecon?style=for-the-badge)
8+
</h1>
9+
10+
PySQLRecon is a Python port of the awesome [SQLRecon](https://github.com/skahwah/SQLRecon) project by [@sanjivkawa](https://twitter.com/sanjivkawa). See the [commands](#commands) section for a list of capabilities.
11+
12+
## Install
13+
PySQLRecon can be installed with `pip3 install pysqlrecon` or by cloning this repository and running `pip3 install .`
14+
15+
## Commands
16+
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.
17+
18+
Support for impersonation (`[I]`) or execution on linked servers (`[L]`) are denoted at the end of the command description.
19+
20+
```
21+
adsi [PRIV] Obtain ADSI creds from ADSI linked server [I,L]
22+
agentcmd [PRIV] Execute a system command using agent jobs [I,L]
23+
agentstatus [PRIV] Enumerate SQL agent status and jobs [I,L]
24+
checkrpc [NORM] Enumerate RPC status of linked servers [I,L]
25+
clr [PRIV] Load and execute .NET assembly in a stored procedure [I,L]
26+
columns [NORM] Enumerate columns within a table [I,L]
27+
databases [NORM] Enumerate databases on a server [I,L]
28+
disableclr [PRIV] Disable CLR integration [I,L]
29+
disableole [PRIV] Disable OLE automation procedures [I,L]
30+
disablerpc [PRIV] Disable RPC and RPC Out on linked server [I]
31+
disablexp [PRIV] Disable xp_cmdshell [I,L]
32+
enableclr [PRIV] Enable CLR integration [I,L]
33+
enableole [PRIV] Enable OLE automation procedures [I,L]
34+
enablerpc [PRIV] Enable RPC and RPC Out on linked server [I]
35+
enablexp [PRIV] Enable xp_cmdshell [I,L]
36+
impersonate [NORM] Enumerate users that can be impersonated
37+
info [NORM] Gather information about the SQL server
38+
links [NORM] Enumerate linked servers [I,L]
39+
olecmd [PRIV] Execute a system command using OLE automation procedures [I,L]
40+
query [NORM] Execute a custom SQL query [I,L]
41+
rows [NORM] Get the count of rows in a table [I,L]
42+
search [NORM] Search a table for a column name [I,L]
43+
smb [NORM] Coerce NetNTLM auth via xp_dirtree [I,L]
44+
tables [NORM] Enumerate tables within a database [I,L]
45+
users [NORM] Enumerate users with database access [I,L]
46+
whoami [NORM] Gather logged in user, mapped user and roles [I,L]
47+
xpcmd [PRIV] Execute a system command using xp_cmdshell [I,L]
48+
```
49+
50+
## Usage
51+
PySQLRecon has global options (available to any command), with some commands introducing additional flags. All global options must be specified *before* the command name:
52+
```
53+
pysqlrecon [GLOBAL_OPTS] COMMAND [COMMAND_OPTS]
54+
```
55+
56+
View global options:
57+
```
58+
pysqlreocn --help
59+
```
60+
61+
View command specific options:
62+
```
63+
pysqlrecon [GLOBAL_OPTS] COMMAND --help
64+
```
65+
66+
Change the database authenticated to, or used in certain PySQLRecon commands (`query`, `tables`, `columns` `rows`), with the `--database` flag.
67+
68+
Target execution of a PySQLRecon command on a linked server (instead of the SQL server being authenticated to) using the `--link` flag.
69+
70+
Impersonate a user account while running a PySQLRecon command with the `--impersonate` flag.
71+
72+
`--link` and `--impersonate` and not compatible when used together,
73+
74+
75+
## Development
76+
pysqlrecon uses Poetry to manage dependencies. Install from source and setup for development with:
77+
```
78+
git clone https://github.com/tw1sm/pysqlrecon
79+
cd pysqlrecon
80+
poetry install
81+
poetry run pysqlrecon --help
82+
```
83+
84+
### Adding a Command
85+
PySQLRecon is easily extensible - see the template and instructions in [resources](resources/command_template/)
86+
87+
## References and Credits
88+
- [Impacket](https://github.com/fortra/impacket)
89+
- [@sanjivkawa](https://twitter.com/sanjivkawa) for the [SQLRecon](https://github.com/skahwah/SQLRecon) project
90+
- [https://securityintelligence.com/x-force/databases-beware-abusing-microsoft-sql-server-with-sqlrecon/](https://securityintelligence.com/x-force/databases-beware-abusing-microsoft-sql-server-with-sqlrecon/)
91+
- [https://gist.github.com/skahwah/a585e176e4a5cf319b0c759637f5c410](https://gist.github.com/skahwah/a585e176e4a5cf319b0c759637f5c410)
92+
- Also checkout [MSSqlPwner](https://github.com/ScorpionesLabs/MSSqlPwner) for other offensive MSSQL capabilities written in Python

0 commit comments

Comments
 (0)