Convert Figma logo to code with AI

NetSPI logoPowerUpSQL

PowerUpSQL: A PowerShell Toolkit for Attacking SQL Server

2,512
464
2,512
23

Top Related Projects

33,108

Automatic SQL injection and database takeover tool

Find, verify, and analyze leaked credentials

A list of useful payloads and bypass for Web Application Security and Pentest/CTF

60,203

SecLists is the security tester's companion. It's a collection of multiple types of lists used during security assessments, collected in one place. List types include usernames, passwords, URLs, sensitive data patterns, fuzzing payloads, web shells, and many more.

Metasploit Framework

PowerSploit - A PowerShell Post-Exploitation Framework

Quick Overview

PowerUpSQL is a PowerShell toolkit for attacking SQL Server. It provides a collection of PowerShell scripts and functions designed to assist penetration testers and security professionals in assessing and exploiting SQL Server instances. The toolkit covers various aspects of SQL Server security, including discovery, auditing, and exploitation.

Pros

  • Comprehensive set of tools for SQL Server security assessment
  • Written in PowerShell, making it easily accessible for Windows environments
  • Regularly updated with new features and bug fixes
  • Well-documented with detailed usage instructions

Cons

  • Primarily focused on Microsoft SQL Server, limiting its use for other database systems
  • Requires PowerShell knowledge for effective use
  • Some functions may trigger antivirus or security software alerts
  • Potential for misuse if not handled responsibly

Code Examples

  1. Discovering SQL Server instances on the network:
Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose
  1. Checking for weak passwords:
Get-SQLInstanceDomain | Get-SQLConnectionTest -Verbose | Where-Object {$_.Status -eq "Accessible"} | Get-SQLServerLoginDefaultPw -Verbose
  1. Executing commands on the SQL Server:
Invoke-SQLOSCmd -Instance "SQLServer1\SQLEXPRESS" -Command "whoami"

Getting Started

To get started with PowerUpSQL:

  1. Clone the repository:

    git clone https://github.com/NetSPI/PowerUpSQL.git
    
  2. Import the PowerUpSQL module in PowerShell:

    Import-Module .\PowerUpSQL.psd1
    
  3. Run a basic discovery command:

    Get-SQLInstanceLocal
    

Remember to use these tools responsibly and only on systems you have permission to test.

Competitor Comparisons

33,108

Automatic SQL injection and database takeover tool

Pros of sqlmap

  • More comprehensive database support, covering a wide range of DBMS systems
  • Extensive feature set for automated SQL injection and database takeover
  • Active development with frequent updates and a large community

Cons of sqlmap

  • Steeper learning curve due to its complexity and numerous options
  • Can be overkill for simple SQL injection tasks or specific Microsoft SQL Server scenarios

Code Comparison

sqlmap:

def getFingerprint(self):
    value = ""
    wsOsFp = Format.getOs("web server", kb.headersFp)
    if wsOsFp:
        value += "%s\n" % wsOsFp
    return value

PowerUpSQL:

function Get-SQLInstanceDomain
{
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $false,
        HelpMessage = 'Domain to search for SQL Servers.')]
        [string]$Domain,
        [Parameter(Mandatory = $false,
        HelpMessage = 'Suppress verbose errors.  Used when function is wrapped.')]
        [switch]$SuppressVerbose
    )

Summary

sqlmap is a more versatile and feature-rich tool for SQL injection across various database systems, while PowerUpSQL focuses specifically on Microsoft SQL Server and offers PowerShell integration. sqlmap may be preferred for complex scenarios and diverse database environments, whereas PowerUpSQL excels in Windows environments and for targeted Microsoft SQL Server testing.

Find, verify, and analyze leaked credentials

Pros of TruffleHog

  • Language-agnostic, supporting multiple programming languages and file types
  • Utilizes regex patterns and entropy for more comprehensive secret detection
  • Actively maintained with frequent updates and community contributions

Cons of TruffleHog

  • May produce more false positives due to its broad detection approach
  • Requires additional setup and configuration for optimal results
  • Less focused on SQL-specific vulnerabilities and attack vectors

Code Comparison

TruffleHog (Python):

def find_strings(blob, custom_regexes={}):
    strings_found = []
    for key in regexes:
        found = re.findall(regexes[key], blob)
        for string in found:
            strings_found.append((key, string))
    return strings_found

PowerUpSQL (PowerShell):

function Get-SQLConnectionObject
{
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server or domain name.')]
        [string]$Instance,
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server login username.')]
        [string]$Username,
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server login password.')]
        [string]$Password
    )
    # Function implementation...
}

A list of useful payloads and bypass for Web Application Security and Pentest/CTF

Pros of PayloadsAllTheThings

  • Covers a wider range of security topics and attack vectors
  • Regularly updated with new payloads and techniques
  • Provides a comprehensive resource for various penetration testing scenarios

Cons of PayloadsAllTheThings

  • Less focused on SQL-specific attacks and techniques
  • May require more time to find relevant SQL payloads among other content
  • Not specifically designed for PowerShell integration

Code Comparison

PowerUpSQL:

Get-SQLInstanceDomain | Get-SQLConnectionTest | Where-Object {$_.Status -eq "Accessible"} | Get-SQLServerInfo

PayloadsAllTheThings (SQL Injection example):

UNION SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL--

PowerUpSQL is specifically designed for SQL Server enumeration and exploitation using PowerShell, while PayloadsAllTheThings provides a broader range of payloads for various security testing scenarios. PowerUpSQL offers more specialized SQL-related functions, whereas PayloadsAllTheThings serves as a general reference for multiple attack vectors, including SQL injection.

