<?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>All Free For You</title>
	<atom:link href="http://tusforyou.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tusforyou.com</link>
	<description></description>
	<lastBuildDate>Thu, 04 Mar 2010 17:51:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon</title>
		<link>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p2/</link>
		<comments>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p2/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:58:03 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[
Install Prewikka
Prewikka is the graphical frontend to Prelude, using a web server.

&#160;
Installation
Prewikka requires two databases: one to get the Prelude alerts (which is the same as configured before), and one to store its own data (prewikka). Actually, the Ubuntu packages does only create the prewikka database, and does not configure access to Prelude alerts, so [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span id="more-2046"></span></p>
<h3>Install Prewikka</h3>
<p>Prewikka is the graphical frontend to Prelude, using a web server.<br />
</p>
<p>&nbsp;</p>
<h4>Installation</h4>
<p>Prewikka requires two databases: one to get the Prelude alerts (which is the same as configured before), and one to store its own data (prewikka). Actually, the Ubuntu packages does only create the <i>prewikka</i> database, and does not configure access to Prelude alerts, so alert installation needs to be done manually.</p>
<p>&nbsp; </p>
<h4>
Install Prewikka</h4>
<p class="command">apt-get install prewikka</p>
<p>The package will install required dependencies (python, for ex), and will ask for the database configuration. As for Prelude,<br />
we choose to use dbconfig-common, give the administrator password and<br />
press enter for the DB password to let dbconfig-common generate one for<br />
us.</p>
<p>&nbsp;</p>
<h4>Configure Prelude-Manager Access</h4>
<p>Get the password from prelude-manager configuration file <i>/etc/prelude-manager/prelude-manager.conf </i>and edit prewikka configuration file <i>/etc/prewikka/prewikka.conf</i>:<br />
</p>
<p class="command">vi /etc/prewikka/prewikka.conf</p>
<pre>[idmef_database]
type: mysql
host: localhost
user: prelude
pass: **********
name: prelude
</pre>
<p>The [database] section is automatically configured by dbconfig-common, so do not modify it.<br />
</p>
<p>&nbsp;</p>
<h4>Web Server Configuration:</h4>
<p>The configuration is explained in file <i>/usr/share/doc/prewikka/README.Debian</i>. You can choose between 3 configurations:<br />
</p>
<ul>
<li>Apache / CGI setup with VirtualHost
</li>
<li>Apache / mod_python setup with VirtualHost
</li>
<li>Prewikka from the command line tool
</li>
</ul>
<p>As an example I&#8217;ll use the <i>mod_python</i> setup.</p>
<p class="command">apt-get install libapache2-mod-python</p>
<p>&nbsp;Add a VirtualServer to your apache configuration with the following content:</p>
<pre>NameVirtualHost *&lt;VirtualHost *&gt;        ServerAdmin admin@domain.com        &lt;Location /&gt;                SetHandler mod_python                PythonHandler prewikka.ModPythonHandler                PythonOption PrewikkaConfig /etc/prewikka/prewikka.conf        &lt;/Location&gt;

        &lt;Location /prewikka&gt;                SetHandler None        &lt;/Location&gt;

        Alias /prewikka /usr/share/prewikka/htdocs        Alias /htdocs /usr/share/prewikka/htdocs&lt;/VirtualHost&gt;</pre>
<p>Restart you apache webserver and you can login to the prewikka interface.</p>
<p>Note: you can of course always us a setting for apache like:</p>
<pre>NameVirtualHost xxx.xxx.xxx.xxx:80
&lt;VirtualHost prewikka.yourdomain.tld:80&gt;</pre>
<p>This is usefull when you have other services running on your apache server.</p>
<p>&nbsp;</p>
<h3>Part 2: Installing And Configuring Snort</h3>
<p>I will not write the complete howto for this since there is a hwto for snort: <a href="http://tusforyou.com/intrusion-detection-with-snort-mysql-apache2-on-ubuntu-7.10-updated" target="_blank">Intrusion Detection: Snort, Base, MySQL, and Apache2 On Ubuntu 7.10 (Gutsy Gibbon) (Updated)</a>.</p>
<p>I&#8217;ll describe here the steps necessary to have <i>snort</i> logging to <i>prelude</i>. In this setup you also don&#8217;t need to install a <i>mysql</i> database and the base webinterface since <i>snort</i> will log to <i>prelude</i> and you can use the <i>prewikka</i> interface to see the <i>snort</i> alerts.&nbsp;</p>
<p>Follow all of the steps described in the howto above and replace the entry below with the new one:</p>
<p><i>Replace</i>&nbsp;</p>
<p class="command">./configure -enable-dynamicplugin &#8211;with-mysql<br />
make<br />make install</p>
<p><i>With</i></p>
<p class="command">./configure -enable-dynamicplugin &#8211;eanble-prelude<br />
make<br />
make install</p>
<p>Instead of doing:</p>
<p><i>Scroll down the list to the section with &#8220;<b># output database: log, mysql, user=</b>&#8220;, remove the &#8220;<b>#</b>&#8221; from in front of this line.<br />
  Change the &#8220;<b>user=root</b>&#8221; to &#8220;<b>user=snort&#8221;</b>, change the &#8220;<b>password=password</b>&#8221; to &#8220;<b>password=snort_password</b>&#8220;, &#8220;<b>dbname=snort</b>&#8220;<br />
Make note of the username, password, and dbname. You will need this information when we set up the Mysql db.<br />
Save and quit.</i></p>
<p>Do:</p>
<p><i>Scroll down the list to the section with &#8220;# <b>output alert_prelude: profile=snort</b>&#8220;, remove the &#8220;#é in front of this line and that&#8217;s it.</i></p>
<p>From step 5 on (<b>5. Set up the Mysql database.</b>) everything can be skipped. </p>
<p>Now we have to register the snort agent to the <i>prelude manager</i>:</p>
<p class="command">prelude-adduser register snort &#8220;idmef:w&#8221; &lt;manager address&gt; &#8211;uid snort &#8211;gid snort</p>
<p>On the <i>prelude manager</i> server:</p>
<p class="command">prelude-adduser registration-server prelude-manager</p>
<p>This will register the snort agent to the prelude manager, as you did above for the prelude-lml.</p>
<p>Once the registration process is complete run:</p>
<p class="command">snort -c /etc/snort/snort.conf</p>
<p>If everything goes right than you will see:</p>
<p class="system">Initializing Network Interface eth0<br />
Decoding Ethernet on interface eth0<br />- Connecting to 127.0.0.1:4690 prelude Manager server.<br />- TLS authentication succeed with Prelude Manager.</p>
<p>The entry eth0 depends on the ethernet adapter you specified. Important is that you see that snort is connecting to the prelude manager server and tls authentication was successfull.</p>
<p>If the agent is connecting, and you see <i>snort</i> in the agent list of <i>prewikka</i> than you can stop the process with ctrl-c and issue:</p>
<p class="command">snort -c /snort/snort.conf -D</p>
<p>&nbsp;to start <i>snort</i> as a daemon. In the line above you can always add <span class="system">-i ethX</span> if you don&#8217;t listen on all network interfaces and want to specify a specific interface.</p>
<div class="book">
<div class="tree"></div>
<div class="nav1">
<div class="links">
<div class="prev"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon" title="View the previous page.">previous</a></div>
<div class="next"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p3" title="View the next page.">next</a></div>
<div class="up"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon" title="View this page&#39;s parent section.">up</a></div>
</p></div>
<div class="titles">
<div class="prev">Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon</div>
<div class="next">Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon &#8211; Page 3</div>
</p></div>
</p></div>
</p></div>
</p>
<div class="copyright-footer">Copyright © 2008 Miguel Brams<br />All Rights Reserved.
</div>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon</title>
		<link>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon/</link>
		<comments>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:58:01 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Detection]]></category>
		<category><![CDATA[Gibbon]]></category>
		<category><![CDATA[Gutsy]]></category>
		<category><![CDATA[HbIDS]]></category>
		<category><![CDATA[HIDS]]></category>
		<category><![CDATA[Intrusion]]></category>
		<category><![CDATA[OSSEC]]></category>
		<category><![CDATA[Prelude]]></category>
		<category><![CDATA[Snort]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon/</guid>
		<description><![CDATA[Everybody knows the problem, you have a IDS tool(s) installed and every tool has his own interface. Prelude will allow to log all of the events to the prelude database
and be consulted using one interface (prewikka). This howto will
describe how to install and configure the different tools that will
make up the complete solution.
Intrusion Detection: Snort [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Everybody knows the problem, you have a IDS tool(s) installed and every tool has his own interface. Prelude will allow to log all of the events to the prelude database<br />
and be consulted using one interface (prewikka). This howto will<br />
describe how to install and configure the different tools that will<br />
make up the complete solution.<span id="more-2045"></span></p>
<h2>Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon</h2>
<p>Everybody knows the problem, you have a IDS tool(s) installed and every tool has his own interface.</p>
<p>Prelude will allow to log all of the events to the prelude database and be consulted using one interface (prewikka). This howto will describe how to install and configure the different tools that will make up the complete solution.</p>
<p>This howto is based on bits and scraps I found in order to resolve some issues, parts from the manuals and my own experiance with installing the complete solution.</p>
<p>For more information on snort visit: <a href="http://www.snort.org" target="_blank">www.snort.org</a></p>
<p>For more information on ossec visit: <a title="www.ossec.net" href="http://www.ossec.net" target="_blank">www.ossec.net</a></p>
<p>For more information on prelude visit: <a title="http://www.prelude-ids.org/" href="http://www.prelude-ids.org/" target="_blank">www.prelude-ids.org</a></p>
<p>&nbsp;</p>
<h3>Prerequisites:</h3>
<p>Let&#8217;s just assume you followed the <a href="http://tusforyou.com/perfect_server_ubuntu7.10" target="_blank">The Perfect Server &#8211; Ubuntu Gutsy Gibbon (Ubuntu 7.10)</a>. If not follow that howto and only install / add those part&#8217;s you havent got installed on your system.</p>
<p>The following packages are useful, so please check that they are installed correctly:</p>
<p class="command">apt-get install ntpdate<br />apt-get install dbconfig-common<br />
</p>
<p>&nbsp;</p>
<h3>Installing And Configuring Prelude</h3>
<p>Normally, we would have to compile and install <i>libprelude</i>, <i>libpreludedb</i>, and then create the databases. Luckely enough the packages are provide by the Ubuntu repositories.</p>
<p>&nbsp;</p>
<h4>Prelude Manager</h4>
</p>
<p class="command">apt-get install prelude-manager</p>
<p class="system">- Using default TLS settings from /etc/prelude/default/tls.conf:<br />
  &#8211; Generated key size: 1024 bits.<br />
  &#8211; Authority certificate lifetime: unlimited.<br />
  &#8211; Generated certificate lifetime: unlimited.</p>
<p>  &#8211; Creating analyzer prelude-manager.<br />
  &#8211; Creating /etc/prelude/profile/prelude-manager&#8230;<br />
  &#8211; Allocated ident for prelude-manager: 4232957740008155.<br />
  &#8211; Generating RSA private key&#8230; This might take a very long time.<br />
  [Increasing system activity will speed-up the process.]</p>
<p>  &#8211; Generating 1024 bits RSA private key&#8230;</p>
<p>During the installation, the manager will create the profile for the <i>prelude</i> user. It can take a (very) long time, since GnuTLS tries to access <i>/dev/random</i> instead of <i>/dev/urandom</i><br />
(for security reasons). This may change in the future (maybe using an<br />
option to have a faster generation, but crytographically less secure).<br />
</p>
<p>dbconfig will then ask you if you want it to configure the database<br />
automatically. If you don&#8217;t want to, just say no, and configure<br />
everything manually (the sql scripts are in directory <i>/usr/share/libpreludedb/</i>). Let&#8217;s suppose the answer is yes.</p>
<p><i>Note</i>: the number of questions may change, depending on debconf verbosity (set using <i>dpkg-reconfigure debconf</i>), and dbconfig parameters, in file <i>/etc/dbconfig-common/config.</i></p>
<p class="system">configure database with dbconfig-common: yes<br />database type:</p>
<p>Set the type to the database you previously installed. In this case <span class="system">mysql</span>.</p>
<p class="system">Database admin password: ******</p>
<p>dbconfig-common will ask for a password for the &#8216;prelude&#8217;<br />
user. If you don&#8217;t provide any (just pressing enter), it will generate<br />
a random one. Don&#8217;t worry, the configuration file will be update<br />
automatically.</p>
<p class="system">dbconfig-common: writing config to /etc/dbconfig-common/prelude-manager.conf</p>
<p>Creating config file /etc/dbconfig-common/prelude-manager.conf with new version<br />granting access to database prelude for prelude@localhost: success.<br />verifying access for prelude@localhost: success.<br />creating database prelude: success.<br />verifying database prelude exists: success.<br />populating database via sql&#8230;  done.<br />dbconfig-common: flushing administrative password<br />Starting Prelude Manager: prelude-manager.</p>
<p>The Ubunty package automatically<br />
creates the user and the database for prelude. If you want to change the password, do so first in mysql and after in<i> /etc/prelude-manager/prelude-manager.conf</i>.<br />
</p>
<p>Prelude-Manager should now be running:<br />
</p>
<p class="command">ps auxw | grep manager</p>
<p class="system">prelude 28530  0.0  0.1  59384  4480 ?        Ssl  13:49   0:00 /usr/sbin/prelude-manager</p>
<p>The first part is over, you now have a manager up and running.<br />
</p>
<p class="system">Listen address:</p>
<p>The default listen address is localhost (127.0.0.1). This means that you have to change this to add sensors on different hosts in order for the agents to be able to reach the prelude-manager.</p>
<p>Edit&nbsp; <i>/etc/prelude-manager/prelude-manager.conf</i>:</p>
<pre>listen = xxx.xxx.xxx.xxx</pre>
<p>Restart the server, and check the address (if you changed the address):</p>
<p class="command"># /etc/init.d/prelude-manager stop</p>
<p class="system">   Stopping Prelude Manager: prelude-manager.</p>
<p class="command"># /etc/init.d/prelude-manager start</p>
<p class="system">Starting Prelude Manager: prelude-manager.</p>
<p class="command"># netstat -pantu | grep prelude</p>
<p class="system">tcp        0      0 192.168.66.1:4690          0.0.0.0:*      LISTEN     30544/prelude-manager</p>
<p>&nbsp;</p>
<h4>Prelude-LML</h4>
<p>You need to install <i>prelude-lml</i> on every host you want to monitor. Prelude-LML will analyze your logs and reports event to the managers.<br />
</p>
<p class="command"># apt-get install prelude-lml</p>
<p class="system">&#8230;<br />
Starting Prelude LML: prelude-lml.</p>
<p>Before it can be used, two things needs to be done:<br />
</p>
<ul>
<li>The address of the manager must be configured on the lml
</li>
<li>The manager won&#8217;t trust sensors, until they are registered
</li>
</ul>
<p><i>Manager address</i></p>
<p>If you changed the address the manager is listening on, you need to change the address in the client config on every machine you install <i>prelude-lml</i> .</p>
<p>The adress of the manager is stored in file <i>/etc/prelude/default/client.conf</i>:<br />
</p>
<pre>[prelude]server-addr = 127.0.0.1</pre>
<p><i>Registering the sensor</i></p>
<p>Registering the sensor is a four-step process, which requires to run commands on both the sensor and the manager:</p>
<p>On the LML client, run the register command:</p>
<p class="command">prelude-adduser register prelude-lml &#8220;idmef:w&#8221; &lt;manager address&gt; &#8211;uid 0 &#8211;gid 0</p>
<p><i>Tip</i>: if you don&#8217;t remember the command, just run <i>prelude-lml</i>. Since it is not registered, it will fail, but is smart enough to display the help:<br />
</p>
<p class="system"># prelude-lml <br />- Subscribing plugin pcre[default]<br />- pcre plugin loaded 394 rules.<br />- Monitoring /var/log/messages through pcre[default]<br />* WARNING: /var/log/everything/current does not exist.<br />prelude-client: error starting prelude-client: could not open &#8216;/etc/prelude/profile/prelude-lml/analyzerid&#8217; for reading</p>
<p>Profile &#8216;prelude-lml&#8217; does not exist. In order to create it, please run:<br />prelude-adduser register prelude-lml &#8220;idmef:w&#8221; &lt;manager address&gt; &#8211;uid 0 &#8211;gid 0.</p>
<p>LML must be registered with uid and gid 0, since the process will be executed as root (to be able to analyze logs).<br />
</p>
<p>LML will then one for the One-Time Password(OTP), which will be provided by the manager:<br />
</p>
<p class="system">Enter the one-shot password provided by the &#8220;prelude-adduser&#8221; program:<br />- enter registration one-shot password:</p>
<p>On the manager, run the following:</p>
<p class="command">prelude-adduser registration-server prelude-manager</p>
<p class="system">&#8230;<br />
  &#8211; Starting registration server.<br />
  &#8211; generated one-shot password is &#8220;dummypass&#8221;.<br />
  &#8230;</p>
<p>Enter the password to the LML prompt:</p>
<p class="system">  &#8211; enter registration one-shot password:<br />
- confirm registration one-shot password:<br />- connecting to registration server (127.0.0.1:5553)&#8230;<br />- Anonymous authentication to registration-server successful.<br />- Sending certificate request.</p>
<p>The LML is now waiting for the Manager to sign the certificate.</p>
<p>On the manager, validate the certificate signing request:</p>
<p class="system">- Anonymous authentication one-shot password check successful.<br />
- Waiting for client certificate request.<br />- Analyzer with ID=&#8221;3559090256170900&#8243; ask for registration with permission=&#8221;idmef:w&#8221;.<br />Approve registration [y/n]: y<br />The certificate is generated and sent to the client:<br />- Registering analyzer &#8220;3559090256170900&#8243; with permission &#8220;idmef:w&#8221;.<br />- Generating signed certificate for client.<br />- Sending server certificate to client.<br />- ::ffff:127.0.0.1:47054 successfully registered.</p>
<p>On the client you will see:</p>
<p class="system">LML registration is successful<br />
- Receiving signed certificate.<br />- Receiving CA certificate.<br />- prelude-lml registration to 127.0.0.1 successful.</p>
<p>Now, the manager and the sensor have a trust relation, and can send messages to each other.<br />
<br />
This process takes some time, but it increases security and th communication between the sensor and the manager is encrypted.<br />
Finally, the LML sensor should be up too:<br />
</p>
<p class="command">/etc/init.d/prelude-lml start</p>
<p class="system">Starting Prelude LML: prelude-lml.<br />
  ps auxw | grep lml<br />
  root      1946  0.3  0.0  20856  3424 ?        Ss   14:35   0:00 /usr/bin/prelude-lml -d -q -P /var/run/prelude-lml.pid</p>
<p>This concludes the first part.</p>
<div class="book">
<div class="tree">
<div class="menu1">
<ul>
<li class="leaf"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p2">Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon &#8211; Page 2</a></li>
<li class="leaf"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p3">Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon &#8211; Page 3</a></li>
</ul>
</div>
<div class="nav1">
<div class="links">
<div class="prev">&nbsp;</div>
<div class="next"><a href="snort-ossec-prelude-on-ubuntu-gutsy-gibbon-p2" title="View the next page.">next</a></div>
</div>
<div class="titles">
<div class="next">Intrusion Detection: Snort (IDS), OSSEC (HbIDS) And Prelude (HIDS) On Ubuntu Gutsy Gibbon &#8211; Page 2</div>
</div>
</div>
</div>
<p>
<div class="copyright-footer">Copyright © 2008 Miguel Brams<br />All Rights Reserved.
</div>
</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/snort-ossec-prelude-on-ubuntu-gutsy-gibbon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meet the Anti-Nmap: PSAD (EnGarde Secure Linux)</title>
		<link>http://tusforyou.com/psad-port-scan-attack-detector-on-engarde-secure-linux/</link>
		<comments>http://tusforyou.com/psad-port-scan-attack-detector-on-engarde-secure-linux/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:59 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Anti]]></category>
		<category><![CDATA[EnGarde]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Meet]]></category>
		<category><![CDATA[Nmap]]></category>
		<category><![CDATA[PSAD]]></category>
		<category><![CDATA[Secure]]></category>

		<guid isPermaLink="false">http://tusforyou.com/psad-port-scan-attack-detector-on-engarde-secure-linux/</guid>
		<description><![CDATA[Having a great defense involves proper detection and recognition of an
attack. In our security world we have great IDS tools to properly
recognize when we are being attacked as well as firewalls to prevent
such attacks from happening. However, certain attacks are not blindly
thrown at you &#8211; a good attacker knows that a certain amount of
reconnaissance and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Having a great defense involves proper detection and recognition of an<br />
attack. In our security world we have great IDS tools to properly<br />
recognize when we are being attacked as well as firewalls to prevent<br />
such attacks from happening. However, certain attacks are not blindly<br />
thrown at you &#8211; a good attacker knows that a certain amount of<br />
reconnaissance and knowledge about your defenses greatly increases the<br />
chances of a successful attack. How would you know if someone is<br />
scanning your defenses? Is there any way to properly respond to such<br />
scans? You bet there is&#8230;<span id="more-2044"></span></p>
<h2>Meet the Anti-Nmap: PSAD (EnGarde Secure Linux) </h2>
<p>(by Eckie S. from Linuxsecurity.com)<br />
The Port Scan Attack Detector (psad) is an excellent tool for detecting various types of suspicious traffic, including port scans from popular tools such as Nmap, DDoS attacks, and other efforts to brute force certain protocols on your system.&nbsp; By analyzing firewall logs, psad can not only pick up on certain attack patterns, but even manipulate firewall rules to properly respond to suspicious activity.<br />
This article will walk the reader through an EnGarde Secure Linux implementation of psad, from the initial iptables rules setup to the deployment of psad on the server side.&nbsp; By the end of the article, the user will be able to detect certain Nmap scans and have psad respond to these scans by blocking the source.<br />
&nbsp;</p>
<h3>Prerequisites</h3>
<p>You will need:</p>
<p>&nbsp; &#8211; A machine with EnGarde Secure Community 3.0.18 or above installed to do your development on.&nbsp; These commands should NOT be run on a production server since psad will eventually deny any type of access from the remote scanning machine!<br />
&nbsp; &#8211; A separate machine on the same network with Nmap installed on it.&nbsp; You will be running certain scans on the server from this machine.<br />
Once you have all the above you may log in as root, transition over to sysadm_r, and disable SELinux:</p>
<p class="command">newrole -r sysadm_r<br />
<span class="system">&nbsp; [psad_server]# newrole -r sysadm_r <br />
&nbsp; Authenticating root.<br />
&nbsp; Password:</p>
<p>&nbsp; [psad_server]# setenforce 0</span></p>
<p>Throughout the HowTo, the server will be referred to as psad_server and the Nmap scanning machine as nmap_scanner.<br />
&nbsp;</p>
<h3>Install psad</h3>
<p>EnGarde Secure Linux makes the installation of psad a breeze due to its Guardian Digital Secure Network (GDSN).&nbsp; You can install the package through the command line:
</p>
<p class="command">apt-get install psad<br />
&#8230;or log in to WebTool and download the package from the package manager interface.<br />
We shall get around to the setup of psad after we configure the firewalls on psad_server to log packets:<br />
&nbsp;</p>
<h3>iptables Rules Setup</h3>
<p>Since iptables is installed out of the box on EnGarde Secure Linux, you only have to run two simple commands to start logging packets with iptables:
</p>
<p class="command">iptables -A INPUT -j LOG<br />
iptables -A FORWARD -j LOG<br />
From here on out incoming packets (especially those of Nmap scans) will be logged.&nbsp; Let&#8217;s see if we can start detecting such scans by setting up psad to do so.<br />
&nbsp;</p>
<h3>psad Configuration</h3>
<p>On psad_server, use your favorite editor to modify the <span class="system">/etc/psad/psad.conf</span> file.&nbsp; We&#8217;re interested in the following tunables:<br />
&nbsp; <br />&nbsp;&nbsp; <span class="system">EMAIL_ADDRESSES<br />&nbsp; HOSTNAME<br />&nbsp; SYSLOG_DAEMON<br />&nbsp; ETC_SYSLOGNG_CONF</span><br />&nbsp; <br />
The EMAIL_ADDRESSES should be whichever email addresses you wish to have psad send feedback to.&nbsp; This feedback includes error messages and alerts of potential dangerous scans depending on danger levels which can be fine-tuned for your purposes.<br />
&nbsp;- The HOSTNAME tunable will be the hostname of the psad_server machine.<br />
&nbsp;- The SYSLOG_DAEMON refers to the logging daemon for the machine.&nbsp; For EnGarde Secure Linux, this should be set to &#8217;syslog-ng&#8217;.<br />
&nbsp;- The ETC_SYSLOGNG_CONF refers to the direct path of the syslog-ng daemon&#8217;s configuration file.&nbsp; For EnGarde Secure Linux, this should be set to &#8216;/etc/syslog-ng.conf&#8217;.<br />
&nbsp;- Once you&#8217;ve properly configured those tunables, you can start the psad daemon:
</p>
<p class="command">/etc/init.d/psad start<br />
<span class="system">&nbsp; [psad_server]# /etc/init.d/psad start<br />&nbsp; [ SUCCESSFUL ] psad Daemons</span><br />
&nbsp;</p>
<h4>Note:&nbsp; </h4>
<p>As far as danger levels are concerned, these range from one to five&lt;br /&gt; and are assigned to the IP addresses from which an attack or scan is detected. They are assigned based on the number of packets sent, port range, thetime interval of the scan, whether or not the signatures of the packets match up with psad signature attacks, and the IP address where the packet originated from. Depending on the number of such packets, a level is assigned as per the configuration file.&nbsp; For more information on danger levels and ideas for fine-tuning them, please refer to the resources at the end of the article. <br />
&nbsp;</p>
<h3>psad&nbsp; &#8211; Active Detection</h3>
<p>We will now use psad to detect certain Nmap scans.&nbsp; On the Nmap scanning machine, run a TCP connect() scan by executing the following:
</p>
<p class="command">nmap -sT 1.2.3.4<br />
Replace 1.2.3.4 with the IP address of your psad_server.<br />
If we check the /var/log/psad/fwdata file on the psad_server, you will find the following:<br />
<span class="system">&nbsp; Feb&nbsp; 2 11:58:11 psad_server kernel: IN=eth0 OUT=<br />
&nbsp; MAC=00:0c:29:78:22:73:00:0c:76:4b:f6:3e:08:00 SRC=5.6.7.8<br />
&nbsp; DST=1.2.3.4 LEN=60 TOS=0&#215;00 PREC=0&#215;00 TTL=64 ID=23609 DF PROTO=TCP<br />
&nbsp; SPT=49021 DPT=113 WINDOW=5840 RES=0&#215;00 SYN URGP=0 </span><br />
We can see that SRC will have the IP address of the nmap_scanner machine, and DST will have the address of the psad_server.&nbsp; Also note that PROTO=TCP, showing that the attack was a TCP connect() scan.<br />
If you had previously configured psad to send email alerts, you will begin receiving emails concerning this scan showing lots more data than these log messages can ever produce.&nbsp; There are configuration tunables in the /etc/psad/psad.conf file to limit and even disable email:<br />
<span class="system">&nbsp; EMAIL_LIMIT<br />
&nbsp; ALERTING_METHODS<br />
&nbsp; EMAIL_ALERT_DANGER_LEVEL</span><br />
EMAIL_LIMIT defines the maximum number of emails a configured user will receive for a given IP address.<br />
ALERTING_METHODS can be set to noemail, nosyslog, and ALL, depending on whether you want only syslog-ng messages, email alerts, or both.<br />
EMAIL_ALERT_DANGER_LEVEL is the minimum danger level that must be hit in order for psad to send email alerts concerning a detection.&nbsp; The default setting is one, so you can expect lots of emails for this tutorial&#8217;s purpose.<br />
Here is an example email showing psad output of the previous Nmap scan:
</p>
<p class="system"><b>Subject</b>: [psad-alert] DL2 src: nmap_scanner.yournetwork.com dst:<br />&nbsp;&nbsp;&nbsp; psad_server.yournetwork.com</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Danger level: [2] (out of 5)</p>
<p>&nbsp;&nbsp;&nbsp; Scanned UDP ports: [32772: 1 packets, Nmap: -sU]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iptables chain: INPUT, 1 packets</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source: 5.6.7.8<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DNS: nmap_scanner.yournetwork.com<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OS guess: Linux (2.4.x kernel)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Destination: 1.2.3.4<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DNS: psad_server.yournetwork.com</p>
<p>&nbsp;&nbsp; Overall scan start: Mon Feb&nbsp; 2 11:57:19 2008<br />&nbsp;&nbsp; Total email alerts: 2<br />&nbsp;&nbsp; Complete TCP range: [64-49400]<br />&nbsp;&nbsp; Complete UDP range: [32772]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Syslog hostname: unknown</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Global stats: chain:&nbsp;&nbsp; interface:&nbsp;&nbsp; TCP:&nbsp;&nbsp; UDP:&nbsp;&nbsp; ICMP:&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INPUT&nbsp;&nbsp;&nbsp; eth0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 40&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>[+] TCP scan signatures:</p>
<p>&nbsp;&nbsp; &#8220;P2P Napster Client Data communication attempt&#8221;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dst port:&nbsp; 5555 (no server bound to local port)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags:&nbsp;&nbsp;&nbsp;&nbsp; SYN<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sid:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 564<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chain:&nbsp;&nbsp;&nbsp;&nbsp; INPUT<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; packets:&nbsp;&nbsp; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classtype: policy-violation <br />
As you can see, psad does a wonderful job of taking packet data from logs, analyzing it and producing useful information on the type of scans used.<br />
&nbsp;</p>
<h3>psad&nbsp; &#8211; Active Defense</h3>
<p>One of the more prominent features of psad is its active defense implementation &#8211; being able to detect Nmap scans is nice, but how do you respond?&nbsp; Let&#8217;s configure psad to automatically block the source of such scans upon detection.<br />
Before implementing this feature, it is obvious for certain security veterans who are reading this article that there is a definite tradeoff for enforcing an active response policy.&nbsp; Although malicious traffic will be blocked, there is always the risk of blocking out valid traffic.&nbsp; Certain attackers can exploit active defenses and turn it against the target by attempting to spoof valid addresses, thus blocking out otherwise harmless traffic.<br />
This only happens in cases where the active response system has been configured to respond to nearly ALL types of potentially harmful traffic, including port scans or port sweeps.&nbsp; This also applies to traffic which does not require bidirectional communication with the target.&nbsp; A better strategy to employ is to only respond to traffic where bidirectional communication is required i.e. TCP connections.&nbsp; Even then, one must take care to tailor their active response to certain types of TCP connections, such as attempted SQL injection attacks, etc.&nbsp; Please be sure you are absolutely positive of how your detection scheme is working before deploying an active defense.<br />
Using your favorite editor, modify the /etc/psad/psad.conf file.&nbsp; We&#8217;re interested in the following tunables:<br />
<span class="system">&nbsp; ENABLE_AUTO_IDS<br />
&nbsp; AUTO_IDS_DANGER_LEVEL</span><br />
&nbsp; ENABLE_AUTO_IDS should be set to &#8216;Y&#8217; to enable the automated IDS response.<br />
&nbsp; AUTO_IDS_DANGER_LEVEL, for this HowTo&#8217;s sake, will be set to &#8216;3&#8242;.&nbsp; This danger&nbsp; level is customizable and the setting we use in this HowTo is for demonstration&nbsp; purposes only.<br />
Restart the psad on the psad_server:
</p>
<p class="command">/etc/init.d/psad restart<br />
<span class="system">&nbsp; [psad_server]# /etc/init.d/psad restart<br />
&nbsp; [ SUCCESSFUL ] psadwatchd Daemon<br />
&nbsp; [ SUCCESSFUL ] psad Daemon<br />
&nbsp; [ SUCCESSFUL ] kmsgsd Daemon<br />
&nbsp; [ SUCCESSFUL ] psad Daemons</span><br />
From the nmap_scanner machine, we&#8217;ll run an Nmap SYN scan along with the &#8216;-P0&#8242; switch &#8211; this type of scan uses no ping and does not fully complete a TCP connection, resulting in fast scans.&nbsp; This usually requires root privileges, and is considered more of a dangerous scan &#8211; just the type of scan that psad detects at a higher danger level.
</p>
<p class="command">nmap -sS -P0 -n 1.2.3.4<br />
Replace the &#8216;1.2.3.4&#8242; with the IP address of your psad_server machine.<br />
psad will detect the SYN scans, and since the danger level of this scan is 3, it manipulates the iptables rules to block the source of the scans.&nbsp; This can be verified on the psad_server by running the following command:
</p>
<p class="command">psad &#8211;fw-list<br />
&nbsp;<span class="system"> [psad_server]# psad &#8211;fw-list<br />
  [+] Listing chains from IPT_AUTO_CHAIN keywords&#8230;</p>
<p>  Chain PSAD_BLOCK_INPUT (1 references)<br />
&nbsp;pkts bytes target&nbsp;&nbsp;&nbsp;&nbsp; prot opt in&nbsp;&nbsp;&nbsp;&nbsp; out&nbsp;&nbsp;&nbsp;&nbsp; source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; destination<br />
&nbsp; 820 36080 DROP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all&nbsp; &#8211;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.6.7.8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0/0</p>
<p>  Chain PSAD_BLOCK_OUTPUT (1 references)<br />
&nbsp;pkts bytes target&nbsp;&nbsp;&nbsp;&nbsp; prot opt in&nbsp;&nbsp;&nbsp;&nbsp; out&nbsp;&nbsp;&nbsp;&nbsp; source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; destination<br />
&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 DROP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all&nbsp; &#8211;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0/0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.6.7.8</p>
<p>  Chain PSAD_BLOCK_FORWARD (1 references)<br />
&nbsp;pkts bytes target&nbsp;&nbsp;&nbsp;&nbsp; prot opt in&nbsp;&nbsp;&nbsp;&nbsp; out&nbsp;&nbsp;&nbsp;&nbsp; source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; destination<br />
&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 DROP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all&nbsp; &#8211;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0/0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.6.7.8<br />
&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 DROP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all&nbsp; &#8211;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.6.7.8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0/0</span><br />
You will even receive an email alerts that inform you of the scan detection, as well as an email informing you that iptables rules have been added to auto-block the nmap_scanner!<br />
&nbsp;</p>
<h3>Wrapping It All Up</h3>
<p>Congratulations, you&#8217;ve successfully implemented psad to actively detect and respond to signature Nmap scans!<br />
Keep in mind this is one of the more basic setups for psad.&nbsp; You can go even further and adjust danger levels to suit degrees of paranoia, put psad into forensics mode, incorporate the software with DShield, and even manually use psad to manipulate iptables rules.&nbsp; A great resource for psad research is &#8216;Linux Firewalls&#8217; by Michael Rash.&nbsp; Rash includes several chapters on psad covering not only theory but advanced implementation of psad from start to finish.&nbsp; If you wish to gain suggestions for an advanced, finely-tuned active defense setup with psad, be sure to check this book out!<br />
Have fun implementing an active defense against those who try to scan your system!<br />
&nbsp;</p>
<h3>Resources</h3>
<p><a title="http://www.linuxsecurity.com" target="_blank" href="http://www.linuxsecurity.com">http://www.linuxsecurity.com</a><br />
<a title="www.GuardianDigital.com" target="_blank" href="http://www.guardiandigital.com">http://www.guardiandigital.com</a></p>
<p>&#8220;&#8216;Linux Firewalls&#8217; by Michael Rash&#8221;</p>
<p><a title="'Knock, Knock, Knockin on EnGarde's Door'" target="_blank" href="http://www.linuxsecurity.com/content/view/131846/171/">&#8216;Knock, Knock, Knockin&#8217; on EnGarde&#8217;s Door&#8217;</a></p>
<div class="copyright-footer">Copyright © 2008 Ryan<br />All Rights Reserved.
  </div></p>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/psad-port-scan-attack-detector-on-engarde-secure-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Check If Your Server Is Infected With The Linux/Rst-B Backdoor (Debian Etch)</title>
		<link>http://tusforyou.com/sophos-linux-rst-b-backdoor-detection-tool-debian-etch/</link>
		<comments>http://tusforyou.com/sophos-linux-rst-b-backdoor-detection-tool-debian-etch/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:56 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Backdoor]]></category>
		<category><![CDATA[Check]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Etch]]></category>
		<category><![CDATA[Infected]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[With]]></category>
		<category><![CDATA[Your]]></category>

		<guid isPermaLink="false">http://tusforyou.com/sophos-linux-rst-b-backdoor-detection-tool-debian-etch/</guid>
		<description><![CDATA[Linux Rst-B is a backdoor that can be used to add your server to botnets (see http://www.heise.de/newsticker/meldung/103563 (in German)). This short guide explains how you can install and use the Sophos Linux/RST-B detection tool to check your Debian Etch server and find out if it is infected with Linux Rst-B.
How To Check If Your Server [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Linux Rst-B is a backdoor that can be used to add your server to botnets (see http://www.heise.de/newsticker/meldung/103563 (in German)). This short guide explains how you can install and use the Sophos Linux/RST-B detection tool to check your Debian Etch server and find out if it is infected with Linux Rst-B.<span id="more-2043"></span></p>
<h2>How To Check If Your Server Is Infected With The Linux/Rst-B Backdoor (Debian Etch)</h2>
<p>Version 1.0 <br />
  Author: Falko Timme &lt;ft [at] falkotimme [dot] com&gt; <br />
Last edited 02/15/2008<br />
<a href="http://www.sophos.com/virusinfo/analyses/linuxrstb.html" target="_blank">Linux Rst-B</a> is a backdoor that can be used to add your server to botnets (see <a href="http://www.heise.de/newsticker/meldung/103563" target="_blank">http://www.heise.de/newsticker/meldung/103563</a> (in German)). This short guide explains how you can install and use the <a href="http://www.sophos.com/rst-detection-tool" target="_blank">Sophos Linux/RST-B detection tool</a> to check your Debian Etch server and find out if it is infected with Linux Rst-B.<br />
I do not issue any guarantee that this will work for you!<br />
&nbsp;</p>
<h3>1 Download And Install The Sophos Linux/RST-B Detection Tool</h3>
<p>I want to install the Linux/RST-B detection tool in the <span class="system">/usr/local/sbin</span> directory (so that the detection tool is in our <span class="system">PATH</span> later on):</p>
<p class="command">cd /usr/local/sbin<br />
  wget http://www.sophos.com/support/cleaners/detection_tool.tar.gz<br />
tar xvfz detection_tool.tar.gz<br />
You should then find the contents of the tar.gz file in the <span class="system">/usr/local/sbin/detection_tool</span> directory.<br />
There are two ways of installing the detection tool: you can either use the pre-compiled binary that you can find in the <span class="system">/usr/local/sbin/detection_tool/pre-compiled</span> directory, or you compile it yourself. I&#8217;ll show both ways now. <br />
&nbsp;</p>
<h4>1.1 Use The Pre-Compiled Binary</h4>
<p>To use the pre-compiled binary, we can <span class="highlight">either</span> simply create a symlink called <span class="system">rst_detection_tool</span> from the <span class="system">/usr/local/sbin</span> directory to <span class="system">detection_tool/pre-compiled/detection_tool</span>:
</p>
<p class="command">cd /usr/local/sbin<br />
ln -s detection_tool/pre-compiled/detection_tool rst_detection_tool<br />
<span class="highlight">Or</span> we move <span class="system">detection_tool/pre-compiled/detection_tool</span> to <span class="system">/usr/local/sbin</span> and rename it to <span class="system">rst_detection_tool</span>:
</p>
<p class="command">cd /usr/local/sbin<br />
mv detection_tool/pre-compiled/detection_tool rst_detection_tool<br />
&nbsp;</p>
<h4>1.2 Build The Detection Tool From The Sources</h4>
<p>To compile the detection tool from the sources, we first install the package <span class="system">build-essential</span>:
</p>
<p class="command">apt-get install build-essential<br />
Afterwards we build the detection tool as follows:
</p>
<p class="command">cd /usr/local/sbin/detection_tool<br />
make<br />
This creates the program <span class="system">/usr/local/sbin/detection_tool/detection_tool</span>. I want to have it directly in the <span class="system">/usr/local/sbin</span> directory and name it <span class="system">rst_detection_tool</span>, so we can <span class="highlight">either</span> create a symlink: 
</p>
<p class="command">cd /usr/local/sbin<br />
ln -s detection_tool/detection_tool rst_detection_tool<br />
<span class="highlight">Or</span> we move <span class="system">detection_tool/detection_tool</span> to <span class="system">/usr/local/sbin</span> and rename it to <span class="system">rst_detection_tool</span>:
</p>
<p class="command">cd /usr/local/sbin<br />
mv detection_tool/detection_tool rst_detection_tool<br />
&nbsp;</p>
<h3>2 Use The Linux/RST-B Detection Tool</h3>
<p>Now we can use the detection tool as follows:<br />
Outside  the <span class="system">/usr/local/sbin</span> directory: 
</p>
<p class="command">rst_detection_tool [-v] &lt;path&gt;<br />
Inside the <span class="system">/usr/local/sbin</span> directory we must prepend <span class="system">./</span>:
</p>
<p class="command">./rst_detection_tool [-v] &lt;path&gt;  <br />
So if you want to scan your whole file system, you&#8217;d simply use:
</p>
<p class="command">rst_detection_tool /<br />
or
</p>
<p class="command">./rst_detection_tool /<br />
if you are in <span class="system">/usr/local/sbin</span>.  <br />
On a clean system the output looks as follows:
</p>
<p class="system">server2:/usr/local/sbin# ./rst_detection_tool /<br />
  Sophos Rst-B Detection Tool<br />
  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Copyright (c) 2008 Sophos Plc. All rights reserved.
</p>
<p class="system">Scanned 43134 files, found 0 infections of Linux/Rst-B.<br />
  End of scan.<br />
  server2:/usr/local/sbin#<br />
&nbsp;</p>
<h3>3 Links</h3>
<ul>
<li>Sophos Linux/RST-B Detection Tool: <a href="http://www.sophos.com/rst-detection-tool" target="_blank">http://www.sophos.com/rst-detection-tool</a></li>
<li> Debian: <a href="http://www.debian.org/" target="_blank">http://www.debian.org</a></li>
</ul>
<p>
<div class="copyright-footer">Copyright © 2008 Falko Timme<br />All Rights Reserved.
  </div></p>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/sophos-linux-rst-b-backdoor-detection-tool-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing the security of PPTP by adding two-factor authentication to poptop</title>
		<link>http://tusforyou.com/security-issues-and-poptop-pptp-p3/</link>
		<comments>http://tusforyou.com/security-issues-and-poptop-pptp-p3/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:54 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Adding]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Increasing]]></category>
		<category><![CDATA[poptop]]></category>
		<category><![CDATA[PPTP]]></category>
		<category><![CDATA[twofactor]]></category>

		<guid isPermaLink="false">http://tusforyou.com/security-issues-and-poptop-pptp-p3/</guid>
		<description><![CDATA[
Configuring the Token Client
Download and install a WiKID Token client.  You can manually validate yourself as a user from the WiKIDAdmin web interface.  Once validated, select the Domain associated with the PPTP VPN:

Enter the PIN:

And you will get back the one-time passcode. The OTP is time-bounded, but the time can be set on [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span id="more-2042"></span></p>
<h3>Configuring the Token Client</h3>
<p>Download and install a <a href="http://www.wikidsystems.com/downloads/token-clients/?htf_pptp" target="_blank">WiKID Token client</a>.  You can manually validate yourself as a user from the WiKIDAdmin web interface.  Once validated, select the Domain associated with the PPTP VPN:</p>
<p><img src="http://tusforyou.com/images/securing_poptop/ac355f01b75bc686a09b686731242584-2087.jpg" height="350" width="400" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="ac355f01b75bc686a09b686731242584 2087 Increasing the security of PPTP by adding two factor authentication to poptop" /></p>
<p>Enter the PIN:</p>
<p><img src="http://tusforyou.com/images/securing_poptop/497711f9a0eee6ec80be3bb723654147-2088.jpg" alt="token2.jpg" height="350" width="400" title="Increasing the security of PPTP by adding two factor authentication to poptop" /></p>
<p>And you will get back the one-time passcode. The OTP is time-bounded, but the time can be set on the WiKID server to whatever you want:<br />
<img src="http://tusforyou.com/images/securing_poptop/03015e617c4fd4f7742a0b0f95005c2a-2089.jpg" alt="token3.jpg" height="350" width="400" title="Increasing the security of PPTP by adding two factor authentication to poptop" /></p>
<p>Now, bring up the PPTP connection we created earlier and enter the WiKID one-time passcode into the password box along with the appropriate username:   <br />
<img src="http://tusforyou.com/images/securing_poptop/connect.jpg" align="bottom" border="0" height="320" width="344" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="connect Increasing the security of PPTP by adding two factor authentication to poptop" /></p>
<p>You should see a &#8220;Connecting&#8230;&#8221; window followed by a notice that you are connected:<br />
<img src="http://tusforyou.com/images/securing_poptop/connected.jpg" align="bottom" border="0" height="193" width="379" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="connected Increasing the security of PPTP by adding two factor authentication to poptop" /></p>
<p>Congratulations!  <br />
If you are getting an error, check both /var/log/messages on the pptp server and the WiKID logs via the WiKIDAdmin web interface for potential problems. 
<div class="book">
<div class="tree"></div>
<div class="nav1">
<div class="links">
<div class="prev"><a href="security-issues-and-poptop-pptp-p2" title="View the previous page.">previous</a></div>
<div class="next"><a href="" title="View the next page.">next</a></div>
<div class="up"><a href="security-issues-and-poptop-pptp" title="View this page&#39;s parent section.">up</a></div>
</p></div>
<div class="titles">
<div class="prev">Increasing the security of PPTP by adding two-factor authentication to poptop &#8211; Page 2</div>
<div class="next"></div>
</p></div>
</p></div>
</p></div>
</p>
<div class="copyright-footer">Copyright © 2008 Nick Owen<br />All Rights Reserved.
</div>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/security-issues-and-poptop-pptp-p3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing the security of PPTP by adding two-factor authentication to poptop</title>
		<link>http://tusforyou.com/security-issues-and-poptop-pptp-p2/</link>
		<comments>http://tusforyou.com/security-issues-and-poptop-pptp-p2/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:49 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Adding]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Increasing]]></category>
		<category><![CDATA[poptop]]></category>
		<category><![CDATA[PPTP]]></category>
		<category><![CDATA[twofactor]]></category>

		<guid isPermaLink="false">http://tusforyou.com/security-issues-and-poptop-pptp-p2/</guid>
		<description><![CDATA[
Configure the Windows PPTP VPN Client
Start the New Connection Wizard:  Start -&#62; Settings -&#62; Network and Dial-up Connections -&#62; Make New Connection
  
Click Next to start the Wizard.

Select Connect to a private network through the Internet.

Select to not dial an initial connection (assuming you have broadband internet access).

Enter the hostname or IP address [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span id="more-2041"></span></p>
<h3>Configure the Windows PPTP VPN Client</h3>
<p>Start the New Connection Wizard:  Start -&gt; Settings -&gt; Network and Dial-up Connections -&gt; Make New Connection</p>
<p>  <img src="http://tusforyou.com/images/securing_poptop/01-new_connection.jpg" height="385" width="550" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="01 new connection Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Click Next to start the Wizard.<br />
<img src="http://tusforyou.com/images/securing_poptop/02-new_wizard.jpg" align="bottom" border="0" height="385" width="503" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="02 new wizard Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Select Connect to a private network through the Internet.<br />
<img src="http://tusforyou.com/images/securing_poptop/03-vpn_connection.jpg" align="bottom" border="0" height="383" width="501" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="03 vpn connection Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Select to not dial an initial connection (assuming you have broadband internet access).<br />
<img src="http://tusforyou.com/images/securing_poptop/04-nodial.jpg" align="bottom" border="0" height="385" width="503" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="04 nodial Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Enter the hostname or IP address of the PPTP VPN server.<br />
<img src="http://tusforyou.com/images/securing_poptop/05-pptpd_server.jpg" align="bottom" border="0" height="383" width="501" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="05 pptpd server Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Select whether this connection should be just for you or for all users.<br />
<img src="http://tusforyou.com/images/securing_poptop/06-allusers.jpg" align="bottom" border="0" height="383" width="501" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="06 allusers Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Do not enable Internet Connection Sharing.<br />
<img src="http://tusforyou.com/images/securing_poptop/07-sharing.jpg" align="bottom" border="0" height="381" width="498" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="07 sharing Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Give the connection a name.<br />
<img src="http://tusforyou.com/images/securing_poptop/08-name_vpn.jpg" align="bottom" border="0" height="382" width="506" title="Increasing the security of PPTP by adding two factor authentication to poptop" alt="08 name vpn Increasing the security of PPTP by adding two factor authentication to poptop" /><br />
Click Finish.
<div class="book">
<div class="tree"></div>
<div class="nav1">
<div class="links">
<div class="prev"><a href="security-issues-and-poptop-pptp" title="View the previous page.">previous</a></div>
<div class="next"><a href="security-issues-and-poptop-pptp-p3" title="View the next page.">next</a></div>
<div class="up"><a href="security-issues-and-poptop-pptp" title="View this page&#39;s parent section.">up</a></div>
</p></div>
<div class="titles">
<div class="prev">Increasing the security of PPTP by adding two-factor authentication to poptop</div>
<div class="next">Increasing the security of PPTP by adding two-factor authentication to poptop &#8211; Page 3</div>
</p></div>
</p></div>
</p></div>
</p>
<div class="copyright-footer">Copyright © 2008 Nick Owen<br />All Rights Reserved.
</div>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/security-issues-and-poptop-pptp-p2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing the security of PPTP by adding two-factor authentication to poptop</title>
		<link>http://tusforyou.com/security-issues-and-poptop-pptp/</link>
		<comments>http://tusforyou.com/security-issues-and-poptop-pptp/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:39 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Adding]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[factor]]></category>
		<category><![CDATA[Increasing]]></category>
		<category><![CDATA[poptop]]></category>
		<category><![CDATA[PPTP]]></category>

		<guid isPermaLink="false">http://tusforyou.com/security-issues-and-poptop-pptp/</guid>
		<description><![CDATA[PPTP does not have the best history in terms of security.  The original Microsoft implementation for PPTP faired very poorly. MS-CHAPV2 solved these weaknesses &#8211; for wired networks.  Unfortunately, back in 2004, Joshua Wright released a version of ASLEAP capable of brute-force attacking PPTP passwords
in a wireless environment. As a systems administrator for [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>PPTP does not have the best history in terms of security.  The original Microsoft implementation for PPTP faired very poorly. MS-CHAPV2 solved these weaknesses &#8211; for wired networks.  Unfortunately, back in 2004, Joshua Wright released a version of ASLEAP capable of brute-force attacking PPTP passwords<br />
in a wireless environment. As a systems administrator for the VPN, you<br />
can&#8217;t tell if a user is connecting via some public WiFi service where<br />
someone might be running a tool like ASLEAP. Yet, the presense of PPTP<br />
client software on Windows machines makes using PPTP very tempting. The<br />
best answer to this problem is to utilize two-factor authentication. If<br />
a one-time passcode is brute-forced, it won&#8217;t matter as it can&#8217;t be<br />
used again.<span id="more-2040"></span></p>
<h2>Security Issues and Poptop </h2>
<p>PPTP does not have the best history in terms of security.  The original Microsoft implementation for PPTP <a href="http://www.schneier.com/pptp-faq.html" target="_blank">faired very poorly</a>. MS-CHAPV2 solved these weaknesses &#8211; for wired networks.  Unfortunately, back in 2004, Joshua Wright released a version of <a href="http://asleap.sourceforge.ne" target="_blank">ASLEAP</a> capable of <a href="http://blogs.zdnet.com/Ou/index.php?p=21" target="_blank">brute-force attacking PPTP passwords</a> in a wireless environment.  As a systems administrator for the VPN, you can&#8217;t tell if a user is connecting via some public WiFi service where someone might be running a tool like ASLEAP. Yet, the presense of PPTP client software on Windows machines makes using PPTP very tempting. The best answer to this problem is to utilize two-factor authentication.  If a one-time passcode is brute-forced, it won&#8217;t matter as it can&#8217;t be used again. <br />
This document describes how to install and configure the open source <a href="http://poptop.sourceforge.net" target="_blank">Poptop PPTP VPN</a> server with two-factor authentication from <a href="http://www.wikidsytstems.com/?pptp" target="_blank">WiKID Systems</a>.<br />
&nbsp;</p>
<h3>Install Poptop</h3>
<p>Choose your appropriate repo, here is FC6:</p>
<p class="command"> # rpm -Uvh http://poptop.sourceforge.net/yum/stable/fc6/i386/pptp-release-4-2.fc6.noarch.rpm
</p>
<p class="command">yum &#8211;enablerepo=poptop-stable install pptpd </p>
<p class="command">
yum install pptp</p>
<p><a href="http://www.members.optushome.com.au/%7Ewskwok/poptop_ads_howto_3.htm#pforward" target="_blank">http://www.members.optushome.com.au/~wskwok/poptop_ads_howto_3.htm#pforward</a><br />
For ppp to work, the packet forwarding must be enabled. Edit /etc/sysctl.conf with your favourite editor and change the line:</p>
<pre>net.ipv4.ip_forward = 0</pre>
<p>to</p>
<pre>net.ipv4.ip_forward = 1 </pre>
<p>The change will be effective on the next reboot. To enable it immediately:
</p>
<p class="command">sudo sysctl -p</p>
<p>We also need radiusclient:</p>
<p class="command">yum install radiusclient</p>
<p>I created a sym link to the microsoft dictionary in /etc/radiusclient:
</p>
<p class="command"> ln -s /usr/share/freeradius/dictionary.microsoft dictionary.microsoft</p>
<p>Edit /etc/radiusclient/servers and add wikid server along with a s shared secret:</p>
<pre>#Server Name or Client/Server pair              Key
#----------------                               ---------------
#portmaster.elemental.net                       hardlyasecret
#portmaster2.elemental.net                      donttellanyone
your.wikidserver.com                         wikidserver_secret</pre>
<p>Please note that pptpd by default has a 100 connections limit. You can override it by the &#8220;connections&#8221; parameter in the pptp.conf file. Read the remarks in the file. </p>
<p>You need  port 47 and 1723 open for pptp traffic:</p>
<p></p>
<p class="command">iptables -A INPUT -p tcp &#8211;dport 1723 -j ACCEPT
</p>
<p class="command">iptables -A INPUT -p 47 -j ACCEPT</p>
<p>Edit /etc/pptpd.conf with your favorite editor:</p>
<pre>option /etc/ppp/options.pptpd
logwtmp
localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245</pre>
<p>Set your remote IP range using remoteip.</p>
<p>Edit  /etc/ppp/options.pptp</p>
<pre>lock
noauth
refuse-eap
refuse-chap
refuse-mschap
nobsdcomp
nodeflate
ms-dns 74.188.41.129
plugin radius.so
</pre>
<p>Obviously,  plugin radius.so specifies that we will use Radius.</p>
<p>Edit /etc/radiusclient/radiusclient.conf</p>
<pre>auth_order      radius,local
login_tries     4
login_timeout   60
nologin /etc/nologin
issue   /etc/radiusclient/issue
authserver      your.wikidserver.com 1812
acctserver      localhost
servers         /etc/radiusclient/servers
dictionary      /etc/radiusclient/dictionary
login_radius    /usr/sbin/login.radius
seqfile         /var/run/radius.seq
mapfile         /etc/radiusclient/port-id-map
default_realm
radius_timeout  10
radius_retries  3
login_local     /bin/login</pre>
<p>Edit  /etc/radiusclient/servers and add server and secret:</p>
<pre>&lt;wikid_server_ip&gt;                                        wikidserver_secret</pre>
<p>Start the pptpd service:</p>
<p class="command">service pptpd start<br />
&nbsp;</p>
<h3>Configure the WiKID server</h3>
<p>Log into the WiKID server using the WiKIDAdmin browser interface and click on the Domains Tab (If you already have a domain setup, you can skip this step.)</p>
<p>Click on Create a New Domain,</p>
<p>Enter the information requested. The Domain Server code is the zero-padded IP address of the WiKID server. So, if the external IP address is 216.239.51.99, the WiKID server code would be 216239051099. Click &#8220;Create&#8221;. </p>
<p>Click Network Clients tab and on &#8220;Create a new Network Client&#8221;. </p>
<p>Enter the information requested.  For the IP Address, use the IP address of the PPTP server.  Select Radius and the domain you just created. Click &#8220;Add&#8221; when you&#8217;re finished. </p>
<p>On the next page, enter the shared secret you entered in /etc/raddb/server.  You do not have to enter any information under &#8220;Return Attributes&#8221;.</p>
<p><b>Important: </b>From the WiKID server&#8217;s console or via SSH, you will need to run &#8220;wikidctl restart&#8221; to load the new configuration into the WiKID Radius server. (WiKID 2.0 users just run &#8220;stop&#8221; and &#8220;start&#8221;.) </p>
<div class="book">
<div class="tree">
<div class="menu1">
<ul>
<li class="leaf"><a href="security-issues-and-poptop-pptp-p2">Increasing the security of PPTP by adding two-factor authentication to poptop &#8211; Page 2</a></li>
<li class="leaf"><a href="security-issues-and-poptop-pptp-p3">Increasing the security of PPTP by adding two-factor authentication to poptop &#8211; Page 3</a></li>
</ul>
</div>
<div class="nav1">
<div class="links">
<div class="prev">&nbsp;</div>
<div class="next"><a href="security-issues-and-poptop-pptp-p2" title="View the next page.">next</a></div>
</div>
<div class="titles">
<div class="next">Increasing the security of PPTP by adding two-factor authentication to poptop &#8211; Page 2</div>
</div>
</div>
</div>
<p>
<div class="copyright-footer">Copyright © 2008 Nick Owen<br />All Rights Reserved.
</div>
</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/security-issues-and-poptop-pptp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrooting Apache2 With mod_chroot On Debian Etch</title>
		<link>http://tusforyou.com/chrooting-apache2-mod-chroot-debian-etch/</link>
		<comments>http://tusforyou.com/chrooting-apache2-mod-chroot-debian-etch/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:37 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Chroot]]></category>
		<category><![CDATA[Chrooting]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Etch]]></category>
		<category><![CDATA[With]]></category>

		<guid isPermaLink="false">http://tusforyou.com/chrooting-apache2-mod-chroot-debian-etch/</guid>
		<description><![CDATA[This guide explains how to set up mod_chroot
with Apache2 on a Debian Etch system. With mod_chroot, you can run
Apache2 in a secure chroot environment and make your server less
vulnerable to break-in attempts that try to exploit vulnerabilities in
Apache2 or your installed web applications.
Chrooting Apache2 With mod_chroot On Debian Etch 
Version 1.0 
  Author: Falko [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This guide explains how to set up mod_chroot<br />
with Apache2 on a Debian Etch system. With mod_chroot, you can run<br />
Apache2 in a secure chroot environment and make your server less<br />
vulnerable to break-in attempts that try to exploit vulnerabilities in<br />
Apache2 or your installed web applications.<span id="more-2039"></span></p>
<h2>Chrooting Apache2 With mod_chroot On Debian Etch </h2>
<p>Version 1.0 <br />
  Author: Falko Timme &lt;ft [at] falkotimme [dot] com&gt; <br />
Last edited 02/11/2008<br />
This guide explains how to set up <a href="http://core.segfault.pl/%7Ehobbit/mod_chroot/" target="_blank">mod_chroot</a> with Apache2 on a Debian Etch system. With mod_chroot, you can run Apache2 in a secure chroot environment and make your server less vulnerable to break-in attempts that try to exploit vulnerabilities in Apache2 or your installed web applications. <br />
I do not issue any guarantee that this will work for you!<br />
&nbsp;</p>
<h3>1 Preliminary Note</h3>
<p>I&#8217;m assuming that you have a running Debian Etch system with a working Apache2, e.g. as shown in this tutorial: <a href="http://www.tusforyou.com/perfect_setup_debian_etch" target="_blank">The Perfect Setup &#8211; Debian Etch (Debian 4.0)</a>. In addition to that I assume that you have one or more web sites set up within the <span class="system">/var/www</span> directory (e.g. if you use ISPConfig). <br />
&nbsp;</p>
<h3>2 Installing mod_chroot</h3>
<p>To install mod_chroot, we simply run:</p>
<p class="command">apt-get install libapache2-mod-chroot<br />
Then we enable mod_chroot and restart Apache:
</p>
<p class="command">a2enmod mod_chroot<br />
/etc/init.d/apache2 force-reload<br />
&nbsp;</p>
<h3>3 Configuring Apache</h3>
<p>I want to use the <span class="system">/var/www</span> directory as the directory containing the chroot jail. Debian&#8217;s Apache uses the PID file <span class="system">/var/run/apache2.pid</span>; when Apache is chrooted to <span class="system">/var/www</span>, <span class="system">/var/run/apache2.pid</span> translates to <span class="system">/var/www/var/run/apache2.pid</span>.  Therefore we create that directory now:
</p>
<p class="command">mkdir -p /var/www/var/run<br />
chown -R root:root /var/www/var/run<br />
Now we must tell Apache that we want to use <span class="system">/var/www</span> as our chroot directory. We open <span class="system">/etc/apache2/apache2.conf</span>, and right below the <span class="system">PidFile</span> line, we add a <span class="system">ChrootDir</span> line:
</p>
<p class="command">vi /etc/apache2/apache2.conf</p>
<pre>[...]
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
PidFile /var/run/apache2.pid
ChrootDir /var/www
[...]</pre>
<p>Next we must tell our vhosts that the document root has changed (for example, a <span class="system">DocumentRoot /var/www</span> translates now to <span class="system">DocumentRoot /</span>). We can do this either by changing the <span class="system">DocumentRoot</span> directive of each vhost, or more easier, by creating a symlink in the file system.</p>
<hr />
<h4>3.1 First Method: Changing The DocumentRoot</h4>
<p>Let&#8217;s assume we have a vhost with <span class="system">DocumentRoot /var/www</span>. We must now open the vhost configuration of that vhost and change <span class="system">DocumentRoot /var/www</span> to <span class="system">DocumentRoot /</span>. Accordingly, <span class="system">DocumentRoot /var/www/web1/web</span> would now translate to <span class="system">DocumentRoot /web1/web</span>, and so on. If you want to use this method, you must change the <span class="system">DocumentRoot</span> for every single vhost. <br />
&nbsp;</p>
<h4>3.2 Second Method: Creating A Symlink In the File System</h4>
<p>This method is easier, because you have to do it only once and don&#8217;t have to modify any vhost configuration. We create a symlink pointing from <span class="system">/var/www/var/www</span> to <span class="system">/var/www</span>:
</p>
<p class="command">mkdir -p /var/www/var<br />
  cd /var/www/var<br />
ln -s ../../ www</p>
<hr />
Finally, we have to stop Apache, create a symlink from <span class="system">/var/run/apache2.pid</span> to <span class="system">/var/www/var/run/apache2.pid</span>, and start it again:
</p>
<p class="command">/etc/init.d/apache2 stop
</p>
<p class="command">ln -s /var/www/var/run/apache2.pid /var/run/apache2.pid<br />
  /etc/init.d/apache2 start<br />
That&#8217;s it. You can now call your web pages as before, and they should be served without problems, as long as they are static HTML files or using mod_php.<br />
<img src="http://tusforyou.com/images/apache2_mod_chroot_debian_etch/1.png" height="382" width="550" title="Chrooting Apache2 With mod chroot On Debian Etch" alt="1 Chrooting Apache2 With mod chroot On Debian Etch" /><br />
If you are using CGI, e.g. Perl, suPHP, Ruby, etc., then you must copy the interpreter (e.g. <span class="system">/usr/bin/perl</span>, <span class="system">/usr/sbin/suphp</span>, etc.) to the chroot jail together with all libraries needed by the interpreter. You can find out about the required libraries with the <span class="system">ldd</span> command, e.g.
</p>
<p class="command">ldd /usr/sbin/suphp
</p>
<p class="system">server2:/var/www/web1/log#&nbsp;ldd&nbsp;/usr/sbin/suphp<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linux-gate.so.1&nbsp;=&gt;&nbsp;&nbsp;(0xffffe000)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libstdc++.so.6&nbsp;=&gt;&nbsp;/usr/lib/libstdc++.so.6&nbsp;(0xb7e34000)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libm.so.6&nbsp;=&gt;&nbsp;/lib/tls/i686/cmov/libm.so.6&nbsp;(0xb7e0f000)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libgcc_s.so.1&nbsp;=&gt;&nbsp;/lib/libgcc_s.so.1&nbsp;(0xb7e03000)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libc.so.6&nbsp;=&gt;&nbsp;/lib/tls/i686/cmov/libc.so.6&nbsp;(0xb7cd2000)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/lib/ld-linux.so.2&nbsp;(0xb7f23000)<br />
server2:/var/www/web1/log#<br />
If you&#8217;ve copied all required files, but the page still isn&#8217;t working, you should take a look at the Apache error log. Usually it tells you where the problem is. Also read <a href="http://core.segfault.pl/%7Ehobbit/mod_chroot/caveats.html" target="_blank">http://core.segfault.pl/~hobbit/mod_chroot/caveats.html</a> for known problems and solutions.<br />
&nbsp;</p>
<h3>4 Links</h3>
<ul>
<li>mod_chroot: <a href="http://core.segfault.pl/%7Ehobbit/mod_chroot/" target="_blank">http://core.segfault.pl/~hobbit/mod_chroot</a></li>
<li>Apache: <a href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org</a></li>
<li>Debian: <a href="http://www.debian.org/" target="_blank">http://www.debian.org</a></li>
</ul>
<p>
<div class="copyright-footer">Copyright © 2008 Falko Timme<br />All Rights Reserved.
  </div></p>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/chrooting-apache2-mod-chroot-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Hosting Howto With Virtualmin On CentOS 5.1</title>
		<link>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p6/</link>
		<comments>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p6/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:34 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Virtual]]></category>
		<category><![CDATA[Virtualmin]]></category>
		<category><![CDATA[With]]></category>

		<guid isPermaLink="false">http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p6/</guid>
		<description><![CDATA[
Configure Virtualmin
Introduction
Virtualmin is a powerful and flexible hosting control panel that integrates with webmin. We will be using it to provide the virtual hosting functions such as creation of domains, accounts and maintaining configurations on the system.

&#160;
Start Services
You need to start up services that are required to be able to configure virtualmin. Start the following [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span id="more-2038"></span></p>
<h3>Configure Virtualmin</h3>
<h4>Introduction</h4>
<p>Virtualmin is a powerful and flexible hosting control panel that integrates with webmin. We will be using it to provide the virtual hosting functions such as creation of domains, accounts and maintaining configurations on the system.<br />
<br />
&nbsp;</p>
<h4>Start Services</h4>
<p>You need to start up services that are required to be able to configure virtualmin. Start the following services:<br />
</p>
<p class="command">
service named start<br />
service spamassassin start<br />
service spamass-milter start<br />
service clamav-milter start<br />
service postfix start<br />
service dovecot start<br />
service imapproxy start<br />
service httpd start<br />
&nbsp;</p>
<h4>Initial Settings</h4>
<h4>MySQL</h4>
<p>Webmin needs to be able to communicate with mysql since we have set a password for mysql we need to set that up in webmin, go to servers ? mysql and enter this information:<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_mysql.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_mysql.jpg" height="130" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin mysql Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Configure Features</h4>
<p>You need to enable the features and plugins that we want to use. On login this is the screen that you will see.<br />
</p>
<ul>
<li> Enable the following features and save
<ul>
<li> Home directory
</li>
<li> Administration user
</li>
<li> Mail for domain
</li>
<li> BIND DNS domain
</li>
<li> Apache website
</li>
<li> Webalizer reporting
</li>
<li> Log file rotation
</li>
<li> Mysql database
</li>
<li> Webmin user
</li>
</ul>
</li>
</ul>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_features.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_features.jpg" height="235" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin features Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Configure Server Templates</h4>
<p>Server template are used to customize the services and to create packages for different hosting account types.<br />
&nbsp; </p>
<h4>Apache Template</h4>
<p>You can make changes to the way apache virtual hosts are created by editing this template, The defaults however will do for purposes of this howto.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_apache.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_apache.jpg" height="350" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin apache Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Domain Owner Template</h4>
<p>This template is used to configure various server limits such as number of mailboxes,aliases,databases,virtual servers and other options like bandwidth limits, admin abilities. For this howto we will use the default values.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_limits.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_limits.jpg" height="356" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin limits Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Home Directory Template</h4>
<p>This template allows you to set a skel directory to hold setting for new users for this howto we will use the defaults.<br />
&nbsp; </p>
<h4>Administration User</h4>
<p>This template lets you set the quota for the virtual server and the admin user for this howto we will use the default quota 1GB.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_adminuser.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_adminuser.jpg" height="230" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin adminuser Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Mail For Domain Template</h4>
<p>This template sets various mail related options, we will modify the email message sent on server creation to have the content below:<br />
</p>
<pre>The following virtual server has been set up successfully :
Domain name:             ${DOM}
Hosting server:          ${HOSTNAME}
${IF-VIRT}
Virtual IP address:      ${IP}
${ENDIF-VIRT}
Administration login:    ${USER}
Administration password: ${PASS}
${IF-WEBMIN}
Administration URL:      ${WEBMIN_PROTO}://www.${DOM}:${WEBMIN_PORT}/
${ENDIF-WEBMIN}
${IF-WEB}
Website:                 http://www.${DOM}/
${IF-WEBALIZER}
Webalizer log reporting: Enabled
${ELSE-WEBALIZER}
Webalizer log reporting: Disabled
${ENDIF-WEBALIZER}
${ENDIF-WEB}
${IF-MAIL}
Email domain:            ${DOM}
SMTP server:             mail.${DOM}
POP3 server:             mail.${DOM}
Webmail:                 webmail.${DOM}
${ENDIF-MAIL}
${IF-DNS}
DNS domain:              ${DOM}
Nameserver:              ${HOSTNAME}
${ENDIF-DNS}
${IF-MYSQL}
MySQL database:          ${DB}
MySQL login:             ${MYSQL_USER}
MySQL password:          ${PASS}
${ENDIF-MYSQL}
${IF-POSTGRES}
PostgreSQL database:     ${DB}
PostgreSQL login:        ${USER}
PostgreSQL password:     ${PASS}
${ENDIF-POSTGRES}
</pre>
<p> We will leave the other options as the defaults.<br />
<br />
&nbsp;</p>
<h4>BIND DNS Domain Template</h4>
<p>This template is used to customize the zones that will be created by virtualmin. The changes to be made are adding a spf record, add the following records to auto generated text box (replace <span class="system">ns1.home.topdog-software.com.</span> with your slave server):<br />
</p>
<pre>@     IN NS ns1.home.topdog-software.com. ;slave
admin IN A 192.168.1.6 ;virtualmin
webmail IN A 192.168.1.5 ;webmail
</pre>
<p> In the directives text box add the following with the IP address of your slave server such that the slave is allowed to do zone transfers.<br />
</p>
<pre>allow-transfer { 192.168.1.2; };
</pre>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_bind.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_bind.jpg" height="333" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin bind Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>MySQL Database Template</h4>
<p>Contains options on creation of databases by virtualmin, for the howto we will use the defaults.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_my.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_my.jpg" height="234" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin my Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Webmin Login Template</h4>
<p>Contains option on creation of new users by virtualmin, for the howto we will use the defaults.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_vmuser.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_vmuser.jpg" height="199" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin vmuser Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h4>Create Virtual Server</h4>
<p>Finally we have a working virtual server system, lets create our first virtual server. Go to servers ? virtualmin virtual servers and click add new virtual server, owned by new user.<br />
</p>
<p>Fill in the require fields and click create.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_newserver.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_newserver.jpg" height="193" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin newserver Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_servercreated.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_servercreated.jpg" height="226" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin servercreated Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)</p>
<p>Add a mail user to the domain. click on the domain name, then click edit mail and FTP users, then add user and fill in the information.<br />
</p>
<p>  <a href="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/big/virtualmin_createuser.jpg" class="thickbox"><img src="http://tusforyou.com/images/virtual_hosting_virtualmin_centos5.1/virtualmin_createuser.jpg" height="207" width="550" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" alt="virtualmin createuser Virtual Hosting Howto With Virtualmin On CentOS 5.1" />
<div><img src="http://tusforyou.com/images/click_to_enlarge.png" width="100" height="12" border="0" alt="Click to enlarge" title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> </div>
<p></a>(JavaScript must be enabled in your browser to view the large image as an image overlay.)<br />
&nbsp;</p>
<h3>Testing</h3>
<h3>Postfix</h3>
<h4>Test SMTP </h4>
</p>
<p class="command">
telnet 192.168.1.5 25<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.<br />
220 tds mail cluster<br />
helo me<br />
250 hosting1<br />
mail from:address@yahoo.com<br />
250 2.1.0 Ok<br />
rcpt: andrew@example.com<br />
250 2.1.0 Ok<br />
DATA<br />
354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;</p>
<p>From:address@yahoo.com<br />
To:andrew@example.com<br />
Subject:This is a test<br />
Hi<br />
This is a test<br />
.<br />
250 2.0.0 Ok: queued as 4ACCC7C5A6</p>
<p class="command">
telnet 192.168.1.5 25<br />
Trying 192.168.1.5&#8230;<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.<br />
220 tds mail cluster<br />
ehlo me<br />
250-hosting1<br />
250-PIPELINING<br />
250-SIZE 10240000<br />
250-ETRN<br />
250-STARTTLS<br />
250-ENHANCEDSTATUSCODES<br />
250-8BITMIME<br />
250 DSN<br />
&nbsp;</p>
<h4>Test dkim</h4>
<p>Send a mail to autorespond+dkim@dk.elandsys.com.<br />
&nbsp;</p>
<h4>Test domainkeys</h4>
<p>Send a mail to autorespond+dk@dk.elandsys.com.<br />
&nbsp; </p>
<h3>Dovecot</h3>
<h4>Test POP3</h4>
</p>
<p class="command">
telnet 192.168.1.5 110<br />
+OK Dovecot ready.<br />
user andrew.example<br />
+OK<br />
pass password<br />
+OK Logged in.<br />
quit<br />
+OK Logging out.<br />
&nbsp;</p>
<h4>Test IMAP </h4>
</p>
<p class="command">
telnet 192.168.1.5 143<br />
* OK Dovecot ready.<br />
01 login andrew.example password<br />
01 OK User logged in<br />
01 list &#8220;&#8221; &#8220;*&#8221;</p>
<p>* LIST (\HasNoChildren) &#8220;.&#8221; &#8220;Trash&#8221;<br />
* LIST (\HasNoChildren) &#8220;.&#8221; &#8220;Drafts&#8221;<br />
* LIST (\HasNoChildren) &#8220;.&#8221; &#8220;Junk&#8221;<br />
* LIST (\HasNoChildren) &#8220;.&#8221; &#8220;Sent&#8221;</p>
<p>* LIST (\HasNoChildren) &#8220;.&#8221; &#8220;INBOX&#8221;<br />
01 OK List completed.<br />
01 logout<br />
* BYE LOGOUT received<br />
01 OK Completed<br />
&nbsp;</p>
<h3>BIND</h3>
</p>
<p class="command">
dig example.com @127.0.0.1<br />
&nbsp;</p>
<h3>Clamav-milter</h3>
<p>We are using the test virus from <a href="http://www.eicar.org" target="_blank">www.eicar.org</a>.<br />
</p>
<p class="command">
telnet 192.168.1.5 25<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.<br />
220 tds mail cluster<br />
helo me<br />
250 hosting1<br />
mail from:address@yahoo.com<br />
250 2.1.0 Ok<br />
rcpt: andrew@example.com<br />
250 2.1.0 Ok<br />
DATA<br />
354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;</p>
<p>X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*<br />
.<br />
550 5.7.1 virus Eicar-Test-Signature detected by ClamAV - http://www.clamav.net<br />
quit<br />
221 2.0.0 Bye</p>
<p>Take a lot at your <span class="system">/var/log/maillog</span> you should see something like this:<br />
</p>
<pre>73BC87C4E4: milter-reject: END-OF-MESSAGE from localhost[127.0.0.1]:
5.7.1 virus Eicar-Test-Signature detected by ClamAV &#8211; http://www.clamav.net;
from=&lt;address@yahoo.com&gt; to=&lt;andrew@example.com&gt; proto=SMTP helo=&lt;me&gt;
</pre>
<p>&nbsp;</p>
<h3>Spamass-milter</h3>
<p>We are using the test message from <a href="http://spamassassin.apache.org/gtube/" target="_blank">http://spamassassin.apache.org/gtube/</a>.<br />
</p>
<p class="command">
telnet 192.168.1.5 25<br />
Connected to localhost.<br />
Escape character is '^]'.<br />
220 tds mail cluster<br />
helo me<br />
250 hosting1<br />
mail from:address@yahoo.com<br />
250 2.1.0 Ok<br />
rcpt: andrew@example.com<br />
250 2.1.0 Ok<br />
DATA<br />
354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;</p>
<p>XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X<br />
.<br />
550 5.7.1 Blocked by SpamAssassin<br />
quit<br />
221 2.0.0 Bye</p>
<p> You will see this in your log files:<br />
</p>
<pre>spamd: result: Y 1002 - AWL,GTUBE,MISSING_SUBJECT,TVD_SPACE_RATIO,UNPARSEABLE_RELAY scantime=0.5,size=723,user=root,uid=99,required_score=5.0,
</pre>
<div class="book">
<div class="tree"></div>
<div class="nav1">
<div class="links">
<div class="prev"><a href="virtual-hosting-with-virtualmin-on-centos5.1-p5" title="View the previous page.">previous</a></div>
<div class="next"><a href="" title="View the next page.">next</a></div>
<div class="up"><a href="virtual-hosting-with-virtualmin-on-centos5.1" title="View this page&#39;s parent section.">up</a></div>
</p></div>
<div class="titles">
<div class="prev">Virtual Hosting Howto With Virtualmin On CentOS 5.1 - Page 5</div>
<div class="next"></div>
</p></div>
</p></div>
</p></div>
</p>
<div class="copyright-footer">Copyright © 2008 Andrew Colin Kissa<br />All Rights Reserved.
</div>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Hosting Howto With Virtualmin On CentOS 5.1</title>
		<link>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p5-3/</link>
		<comments>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p5-3/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 06:57:32 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Virtual]]></category>
		<category><![CDATA[Virtualmin]]></category>
		<category><![CDATA[With]]></category>

		<guid isPermaLink="false">http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p5-3/</guid>
		<description><![CDATA[
Clamav Milter Setup

Edit /etc/sysconfig/clamav-milter:


CLAMAV_FLAGS="
        --config-file=/etc/clamd.conf
        --force-scan
        --local
        --max-children=5
        --sendmail-cf=
        --outgoing
    [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span id="more-2037"></span></p>
<h3>Clamav Milter Setup</h3>
<ul>
<li>Edit <span class="system">/etc/sysconfig/clamav-milter</span>:
</li>
</ul>
<pre>CLAMAV_FLAGS="
        --config-file=/etc/clamd.conf
        --force-scan
        --local
        --max-children=5
        --sendmail-cf=
        --outgoing
        --quiet
"
SOCKET_ADDRESS="local:/var/clamav/clmilter.socket"
</pre>
<ul>
<li>Patch the init file to fix socket permissions:</li>
</ul>
<p class="command">
wget http://www.topdog-software.com/files/clamav-milter.patch<br />
patch /etc/init.d/clamav-milter &lt; clamav-milter.patch<br />
<br />
&nbsp;</p>
<h3>MySQL Setup</h3>
<h4>Basic Config</h4>
<ul>
<li> Listen only to the localhost, edit <span class="system">/etc/my.cnf</span> under the mysqld section:
</li>
</ul>
<pre>bind-address = 127.0.0.1
</pre>
<p>&nbsp;</p>
<h4>Set Root Password</h4>
<ul>
<li> Set the root password:
</li>
</ul>
<p class="command">
service mysqld start<br />
mysqladmin -u root password NEWPASSWORD<br />
<br />
&nbsp;</p>
<h3>SpamAssassin Setup</h3>
<h4>Basic Config</h4>
<pre>required_hits 5
report_safe 0
rewrite_header Subject [SPAM]
</pre>
<p>&nbsp;</p>
<h4>Create MySQL Database</h4>
<ul>
<li> Create the database:
</li>
</ul>
<p class="command">
mysqladmin -p create bayes</p>
<ul>
<li> Populate the database:
</li>
</ul>
<p class="command">
mysql -p bayes &lt; /usr/share/doc/spamassassin-$(rpm &#8211;qf %{VERSION} -q spamassassin)/sql/bayes_mysql.sql</p>
<ul>
<li> Create the user:
</li>
</ul>
<p class="command">
mysql -p<br />
mysql&gt; GRANT ALL ON bayes.* TO bayes@localhost IDENTIFIED BY &#8216;password&#8217;;<br />
&nbsp;</p>
<h4>Configure To Use DB </h4>
<ul>
<li> Edit the file <span class="system">/etc/mail/spamassassin/local.cf</span> and add:
</li>
</ul>
<pre>bayes_store_module  Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn       DBI:mysql:bayes:localhost
bayes_sql_override_username bayes
bayes_sql_username  bayes
bayes_sql_password  password
</pre>
<p>&nbsp;</p>
<h4>Configure FuzzyOCR</h4>
<p>We will be storing the image hashes in a mysql database to improve on performance such that images that we have already scanned do not get scanned again as OCR is a resource intense activity. <br />
&nbsp; </p>
<h4>Create MySQL Database</h4>
<ul>
<li> The sql script creates the database and tables and adds a user fuzzyocr with the password fuzzyocr:
</li>
</ul>
<p class="command">
mysql -p &lt; /usr/local/src/devel/FuzzyOcr.mysql</p>
<ul>
<li> Change the password:
</li>
</ul>
<p class="command">
mysqladmin -u fuzzyocr -p fuzzyocr password<br />
&nbsp;</p>
<h4>Basic Settings</h4>
<ul>
<li> Edit <span class="system">/etc/mail/spamassassin/FuzzyOCR.cf</span> and set the basic options:
</li>
</ul>
<pre>focr_path_bin /usr/bin:/usr/local/bin
focr_minimal_scanset 1
focr_autosort_scanset 1
focr_enable_image_hashing 3
focr_logfile /tmp/FuzzyOcr.log
</pre>
<p>&nbsp;</p>
<h4>Make FuzzyOCR Use The Database</h4>
<ul>
<li> Edit the file <span class="system">/etc/mail/spamassassin/FuzzyOcr.cf</span> and add:
</li>
</ul>
<pre>focr_mysql_db FuzzyOcr
focr_mysql_hash Hash
focr_mysql_safe Safe
focr_mysql_user fuzzyocr
focr_mysql_pass password
focr_mysql_host localhost
focr_mysql_port 3306
focr_mysql_socket /var/lib/mysql/mysql.sock
</pre>
<p>&nbsp;</p>
<h4>SARE Rule Updates</h4>
<ul>
<li> Import the GPG key used to sign the rules:
</li>
</ul>
<p class="command">
mkdir /etc/mail/spamassassin/sa-update-keys/<br />
chmod 700 /etc/mail/spamassassin/sa-update-keys/<br />
wget http://daryl.dostech.ca/sa-update/sare/GPG.KEY<br />
sa-update &#8211;import GPG.KEY<br />
</p>
<ul>
<li> Create the channels file <span class="system">/etc/mail/spamassassin/sare-sa-update-channels.txt</span>:
</li>
</ul>
<pre>updates.spamassassin.org
72_sare_redirect_post3.0.0.cf.sare.sa-update.dostech.net
70_sare_evilnum0.cf.sare.sa-update.dostech.net
70_sare_bayes_poison_nxm.cf.sare.sa-update.dostech.net
70_sare_html0.cf.sare.sa-update.dostech.net
70_sare_html_eng.cf.sare.sa-update.dostech.net
70_sare_header0.cf.sare.sa-update.dostech.net
70_sare_header_eng.cf.sare.sa-update.dostech.net
70_sare_specific.cf.sare.sa-update.dostech.net
70_sare_adult.cf.sare.sa-update.dostech.net
72_sare_bml_post25x.cf.sare.sa-update.dostech.net
99_sare_fraud_post25x.cf.sare.sa-update.dostech.net
70_sare_spoof.cf.sare.sa-update.dostech.net
70_sare_random.cf.sare.sa-update.dostech.net
70_sare_oem.cf.sare.sa-update.dostech.net
70_sare_genlsubj0.cf.sare.sa-update.dostech.net
70_sare_genlsubj_eng.cf.sare.sa-update.dostech.net
70_sare_unsub.cf.sare.sa-update.dostech.net
70_sare_uri0.cf.sare.sa-update.dostech.net
70_sare_obfu0.cf.sare.sa-update.dostech.net
70_sare_stocks.cf.sare.sa-update.dostech.net
</pre>
<ul>
<li> Create an update script <span class="system">/usr/local/bin/update-sa</span>:
</li>
</ul>
<pre>#!/bin/bash
#
#
sa-update -D --channelfile /etc/mail/spamassassin/sare-sa-update-channels.txt --gpgkey 856AA88A &amp;&gt;/var/log/sa-updates.log
</pre>
<ul>
<li> Make it executable and add to cron:
</li>
</ul>
<p class="command">
chmod +x /usr/local/bin/update-sa<br />
ln -s /usr/local/bin/update-sa /etc/cron.daily/<br />
ln -s /usr/local/bin/update-sa /etc/cron.hourly/<br />
<br />
&nbsp;</p>
<h3>Spamass-milter Setup</h3>
<h4>Basic Configuration</h4>
<ul>
<li> Edit <span class="system">/etc/sysconfig/spamass-milter</span>:
</li>
</ul>
<pre>SOCKET=/var/run/spamass.sock
EXTRA_FLAGS="-m -r 8"
</pre>
<p>&nbsp;</p>
<h4>Patch</h4>
<p>We need to <a href="http://www.topdog-software.com/files/spamass-milter.patch" target="_blank">patch</a> the init file to fix the permissions of the socket created such that postfix is able to use the socket.<br />
</p>
<p class="command">
wget http://www.topdog-software.com/files/spamass-milter.patch<br />
patch /etc/rc.d/init.d/spamass-milter &lt; spamass-milter.patch</p>
<p>&nbsp;</p>
<h3>Apache Setup</h3>
<h4>Disable Modules</h4>
<p>We will disable some modules that we are not using thus freeing up memory and also improving security.<br />
</p>
<ul>
<li> Edit <span class="system">/etc/httpd/conf/httpd.conf</span> and comment out the modules as below.
</li>
</ul>
<pre>#LoadModule ldap_module modules/mod_ldap.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule status_module modules/mod_status.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule mem_cache_module modules/mod_mem_cache.so
</pre>
<ul>
<li> Edit <span class="system">/etc/httpd/conf.d/proxy_ajp.conf</span> and comment out as below:
</li>
</ul>
<pre>#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
</pre>
<p>&nbsp;</p>
<h4>Listen To One IP For HTTPS </h4>
<p>Apache has to be configured to listed to one address for port 443 as webmin will be using the same port. Edit <span class="system">/etc/httpd/conf.d/ssl</span>:<br />
</p>
<pre>Listen 192,168.1.6:443
</pre>
<p>&nbsp;</p>
<h4>Enable Gzip Compression</h4>
<p>We setup gzip compression via the mod_deflate module to improve web server performance and to cut down on bandwidth usage by compressing responses to the client.<br />
</p>
<pre>SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</pre>
<p> Set up logging for the deflate module:<br />
</p>
<pre>DeflateFilterNote deflate_ratio
LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b mod_deflate: %{deflate_ratio}n pct." vhost_with_deflate_info
CustomLog logs/deflate_access_log vhost_with_deflate_info
</pre>
<p>&nbsp;</p>
<h4>Increase PHP Max Memory</h4>
<p>Edit the file <span class="system">/etc/php.ini</span> and set the following:<br />
</p>
<pre>memory_limit = 64M
</pre>
<p>&nbsp;</p>
<h4>Enable Virtual Hosting</h4>
<pre>NameVirtualHost *:80
</pre>
<p>&nbsp;</p>
<h4>Create Default Virtual Host</h4>
<p>This needs to be the first virtual host, it will be the default on the server the equivalent of the server with out virtual hosting.<br />
</p>
<pre>&lt;VirtualHost *:80&gt;
        Servername localhost.localdomain
        Serveradmin root@localhost.localdomain
&lt;/Virtualhost&gt;
</pre>
<p>&nbsp;</p>
<h3>Roundcube Webmail Setup</h3>
<h4>Create Database</h4>
<ul>
<li> Create the database and add the roundcube user.
</li>
</ul>
<p class="command">
mysqladmin -p create roundcube<br />
mysql -p<br />
mysql&gt; GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY &#8216;password&#8217;;</p>
<ul>
<li> Initialize the database:
</li>
</ul>
<p class="command">
mysql -u roundcube -p roundcube &lt; /usr/share/doc/roundcube-0.1/SQL/mysql5.initial.sql<br />
&nbsp;</p>
<h4>Basic Config</h4>
<ul>
<li> Configure database DSN in <span class="system">/var/www/roundcube/config/db.inc.php</span>:
</li>
</ul>
<pre>$rcmail_config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcube';
</pre>
<ul>
<li> Configure roundcube in <span class="system">/var/www/roundcube/config/main.inc.php</span>:
</li>
</ul>
<pre>$rcmail_config['default_host'] = 'localhost';
$rcmail_config['default_port'] = 143;
$rcmail_config['virtuser_file'] = '/etc/postfix/virtual';
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_port'] = 25;
$rcmail_config['smtp_helo_host'] = 'localhost';
</pre>
<p>&nbsp;</p>
<h4>Set Up Catch All Virtualhost</h4>
<p>As we will be providing webmail for all domains that are created on the system we need to setup a catch all virtualhost that can display roundcube when ever a user accesses <span class="system">http://webmail.domainname</span>. Edit <span class="system">/etc/httpd/conf/httpd.conf</span> and append:<br />
</p>
<pre>&lt;VirtualHost *:80&gt;
ServerName webmail.example.com
ServerAlias webmail.*
DocumentRoot /var/www/roundcube
&lt;Directory /var/www/roundcube&gt;
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
&lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre>
<p>&nbsp;</p>
<h3>Firewall Setup</h3>
<h4>Introduction</h4>
<p>This is a basic firewall it may not suit your needs, firewalling is an art so i recommend to read into it to improve on this basic one.<br />
<br />
&nbsp;</p>
<h4>Basic Config</h4>
<p>Add these rules in your configuration file <span class="system">/etc/sysconfig/iptables</span>:<br />
</p>
<pre>*raw <img src='http://tusforyou.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> REROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*nat <img src='http://tusforyou.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> REROUTING ACCEPT [0:0] <img src='http://tusforyou.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> OSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*mangle <img src='http://tusforyou.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> REROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0] <img src='http://tusforyou.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Virtual Hosting Howto With Virtualmin On CentOS 5.1" /> OSTROUTING ACCEPT [0:0]
COMMIT
*filter
:FORWARD DROP [0:0]
:INPUT DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m multiport -j ACCEPT --dports 80,443,25,110,143,53
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p icmp -m icmp -m limit --icmp-type 8 --limit 5/min -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -s 127.0.0.1 -j ACCEPT
-A OUTPUT -s 192.168.1.5 -j ACCEPT
-A OUTPUT -s 192.168.1.6 -j ACCEPT
COMMIT
</pre>
<p>&nbsp;</p>
<h4>Activate Config</h4>
</p>
<p class="command">service iptables restart
<div class="book">
<div class="tree"></div>
<div class="nav1">
<div class="links">
<div class="prev"><a href="virtual-hosting-with-virtualmin-on-centos5.1-p4" title="View the previous page.">previous</a></div>
<div class="next"><a href="virtual-hosting-with-virtualmin-on-centos5.1-p6" title="View the next page.">next</a></div>
<div class="up"><a href="virtual-hosting-with-virtualmin-on-centos5.1" title="View this page&#39;s parent section.">up</a></div>
</p></div>
<div class="titles">
<div class="prev">Virtual Hosting Howto With Virtualmin On CentOS 5.1 &#8211; Page 4</div>
<div class="next">Virtual Hosting Howto With Virtualmin On CentOS 5.1 &#8211; Page 6</div>
</p></div>
</p></div>
</p></div>
</p>
<div class="copyright-footer">Copyright © 2008 Andrew Colin Kissa<br />All Rights Reserved.
</div>
]]></content:encoded>
			<wfw:commentRss>http://tusforyou.com/virtual-hosting-with-virtualmin-on-centos5-1-p5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
