Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Changelog
## [v0.1.2] - 09/21/2023
## [v0.1.3] - 12/30/2023
### Fixed
- Issue #1
- Issue [#3](https://github.com/Tw1sm/PySQLRecon/issues/3)
- Roles queried from the database now use `IS_MEMBER` call instead `IS_SRVMEMBER` to check membership

## [v0.1.2] - 12/21/2023
### Fixed
- Issue [#1](https://github.com/Tw1sm/PySQLRecon/issues/1)
- When using `clr` module, if custom assembly already exists under a different name `pysqlrecon` would previously log the error and exit
- Now it deletes the offending assembly and tries creation again

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pysqlrecon"
version = "0.1.2"
version = "0.1.3"
description = "Offensive MSSQL Python toolkit"
authors = ["Matt Creel <mcreel31@gmail.com>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion pysqlrecon/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.2'
__version__ = '0.1.3'
31 changes: 22 additions & 9 deletions pysqlrecon/modules/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,32 @@ def main(ctx: typer.Context):
pysqlrecon.query_handler("SELECT USER_NAME();")
logger.info(f"Mapped to the user [cyan]{pysqlrecon.get_last_resp()}[/]", extra=OBJ_EXTRA_FMT)

logger.info("Gathering roles:")
pysqlrecon.query_handler("SELECT [name] FROM sysusers WHERE issqlrole = 1;")
roles = [row['name'] for row in pysqlrecon.ms_sql.rows]
roles.extend(DEFAULT_ROLES)

logger.info("Gathering roles:")
print()
logger.debug(f"Identified {len(roles)} database roles")
logger.debug(f"Roles: {roles}")

print()

# db-specific roles
for role in roles:
pysqlrecon.query_handler(f"SELECT IS_MEMBER('{role}');")
check_role(role, pysqlrecon.get_last_resp())

# check server roles
for role in DEFAULT_ROLES:
pysqlrecon.query_handler(f"SELECT IS_SRVROLEMEMBER('{role}');")
if pysqlrecon.get_last_resp() == 1:
console.print(f"{' |->':>15} User is a member of the [green]{role}[/] role")
else:
console.print(f"{' |->':>15} User is NOT a member of the [red]{role}[/] role")

check_role(role, pysqlrecon.get_last_resp())


print()
pysqlrecon.disconnect()
pysqlrecon.disconnect()


def check_role(role, last_resp):
if last_resp == 1:
console.print(f"{' |->':>15} User is a member of the [green]{role}[/] role")
else:
console.print(f"{' |->':>15} User is NOT a member of the [red]{role}[/] role")