60,203

SecLists is the security tester's companion. It's a collection of multiple types of lists used during security assessments, collected in one place. List types include usernames, passwords, URLs, sensitive data patterns, fuzzing payloads, web shells, and many more.

Pros of SecLists

  • Comprehensive collection of multiple types of lists for various security testing scenarios
  • Regularly updated with community contributions
  • Useful for a wide range of security testing activities beyond just SQL-related tasks

Cons of SecLists

  • Not specifically focused on SQL or database security
  • Requires more manual effort to utilize in specific testing scenarios
  • May contain outdated or less relevant entries due to its broad scope

Code Comparison

While a direct code comparison isn't applicable due to the nature of these repositories, here's a brief example of how they might be used:

SecLists:

# Using SecLists for password cracking
john --wordlist=/path/to/SecLists/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt target_hashes.txt

PowerUpSQL:

# Using PowerUpSQL for SQL Server discovery
Import-Module PowerUpSQL
Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose

PowerUpSQL is specifically designed for SQL Server security assessment and exploitation, while SecLists provides general-purpose wordlists and patterns for various security testing scenarios.

Metasploit Framework

Pros of Metasploit-Framework

  • Broader scope: Covers a wide range of security testing and exploitation techniques
  • Larger community: More contributors and extensive documentation
  • Multi-platform support: Works on various operating systems

Cons of Metasploit-Framework

  • Steeper learning curve: More complex to use for beginners
  • Resource-intensive: Requires more system resources to run effectively
  • Less focused on SQL-specific tasks: Not specialized for SQL server attacks

Code Comparison

PowerUpSQL (PowerShell):

Get-SQLInstanceDomain | Get-SQLConnectionTest | Where-Object {$_.Status -eq "Accessible"} | Get-SQLServerInfo

Metasploit-Framework (Ruby):

use auxiliary/scanner/mssql/mssql_ping
set RHOSTS 192.168.1.0/24
run

PowerUpSQL focuses on SQL-specific tasks with PowerShell, while Metasploit-Framework offers a broader range of security testing capabilities using Ruby. PowerUpSQL's code is more concise for SQL-related operations, whereas Metasploit-Framework requires additional setup but provides more versatility for various security testing scenarios.

PowerSploit - A PowerShell Post-Exploitation Framework

Pros of PowerSploit

  • Broader scope: Covers a wide range of post-exploitation tasks beyond SQL Server
  • More mature project: Longer development history and larger community
  • Extensive documentation and usage examples

Cons of PowerSploit

  • Less focused on SQL Server specific tasks
  • Not actively maintained (last commit in 2018)
  • Larger codebase may be overwhelming for specific SQL Server tasks

Code Comparison

PowerSploit (Get-SQLServerLoginDefaultPw):

function Get-SQLServerLoginDefaultPw
{
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server or domain account to authenticate with.')]
        [string]$Username,
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server or domain account password to authenticate with.')]
        [string]$Password,
        [Parameter(Mandatory = $false,
        HelpMessage = 'Windows credentials.')]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
    )

PowerUpSQL (Get-SQLServerLoginDefaultPw):

function Get-SQLServerLoginDefaultPw
{
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $false,
        ValueFromPipelineByPropertyName = $true,
        HelpMessage = 'SQL Server instance to connection to.')]
        [string]$Instance,
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server or domain account to authenticate with.')]
        [string]$Username,
        [Parameter(Mandatory = $false,
        HelpMessage = 'SQL Server or domain account password to authenticate with.')]
        [string]$Password,
        [Parameter(Mandatory = $false,
        HelpMessage = 'Windows credentials.')]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty,
        [Parameter(Mandatory = $false,
        HelpMessage = 'Connection timeout.')]
        [string]$TimeOut = 1
    )

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

  licence badge wiki Badge stars badge forks badge issues badge

PowerUpSQLLogo

PowerUpSQL includes functions that support SQL Server discovery, weak configuration auditing, privilege escalation on scale, and post exploitation actions such as OS command execution. It is intended to be used during internal penetration tests and red team engagements. However, PowerUpSQL also includes many functions that can be used by administrators to quickly inventory the SQL Servers in their ADS domain and perform common threat hunting tasks related to SQL Server.

PowerUpSQL Wiki

For setup instructions, cheat Sheets, blogs, function overviews, and usage information check out the wiki: https://github.com/NetSPI/PowerUpSQL/wiki

Author and Contributors

  • Author: Scott Sutherland (@_nullbind) Twitter Follow
  • Major Contributors: Antti Rantasaari, Eric Gruber (@egru), Thomas Elling (@thomaselling)
  • Contributors: Alexander Leary (@0xbadjuju), @leoloobeek, Andrew Luke(@Sw4mpf0x), Mike Manzotti (@mmanzo_), @TVqQAAMA, @cobbr_io, @mariuszbit (mgeeky), @0xe7 (@exploitph), phackt(@phackt_ul), @vsamiamv, and @ktaranov

Issue Reports

I perform QA on functions before we publish them, but it's hard to consider every scenario. So I just wanted to say thanks to those of you that have taken the time to give me a heads up on issues with PowerUpSQL so that we can make it better.

  • Bug Reporters: @ClementNotin, @runvirus, @CaledoniaProject, @christruncer, rvrsh3ll(@424f424f),@mubix (Rob Fuller)

License

  • BSD 3-Clause