<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://crunchbang.org/forums/extern.php?action=feed&amp;type=rss&amp;tid=14232" rel="self" type="application/rss+xml" />
		<title><![CDATA[CrunchBang Linux Forums / OSSEC HIDS (with Web UI)]]></title>
		<link>http://crunchbang.org/forums/viewtopic.php?id=14232</link>
		<description><![CDATA[The most recent posts in OSSEC HIDS (with Web UI).]]></description>
		<lastBuildDate>Sat, 23 Jul 2011 15:14:09 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[OSSEC HIDS (with Web UI)]]></title>
			<link>http://crunchbang.org/forums/viewtopic.php?pid=133422#p133422</link>
			<description><![CDATA[<p><a href="http://www.ossec.net/">OSSEC</a> is an Open Source Host-based Intrusion Detection System. It performs log analysis, integrity checking, Windows registry monitoring, rootkit detection, real-time alerting and active response. It runs on most operating systems, including Linux, OpenBSD, FreeBSD, MacOS, Solaris and Windows. </p><p>This guide provides instructions for installing OSSEC with a password protected Web interface over SSL which only accepts connections from localhost. Nmap also cannot guess the server version.</p><p>First <a href="http://www.ossec.net/main/downloads">download OSSEC</a> &amp; uncompress the archive. In the resulting folder run the setup script:</p><div class="codebox"><pre><code>./install.sh</code></pre></div><p>Change the LSB header:</p><div class="codebox"><pre><code>sudo -s
nano /etc/init.d/ossec</code></pre></div><p>&amp; replace the header information with the following:</p><div class="codebox"><pre><code># OSSEC         Controls OSSEC HIDS
# Author:       Daniel B. Cid &lt;dcid@ossec.net&gt;
# Modified for slackware by Jack S. Lai
# Modified for Debian Squeeze by Ben Jackson &lt;bbj@mayhemiclabs.com&gt;
### BEGIN INIT INFO
# Provides:          ossec
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start/stop OSSEC Host Intrusion Detection System
### END INIT INFO</code></pre></div><p>&amp; update the init scripts &amp; start OSSEC:</p><div class="codebox"><pre><code>update-rc.d ossec defaults
service ossec start</code></pre></div><p>Install the web server &amp; enable FastCGI:</p><div class="codebox"><pre><code>apt-get install lighttpd php5-cgi apache2-utils
lighty-enable-mod fastcgi</code></pre></div><p>Now install the Web UI &amp; verify the file integrity:</p><div class="codebox"><pre><code>wget http://www.ossec.net/files/ui/ossec-wui-0.3.tar.gz
wget http://www.ossec.net/files/ui/ossec-wui-0.3-checksum.txt
wget http://www.ossec.net/files/ui/ossec-wui-0.3.tar.gz.sig
md5 ossec-wui-0.3.tar.gz
sha1 ossec-wui-0.3.tar.gz
gpg --verify ossec-wui-0.3.tar.gz.sig ossec-wui-0.3.tar.gz</code></pre></div><p>Uncompress the archive &amp; move it into the web root &amp; run the setup script:</p><div class="codebox"><pre><code>tar -zxvf ossec-wui-0.3.tar.gz
mv ossec-wui-0.3 /var/www/htdocs/ossec-wui
cd /var/www/htdocs/ossec-wui
./setup.sh</code></pre></div><p>Add your web server user (<strong>www-data</strong>) to the ossec group: </p><div class="codebox"><pre><code>nano /etc/group
   ..
   From:
       ossec:x:1002:
   To:
       ossec:x:1002:www-data</code></pre></div><p>&amp; fix the permissions on tmp in the ossec-wui directory:</p><div class="codebox"><pre><code>chmod 770 tmp/
chgrp www-data tmp/</code></pre></div><p>Create a digest file to use inside mod_auth (replacing <strong>yourusername</strong> with your own):</p><div class="codebox"><pre><code>htdigest -c /etc/lighttpd/www-root.user &quot;ossec wui&quot; yourusername</code></pre></div><p>Add the digest information to mod_auth:</p><div class="codebox"><pre><code>nano /etc/lighttpd/conf-enabled/10-auth.conf</code></pre></div><p>&amp; add the following (replacing <strong>yourusername</strong> with your own):</p><div class="codebox"><pre><code>auth.backend = &quot;htdigest&quot;
auth.backend.htdigest.userfile = &quot;/etc/lighttpd/www-root.user&quot;
auth.require = ( &quot;/ossec-wui&quot; =&gt;
                                (
                                  &quot;method&quot;  =&gt; &quot;digest&quot;,
                                  &quot;realm&quot;   =&gt; &quot;ossec wui&quot;,
                                  &quot;require&quot; =&gt; &quot;user=yourusername&quot;
                                 )
               )</code></pre></div><p>Create a Self Signed SSL Certificate:</p><div class="codebox"><pre><code>mkdir /etc/lighttpd/ssl/domain.com -p
cd /etc/lighttpd/ssl/domain.com
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
chown www-data:www-data /etc/lighttpd/ssl -R
chmod 0600 /etc/lighttpd/ssl/domain.com</code></pre></div><p>To bind the webserver ports to 127.0.0.1 / force SSL on port 80 &amp; only accept connections from 127.0.0.1 use the following config for <strong>/etc/lighttpd/lighttpd.conf</strong>:</p><div class="codebox"><pre class="vscroll"><code>server.modules = (
    &quot;mod_access&quot;,
    &quot;mod_alias&quot;,
    &quot;mod_compress&quot;,
    &quot;mod_redirect&quot;,
    &quot;mod_fastcgi&quot;,
    &quot;mod_auth&quot;,
#   &quot;mod_rewrite&quot;,
)

server.document-root        = &quot;/var/www/htdocs/ossec-wui&quot;
server.upload-dirs          = ( &quot;/var/cache/lighttpd/uploads&quot; )
server.errorlog             = &quot;/var/log/lighttpd/error.log&quot;
server.pid-file             = &quot;/var/run/lighttpd.pid&quot;
server.username             = &quot;www-data&quot;
server.groupname            = &quot;www-data&quot;
server.bind                   = &quot;127.0.0.1&quot;
server.port                    = 81
server.tag                     = &quot;myWebServer v1.0&quot; 
index-file.names            = ( &quot;index.php&quot;, &quot;index.html&quot;, &quot;index.lighttpd.html&quot; )
url.access-deny             = ( &quot;~&quot;, &quot;.inc&quot; )
static-file.exclude-extensions = ( &quot;.pl&quot;, &quot;.fcgi&quot; )

compress.cache-dir          = &quot;/var/cache/lighttpd/compress/&quot;
compress.filetype           = ( &quot;application/javascript&quot;, &quot;text/css&quot;, &quot;text/html&quot;, &quot;text/plain&quot; )
debug.log-request-handling  = &quot;enable&quot; 

include_shell &quot;/usr/share/lighttpd/use-ipv6.pl&quot;
include_shell &quot;/usr/share/lighttpd/create-mime.assign.pl&quot;
include_shell &quot;/usr/share/lighttpd/include-conf-enabled.pl&quot;

$HTTP[&quot;host&quot;] == &quot;127.0.0.1&quot; {
    $HTTP[&quot;remoteip&quot;] != &quot;127.0.0.1&quot; {
        url.access-deny = ( &quot;&quot; )
    }
}  

$SERVER[&quot;socket&quot;] == &quot;127.0.0.1:80&quot; {
  $HTTP[&quot;host&quot;] =~ &quot;(.*)&quot; {
    url.redirect = ( &quot;^/(.*)&quot; =&gt; &quot;https://%1/$1&quot; )
  }
}

$SERVER[&quot;socket&quot;] == &quot;127.0.0.1:443&quot; {
ssl.engine = &quot;enable&quot;
ssl.pemfile = &quot;/etc/lighttpd/ssl/domain.com/server.pem&quot;
}</code></pre></div><p>The above config binds a default port 81 so port 80 can be bound to 127.0.0.1 with SSL forced. Otherwise by default lightppd listens on port 80 on the Default Route (0.0.0.0) which is not what we want for a local install. </p><p>Also change the config for FastCGI in <strong>/etc/lighttpd/conf-enabled/10-fastcgi.conf</strong> to the following:</p><div class="codebox"><pre><code># /usr/share/doc/lighttpd-doc/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi

fastcgi.server = ( &quot;.php&quot; =&gt; ((
                     &quot;bin-path&quot; =&gt; &quot;/usr/bin/php-cgi&quot;, 
                     &quot;socket&quot; =&gt; &quot;/tmp/php.socket&quot;,
                     &quot;max-procs&quot; =&gt; 2,
                     &quot;bin-environment&quot; =&gt; (
                       &quot;PHP_FCGI_CHILDREN&quot; =&gt; &quot;16&quot;,
                       &quot;PHP_FCGI_MAX_REQUESTS&quot; =&gt; &quot;10000&quot;
                     ),
                     &quot;bin-copy-environment&quot; =&gt; (
                       &quot;PATH&quot;, &quot;SHELL&quot;, &quot;USER&quot;
                     ),
                     &quot;broken-scriptfilename&quot; =&gt; &quot;enable&quot;
                 )))</code></pre></div><p><strong>***</strong> If you installed OSSEC in a directory other than the default ( <strong>/opt/ossec</strong> instead of<strong> /var/ossec</strong> ), edit <strong>/var/www/htdocs/ossec-wui/ossec_conf.php</strong> and change the <strong>$ossec_dir</strong> variable to match <strong>***</strong></p><p>Restart lighttpd:</p><div class="codebox"><pre><code>/etc/init.d/lighttpd restart</code></pre></div><p>You should now be able to enter <strong>127.0.0.1</strong> into your browser &amp; be redirected to an SSL login for the OSSEC Web UI.</p><p>I have also posted a <a href="http://crunchbanglinux.org/forums/post/150184/#p150184">guide for setting up a firewall with active intrustion detection.</a></p>]]></description>
			<author><![CDATA[dummy@example.com (tradetaxfree)]]></author>
			<pubDate>Sat, 23 Jul 2011 15:14:09 +0000</pubDate>
			<guid>http://crunchbang.org/forums/viewtopic.php?pid=133422#p133422</guid>
		</item>
	</channel>
</rss>
