<?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>Thijs Lensselink&#039;s Blog &#187; PHP</title>
	<atom:link href="http://lenss.nl/category/code/php-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://lenss.nl</link>
	<description>Webdevelopment and stuff...</description>
	<lastBuildDate>Thu, 26 Apr 2012 21:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Regular expression name based matches</title>
		<link>http://lenss.nl/2012/04/regular-expression-name-based-matches/</link>
		<comments>http://lenss.nl/2012/04/regular-expression-name-based-matches/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 18:14:49 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[name based]]></category>
		<category><![CDATA[preg_match]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1458</guid>
		<description><![CDATA[Normally when i write regular expressions with for instance PHP´s preg_match. I will use the standard $matches array to catch the result of pattern matches. This array has a normal numeric index for each match found. And looks something like $matches = array(); preg_match("/^Get(.+)Repository$/", "GetFooBarRepository", $matches); var_dump($matches); array(2) { [0] => string(19) &#8220;GetFooBarRepository&#8221; [1] => [...]]]></description>
			<content:encoded><![CDATA[<p>Normally when i write regular expressions with for instance <a href="http://php.net">PHP</a>´s <a href="http://php.net/preg_match">preg_match</a>. I will use the standard $matches array to catch the result of pattern matches. This array has a normal numeric index for each match found. And looks something like</p>
<pre class="php" name="code">
$matches = array();
preg_match("/^Get(.+)Repository$/", "GetFooBarRepository", $matches);
var_dump($matches);
</pre>
<blockquote><p>array(2) {<br />
  [0] => string(19) &#8220;GetFooBarRepository&#8221;<br />
  [1] => string(6) &#8220;FooBar&#8221;<br />
}</p></blockquote>
<p>And there is nothing wrong with that. Except for the fact that numeric indexes are not always easy to work with. And it does not look all that clean in the code itself. SO last week my LD pointed out the fact that the likes using name based indexes for the matched patterns. And this is pretty sweet. I have seen it before but never bothered to adopt it myself. And the result looks like</p>
<pre class="php" name="code">
$matches = array();
preg_match("/^Get(?<repositoryName>.+)Repository$/", "GetFooBarRepository", $matches);
var_dump($matches);
</pre>
<blockquote><p>array(3) {<br />
  [0] => string(19) &#8220;GetFooBarRepository&#8221;<br />
  &#8216;repositoryName&#8217; => string(6) &#8220;FooBar&#8221;<br />
  [1] => string(6) &#8220;FooBar&#8221;<br />
}</p></blockquote>
<p>And i have to say. It looks a lot cleaner. So i added this to my bag of tricks. And will be using it from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/04/regular-expression-name-based-matches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Only variables should be passed by reference</title>
		<link>http://lenss.nl/2012/03/php-only-variables-should-be-passed-by-reference/</link>
		<comments>http://lenss.nl/2012/03/php-only-variables-should-be-passed-by-reference/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 08:19:20 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Passed]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Variable]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1450</guid>
		<description><![CDATA[Last week i got this error while doing some coding with a new library. And at first i didn&#8217;t quite get what was causing this. The line in question looked like $url = reset($file->getPaths()); So how can that throw an error like &#8220;Only variables should be passed by reference&#8221; you might ask? Well as it [...]]]></description>
			<content:encoded><![CDATA[<p>Last week i got this error while doing some coding with a new library. And at first i didn&#8217;t quite get what was causing this. The line in question looked like</p>
<pre class="php" name="code">
$url = reset($file->getPaths());
</pre>
<p>So how can that throw an error like &#8220;Only variables should be passed by reference&#8221; you might ask? Well as it turns out to be. PHP functions don&#8217;t like arguments returned from another function. As with this case. The ->getPaths() method holds a reference to the returned array. Which it shouldn&#8217;t but that&#8217;s another thing.</p>
<p>So i guess from now i will doing the thing below. Or check for references beforehand!</p>
<pre class="php" name="code">
$paths = $file->getPaths();
$url = reset($paths);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/03/php-only-variables-should-be-passed-by-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SSH key authentication with EGit in ZendStudio</title>
		<link>http://lenss.nl/2012/02/using-ssh-key-authentication-with-egit-in-zendstudio/</link>
		<comments>http://lenss.nl/2012/02/using-ssh-key-authentication-with-egit-in-zendstudio/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 14:17:19 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[/home]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[EGit]]></category>
		<category><![CDATA[Jsch]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1442</guid>
		<description><![CDATA[For the past few months i have been switching some projects over to git from Subversion. And have been trying to get the hang of all the command line options available. And i will be doing that for a while longer until i get completely comfortable. And for communication to the remote git server i [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few months i have been switching some projects over to <a href="http://git-scm.com/">git</a> from <a href="http://subversion.tigris.org/">Subversion</a>. And have been trying to get the hang of all the command line options available. And i will be doing that for a while longer until i get completely comfortable. And for communication to the remote git server i have been using SSH key authentication. Which works smoothly just like it did with Subversion. </p>
<p>But i wanted to check out the GIT support available in <a href="http://www.zend.com/products/studio/">Zend Studio 9</a>. And hit a problem pretty quickly. But i will describe that below. First i will create a local clone of my git project.</p>
<blockquote><p>$ git clone ssh://[somehost]/~/git/project.git</p></blockquote>
<p>To test if everything is working i do a test commit. If that succeeds if push it out to the remote master.</p>
<blockquote><p>
$ cd project.git<br />
$ touch TEST<br />
$ git commit<br />
$ git push origin master
</p></blockquote>
<p>So that works fine. Now time to see how Zen Studio handles this. To create a project i use the <strong>Create from Git</strong> option. And select the local checkout i just created. This will read the whole repository configuration. And you are basically done from here. But as i mentioned earlier, i had some difficulties getting things running smoothly. I discovered that when it was time to push changes to the master repository.</p>
<p>When i used the <strong>Push to Upstream</strong> option. I was greeted by a login panel that seemed to have selected the correct SSH key and user to perform the login. But when i typed the password, it just kept asking for the password. Again and again. Hmm. That sucks! The password was correct. I tried with a newly created key. No luck either. The last thing i tried was updating to a nightly build of <a href="http://www.eclipse.org/egit/">Egit</a> found <a href="http://www.eclipse.org/egit/download/">here</a>. But this offered no solution either.</p>
<p>After reading a couple of complaints i found this <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=326526">bug</a> report for the EGit eclipse plugin. The thread contains a solution for the login issue i was having. Gotta love Google!</p>
<p>Apparently the problem has to do with the encryption algorithm used to create the SSH keys. In this case the EGit plugin (which uses <a href="http://www.jcraft.com/jsch/">Jsch</a> to do the SSH communication) was having problems with <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a> encrypted keys. And to solve the problem the Jsch library should be replaced with a newer version to make things work again.</p>
<p>So lets download this JSch library and update it manually. The library (JSch v 0.1.46) can be found <a href="http://www.jcraft.com/jsch/">here</a>.</p>
<blockquote><p>
$ cd ZendStudio9<br />
$ find . -name &#8216;*jsch*&#8217; -type f
</p></blockquote>
<p>Found it <strong>plugins/com.jcraft.jsch_0.1.41.v201101211617.jar</strong>. So let&#8217;s try to update that.</p>
<blockquote><p>
$ cp plugins/com.jcraft.jsch_0.1.41.v201101211617.jar plugins/com.jcraft.jsch_0.1.41.v201101211617.jar.backup<br />
$ wget http://sourceforge.net/projects/jsch/files/jsch.jar/0.1.46/jsch-0.1.46.jar/download<br />
$ mv jsch-0.1.46.jar plugins/com.jcraft.jsch_0.1.41.v201101211617.jar
</p></blockquote>
<p>After restarting ZS everything worked fine again. Another problem solved! Thanks to the guys who posted in the EGit bug thread. Some good community Karma here! Time for other things. Hope it helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/02/using-ssh-key-authentication-with-egit-in-zendstudio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recruiter rant</title>
		<link>http://lenss.nl/2012/02/recruiter-rant/</link>
		<comments>http://lenss.nl/2012/02/recruiter-rant/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 21:14:03 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[/home]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[aggressive]]></category>
		<category><![CDATA[Recruiter]]></category>
		<category><![CDATA[unmannered]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1435</guid>
		<description><![CDATA[While doing our routine sprint retrospective today. We got interrupted by our office manager Wendy. An important phone call for me. Hmm&#8230; Should have known. I picked up the phone. And the guy (Amoria Bond) on the other end immediately started his sales pitch. O shit another one of those nasty recruiters. So after listening [...]]]></description>
			<content:encoded><![CDATA[<p>While doing our routine <a href="http://sites.google.com/site/agiledevelopmentsite/process/sprint-retrospective">sprint retrospective</a> today. We got interrupted by our office manager Wendy. An important phone call for me. Hmm&#8230; Should have known.</p>
<p>I picked up the phone. And the guy (<a href="http://www.amoriabond.com/">Amoria Bond</a>) on the other end immediately started his sales pitch. O shit another one of those nasty recruiters. So after listening to him for a few seconds i quickly interrupted him. Told him i was not interested in a new job at all. And that he was a jerk and extremely unprofessional for calling me at the office. Completely unaware (or maybe intentionally?) what impact this might have if for instance my manager picks up the phone. Besides it&#8217;s just plain rude. </p>
<p>Now don&#8217;t get me wrong. It&#8217;s not a rant for nothing. I don&#8217;t hate recruiters. And have worked with some professional ones in the past. I&#8217;ve always enjoyed communicating with linda-lotte while she was still working for <a href="http://www.recruit4it.nl/">Recruit4it</a>. And the guys at <a href="http://www.starapple.nl">Starapple</a> are OK as well. But this guy today really pissed me off with his aggressive unmannered approach. It&#8217;s a shame i didn&#8217;t catch his name while i was in rant mode. But please don&#8217;t ever call me again.</p>
<p><strong>Update:</strong></p>
<p>It seems to be some form of new tactic to call developers in the office where they work. This happened a couple of times more after this post. So this is for the next recruiter that calls me in the office. I&#8217;ll personally come over and kick your ass!!</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/02/recruiter-rant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress install compromised</title>
		<link>http://lenss.nl/2012/02/wordpress-install-compromised/</link>
		<comments>http://lenss.nl/2012/02/wordpress-install-compromised/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 20:37:10 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[/home]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[brazil]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[IRC bot]]></category>
		<category><![CDATA[pbot]]></category>
		<category><![CDATA[PHP bot]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1408</guid>
		<description><![CDATA[Last week i got an email from the Dutch NCSC (Nationaal Cyber Security Centrum). Apparently one of the nodes i manage for a customer was part of a botnet. There were no further demands. They just informed me about the issue. Damn cool! Being part of a botnet however. Not so cool! With the email [...]]]></description>
			<content:encoded><![CDATA[<p>Last week i got an email from the Dutch <a href="https://www.ncsc.nl/">NCSC</a> (Nationaal Cyber Security Centrum). Apparently one of the nodes i manage for a customer was part of a <a href="http://en.wikipedia.org/wiki/Botnet">botnet</a>. There were no further demands. They just informed me about the issue. Damn cool! Being part of a <a href="http://en.wikipedia.org/wiki/Botnet">botnet</a> however. Not so cool!</p>
<p>With the email came a small excerpt of a IRC channel log. I recognized the node. So SSH&#8217;ed into that specific node. And used <a href="http://linux.die.net/man/8/netstat">netstat</a> to check for any strange connections. A connection on port 20 to the C&#038;C node of the <a href="http://en.wikipedia.org/wiki/Botnet">botnet</a>. Thats not good.</p>
<blockquote><p>
$ netstat -an<br />
Active Internet connections (servers and established)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State<br />
tcp        0      0 xxx.xxx.xxx.xx:20       69.162.80.62:20         ESTABLISHED
</p></blockquote>
<p>In the email from NCSC it was mentioned to look for files called <strong>wp-rss3.php</strong>. But a search for this file did not return any hits. Hmmm. And i still  had no idea which site it concerned. Since a couple were running on this particular node. The only thing certain. It&#8217;s <a href="http://wordpress.org">WordPress</a> related. So i started searching for recent <a href="http://wordpress.org">WordPress</a> compromises. And found a lot of hits on Google for the <a href="http://code.google.com/p/timthumb/">timThumb</a> and <a href="http://code.google.com/p/wps3slider/">wps3slider</a> plugins. But checking the log files for these plugins revealed nothing. And for some weird reason i just cleaned up the log partition a couple of days before. So not much luck there.</p>
<p>Some more Googling <a href="http://markmaunder.com/2011/08/01/zero-day-vulnerability-in-many-wordpress-themes/">told</a> me to do a search on the WordPress installs for the PHP function <a href="http://php.net/manual/en/function.base64-decode.php">base64_decode()</a>. O well. Lets give it a try. Some suspicious files did show up instantly.</p>
<blockquote><p>
$ find . -type f -exec grep -l &#8216;base64_decode&#8217; {} \;<br />
./uploads/2010/06/wp-rss4.php (<a href="http://pastebin.com/rWD1Tfxk">source</a>)<br />
./uploads/2011/05/alienee.php (<a href="http://pastebin.com/LwDaSFUK">source</a>)<br />
./plugins/wps3slider/temp/34e3a3a74f6e2d0f236bdd3ba70c0c03.php (<a href="http://pastebin.com/fG6pDWC2">source</a>)<br />
./plugins/wps3slider/temp/cf2cdb3ad3249b9692de07290f16f287.php (<a href="http://pastebin.com/pRSwG7Ud">encoded</a>) (<a href="http://pastebin.com/0qQ3Qeut">decoded</a>)<br />
./plugins/wps3slider/temp/771b821c974131c67e34c83d8d2db725.php (<a href="http://pastebin.com/KUP8xBEQ">encoded</a>) (<a href="http://pastebin.com/Z77iMH1X">decoded</a>)<br />
./plugins/wps3slider/temp/2b3753ea4769084f2e571737b695b03a.php (<a href="http://pastebin.com/RLgsTerk">encoded</a>) (<a href="http://pastebin.com/KwgqCS8R">decoded</a>)<br />
./plugins/wps3slider/temp/7228f168d9692eafeafc54dbc3a1ab49.php (<a href="http://pastebin.com/HeE3PdnJ">encoded</a>) (<a href="http://pastebin.com/FzCqSfg6">decoded</a>)<br />
./plugins/wps3slider/uploads/1.php (<a href="http://pastebin.com/YJ17ygSL">source</a>)<br />
/var/tmp/dc.pl (<a href="http://pastebin.com/YTusrVZk">encoded</a>) (<a href="http://pastebin.com/0WfqZt0R">decoded</a>)
</p></blockquote>
<p>Interesting. A quick look at the files showed that most of them were obfuscated. But not all. Two of the files were IRC bots written in <a href="http://www.php.net/">PHP</a>. At this moment i couldn&#8217;t resist but crack a little smile. But its also a reminder of how fragile the web really is. I quickly moved the files out of the way. And rebooted the machine. When it  came back online i monitored all connections for a while. But the connection to the C&#038;C node was not restored. So i informed NCSC. And went back to bed!</p>
<p>The WordPress admin should have kept the sites up to date. Lesson learned i hope! of course i could not resist to come back to it later. And so i did. I started by searching the Apache log files for <strong>wp-rss4.php</strong>. And found a couple of instances where this file was directly called. From a total of 4 different IP addresses.</p>
<blockquote><p>69.162.80.62</p></blockquote>
<p>This is the IP address of the C&#038;C server.</p>
<blockquote><p>
186.241.16.25<br />
201.8.237.18<br />
201.8.226.109
</p></blockquote>
<p>These IP addresses are all originating from Brasil. No further information is available at this moment. After that i started poking around the trojans / IRC bots found earlier. And as mentioned earlier. There were two bots installed on the server, One was running. The other wasn&#8217;t. This is configuration snippet from both bots.</p>
<p>The first bot. And the one i was informed about.</p>
<pre class="php" name="code">var $config = array("server"=>"antesedepois.servegame.com",^M
                     "port"=>20,^M
                     "pass"=>"depois",^M
                     "prefix"=>"depois",^M
                     "maxrand"=>8,^M
                     "chan"=>"#depoiswp",^M
                     "key"=>"",^M
                     "modes"=>"+iB-x",^M
                     "password"=>"depois",^M
                     "trigger"=>".",^M
                     "hostauth"=>"*" // * for any hostname^M</pre>
<p>And the second one</p>
<pre class="php" name="code">
var $config = array("server"=>"58.225.75.155",
                     "port"=>9999,
                     "pass"=>"",
                     "prefix"=>"animal",
                     "maxrand"=>8,
                     "chan"=>"#animal",
                     "key"=>"",
                     "modes"=>"+iB-x",
                     "password"=>"oishi",
                     "trigger"=>".",
                     "hostauth"=>"*!*@The.Black.Cat" // * for any hostname
                     );
</pre>
<p>Notice the <strong>^M</strong> characters at the end. Seems like somebody is using windows. So now we have login details for two C&#038;C servers. Why not take a look. </p>
<blockquote><p>
$ ircii<br />
/server antesedepois.servegame.com:20
</p></blockquote>
<p>Some standard IRC stuff</p>
<blockquote><p>*** Connecting to port 20 of server antesedepois.servegame.com<br />
*** Welcome to the Internet Relay Chat Network, root (from IRCPRIVATE)<br />
*** /etc/irc/script/local V0.5 for Debian finished. Welcome to ircII.<br />
*** If you have not already done so, please read the new user information with /HELP NEWUSER<br />
*** Your host is IRCPRIVATE, running version 1.2.1546<br />
*** This server was created jan 27 2012 at 06: 29:02 HodB (Serial # 00-00-00)<br />
*** channel modes available abdefghijklmnopqrstuvwxyzACEFIKLMOPT<br />
*** IRCX<br />
*** There are 6 users and 362 invisible on 1 servers<br />
*** 7 channels have been formed<br />
*** This server has 368 clients and 0 servers connected<br />
*** Current local users:  368  Max: 989<br />
*** Current global users:  368  Max: 989<br />
*** MOTD Not Present</p></blockquote>
<p>So let&#8217;s check the channels on this thing</p>
<blockquote><p>/list</p>
<p>*** Channel    Users  Topic<br />
*** #depoiswp  360    Entrou = Ban :)<br />
*** #grmteam   6<br />
*** #depoisSca 4      Entrou = Ban :)<br />
*** #depoisSca 4      Entrou = Ban :)<br />
*** #depoisVul 6      Entrou = Ban :)<br />
*** #rfi       3<br />
*** #sql       1  </p></blockquote>
<p>I entered all of the channels and waited for a while. But no activity took place. The only really interested channel is #depoiswp. This is the channel where all the bots connect. At the time i logged in there were about 360 of them  available. I immediately recognized the log excerpt send to me by the NCSC.</p>
<blockquote><p>*** Topic for #depoiswp: Entrou = Ban :)<br />
*** #depoiswp SYSTEM 1327945185<br />
(#depoiswp/#depoiswp) Entrou = Ban :)<br />
*** [A]depois88802849 (~depois48170648@68.233.238.XX) has joined channel #depoiswp<br />
*** #depoiswp 1327653297<br />
*** [A]depois13436992 (~depois92951214@212.227.114.XX) has joined channel #depoiswp<br />
*** [A]depois18833547 (~depois69088341@184.154.130.XX) has joined channel #depoiswp<br />
*** [A]depois80116634 (~depois13242297@213.251.189.XXX) has joined channel #depoiswp<br />
*** [A]depois31855907 (~depois23946193@82.85.28.XXX) has joined channel #depoiswp<br />
*** [A]depois25458508 (~depois64120008@87.106.214.XX) has joined channel #depoiswp<br />
*** [A]depois17803105 (~depois55004207@74.208.16.XX) has joined channel #depoiswp<br />
*** [A]depois96800217 (~depois89042073@174.121.216.XXX) has joined channel #depoiswp<br />
*** [A]depois17108432 (~depois51961332@209.68.1.XXX) has joined channel #depoiswp<br />
*** [A]depois95432403 (~depois13925479@209.68.1.XXX) has joined channel #depoiswp<br />
*** [A]depois96515275 (~depois10767943@195.74.38.XXX) has joined channel #depoiswp<br />
*** [A]depois73596561 (~depois90562179@69.89.31.XXX) has joined channel #depoiswp<br />
*** [A]depois85357227 (~depois31697723@64.191.115.XX) has joined channel #depoiswp<br />
*** [A]depois07993697 (~depois40240585@79.96.128.XX) has joined channel #depoiswp<br />
*** [A]depois97441253 (~depois19633359@193.189.74.XX) has joined channel #depoiswp<br />
*** [A]depois76843389 (~depois55419325@176.9.34.XXX) has joined channel #depoiswp<br />
*** [I]depois16679788 (~depois28004829@213.171.218.XXX) has joined channel #depoiswp<br />
*** [A]depois88178285 (~depois05296405@74.220.215.XXX) has joined channel #depoiswp</p></blockquote>
<blockquote><p>
<[A]depois16231776> [Attack Finalizado!]: 1749605 MB enviados / Pacotes enviados: 14580 MB/s<br />
<[I]depois60130568> [Attack Finalizado!]: 75 MB enviados / Pacotes enviados: 1 MB/s<br />
<[I]depois48664304> [Attack Finalizado!]: 75 MB enviados / Pacotes enviados: 1 MB/s<br />
<[I]depois65415449> [Attack Finalizado!]: 75 MB enviados / Pacotes enviados: 1 MB/s<br />
<[I]depois11325010> [Attack Finalizado!]: 75 MB enviados / Pacotes enviados: 1 MB/s<br />
*** [A]depois40994506 (~depois72760562@79.98.28.XX) has joined channel #depoiswp<br />
<[A]depois07568398> [Attack Finalizado!]: 2187317 MB enviados / Pacotes enviados: 18228 MB/s<br />
<[A]depois55402758> [Attack Finalizado!]: 11425 MB enviados / Pacotes enviados: 95 MB/s<br />
*** [A]depois03383512 (~depois52457929@74.220.215.XX) has joined channel #depoiswp<br />
<[A]depois37064023> [Attack Finalizado!]: 1264043 MB enviados / Pacotes enviados: 10534 MB/s<br />
<[A]depois69234369> [Attack Finalizado!]: 2205504 MB enviados / Pacotes enviados: 18379 MB/s<br />
*** [A]depois74911768 (~depois04730096@74.220.215.XX) has joined channel #depoiswp<br />
*** Signoff: [A]depois31575043 (Connection reset by peer)<br />
<[I]depois17710498> [Attack Finalizado!]: 81 MB enviados / Pacotes enviados: 1 MB/s<br />
<[I]depois28464134> [Attack Finalizado!]: 81 MB enviados / Pacotes enviados: 1 MB/s</p></blockquote>
<p>Thats fine and all. I disconnected shortly after that. I really have no reason  to be poking around there now do i ;) Besides who want to  interfere with an ongoing investigation. So poking around the files a bit more didnot  reveal  all that information.Except for the fact that besides a IRC bot a backdoor was also installed in the form of a perl script dc.pl installed in /var/tmp. So who knows. The server might be rooted at this point.</p>
<p>I spend some more time on decoding the bot and trojan contents. And posted them on pastebin if you are interested. The server is going to be  decommissioned soon. So i am not going to pay much more attention to it.</p>
<blockquote><p>1.php and b2dabd0e2c42b55fabf741bcac29f857.php</p></blockquote>
<p>Web Shell by boff</p>
<blockquote><p>2b3753ea4769084f2e571737b695b03a.php</p></blockquote>
<p>This file was base64 encoded but once decoded reveled to be a simple script by v0pCr3w and nob0dyCr3w to run system commands on the server. Also included was a simple upload form.</p>
<blockquote><p>34e3a3a74f6e2d0f236bdd3ba70c0c03.php</p></blockquote>
<p> c99 injector v1</p>
<blockquote><p>771b821c974131c67e34c83d8d2db725.php</p></blockquote>
<p>This script was rot13 and base64 encoded and was trying to cleanup after the hacker. And install a second back door.</p>
<blockquote><p>7228f168d9692eafeafc54dbc3a1ab49.php and cce0a37ffc138a8908da05977639bed1.php</p></blockquote>
<p>Again rot13 and base64 encoded.But this script contained something that looks like a control panel. The page title was &#8216;Hacked by Sherif #oishi @ ALLnet&#8217;</p>
<blockquote><p>alienee.php</p></blockquote>
<p>Still working on this one</p>
<blockquote><p>cf2cdb3ad3249b9692de07290f16f287.php and ded3244749701c4eb5a29b959ad56736.php</p></blockquote>
<p>These files contained a second bot that was connecting to a whole different server. Probably exploited by another crew?</p>
<blockquote><p>dc.pl</p></blockquote>
<p>This Perl backdoor was created by one  of the IRC bot scripts. And was hiding in /var/tmp after creation.</p>
<p>And some links i found useful while working on this issue.<br />
<a href=" http://eromang.zataz.com/2012/01/08/gangbang-mytijn-org-malware-spreader-down/"></p>
<p>http://eromang.zataz.com/2012/01/08/gangbang-mytijn-org-malware-spreader-down/</a></p>
<p><a href="http://www.madirish.net/content/hookworm-stealth-php-backdoor">http://www.madirish.net/content/hookworm-stealth-php-backdoor</a><br />
<a href="http://markmaunder.com/2011/08/01/zero-day-vulnerability-in-many-wordpress-themes/">http://markmaunder.com/2011/08/01/zero-day-vulnerability-in-many-wordpress-themes/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/02/wordpress-install-compromised/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP critical bug CVE-2012-0830</title>
		<link>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/</link>
		<comments>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 11:39:43 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Crash]]></category>
		<category><![CDATA[CVE-2012-0830]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1423</guid>
		<description><![CDATA[Ok it&#8217;s a bit late But i have been laying under a rock for the last week. And i guess it can&#8217;t hurt! Last week a critical bug was discovered in PHP. Which affects versions 5.3.9 and 5.2.17. The bug could be exploited to run arbitrary code on a remote PHP system. So upgrade your [...]]]></description>
			<content:encoded><![CDATA[<p>Ok it&#8217;s a bit late But i have been laying under a rock for the last week. And i guess it can&#8217;t hurt!</p>
<p>Last week a critical bug was discovered in PHP. Which affects versions 5.3.9 and 5.2.17. The bug could be exploited to run arbitrary code on a remote PHP system. So upgrade your systems. And of course Stefan Esser <a href="http://news.php.net/php.internals/57655">popped up</a> with some wise words :)&#8230; O well i still think the guy does great work.</p>
<p>More info about the issue can be found on packetstorm (<a href="http://packetstormsecurity.org/files/cve/CVE-2012-0830">CVE-2012-0830</a>) </p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2012/02/php-critical-bug-cve-2012-0830/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP getting strict sessions</title>
		<link>http://lenss.nl/2011/11/php-getting-strict-sessions/</link>
		<comments>http://lenss.nl/2011/11/php-getting-strict-sessions/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:38:28 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[5.4]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[session fixation]]></category>
		<category><![CDATA[strict_session]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1405</guid>
		<description><![CDATA[For years PHP has been vulnerable to session adoption which can enable session fixation. And since sessions are a major part of web applications now a days. A lot of platforms are open and waiting for an attack to happen. session adoption &#038; session fixation The problem exists because the current session module does not [...]]]></description>
			<content:encoded><![CDATA[<p>For years <a href="http://php.net/">PHP</a> has been vulnerable to session adoption which can enable <a href="http://en.wikipedia.org/wiki/Session_fixation">session fixation</a>. And since sessions are a major part of web applications now a days. A lot of platforms are open and waiting for an attack to happen.</p>
<p><strong>session adoption &#038; session fixation</strong></p>
<p>The problem exists because the current session module does not validate the session id that comes in from a cookie. This means uninitialized session id&#8217;s can be passed by the client. This happens due to the fact that browsers overwrite cookie if multiple cookies are send per request.<br />
Some people would say this is solvable by implementing <a href="http://nl3.php.net/manual/en/function.session-regenerate-id.php">session_regenerate_id()</a>. But this is not the case.</p>
<p>Because session fixation can be used to take over control of web applications. Validation is required when multiple cookies are send per request. When multiple cookie are send with a request. Browsers send multiple cookies without domain / path information. This way it&#8217;s impossible to tell which cookie belongs to which domain. </p>
<p><strong>So how do we fix this?</strong></p>
<p>There is some userland code that does offer the ability to validate session data. But this has not been widely adopted by other developers.</p>
<p>Code that adds the session ID as a validation key:</p>
<pre class="php" name="code">
session_destory();
session_regenerate_id();
$_SESSION['valid_id'] = session_id();
</pre>
<p>And the code to check if the session was properly initialized:</p>
<pre class="php" name="code">
if ($_SESSION['valid_id'] !== session_id()) {
  die('Invalid use of session ID');
}
</pre>
<p>Thank god the internal developer know this. And are working to fix this. For the past days there has been an interesting discussion going on on the <a href="http://news.php.net/php.internals">internals</a> list. About applying a patch that will fix this. The patch will add some new php.ini features and a new method validate_id() for the session save handler. Hopefully this will be available in version 5.4.</p>
<p>To not break BC strict_mode will be disabled by default. But can be enabled by setting the following setting in php.ini. When enabled uninitialized session ID will be discarded.</p>
<blockquote><p>session.use_strict_mode=0</p></blockquote>
<p>To prevent a DoS instead of session fixation. An new feature has been added that deletes possible malicious cookies that prevent new session ID.</p>
<blockquote><p>session.safe_session_cookie=1</p></blockquote>
<p>You can read more about session fixation and the upcoming patch on the <a href="https://wiki.php.net/rfc/strict_sessions">PHP-Wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/11/php-getting-strict-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abbywinters.com is hiring!</title>
		<link>http://lenss.nl/2011/11/abbywinters-com-is-hiring/</link>
		<comments>http://lenss.nl/2011/11/abbywinters-com-is-hiring/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 12:46:51 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[abbywinters.com]]></category>
		<category><![CDATA[Adult]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[naturally delicious]]></category>
		<category><![CDATA[SCRUM]]></category>
		<category><![CDATA[Sexy]]></category>
		<category><![CDATA[Webdeveloper]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1386</guid>
		<description><![CDATA[If you&#8217;re looking for a new challenging and exiting Senior Webdeveloper position. Don&#8217;t look any further. If you already think you have the job of your dreams. Think again! abbywinters.com (NSFW) is one of the largest and most ethical, highly rated, well designed, and successful erotic websites in the world today. abbywinters.com is the WINNER [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://careers.abbywinters.com/job-opportunities/senior-php-developer/" target="_blank"><img src="http://lenss.nl/wp-content/uploads/2011/11/aw-logo-roundel-blue.png" alt="" title="abbywinters.com - Delivering game-changing experiences" style="float:left;margin:10px;" width="140" height="140" class="alignright size-full wp-image-1385" /></a> If you&#8217;re looking for a new challenging and exiting Senior Webdeveloper position. Don&#8217;t look any further. If you already think you have the job of your dreams. Think again!</p>
<p><em><a href="http://www.abbywinters.com" target="_blank">abbywinters.com</a> <b>(NSFW)</b> is one of the largest and most ethical, highly rated, well designed, and successful erotic websites in the world today. abbywinters.com is the WINNER of the AVN 2011 Awards for Best Membership site!</em></p>
<p>And we are looking to hire a new talented webdeveloper to expand our small team. What would you think about joining our small Agile team of highly qualified professionals? </p>
<p>You will be creating sexy, exiting and game changing experiences for the web, work for one of the industry leaders. And just be part of an awesome company. Some of the jobs key elements are:</p>
<ul>
<li>Implementing development projects</li>
<li>Leading informal mentoring during day-to-day work</li>
<li>Contribute to design of development projects</li>
<li>Track, reduce, and prevent technical debt in Web Development projects</li>
</ul>
<p><br/></p>
<blockquote><p>Motivated by principles of social responsibility, we deliver provocative media by embracing imagination, creativity and emerging technologies. Our models, customers and business partners are inspired by our fervid passion.</p>
<p><br/></p>
<p>Our experienced staff use state-of-the-art content production facilities to produce 10 shoots a week from concept to finished art, utilizing the most advanced digital capture, post production and delivery systems in the world.</p>
<p><br/></p>
<p>You will be working directly with our Web Dev Manager, Lead developer and colleagues in the web dev team. We need each individual to contribute for us to continue as a pioneer in our industry.</p>
</blockquote>
<p><br/></p>
<p>If you posses a &#8220;Can do&#8221; attitude. Would like to work in the center of Amsterdam. And are able to identify your self in the criteria below. You might want to head over to our <a href="http://careers.abbywinters.com/job-opportunities/senior-php-developer/">career portal</a> for a more detailed description.<br/></p>
<p><strong>Technical competencies – Required</strong></p>
<ul>
<li>High level of skill with PHP 5</li>
<li>High level of skill with Object Oriented Programming</li>
<li>High level of skill with HTML/CSS</li>
<li>High level of skill with JavaScript</li>
<li>High level of skill with Internet Applications</li>
<li>Moderate level of skill with Unit Testing and Test Driven Design</li>
<li>Moderate level of skill with MySQL</li>
<li>Moderate level of skill with Windows XP operating system</li>
<li>Experience with the GNU/Linux operating system</li>
<li>Competent with Revision Control systems (Subversion)</li>
<li>Bachelor of Science in Computer Science, or equivalent experience</li>
<li>Zend Certified Engineer, or equivalent experience</li>
<li>At least 5 years experience in Web Application Development</li>
</ul>
<p><br/></p>
<p><strong>Technical competencies – Desired</strong></p>
<ul>
<li>Moderate level of skill with the Apache HTTP server</li>
<li>Good understanding of the Model-View-Controller pattern</li>
<li>Good understanding of the ActiveRecord Object-Relational-Mapping pattern</li>
<li>Familiarity with Agile software development practices (Scrum)</li>
<li>E-commerce</li>
<li>Agile development experience</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/11/abbywinters-com-is-hiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP slow on 32-bit Ubuntu</title>
		<link>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/</link>
		<comments>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 11:09:44 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[largefile]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1325</guid>
		<description><![CDATA[My last post was about the 32-bit integer issue i was having with PHP. And besides setting up a 64-bit server one of the solutions is to compile PHP with the CFLAGS mentioned in my previous post. Intrigued by the fact that my 32-bit Ubuntu installation did not suffer from the same issue. I started [...]]]></description>
			<content:encoded><![CDATA[<p>My last <a href="http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/">post</a> was about the 32-bit integer issue i was having with PHP. And besides setting up a 64-bit server one of the solutions is to compile PHP with the CFLAGS mentioned in my previous post. </p>
<p>Intrigued by the fact that my 32-bit Ubuntu installation did not suffer from the same issue. I started to read the PHP5 changelog for Ubuntu.</p>
<blockquote><p>
CFLAGS=”-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64″ ./configure</p></blockquote>
<p>But this has a negative side effect. Namely PHP running 50% slower then it should be. And to my surprise Ubuntu applies the CFLAGS above when compiling PHP5 for a 32-bit platform. So that would mean PHP on Ubuntu is always running 50% slower? Well according to <a href="https://bugs.php.net/bug.php?id=45942">this</a> is should be the case. </p>
<p>I downloaded <a href="http://nl.php.net/get/php-5.3.8.tar.gz/from/a/mirror">php-5.3.8</a> from php.net and compiled two versions. One with the CFLAGS set for large files. And one normal without any changes. After that i downloaded the benchmark script from <a href="http://www.php-benchmark-script.com">php-benchmark-script.com</a>. And did a couple of runs on each of the two installs. The results are stunning.</p>
<p><strong>PHP-5.3.8 compiled with large file support:</strong></p>
<blockquote><p>test_math                 : 4.414 sec.<br />
test_stringmanipulation   : 4.968 sec.<br />
test_loops                : 3.529 sec.<br />
test_ifelse               : 2.344 sec.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Total time:               : 15.255 sec.</p></blockquote>
<p><strong>PHP-5.3.8 compiled without large file support:</strong></p>
<blockquote><p>test_math                 : 2.274 sec.<br />
test_stringmanipulation   : 2.286 sec.<br />
test_loops                : 1.619 sec.<br />
test_ifelse               : 1.228 sec.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Total time:               : 7.407 sec.</p></blockquote>
<p>That&#8217;s pretty much a 50% speed decrease. One more thing i tried is adding the &#8216;AC_SYS_LARGEFILE&#8217; macro to configure.in and rebuild the configure script. But this had no effect at all.</p>
<blockquote><p>$ cd php-5.3.8<br />
$ vi configure.in (add AC_SYS_LARGEFILE somewhere)<br />
$ export PHP_AUTOCONF=/usr/share/autoconf2.59<br />
$ ./buildconf &#8211;force</p></blockquote>
<p>I then tried two things. First i build without the CFLAGS. But this didn&#8217;t seem to do much. Then i used the same configure script with the CFLAGS for large file support. But there was no speed increase measurable. </p>
<p>So why would Ubuntu have made the choice to compile PHP with the large file support on a 32-bit platform? Are there really that much developers that work on large files in web / cli applications written in PHP? Enough to sacrifice a 50% speed decrease?</p>
<p>I don&#8217;t really know the answer to that. But i will do my large file processing on 64-bit machines. And will compile PHP from scratch from now on. Until i have upgraded my aging hardware.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/09/php-slow-on-32-bit-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP5 filesize limit on 32-bit system</title>
		<link>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/</link>
		<comments>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:38:00 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[filesize]]></category>
		<category><![CDATA[is_file]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=1313</guid>
		<description><![CDATA[So we have a PHP based importer script that does some heavy duty media processing at the office. And i had to import some new media today. But for some reason a couple of files weren&#8217;t picked up without a message. So i cleaned up the upload folder. The only files left were the files [...]]]></description>
			<content:encoded><![CDATA[<p>So we have a PHP based importer script that does some heavy duty media processing at the office. And i had to import some new media today. But for some reason a couple of files weren&#8217;t picked up without a message. So i cleaned up the upload folder. The only files left were the files not being processed. And when i started the importer. The result was.</p>
<blockquote><p>
Importer found (0) files to import!</p></blockquote>
<p>Hmmm. That&#8217;s not right. So i had a look at the code behind the importer. Which basically is a loop using a <a href="http://nl2.php.net/manual/en/class.directoryiterator.php">DirectoryIterator</a> object. And some var_dump calls revealed the issue. For some reason <a href="http://nl2.php.net/manual/en/splfileinfo.isfile.php">->isFile()</a> was returning <em>(false)</em> for regular files. WTF! Let&#8217;s test that on the command line.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(false)</em></p></blockquote>
<p>Ok so we have an issue here. How big are these files really. A inspection revealed they are all over 2GB. Maybe some 32 bit issue? As the platform the code is running on is a 32 bit server. So i asked my colleagues, Googled a bit and read through php.net. To find out that there is an issue with PHP and files larger then 2GB.</p>
<blockquote><p><a href="https://bugs.php.net/bug.php?id=27792">https://bugs.php.net/bug.php?id=27792</a><br />
<a href="https://bugs.php.net/bug.php?id=48886">https://bugs.php.net/bug.php?id=48886</a><br />
<a href="http://nl.php.net/manual/en/function.filesize.php">http://nl.php.net/manual/en/function.filesize.php</a></p></blockquote>
<p>Those however all seem related to filesize. The filesize function manual page even has a note about it. Maybe it&#8217;s related?</p>
<blockquote><p>    <strong>Note:</strong> Because PHP&#8217;s integer type is signed and many platforms use 32bit integers, <strong>filesize() </strong> may return unexpected results for files which are larger than <strong>2GB</strong>. For files between 2GB and 4GB in size this can usually be overcome by using <strong>sprintf(&#8220;%u&#8221;, filesize($file))</strong>. </p></blockquote>
<p>But i can&#8217;t apply that patch on a production server. So i came up with a simple solution for now. I extended the <a href="http://nl2.php.net/manual/en/class.directoryiterator.php">DirectoryIterator</a> class and have overwritten the <em>isFile</em> method. Which works for now (don&#8217;t think this will work on windows).</p>
<pre name="code" class="php">
Class MyDirectoryIterator extends DirectoryIterator {
	public function isFile() {
		return (integer) exec("[ -f {$this->getPathname()} ] &#038;&#038; echo 1 || echo 0");
	}
}
</pre>
<p>Convinced it was a 32 bit issue. I came home later that day. And wanted to try it out on my own desktop. That is a 32 bit system and runs Ubuntu 11.04. To my surprise the result was different then i expected.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(true)</em></p></blockquote>
<p>I used the same files as before. And tested some more big files. But the result was the same. Weird. Let&#8217;s try some other 32 bit machines.</p>
<blockquote><p>Ubuntu 11.04: bool(true)</p>
<p>CentOS release 5.6 (Final): bool(false)<br />
Debian 6.0.2 (squeeze): bool(false)</p></blockquote>
<p>Only my desktop at home seems to have a good result. Ubuntu must have some patch somewhere to fix this issue? To confirm i compiled PHP 5.3.8 from source. And did the same test again on Ubuntu 11.04. And this time it was <em>(false)</em>.</p>
<blockquote><p>$ php -r &#8220;var_dump(is_file(&#8216;/some/file.ext&#8217;));&#8221;;<br />
<em>bool(false)</em></p></blockquote>
<p>I am not really in the mood to search the Ubuntu <a href="http://changelogs.ubuntu.com/changelogs/pool/main/p/php5/">changelog</a>. And for now the work around will do. But i really would like to know what patch is applied to resolve the issue.</p>
<p><strong>[ update ]</strong></p>
<p>While applying the patch for the is_file issue. I was confronted with the fact that way more function calls cause issues. So while waiting for PHP to get patched i had to create some workarounds for the time being.</p>
<p>Getting the filesize:</p>
<pre name="code" class="php">
(integer) exec("stat -c%s {$file->getFilename()}");
</pre>
<p>Calculate a MD5 checksum:</p>
<pre name="code" class="php">
$md5 = exec("md5sum {$file->getFilename()}");
$expl = explode('\t', $md5);
return (string) $expl[0];
</pre>
<p>Calculate the CRC32 checksum:</p>
<pre name="code" class="php">
$hash = exec("cksum {$this->path}");
$expl = explode(' ', $hash);
return $expl[0];
</pre>
<p>Get the modified time:</p>
<pre name="code" class="php">
$stat = explode('.', exec("stat -c%y {$this->path}"));
$timestamp = strtotime($stat[0]);
return $timestamp;
</pre>
<p>Hopefully that will do for now. On a side note the issue is solvable by setting certain <strong>CFLAGS</strong> when compiling PHP. I have no idea what the impact of that will be on the PHP binary. But it does seem to solve the issue. Not sure how one would apply that when PHP is installed from the distro&#8217;s repository though.</p>
<blockquote><p>CFLAGS=&#8221;-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64&#8243; ./configure</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2011/08/php5-filesize-limit-on-32-bit-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
