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

<channel>
	<title>Hello System Admin &#124; Where system admins share technical article and tips &#124; Create free Blog &#124; Updates on domains, web hosting, servers and more &#187; Apache on windows</title>
	<atom:link href="http://hellosystemadmin.com/blog/tag/apache-on-windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://hellosystemadmin.com</link>
	<description></description>
	<lastBuildDate>Fri, 09 Jul 2010 04:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server Injection</title>
		<link>http://hellosystemadmin.com/blog/sql-server-injection/</link>
		<comments>http://hellosystemadmin.com/blog/sql-server-injection/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 04:39:50 +0000</pubDate>
		<dc:creator>Aneesh</dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[Apache on windows]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[IPtables]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://hellosystemadmin.com/?p=375</guid>
		<description><![CDATA[SQL Server Injection
This is a small notes about SQL Injection ( Microsoft SQL Server)
How does SQL injection work?
Formatted SQL queries are passed through text boxes (Login pages, search pages etc). These queries are executed by the sql server. Consider an example of a login page which has two text boxes one for Username and another [...]]]></description>
			<content:encoded><![CDATA[<p><strong>SQL Server Injection</strong></p>
<p>This is a small notes about SQL Injection ( Microsoft SQL Server)</p>
<p><strong>How does SQL injection work?</strong></p>
<p>Formatted SQL queries are passed through text boxes (Login pages, search pages etc). These queries are executed by the sql server. Consider an example of a login page which has two text boxes one for Username and another for password</p>
<p><a href="http://hellosystemadmin.com/files/2010/02/Login.gif"><img class="alignnone size-full wp-image-376" title="SQL Server Injection" src="http://hellosystemadmin.com/files/2010/02/Login.gif" alt="SQL Server Injection" width="437" height="159" /></a></p>
<p>Now, if the program is not well created a hacker (or a person who knows SQL commands) can pass any sql query to through these text boxes. And that will be executed by the sql server. SQL server does not know where the query comes. For example , a person can pass a query to drop a table through this text box.</p>
<p><strong>How to find SQL Injection?</strong></p>
<p>If you doubt that there something wrong in the database (may be tables altered, data dropped , even database dropped  without your permission) you should immediately start SQL server Profiler to monitor  the SQl commands.  The sql profiler will show all queries that the sql server executes. Now you can see that there may be alter or drop commands appearing in the profiler. When you find it, check the details of that and you can understand that which user executes these commands.  I assume that sql server does not allow remote connections. If you allow remote connections, any user who knows the username and password can directly do anything on the database</p>
<p><strong>Following is a case of sql injection</strong></p>
<p>Suppose there is table called ‘City ‘and there is a query to select a user from the city. Let  us take a small search page which fill find a user from the table called ‘usrs’.  There will be a text box to enter the name of the person that we need to search. Suppose the name of the person is ‘Aneesh’. Now when the user types ‘Aneesh’ and hit on the ‘Search’ button the SQL query will be executed ask follows</p>
<p><code>SELECT * FROM users  WHERE name = 'Aneesh'</code> ;</p>
<p>Now think, the user enters in the seach box as given below</p>
<p><code><strong>Aneesh; </strong><strong>drop table users--</strong></code></p>
<p>At this time the sql query will be executed as given below</p>
<p><strong><code>SELECT * FROM users   WHERE name = 'Aneesh';drop table OrdersTable--' </code></strong></p>
<p>Now we know what will do if the above query is executed. It will drop the table ‘users’</p>
<p><strong>How can we Prevent SQL injection?</strong></p>
<p>When a web application is developed make sure that you always use proper validations .I hope this will be the best practice. Also, in our case the login text boxes have no size limit. That means any one can enter long sql queries through these text boxes. <strong>So make sure that you set SIZE FOR EACH TEXT BOXES.  I login text boxes can be up to 10 and password can be up to 10.</strong> It depends upon the nature of the web application. In general for a medium company I don’t think that the user id and password do not need more than 10 characters.</p>
<p>Don’t think that this is only enough, but you can do this in your programs. I experienced and I have taken these measures to prevent it. Following are  few cases of sql injection</p>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fhellosystemadmin.com%2Fblog%2Fsql-server-injection%2F', 'SQL+Server+Injection')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fhellosystemadmin.com%2Fblog%2Fsql-server-injection%2F', title: '+SQL+Server+Injection+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://hellosystemadmin.com/blog/sql-server-injection/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
