<?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>iWebDev&#039;s blog &#187; libfuzzy.so</title>
	<atom:link href="http://www.iwebdev.it/blog/?feed=rss2&#038;tag=libfuzzy-so" rel="self" type="application/rss+xml" />
	<link>http://www.iwebdev.it/blog</link>
	<description>and everything goes around</description>
	<lastBuildDate>Sat, 06 Aug 2011 23:08:45 +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>Fuzzy hashing PHP Extension on OpenBSD 4.9</title>
		<link>http://www.iwebdev.it/blog/?p=209</link>
		<comments>http://www.iwebdev.it/blog/?p=209#comments</comments>
		<pubDate>Thu, 30 Jun 2011 21:15:49 +0000</pubDate>
		<dc:creator>to</dc:creator>
				<category><![CDATA[Forensics]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[fuzzy hashing]]></category>
		<category><![CDATA[libfuzzy.so]]></category>
		<category><![CDATA[php hash extension]]></category>
		<category><![CDATA[ssdeep]]></category>

		<guid isPermaLink="false">http://www.iwebdev.it/blog/?p=209</guid>
		<description><![CDATA[For years, computer forensic investigators have put a great deal of stock in the effectiveness of MD5 hashing. Now to quantify that statement, I mean specifically using MD5 hashes to identify known malicious files. The key word in that sentence is known, but let&#8217;s take that one step further to add the word “unmodified” known [...]]]></description>
			<content:encoded><![CDATA[<p>For years, computer forensic investigators have put a great deal of stock in the effectiveness of MD5 hashing. Now to quantify that statement, I mean specifically using MD5 hashes to identify known malicious files. The key word in that sentence is known, but let&#8217;s take that one step further to add the word “unmodified” known files. One minor change to a file, and the MD5 hash is now completely different, rendering the investigators search totally ineffective. So, what&#8217;s the answer? Easy, <strong>fuzzy hashing</strong>.</p>
<p>Fuzzy hashing allows the discovery of potentially incriminating documents that may not be located using traditional hashing methods.	The use of the fuzzy hash is much like the fuzzy logic search; it is looking for <strong>documents that are similar but not exactly the same</strong>, called homologous files. Homologous files have identical strings of binary data; however they are not exact duplicates. An example would be two identical word processor documents, with a new paragraph added in the middle of one. To locate homologous files, they must be hashed traditionally in segments to identify the strings of identical data.</p>
<p>Download the <strong>ssdeep</strong> package from the following <a title="ssdeep on sourceforge" href="http://ssdeep.sourceforge.net/" target="_blank">link</a>. Once you downloaded it you have to extract and compile the package. The commands to perform these operations are:</p>
<blockquote><p>wget http://downloads.sourceforge.net/project/ssdeep/ssdeep-2.6/ssdeep-2.6.tar.gz?r=http%3A%2F%2Fssdeep.sourceforge.net%2F&amp;ts=1309466525&amp;use_mirror=ovh</p>
<p>tar zxvfp ssdeep-2.6.tar.gz</p></blockquote>
<p>and then</p>
<blockquote><p>./configure &amp;&amp; make &amp;&amp; make install</p></blockquote>
<p>Once you finished to install the tool you can perform this test: (ssdeep -V)</p>
<p><a href="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_version.png"><img class="aligncenter size-medium wp-image-210" title="ssdeep check version" src="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_version-300x160.png" alt="" width="300" height="160" /></a>We have installed the ssdeep tool and it&#8217;s time to proceed to install the <strong>ssdeep PHP extension</strong>. Before to proceed you have to install the <strong>pear</strong> and the <strong>autoconf packages</strong> in order to allow you to use the pecl command:</p>
<blockquote><p>pkg_add -i pear-1.7.2</p>
<p>pkg_add -i autoconf</p>
<p>export AUTOCONF_VERSION=2.64</p></blockquote>
<p>After that you can try to install the PHP extension with the pecl system (<strong>pecl install ssdeep</strong>) but on my side I raised some issue related to the name of the <strong>libfuzzy.so</strong> and the error was</p>
<blockquote><p>checking for ssdeep&#8230; configure: error: &#8220;Could not find &#8216;libfuzzy.so&#8217;. Try specifying the path to the ssdeep build directory.&#8221;</p></blockquote>
<p>If you check in the <strong>/usr/local/lib</strong> folder you should find instead the <strong>libfuzzy.so.2.0</strong> library. In order to avoid this issue I decided to install the extension manually. I download the pecl package from the original path (here the <a title="pecl package ssdeep" href="http://pecl.php.net/package/ssdeep" target="_blank">link</a> to download it). Once you downloaded the package you have to extract it and run the command related to PHP. Here below the commands required:</p>
<blockquote><p>wget http://pecl.php.net/get/ssdeep-1.0.2.tgz</p>
<p>tar zxvfp ssdeep-1.0.2.tar.gz</p>
<p>cd ssdeep-1.0.2</p>
<p>phpize</p>
<p>./configure</p></blockquote>
<p>As you can see from the configure output you raised the same error, so you have to edit the configure file and change the name of the libfuzzy.so required with the <strong>libfuzzy.so.2.0</strong> at line 4174.</p>
<blockquote><p>SSDEEP_LIB_FILENAME=&#8221;lib$SSDEEP_LIB_NAME.so.2.0&#8243;</p></blockquote>
<p>Now you have to perform the make and make install command</p>
<blockquote><p>make &amp;&amp; make install</p></blockquote>
<p>You should get the following message from the shell:</p>
<p><a href="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_php_extension.png"><img class="aligncenter size-medium wp-image-211" title="ssdeep php extension" src="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_php_extension-300x160.png" alt="" width="300" height="160" /></a></p>
<p>The last step is to add the <strong>ssdeep.so extension</strong> in the php.ini:</p>
<blockquote><p>nano /var/www/conf/php.ini</p></blockquote>
<p>and add the following line in the extension section:</p>
<blockquote><p>extension=ssdeep.so</p></blockquote>
<p>Once you saved the file you have to restart the Apache service:</p>
<blockquote><p>apachectl stop</p>
<p>apachectl start</p></blockquote>
<p>If you check the phpinfo file, you should get the following section:</p>
<p><a href="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_extension.png"><img class="aligncenter size-medium wp-image-213" title="ssdeep check extension" src="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_extension-300x66.png" alt="" width="300" height="66" /></a>If you want to check the fully functionality of the extension installed you can copy the &#8220;example.php&#8221; file stored in the pecl package and run it into your webserver. In order to do that you have to perform this command (we supposed to be in ssdeep-1.0.2 folder):</p>
<blockquote><p>mv examples/example.php /var/www/htdocs/</p></blockquote>
<p>and the output should be this:</p>
<p><a href="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_function.png"><img class="aligncenter size-medium wp-image-214" title="ssdeep check PHP function" src="http://www.iwebdev.it/blog/wp-content/uploads/2011/06/ssdeep_check_function-300x25.png" alt="" width="300" height="25" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwebdev.it/blog/?feed=rss2&#038;p=209</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
