<?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>Talkwards &#187; Internet</title>
	<atom:link href="http://www.talkwards.com/category/computers-and-internet/internet/feed" rel="self" type="application/rss+xml" />
	<link>http://www.talkwards.com</link>
	<description>Advancing Talkwards...</description>
	<lastBuildDate>Sat, 03 Sep 2011 16:33:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>SQL Injections, the two most common types</title>
		<link>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types</link>
		<comments>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types#comments</comments>
		<pubDate>Fri, 14 Nov 2008 22:00:03 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Architecture]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL-injections]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=434</guid>
		<description><![CDATA[What is an SQL-injection. How can it affect my site. How does it happen and how can I avoid it? Since Firefox (2 and 3) and MSIE 7 started using Google&#8217;s (and others) system for blocking sites that produce harmful web pages the problem with SQL-injections have been put on the spot. What happens is [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_471" class="wp-caption alignright" style="width: 310px"><a href="http://www.talkwards.com/wp-content/uploads/2008/11/reported-attack-site.png"><img class="size-medium wp-image-471" title="Reported Attack Site" src="http://www.talkwards.com/wp-content/uploads/2008/11/reported-attack-site-300x203.png" alt="Opening a site Google has listed as spreading malicious software via the browser." width="300" height="203" /></a><p class="wp-caption-text">Opening a site Google has listed as spreading malicious software via the browser.</p></div>
<p>What is an SQL-injection.  How can it affect my site.  How does it happen and how can I avoid it?</p>
<p>Since Firefox (2 and 3) and MSIE 7 started using Google&#8217;s (and others) system for blocking sites that produce harmful web pages the problem with SQL-injections have been put on the spot.</p>
<p>What happens is that an attacker hacks a site by placing their own SQL-code into the database of the victim system.  Instead of just performing a DOS (<a href="http://en.wikipedia.org/wiki/Denial_of_service" target="_blank">denial of service</a>) attack bringing the whole site down by for instance deleting all the tables or doing something else harmful to the site the attacker plants client side browser code in the database making all visitors run client side code that will infect their computer with a virus.  This virus may do everything from listening in on traffic between the client (web browser) and bank applications, to connecting the client system to a <a href="http://en.wikipedia.org/wiki/Bot_net" target="_blank">botnet</a>.</p>
<p>Needless to say, the SQL-injection attack has become a problem not so much for the owner of the originally defunct site as for the visitors to said site.  (Although users of the web should not underestimate the consequence of a good virus protection, system update policy and secure browsing policy).</p>
<p>Since the owner of the vulnerable software won&#8217;t notice any detour from business as usual (and neither will most infected clients), nobody is the wiser to the problem.</p>
<p>This is why Google (and others) have started evaluating (and flagging) sites with bad content, and why Firefox and MSIE (and probably others) have started blocking them.</p>
<p><span id="more-434"></span></p>
<h4>What is an SQL-injection?</h4>
<p>The short explanation (hinted above) is that an <a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank">SQL-injection</a> is an attack where the attacker inserts their own SQL code into the attacked system, and thus alters the database content of the attacked system.  Either wrecks havoc by destroying part of or the whole system, or by inserting virus spreading code onto the pages of the attacked site (if their content is stored in the database).</p>
<h4>How is an SQL-injection attack performed?</h4>
<p>There are two major ways of doing this (and in order to follow this part of the conversation you will need to know a bit of SQL).</p>
<p>The first method of performing an SQL-injection is by manipulating the input to different kinds of forms on the site (search forms, contact forms, and other places where the user can put information into the system).</p>
<p>To understand this attack you need a basic understanding of SQL.</p>
<p>Imagine we have a database table with products, each having a color, and we want to list all products that are &#8216;green&#8217;.  This would be done with the following question:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = 'green';</pre>
</blockquote>
<p>Each database command is ended with a semicolon (;), and all literal strings are enclosed by single quotes (&#8216;).  So issuing two commands in a row would look something like:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = 'green';
UPDATE products SET hasBeenSearchedFor = 'true' WHERE color = 'green';</pre>
</blockquote>
<p>Notice the semicolons and the single quotes.  You do not need to understand what the commands do in order to understand the rest.</p>
<p>Now imagine that we get the value &#8216;green&#8217; from an application the user can input data into.  As long as the user types things like green, red, blue everything is safe, but what would happen if the user typed in the following as a color?</p>
<blockquote>
<pre>'; do harmful thing to database; '</pre>
</blockquote>
<p>In an unprotected system the SQL-string is usually tacked together one part after the other without checking if the search parameter is valid or sane.  Imagine the search command is built in the following way (double quotes are used in most systems to create strings, they are not to be confused with the single quotes of the database query):</p>
<blockquote>
<pre>sql = "SELECT * FROM products WHERE color = '" + colorValue + "'";</pre>
</blockquote>
<p>Now if a user would put the above value into the color search (placing it in &#8220;colorValue&#8221;) the value of the sql string (and what would be passed on to the database would be):</p>
<blockquote>
<pre>"SELECT * FROM products WHERE color = '" +
          "'; do harmful thing to database; '" + "'"</pre>
</blockquote>
<p>This in turn would evaluate to:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = ''; do harmful thing to database; ''</pre>
</blockquote>
<p>I.e. select all products with an empty color value, then &#8220;do harmful thing to database&#8221;.  After that the SQL-server will encounter the empty quotes and issue an error.</p>
<p>If the database question is executed in a transaction all changes will be rolled back, however this is a rather weak defense against SQL-injections since it is possible to input values that will create three valid commands easily.  (I&#8217;ll leave that up to the fantasy of the reader!)</p>
<p>The second way of performing an SQL-injection attack is to tack on values to numerical input to the system.  Pages that display products, user profiles, or any other information easily mapped to a row in a database table are usually candidates for this kind of attack.</p>
<p>Imagine a page that displays a product profile.  It might be called with the following URL:</p>
<blockquote>
<pre>http://www.mysite.com/showProduct?productid=123</pre>
</blockquote>
<p>The &#8220;productid&#8221; value will then be passed on to make the following database question:</p>
<blockquote>
<pre>sql = "SELECT * FROM products WHERE id = " + productid;</pre>
</blockquote>
<p>Here the attacker does not even have to add a single quote to get an extra SQL-command.  All they need to do is add a trailing &#8220;;&#8221; and they&#8217;re in.  The only complicating factor is that the URL used to call the system will have to be URL-encoded in order for this attack to work, but that&#8217;s far from a problem even for an unskilled attacker.</p>
<h4>How do you protect against SQL-injections?</h4>
<p>The key concept is: never, NEVER, <strong>NEVER</strong>, trust input from a user!</p>
<p>That&#8217;s right.  NEVER TRUST THE USER.</p>
<p>Don&#8217;t ask what-if a user tries to gain access to our system.</p>
<p>Say WHEN the user tries to gain access to our system, then we&#8217;re gonna&#8230;.</p>
<p>The short, technical answer (for Java, .NET and similar languages) is to NEVER build SQL-strings like shown above.  Use &#8220;prepared statements&#8221; or similar constructs where the input variables can be tested by JDBC (or ADODB or LINQ or similar framworks).</p>
<p>Another safe way to go is to use stored procedures.  These are not just optimized for speed and performance, they are also, almost always strongly typed, disallowing the kind of problems displayed above.</p>
<p>If neither of these are feasible always make sure the input&#8217;s single quotes are filtered away or &#8220;escaped&#8221;.  Escaping a single quote means that all databases have support for using single quotes as values in a table column, if you prepend them with a backslash (\) or use double single quotes (&#8221;, that&#8217;s two single quotes).  Do this programatically before sending the data on to the database.</p>
<p>Protecting against attacks on pages with numerical input is even simpler.  If there&#8217;s a number input value, make sure it is numerical by translating it into a number before passing it on to the database (input from web applications are almost always sent as strings, but if a value should be a number, make sure it is!)</p>
<p>Part from this a sound backup and restore policy is a sure way to not only protect hours of time invested in putting information into the system but the users trust in the system, and the time it will take to get a blocked site back up on its feet.</p>
<p>Read more about SQL-injections here: <a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank">http://en.wikipedia.org/wiki/SQL_injection</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fsql-injections-the-two-most-common-types&amp;title=SQL%20Injections%2C%20the%20two%20most%20common%20types" id="wpa2a_2"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTP with Wget</title>
		<link>http://www.talkwards.com/2008/10/ftp-with-wget</link>
		<comments>http://www.talkwards.com/2008/10/ftp-with-wget#comments</comments>
		<pubDate>Mon, 13 Oct 2008 09:07:18 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Applications and Programs]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.hoakz.com/blog/?p=258</guid>
		<description><![CDATA[I&#8217;ve just had the total pain of trying to get files (a lot of files, in a lot of directories) via a musty old FTP client (in Linux/Ubuntu). The problem is that the FTP client (ftp) doesn&#8217;t offer much to help (like recursive downloads, or mapping up the directories on the client side with those [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just had the total pain of trying to get files (a lot of files, in a lot of directories) via a musty old FTP client (in Linux/Ubuntu).</p>
<p>The problem is that the FTP client (ftp) doesn&#8217;t offer much to help (like recursive downloads, or mapping up the directories on the client side with those on the serverside, etc).</p>
<p>I searched and I found this thread:</p>
<p><a href="http://ubuntuforums.org/archive/index.php/t-378221.html" target="_blank">http://ubuntuforums.org/archive/index.php/t-378221.html</a></p>
<p>&#8230;with this excellent snippet (posted by Mr. C.):</p>
<blockquote><p>wget -r &#8211;ftp-user YourUSERNAME &#8211;ftp-password YourPASS ftp://FTPSITE//dir/&#8217;*.html&#8217;</p></blockquote>
<p>If you want to download something other than *.html, you can change the file name pattern as you would expect.</p>
<p>If you want to add more directories, simply add them, but keep track of the number of slashes (&#8220;/&#8221;).  There should be only one after the new directory names (at least that&#8217;s how I made it work.  It may work wonderfully regardless of the number of slashes, but then again, why challenge fate?)</p>
<p>Happy FTPing!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F10%2Fftp-with-wget&amp;title=FTP%20with%20Wget" id="wpa2a_4"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/10/ftp-with-wget/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoogleBot may crash .NET 2.0 sites</title>
		<link>http://www.talkwards.com/2007/08/googlebot-may-crash-net-20-sites</link>
		<comments>http://www.talkwards.com/2007/08/googlebot-may-crash-net-20-sites#comments</comments>
		<pubDate>Fri, 17 Aug 2007 02:12:29 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.hoakz.com/blog/?p=27</guid>
		<description><![CDATA[ASP.NET 2.0 apparently has a vulnerability when doing URL rewriting, making it possible for Googlebot (and possibly other search engine bots as well?) to crash a .NET 2.0 site. Read more on todotnet.com]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2.0 apparently has a vulnerability when doing URL rewriting, making it possible for Googlebot (and possibly other search engine bots as well?) to crash a .NET 2.0 site.</p>
<p><a href="http://todotnet.com/archive/0001/01/01/7472.aspx" target="_blank">Read more on todotnet.com</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2007%2F08%2Fgooglebot-may-crash-net-20-sites&amp;title=GoogleBot%20may%20crash%20.NET%202.0%20sites" id="wpa2a_6"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2007/08/googlebot-may-crash-net-20-sites/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using UUIDs to Prevent Broken Links</title>
		<link>http://www.talkwards.com/2007/04/using-uuids-to-prevent-broken-links</link>
		<comments>http://www.talkwards.com/2007/04/using-uuids-to-prevent-broken-links#comments</comments>
		<pubDate>Tue, 03 Apr 2007 02:19:29 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[internet search]]></category>
		<category><![CDATA[UUID]]></category>

		<guid isPermaLink="false">http://www.hoakz.com/blog/?p=32</guid>
		<description><![CDATA[I don&#8217;t know if someone has proposed this before, but how about using UUIDs to prevent broken links? A UUID, Universally Unique Identifier, is a hexadecimal number divided into five sections. A UUID has the special quality that it is universally unique. This means two people on each side of the world could create a [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know if someone has proposed this before, but how about using <a href="http://www.wikipedia.com/wiki/UUID">UUIDs</a> to prevent broken links?</p>
<p>A UUID, Universally Unique Identifier, is a hexadecimal number divided into five sections. A UUID has the special quality that it is universally unique. This means two people on each side of the world could create a UUID each at the exact same time, and still be sure their UUIDs are not identical. In fact they can create a large number of UUIDs and still be sure they are not identical. (The same goes for two people on the same server.)</p>
<p>This quality makes UUIDs a perfect tool for assigning unique IDs to web pages or other Internet resources (in fact any resource of any kind, your dog, the cuttlery in your drawers, you name it.)</p>
<p>This could be done like this:</p>
<p><span style="font-size: medium;">Step 1: Place the UUID on the page</span></p>
<p>First a UUID has to be put on the webpage, perhaps with a meta-tag, or with plain text on the page.</p>
<p>With a meta tag it could be done like:</p>
<blockquote><p>&lt;meta name=&#8221;UUID&#8221; content=&#8221;8523813a-7c47-4cd9-ad78-09c14dfb505f&#8221;/&gt;</p></blockquote>
<p>Or on the page, like:</p>
<blockquote><p>UUID: 8523813a-7c47-4cd9-ad78-09c14dfb505f</p></blockquote>
<p><span style="font-size: medium;">Step 2: Find the UUID</span></p>
<p>The second step would be to make sure every time a program stores a URL to the page it also stores the UUID. (When creating bookmarks, or linking from one site to another etc).</p>
<p>So, once the page get lost, either because the link has changed, the page has been moved or something similar, the browser (or site) can use the UUID to find the page again.</p>
<p>The second step obviously demands a search engine (or some other central registry) that utilizes UUIDs in it&#8217;s index since the system does require some kind of central processing for keeping track of a <span style="font-style: italic;">UUID-to-page</span>-link.</p>
<p>A UUID is not a particularly good <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Identifier">URI</a> since even UUIDs generated at the same host just a few seconds apart are still totally different from each others (this actually depends on implementation, but one should not assume UUIDs from the same host shares any similarities).</p>
<p>This however is also one of the strengths of UUIDs since it means an Internet resource should be possible to locate regardless of its physical location (in a contrary to ordinary http-URLs that are tightly bound to their location &#8212; they start with the server name).</p>
<p>Since a UUID (per definition) is <em>universally</em> unique, it is fairly simple to generate one wherever you are, and use it in a page, be sure there are no duplicates and locate the exact page of the UUID again.</p>
<p><span style="font-size: medium;">A Google experiment</span></p>
<p>I&#8217;ve placed the text &#8220;UUID: 8523813a-7c47-4cd9-ad78-09c14dfb505f&#8221; on this page. (Several times now). As far as I&#8217;ve been able to discern, Google indexes even such arbitrary information as UUID data (the exact string &#8220;8523813a-7c47-4cd9-ad78-09c14dfb505f&#8221; to be precise, check out <a href="http://www.google.com/search?q=D709BD00-7E98-36C7-6A4B8D82C4F43744">this page</a> with a discussion on how to use UUIDs to make pages unique&#8230; It has nothing to do with this discussion but is an interesting example on how UUIDs could be used with Google).</p>
<p>By searching for &#8220;8523813a-7c47-4cd9-ad78-09c14dfb505f&#8221; it should be possible to locate this page&#8230; (<span style="text-decoration: line-through;"><a href="http://www.google.com/search?q=8523813a-7c47-4cd9-ad78-09c14dfb505f">see if it works?</a> &#8212; Give Google time to index the page though&#8230;</span> Update: the above link seems to not work, but <a href="http://www.google.com/search?q=8523813a+7c47+4cd9+ad78+09c14dfb505f">this one</a> [searching for the UUID with "-" replaced to space -- or "+"], however, does&#8230;)</p>
<p><span style="font-size: medium;">Finally</span></p>
<p>The page localization should work regardless of the page&#8217;s position, site, or anything. In fact, as long as the UUID is still there, it should even be possible to place this text in a document of type Word/OpenDocument/PDF or any other format a search engine can index, and the text would still be possible to find with nothing but the UUID.</p>
<p>Obviously the end result of this technology would be that there is no &#8220;search-engine-in-between&#8221; but instead whenever the link is lost, the caller goes to the central repository/search engine (or some other place) and locate the page, then links to it automatically. It should even be smart enough to retry until it finds a link that works if a UUID has several possible links.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2007%2F04%2Fusing-uuids-to-prevent-broken-links&amp;title=Using%20UUIDs%20to%20Prevent%20Broken%20Links" id="wpa2a_8"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2007/04/using-uuids-to-prevent-broken-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

