<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 12 Feb 2012 20:01:32 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[C. Sadeesh Kumar's Blog: Smart File Type Detection Using PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16785</guid>
      <link>http://www.phpdeveloper.org/news/16785</link>
      <description><![CDATA[<p>
In a new post today <i>C. Sadeesh Kumar</i> has a quick tip to help your script <a href="http://cakephp-php.blogspot.com/2011/08/smart-file-type-detection-using-php.html">detect file types</a> without having to rely on the extension to be correct.
</p>
<blockquote>
In most web applications today, there is a need to allow users to upload images, audio and video files. Sometimes, we also need to restrict certain types of files from being uploaded - an executable file being an obvious example. Security aside, one might also want to prevent users from misusing the upload facility, e.g. uploading copyrighted music files illegally and using the service to promote piracy! In this article, we'll look into a few ways in which we can achieve this.
</blockquote>
<p>
The trick to his example is in using the <a href="http://pecl.php.net/package/Fileinfo">Fileinfo</a> PECL extension. With the help of this extension you can look inside the file and pick out the "magic bytes" (the first few bytes of a file) and see <a href="http://www.garykessler.net/library/file_sigs.html">what MIME type</a> the file really is. He includes a simple example of using the extension on a file and a file upload script that checks the type and handles the file accordingly.
</p>]]></description>
      <pubDate>Mon, 29 Aug 2011 12:07:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ibuildings techPortal: PHP intrusion Detection System (PHPIDS)]]></title>
      <guid>http://www.phpdeveloper.org/news/12987</guid>
      <link>http://www.phpdeveloper.org/news/12987</link>
      <description><![CDATA[<p>
On the Ibuildings techPortal site today <i>Boy Baukema</i> <a href="http://techportal.ibuildings.com/2009/08/03/php-intrusion-detection-system-phpids/">looks at PHPIDS</a>, the PHP intrusion detection system and how it can start to help protect you and your application feel a little safer.
</p>
<blockquote>
Just a reminder to everyone who is interested in WebAppSec and hasn't done so already to try <a href="http://phpids.org/">PHPIDS</a>, the Intrusion Detection System. [...] Installing PHPIDS is easy. Just <a href="http://php-ids.org/downloads/">download the latest version</a> in your preferred format and then <a href="http://php-ids.org/faq/#faq3">review the the FAQ</a> for sample code on how to install it.
</blockquote>
<p>
He does warn on one thing though - the system is a basic intrusion detection system and is not as complex as other detection tools. There were some complains he had about what it thought were intrusions and recommends that you only have it pointing to the external side of your application to cause less hassle in the long run.
</p>]]></description>
      <pubDate>Tue, 04 Aug 2009 08:48:42 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Maurice Svay's Blog: Face detection in pure PHP (without OpenCV)]]></title>
      <guid>http://www.phpdeveloper.org/news/12731</guid>
      <link>http://www.phpdeveloper.org/news/12731</link>
      <description><![CDATA[<p>
<i>Maurice Svay</i> has <a href="http://svay.com/blog/index/post/2009/06/19/Face-detection-in-pure-PHP-(without-OpenCV)">a new blog post</a> that includes a script he's developed to perform facial recognition (detect faces in images) with PHP without the need of the <a href="http://opencv.willowgarage.com/wiki/">Open-CV library</a>.
</p>
<blockquote>
OpenCV seems to perform well but you need to be able to install it on your server. In my case, I wanted to have a pure PHP solution, so it can work with most hosts. So I started to think about implementing it myself. [...] I kept searching and finally found a canvas+javascript implementation of face detection at <a href="http://blog.kpicturebooth.com/?p=8">http://blog.kpicturebooth.com/?p=8</a>. The code looked fairly compact and simple. Shouldn't be hard to port to PHP.
</blockquote>
<p>
The class takes in the filename of an image (just JPG, but could easily be adapted) and <a href="http://svay.com/experiences/face-detection/detection.dat">a data file</a> to use to run the image through the GD image library and output a JPG similar to <a href="http://svay.com/blog/public/images/2009-06-19/detection.jpg">this</a> with the face highlighted by a red square.
</p>]]></description>
      <pubDate>Mon, 22 Jun 2009 12:53:22 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[HowTo Forge: Intrusion Detection For PHP Applications With PHPIDS]]></title>
      <guid>http://www.phpdeveloper.org/news/10473</guid>
      <link>http://www.phpdeveloper.org/news/10473</link>
      <description><![CDATA[<p>
On the HowTo Forge website, there's a <a href="http://howtoforge.com/intrusion-detection-for-php-applications-with-phpids">recently posted article</a> about using the <a href="http://php-ids.org/">IDS tool</a> for PHP to help with intrusion detection for your website.
</p>
<blockquote>
This tutorial explains how to set up <a href="http://php-ids.org/">IDS tool</a> on a web server with Apache2 and PHP5. PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application. The IDS neither strips, sanitizes nor filters any malicious input, it simply recognizes when an attacker tries to break your site and reacts in exactly the way you want it to. 
</blockquote>
<p>
They <a href="http://howtoforge.com/intrusion-detection-for-php-applications-with-phpids">show the steps</a> you'll need to get things installed and working as well as some of the configuration changes you'll need to add/make (including the creation of an auto-prepend file to make using it all over easy).
</p>]]></description>
      <pubDate>Tue, 24 Jun 2008 10:22:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: On PHPUnit and Software Metrics]]></title>
      <guid>http://www.phpdeveloper.org/news/9589</guid>
      <link>http://www.phpdeveloper.org/news/9589</link>
      <description><![CDATA[<p>
In one of his latest entries, <i>Sebastian Bergmann</i> <a href="http://sebastian-bergmann.de/archives/744-On-PHPUnit-and-Software-Metrics.html">answers a question</a> from another blogger about the future of <a href="http://sebastian-bergmann.de/archives/689-PHPUnit-and-Software-Metrics.html">software metrics</a> and <a href="http://sebastian-bergmann.de/archives/690-PHPUnit-as-a-Project-Mess-Detector.html">project mess detection</a> as a part of the <a href="http://www.phpunit.de">PHPUnit</a> project.
</p>
<blockquote>
When I started to work on these projects, there was no other place for me then to develop them as part of PHPUnit. [...] But the more I thought about it, I realized that these features do not belong into PHPUnit but into a suite of tools that PHPUnit is a well-integrated part of.
</blockquote>
<p>
He did, however, include it as a part of the <a href="http://sebastian-bergmann.de/archives/720-PHPUnit-3.2.html">PHPUnit 3.2</a> release at that time. Now, however, there are the tools and platforms to make those tests useful outside of the PHPUnit environment and is allowing him to <a href="http://www.phpunit.de/changeset/2377">move it out</a> from the testing application and on to <a href="http://www.phpunit.de/changeset/2351">closer integration</a> with other software.
</p>]]></description>
      <pubDate>Fri, 08 Feb 2008 09:31:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Copy & Paste Detection in PHPUnit 3.2]]></title>
      <guid>http://www.phpdeveloper.org/news/8508</guid>
      <link>http://www.phpdeveloper.org/news/8508</link>
      <description><![CDATA[<p>
<i>Sebastian Bergmann</i> <a href="http://sebastian-bergmann.de/archives/693-Copy-Paste-Detection-in-PHPUnit-3.2.html">spotlights another feature</a> of the upcoming <a href="http://www.phpunit.de/">PHPUnit</a> version 3.2 - the inclusion of a <a href="http://sebastian-bergmann.de/archives/690-PHPUnit-as-a-Project-Mess-Detector.html">Project Mess Detector</a>'s ability to help find duplicate code.
</p>
<blockquote>
Duplicate code can be hard to find, especially in a large project. Johann-Peter Hartmann of <a href="http://www.mayflower.de/">MAYFLOWER GmbH</a> recently implemented <a href="http://pmd.sourceforge.net/cpd.html">Copy & Paste Detection</a> for PHPUnit's growing set of features that extends its usage scenarios beyond "just unit testing" to a one-stop solution for quality assurance in PHP-based projects.
</blockquote>
<p>
In <a href="http://sebastian-bergmann.de/archives/693-Copy-Paste-Detection-in-PHPUnit-3.2.html">his example</a>, <i>Sebastian</i> shows what the response will look like when the tests find duplicate code - giving details like the files involved and the code fragment that was duplicated.
</p>
<p>
Check out <a href="http://sebastian-bergmann.de/archives/689-PHPUnit-and-Software-Metrics.html">this list</a> in another post on <i>Sebastian</i>'s blog for more of the metrics that will be included in the upcoming version.
</p>]]></description>
      <pubDate>Wed, 22 Aug 2007 09:31:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Tutorial: An Introduction to PHPIDS (PHP-Intrusion Detection System)]]></title>
      <guid>http://www.phpdeveloper.org/news/8080</guid>
      <link>http://www.phpdeveloper.org/news/8080</link>
      <description><![CDATA[<p>
After several weeks of work Mario Heiderich, Lars Strojny and of course myself released the
first stable versions of the PHPIDS - currently at version 0.2.2. 
</p>
<p>
You will find the project site on <a href="http://php-ids.org/">http://php-ids.org/</a>
</p>
<p>
In this article I would like to present our framework and explain how it can be used, hoping
that developers consider it useful to make their application more secure.
</p>
<p>
The PHPIDS is a system that is meant to be an additional layer of security for any PHP based 
website or web application. In fact, this layer does not filter input - that would be a task
for different layers - but it makes sure that no potential attack against the application
goes unnoticed. 
</p>
<p>
Based on a collection of heavily tested regular expressions the PHPIDS is able to efficiently
recognize, classify and ultimately react on many different kinds of attacks - including,
besides others, XSS, SQL injection, directory traversal, String.fromCharcode attacks,
halfwidth/fullwidth encoding attacks and remote code execution. Due to its flexible and easy
configuration the PHPIDS reaction will happen in exactly the way the developer intends.
</p>
<p>
The integration is as simple as can be. Besides PHP 5.2 the only necessary extension is
SimpleXML and the following code:
</p>
[php]
<?php
set_include_path('../../lib/');
require_once 'IDS/Monitor.php';
require_once 'IDS/Filter/Storage.php';

try {

    // instanciate the storage object and fetch the rules
    $storage = new IDS_Filter_Storage();
    $storage->getFilterFromXML('../../lib/default_filter.xml');
    
    /*
    * Instanciate the IDS and start the detection
    * 
    * here we are using $_GET but you can pass any 
    * array you want like $_SERVER, $_SESSION etc.
    */
    $get = new IDS_Monitor($_GET, $storage);
    $report = $get->run();

    if (!$report->isEmpty()) {
        
        // Get the overall impact
        echo "Impact: {$report->getImpact()}n";
        
        // Get array of every tag used
        echo 'Tags: ' . join(', ', $report->getTags()) . "n";
        
        // Iterate through the report and get every event (IDS_Event)
        foreach ($report as $event) {
            echo "Variable: {$event->getName()} | Value: {$event->getValue()}n";
            echo "Impact: {$event->getImpact()} | Tags: " . join(", ", $event->getTags()) . "n";
            
            // Iterator throught every filter 
            foreach ($event as $filter) {
                echo "Description: {$filter->getDescription()}n";
                echo "Tags: " . join(", ", $filter->getTags()) . "n";
            }
        }
    }
    
    /*
    * Additionally you have the option to store the detected
    * data using IDS_Log_Composite and for example IDS_Log_File
    */
    require_once '../../lib/IDS/Log/File.php';
    require_once '../../lib/IDS/Log/Composite.php';
   
    $compositeLog = new IDS_Log_Composite();
    $compositeLog->addLogger(
       IDS_Log_File::getInstance('log.txt')
    );
    
    if (!$report->isEmpty()) {
        $compositeLog->execute($report);
    }

} catch (Exception $e) {
    printf(
        'An error occured: %s',
        $e->getMessage()
    );
}
?>
[/php]
<p>
Ideally the PHPIDS should be included in a central position of the application or even better
via auto_prepend_file. If an attack takes place the IDS result object will be returned filled
with data and the programmer can decide the appropriate reaction. For the most part decisions
about the reaction are dependent on the detected attacks' cumulative impact. 
</p>
<p>
The impact variable acts as an indicator for an attack's severity and can be used to grade the
application's reaction on that attack. For example, if the impact was 3, an appropriate response
might be to log the issue in a file, whereas if the impact was around 12, a warning mail to the
site owner might be more applicable whilst an impact of 24 or above might print out a message
to the attacker stating that his intrusion attempt has been detected and request aborted.
</p>
<p>
The PHPIDS is heavily tested via phpUnit and profiles via xdebug meaning that you can expect
a minimal performance hit to your applications. We are currently using the PHPIDS with great
success on several high traffic sites; ormigo.com and neu.de being the two foremost examples
of this. Documentation and support is available on the project site or via our forum. Future
development for the PHPIDS will possibly rank around detection of fragmented XSS and enhanced
detection of heavily encoded attack vectors.
</p>
<p>
For users of .NET there's the .NETIDS written by Martin Hinks which is a port of the PHPIDS
and uses the same filter rules. You will find any related resources on the .NETIDS project
page (<a href="http://code.google.com/p/dotnetids/">http://code.google.com/p/dotnetids/</a>). Support for the .NETIDS is also available in the PHPIDS forum.
</p>
<p>
Regards, Christian Matthies & Mario Heiderich
</p>]]></description>
      <pubDate>Tue, 19 Jun 2007 15:28:56 -0500</pubDate>
    </item>
  </channel>
</rss>

