darkoperator/Posh-SecMod — pull request #10 by nullbind (2014-08-27 04:22:00+00:00)
Title: Added Get-SqlServerSpSource Function

The Get-SqlServerSpSource function can be used to export custom stored procedures from all accessible databases on a local or remote SQL Server to .sql files in a provided output directory. It also supports searching for keywords in the code of the procedures that are commonly associated with vulnerabilities like hard coded passwords, hard coded crypto keys, executing with elevated privileges, and SQL injection. This function can accept SQL Credentials or use the current user's trusted connection.

.EXAMPLE
Exporting custom stored procedures from a remote SQL Server using a trusted connection.
The command below also checks the exported stored procedures FOR interesting keywords that
may indicate things like hard coded passwords, elevated execution, and SQL injection.

PS C:\> Get-SqlServerSpSource -SqlServerInstance SQLSERVER1\SQLEXPRESS -RunChecks -OutDir .\myfolder

[*] Attempting to Connect to SQLSERVER1\SQLEXPRESS as DOMAIN\User1...
[*] Connected.
[*] Enumerating accessible databases...
[*] 4 accessible databases found.
[*] Searching for custom stored procedures...
[*] - Found 20 in ApplicationDB1
[*] - Found 300 in ApplicationDB2
[*] - Found 1202 in ApplicationDB3
[*] - Found 0 in ApplicationDB4
[*] 1522 custom stored procedures found across 3 databases.
[*] Exporting source code to .\myfolder\sp_source_output...
[*] - Exporting from ApplicationDB1
[*] - Exporting from ApplicationDB2
[*] - Exporting from ApplicationDB3
[*] Searching for interesting keywords...
[*] NOTE: THIS CAN TAKE A WHILE IF THERE ARE THOUSANDS OF PROCEDURE
[*] All done, results can be found in .\myfolder\sp_source_output\

Not sure if this is a fit so no worries either way.