githubEdit

SQL Injection

MySQL Command Reference

General

mysql -u root -h docker.hackthebox.eu -P 3306 -p  -- Login to MySQL database.
SHOW DATABASES;  -- List available databases.
USE users;  -- Switch to a database.

Tables

CREATE TABLE logins (id INT, ...);  -- Add a new table.
SHOW TABLES;  -- List available tables in the current database.
DESCRIBE logins;  -- Show table properties and columns.
INSERT INTO table_name VALUES (value_1,..);  -- Add values to a table.
INSERT INTO table_name(column2, ...) VALUES (column2_value, ..);  -- Add values to specific columns in a table.
UPDATE table_name SET column1=newvalue1, ... WHERE <condition>;  -- Update table values.

Columns

SELECT * FROM table_name;  -- Show all columns in a table.
SELECT column1, column2 FROM table_name;  -- Show specific columns in a table.
DROP TABLE logins;  -- Delete a table.
ALTER TABLE logins ADD newColumn INT;  -- Add new column.
ALTER TABLE logins RENAME COLUMN newColumn TO oldColumn;  -- Rename a column.
ALTER TABLE logins MODIFY oldColumn DATE;  -- Change column datatype.
ALTER TABLE logins DROP oldColumn;  -- Delete a column.

Output

MySQL Operator Precedence

  1. Division (/), Multiplication (*), and Modulus (%)

  2. Addition (+) and Subtraction (-)

  3. Comparison (=, >, <, <=, >=, !=, LIKE)

  4. NOT (!)

  5. AND (&&)

  6. OR (||)

SQL Injection Techniques

Auth Bypass

Auth Bypass Payloads

  • Use variations based on the application's response to refine bypass strategies.

Union Injection

DB Enumeration

Privileges

File Injection

Last updated