<?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>ZaneHooper.com</title>
	<atom:link href="http://zanehooper.com/feed" rel="self" type="application/rss+xml" />
	<link>http://zanehooper.com</link>
	<description>Web developer, designer, and Internet Entrepreneur</description>
	<lastBuildDate>Mon, 12 Jul 2010 12:13:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP Security: Part 2 &#8211; Protecting vulnerable files</title>
		<link>http://zanehooper.com/blog/php-security-part-2-protecting-vulnerable-files.html</link>
		<comments>http://zanehooper.com/blog/php-security-part-2-protecting-vulnerable-files.html#comments</comments>
		<pubDate>Mon, 12 Jul 2010 03:01:29 +0000</pubDate>
		<dc:creator>Zane Hooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://zanehooper.com/?p=25</guid>
		<description><![CDATA[While developing, a lot of files are files you don&#8217;t want users to see &#8211; whether they are admin, config, or page files &#8211; should be well secured. Admin Files You&#8217;re administrative home page (if you have an administration panel) should require the user to be of a certain level (state, whatever you want to [...]]]></description>
			<content:encoded><![CDATA[<p>While developing, a lot of files are files you don&#8217;t want users to see &#8211; whether they are admin, config, or page files &#8211; should be well secured.</p>
<p><strong>Admin Files</strong></p>
<p>You&#8217;re administrative home page (if you have an administration panel) should require the user to be of a certain level (state, whatever you want to call it) or in a certain user group. This value SHOULD NOT be stored in a cookie. Cookies can be modified too easily, and a nosy hacker would be able to be in your admin panel in seconds.</p>
<p>If you have properly secured your admin panel so that a regular user cannot access it, the next step is to secure the files (assuming you&#8217;re using a paged interface, which I will explain here).</p>
<p>A paged interface is one in which there is a home page that includes files in a pages folder of some sort. There are multiple insecurities that I will cover with this:</p>
<ol>
<li>Users accessing the directory of the pages</li>
<li>Users accessing other directories through this system</li>
</ol>
<p><strong>1. Users accessing the directory of the pages</strong></p>
<p>This can happen through multiple ways. One thing you must do is make sure that the file exists using if( file_exists( $file_name ) ), otherwise a user could enter an incorrect value and PHP will try to include a page that doesn&#8217;t exist. This step covers up your tracks for hiding the directory.</p>
<p>Next, you want to protect the files of the directory. My favorite way to do this is through a .htaccess file (for apache users). In the pages directory, add a .htaccess file with the contents:</p>
<div id="_mcePaste">RewriteEngine on</div>
<div id="_mcePaste">RewriteRule ^(.*)$ /path/to/where/they/should/go.php [L] #Security: Does not allow anyone into anywhere in this folder. Includes still work.</div>
<p>This protects the path and sends the user to the specified path. This could be a home page, a 404 error, page, or whatever you want. I do know that some people don&#8217;t like this method, or don&#8217;t have Apache, so the other way would be to use define( &#8216;SITE&#8217;, true ); in your index page and then add at the beginning of everyone of your pages, add if( !defined(&#8216;SITE&#8217;) ) die( &#8216;Hey! You\&#8217;re not supposed to be here!&#8217; );</p>
<p>These methods protect your pages directory from direct access but still allow use of PHP&#8217;s include(  ), include_once(  ), require(  ), and require_once(  ) functions.</p>
<p><strong>2. Users accessing other directories through this system</strong></p>
<p>This is a pretty simple hack that I found once while testing out the security of my files. I thought &#8220;Well, if I can access anything in the pages directory, what&#8217;s to keep me from accessing other directories?&#8221;</p>
<p>This hack is quite simple actually, and allows the hacker to figure out entire directories of a website and generate plenty of errors. As I said in Part 1, to be good at security you need to learn to hack first. So here&#8217;s how the hack works:</p>
<p>[Some Website]/index.php?page=ucp</p>
<p>Seems pretty simple right? That&#8217;s how links work. The PHP script then performs include( &#8216;pages/ucp.php&#8217; ), but what if we change UCP?</p>
<p>[Some Website]/index.php?page=../index</p>
<p>Hmm&#8230; PHP interprets this as include( &#8216;pages/../index.php&#8217; ), which includes the index page again. Now we start getting errors. Actually, now it includes the index page over and over until the page breaks. Now the user can do some snooping around, with things like:</p>
<p>[Some Website]/index.php?page=../admin/delete_user&amp;id=1</p>
<p>Using things like this the user can access admin/delete_user.php?id=1 and wreak havoc on the website. The simplest protection ever can fix this:</p>
<p>$page = str_replace( &#8216;../&#8217;, &#8221;, $page );</p>
<p>And you&#8217;re done!</p>
<p>Up Next: <strong>PHP Security: Part 3 &#8211; XSS Worms/Hacks</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://zanehooper.com/blog/php-security-part-2-protecting-vulnerable-files.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Security: Part 1 &#8211; SQL Injections</title>
		<link>http://zanehooper.com/blog/php-security-part-1-sql-injections.html</link>
		<comments>http://zanehooper.com/blog/php-security-part-1-sql-injections.html#comments</comments>
		<pubDate>Mon, 12 Jul 2010 02:14:28 +0000</pubDate>
		<dc:creator>Zane Hooper</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Tutorials]]></category>

		<guid isPermaLink="false">http://zanehooper.com/?p=21</guid>
		<description><![CDATA[One of a web developer&#8217;s biggest issues: security. If you don&#8217;t want your data stolen or your user&#8217;s redirected to other sites, there&#8217;s a lot of things you must go through to correct these problems. One of the best ways I find to be able to make a secure website is to try and find [...]]]></description>
			<content:encoded><![CDATA[<p>One of a web developer&#8217;s biggest issues: security. If you don&#8217;t want your data stolen or your user&#8217;s redirected to other sites, there&#8217;s a lot of things you must go through to correct these problems.</p>
<p>One of the best ways I find to be able to make a secure website is to try and find possible insecurities in OTHER websites (AKA, hacking). Try and go to a website and put a few hours into finding a security problem. Maybe your website isn&#8217;t secure against this?</p>
<p><strong>Part 1</strong> &#8211; <em>SQL Injections</em></p>
<p>SQL Injections are one of a programmer&#8217;s biggest nightmares. SQL Injections can be used to steal, delete, or edit data that is supposed to be protected. Like you can use SQL for your websites, SQL might also be able to be injected into your code. Let&#8217;s take a normal login form, for instance:</p>
<blockquote>
<pre>&lt;form method="post"&gt;
&lt;label for="username"&gt;Username:&lt;/label&gt;&lt;input type="text" name="username" id="username" /&gt;
&lt;label for="password"&gt;Password:&lt;/label&gt;&lt;input type="password" name="pass" id="password" /&gt;
&lt;/form&gt;</pre>
</blockquote>
<p>This simple little script will give us a login form. Now the PHP side of things will do something like so:</p>
<blockquote>
<pre>&lt;?php</pre>
<pre>$username = $_POST['username'];</pre>
<pre>$password = $_POST['pass'];</pre>
<pre>$user = mysql_fetch_array( mysql_query( "SELECT `id` FROM `users` WHERE `username` = '{$username}' AND `password` = '{$password}' LIMIT 1" ) );</pre>
<pre>?&gt;</pre>
</blockquote>
<p>Simple enough, right? Maybe you encrypt your password (which we will talk about in another part), but that&#8217;s beside the point.</p>
<p><strong>The Problem: </strong></p>
<p><strong> </strong>Now a hacker would enter something like this into the username field: &#8216; OR &#8217;1&#8242; = &#8217;1&#8242;# and then the query would look like so: <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;"> SELECT `id` FROM `users` WHERE `username` = &#8221; OR &#8217;1&#8242; = &#8217;1&#8242;#&#8217; AND `password` = &#8216;{$password}&#8217; LIMIT 1</span></p>
<p>This would allow the hacker to access accounts without even having a password to the account. The # escapes the rest of the query so that SQL doesn&#8217;t take it into account.</p>
<p><strong>The Fix</strong></p>
<p>Now to fix this problem we have to &#8220;escape&#8221; the data. In PHP, a &#8220;\&#8221; before an apostrophe. I use a global clean so I don&#8217;t forget to clean out any inputs. This cleans out ALL cookie, session, POST, GET, and REQUEST data.</p>
<p><em>The Function:</em></p>
<blockquote>
<pre><em>
<div id="_mcePaste"><span style="font-style: normal;">function Clean( $var )</span></div>
<div id="_mcePaste"><span style="font-style: normal;">{</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">if( is_array( $var ) )</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">{</span></div>
<div id="_mcePaste" style="padding-left: 60px;"><span style="font-style: normal;">foreach( $var as $key =&gt; $val )</span></div>
<div id="_mcePaste" style="padding-left: 60px;"><span style="font-style: normal;">{</span></div>
<div id="_mcePaste" style="padding-left: 90px;"><span style="font-style: normal;">$var[$key] = $this-&gt;Clean( $val );</span></div>
<div id="_mcePaste" style="padding-left: 60px;"><span style="font-style: normal;">}</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">}</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">elseif( is_string( $var ) )</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">{</span></div>
<div id="_mcePaste" style="padding-left: 60px;"><span style="font-style: normal;">$var = str_replace( '\&amp;', '&amp;', escapeshellcmd( htmlentities( $var ) ) );</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">}</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">else return;</span></div>
<div id="_mcePaste" style="padding-left: 30px;"><span style="font-style: normal;">return $var;</span></div>
<div id="_mcePaste"><span style="font-style: normal;">}</span></div>

</em></pre>
</blockquote>
<p><span style="font-style: normal;">This function grabs $var and cleans all of its values, returning the sanitized variable. The escapeshellcmd(  ) function cleans different SQL-dangerous values,while the htmlentities(  ) function cleans things like &#8220;&lt;&#8221; or &#8220;&gt;&#8221; (HTML Entities). The use of the Clean(  ) function:</span></p>
<pre><span style="font-style: normal;">
<pre>
<blockquote><address><span style="font-style: normal;">$check = array(</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_ENV',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_GET',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_POST',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_FILES',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_COOKIE',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_REQUEST',</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">'_SESSION'</span></address>
<address><span style="font-style: normal;">);</span></address>
<address><span style="font-style: normal;">
</span></address>
<address><span style="font-style: normal;">foreach( $check as $key =&gt; $elm )</span></address>
<address><span style="font-style: normal;">{</span></address>
<address><span style="white-space: pre;"><span style="font-style: normal;">	</span></span><span style="font-style: normal;">${$key} = Clean( ${$key});</span></address>
<address><span style="font-style: normal;">}</span></address>
</blockquote>
</pre>
<p></span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">This example will clean all inputs to DB friendly values! This also cleans out things like &lt;script&gt; or &lt;a&gt; that could possibly lead to dangerous outputs.</span></pre>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;"><span style="line-height: 19px; white-space: normal;"><em>Up Next: </em><strong>PHP Security: Part 2 &#8211; Protecting vulnerable files</strong></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://zanehooper.com/blog/php-security-part-1-sql-injections.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Tutorial: Internet Explorer (IE) iframe</title>
		<link>http://zanehooper.com/blog/web-tutorial-internet-explorer-ie-iframe.html</link>
		<comments>http://zanehooper.com/blog/web-tutorial-internet-explorer-ie-iframe.html#comments</comments>
		<pubDate>Tue, 06 Jul 2010 15:33:55 +0000</pubDate>
		<dc:creator>Zane Hooper</dc:creator>
				<category><![CDATA[Web Tutorials]]></category>

		<guid isPermaLink="false">http://zanehooper.com/?p=17</guid>
		<description><![CDATA[I recently ran into a problem while trying to add an iframe with a transparent background in IE. CSS didn't seem to apply to the iframe when I was working with it (at least not very well). What we'll be fixing:

Allowing a background to be set with CSS or a transparent background
Removing borders from around the iframe (they look like crap)]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a problem while trying to add an iframe with a transparent background in IE. CSS didn&#8217;t seem to apply to the iframe when I was working with it (at least not very well). What we&#8217;ll be fixing:</p>
<ol>
<li>Allowing a background to be set with CSS or a transparent background</li>
<li>Removing borders from around the iframe (they look like crap)</li>
</ol>
<p><strong>The Background</strong></p>
<p><strong> </strong>In Internet Explorer, if you try to add a background (or have a transparent background) with your page&#8217;s CSS it doesn&#8217;t work. Instead, it keeps a white, boring background from the iframe (assuming the iframe has no background set). This little code will fix this problem, allowing transparent or colored backgrounds to be set through CSS.</p>
<p>Inside of your &lt;body&gt; tag in the HTML of the iframe, set the background style to &#8220;inherit&#8221; (&lt;body style=&#8221;background:inherit;&#8221;&gt;) and you can have a background using CSS from <em>your</em> page. It&#8217;s that simple.</p>
<p><span style="text-decoration: underline;"><em>Note:</em></span><em> If you are making a transparent background, you need to add allowtransparency=&#8221;true&#8221; to the &lt;iframe&gt; tag as one of its attributes.</em></p>
<p><span style="text-decoration: underline;"><em>Note:</em></span><em> If you want to make this iframe of a page that you cannot edit, look into using PHP to modify the &lt;body&gt; tag.</em></p>
<p><strong>The Border</strong></p>
<p>This one is just as simple, and can be done straight from the HTML. Add to the &lt;iframe&gt;&#8217;s attributes the following: frameborder=&#8221;0&#8243;</p>
]]></content:encoded>
			<wfw:commentRss>http://zanehooper.com/blog/web-tutorial-internet-explorer-ie-iframe.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WGCup</title>
		<link>http://zanehooper.com/blog/wgcup.html</link>
		<comments>http://zanehooper.com/blog/wgcup.html#comments</comments>
		<pubDate>Tue, 04 May 2010 02:19:59 +0000</pubDate>
		<dc:creator>Zane Hooper</dc:creator>
				<category><![CDATA[Jobs]]></category>

		<guid isPermaLink="false">http://zanehooper.com/?p=13</guid>
		<description><![CDATA[WGCup, or World Gaming Cup, is a league and tournament website based on the good parts of other successful leagues in an easy-to-use environment. Although not much other information can be released, WGCup is estimated to be launched early in June of 2010.]]></description>
			<content:encoded><![CDATA[<p><a title="World Gaming Cup" href="http://wgcup.com/" target="_blank">WGCup</a>, or World Gaming Cup, is a league and tournament website based on the good parts of other successful leagues in an easy-to-use environment. Although not much other information can be released, WGCup is estimated to be launched early in June of 2010.</p>
<p>My Jobs:</p>
<ul>
<li>Javascript/AJAX for an interactive front/back -end interface</li>
<li>PHP/MySQL for a secure but fast server</li>
<li>CSS/XHTML for a dazzling look</li>
</ul>
<p>Expect more updates on WGCup in the future.</p>
<p>Zane</p>
]]></content:encoded>
			<wfw:commentRss>http://zanehooper.com/blog/wgcup.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome!</title>
		<link>http://zanehooper.com/blog/welcome.html</link>
		<comments>http://zanehooper.com/blog/welcome.html#comments</comments>
		<pubDate>Wed, 02 Sep 2009 02:17:28 +0000</pubDate>
		<dc:creator>Zane Hooper</dc:creator>
				<category><![CDATA[Jobs]]></category>

		<guid isPermaLink="false">http://zanehooper.com/?p=3</guid>
		<description><![CDATA[Just to update the web with what I've been working on lately (in order of priorities)]]></description>
			<content:encoded><![CDATA[<p>Well, just uploaded wordpress today so there could be a few errors.</p>
<ol></ol>
<p>I hope to install (or create) some good addons for WordPress pretty soon.</p>
<p>Zane</p>
]]></content:encoded>
			<wfw:commentRss>http://zanehooper.com/blog/welcome.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
