Ctfhub_SQL注入
0x01 SQL注入的基础
1.注入类型
- UNION query SQL injection 联合注入
- Error-based SQL injiecttion 报错注入
- Boolean-based blind SQL injection 布尔盲注
- Time-based blind SQL injection 时间盲注
- Stack queries SQL injection 堆叠注入
2.注入点类型
- GET 数据
- POST 数据
- HTTP 请求报文
- Cookie 数据
3.常用函数和参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| version() database() user() current_user() system_user() @@datadir #数据库路径 @@version_compile_os #操作系统版本 length() substring() substr() mid(String,start_local_1,) left() concat() #没有分隔符 concat_ws() #有分隔符 group_concat() #连接一个组的字符串 ord() #返回ASCII码 ascii() #和ord相同 hex() #取16进制 unhex() #反 md5() #取md5 floor() #向下取整 round() #取4,5的整数 rand() #返回0-1之间的数字 load_file() #读取文件,返回字符串 sleep() #延迟 if(true,t,f) #if判断 如果成立执行t,不成立执行f find_in_set() #返回字符串在字符串列表中的位置 benchmark() #指定语句执行的次数 name_const() #返回表结果
|
4.思路
前提是存在SQL注入
- 回显 --> 联合查询
- 报错 --> 报错注入
- 布尔类型状态–> 布尔注入and 延时注入
- 其他 --> Cookie注入
1 2 3 4
| #报错注入 select count (*) from information _schema.tables group by concat ((此处加入执行语句),0x7e,floor (rand (0)*2)); select extractvalue (1,concat (0x7e,(此处加入执行语句),0x7e)); select updatexml (1,concat (0x7e,(此处加入执行语句),0x7e),1);
|