<?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>diginc &#187; Apache</title>
	<atom:link href="http://diginc.us/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://diginc.us</link>
	<description>\'dij-iŋk\</description>
	<lastBuildDate>Fri, 18 Jun 2010 20:17:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using fail2ban to open back door ports in your iptables</title>
		<link>http://diginc.us/2009/09/using-fail2ban-to-open-back-doors-ports-in-your-iptables/</link>
		<comments>http://diginc.us/2009/09/using-fail2ban-to-open-back-doors-ports-in-your-iptables/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:38:26 +0000</pubDate>
		<dc:creator>diginc</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[auth2accept]]></category>
		<category><![CDATA[auth2allow]]></category>
		<category><![CDATA[fail2accept]]></category>
		<category><![CDATA[fail2allow]]></category>
		<category><![CDATA[fail2ban]]></category>

		<guid isPermaLink="false">http://diginc.us/?p=108</guid>
		<description><![CDATA[The opposite of fail2ban would probably be called auth2allow (authenticate to allow) or fail2allow &#8211; but that&#8217;s not necessary because fail2ban&#8217;s configs can be customized to do exactly what I&#8217;m talking about. What am I talking about you ask? Basically &#8230; <a href="http://diginc.us/2009/09/using-fail2ban-to-open-back-doors-ports-in-your-iptables/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The opposite of <a href="http://www.fail2ban.org">fail2ban</a> would probably be called auth2allow (authenticate to allow) or fail2allow &#8211; but that&#8217;s not necessary because fail2ban&#8217;s configs can be customized to do exactly what I&#8217;m talking about.  What am I talking about you ask?  Basically what I&#8217;ve done and am about to explain how to do is setup fail2ban to look for a successful login on a FTP to allow the authenticated IP to get access to another port that isn&#8217;t as secure as FTP so is usually 100% black listed in IPTables.  It&#8217;s just a hack of a security mechanism to allow your self or others into places securely through obscure means.  Like most security it&#8217;s not perfect but it seems pretty solid in my mind.  </p>
<p>If someone can authenticate on the FTP (could even be anonymous ftp, but I&#8217;d recommend using a special username you want to specifically grant access) then fail2ban triggers an ALLOW command for their IP on some port (or all ports), for example SSH (22) or apache https (443) with a private site on it that you want to keep private and totally hidden from the internet at large.  This concept could really apply to anything.  Any command IPTables can run can be triggered through something fail2ban sees in a log file basically, the possibilities are endless.  In my example I&#8217;ll use https, port 443, but in real life I&#8217;m using an obscure port number and the program running on it that is not very secure by default.</p>
<p>So here are my slightly modified configuration files for setting up a custom fail2ban service that does the opposite of what fail2ban typically does.</p>
<p><span id="more-108"></span></p>
<p>In /etc/fail2bain/jail.conf I added:</p>
<pre>
 [vsftpd2allow443]

 enabled  = true
 port     = 443
 filter   = vsftpd-2-https
 banaction = iptables-accept-https
 logpath  = /var/log/vsftpd.log
 maxretry = 1
 bantime  = -1
</pre>
<p>filter has to match the name of the corresponding file in the <code>/etc/fail2ban/filter.d</code> folder.  banaction has to match the corresponding file in the <code>/etc/fail2ban/action.d</code> folder.  Max retry is 1 so the person doesn&#8217;t need to successfully login to the FTP more than once to get access to our secret port back door.  Bantime -1 should add the person for ever.  For added security try <code>bantime = 86400</code> for 1 days access (bantime uses seconds).</p>
<p>Next make a copy of a default action for a template:</p>
<pre>
 cp -vip /etc/fail2ban/action.d/iptables.conf /etc/fail2ban/action.d/iptables-accept-https.conf
</pre>
<p>Then modify all the DENYs to ACCEPT and change the port:</p>
<pre>
 actionban = iptables -I fail2ban-<name> 1 -s <ip> -j DROP
 # Becomes
 actionban = iptables -I fail2ban-<name> 1 -s <ip> -j ACCEPT

 actionunban = iptables -D fail2ban-<name> -s <ip> -j DROP
 # Becomes
 actionunban = iptables -D fail2ban-<name> -s <ip> -j ACCEPT

 port = ssh
 # Becomes
 port = 443
</pre>
<p>And lastly you need your fail2ban filter that watches vsftpd for successful authenticions of our special user who gets special ports opened up for them.  Since I&#8217;m using vsftpd as my FTP I just copied it&#8217;s current filter and modified it to look for good auths instead of bad auths. </p>
<pre>
 cp -vip /etc/fail2ban/filter.d/vsftpd.conf /etc/fail2ban/filter.d/vsftpd-2-accept-https.conf
</pre>
<p>Change &#8216;<code>specialuser</code>&#8216; to whatever FTP user you want to gain special access to your server.</p>
<pre>
 failregex = vsftpd(?:\(pam_unix\))?(?:\[\d+\])?:.* authentication failure; .* rhost=<HOST>(?:\s+user=\S*)?\s*$
     \[.+\] FAIL LOGIN: Client "<HOST>"\s*$
 # Becomes
 failregex = vsftpd(?:\(pam_unix\))?(?:\[\d+\])?:.* authentication failure; .* rhost=<HOST>(?:\s+user=\S*)?\s*$
     \[specialuser\] OK LOGIN: Client "<HOST>"\s*$
</pre>
<p>If you&#8217;re not using VFTPd then fail2ban has many other popular linux FTP client&#8217;s setup in the filter.d folder.  You should also look in your log file (<code>ls /var/log/*ftp*</code> should find it) to find out what syntax it uses to denote a successful FTP login because it will most likely be different than what VSFTPd uses.</p>
<p>Now you just need to remember the password for your <code>specialuser</code> and you just FTP to your server with that login from any computer in the world to open your hidden port to access your secret content.  This idea is mostly for personal use and I recommend against trying to have any beginner users use this as a mechanism for accessing content or even using it in a serious This slight modification isn&#8217;t revolutionary or anything and I may not be the first to come up with it but it definitely isn&#8217;t a well search indexed idea so I thought I&#8217;d throw this out there for others.</p>
]]></content:encoded>
			<wfw:commentRss>http://diginc.us/2009/09/using-fail2ban-to-open-back-doors-ports-in-your-iptables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu SABnzbd+ protected by an apache2 proxy and htpasswd</title>
		<link>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/</link>
		<comments>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 00:00:48 +0000</pubDate>
		<dc:creator>diginc</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[sabnzbd]]></category>
		<category><![CDATA[usenet]]></category>

		<guid isPermaLink="false">http://diginc.us/?p=35</guid>
		<description><![CDATA[Basic SABnzbd+ Setup &#8211; SAB for short. There are plenty of tutorials out there which cover configuring a normal SAB installation so I won&#8217;t cover that here. What I am going to do is make my SAB available through a &#8230; <a href="http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Basic SABnzbd+ Setup</strong> &#8211; SAB for short.</p>
<p>There are plenty of tutorials out there which cover configuring a normal SAB installation so I won&#8217;t cover that here.  What I am going to do is make my SAB available through a web accessible passworded page, this can be accomplished with default SAB features by putting a web username/password in the general configuration section.  However I find it annoying to have to enter the password when I&#8217;m on my internal 192.168 home network just to make it protected from the outside, and I don&#8217;t like the way it presents the username/password prompt in a website form rather than an generic apache pop-up.  I&#8217;m sure open accessibility could be fixed in the SABnzbd+ code but I&#8217;m not a pro python hacker yet so I&#8217;ll just stick to what I know.</p>
<p>Basically I want a generic pop-up password that is only for people outside my network so I&#8217;m not bothered with SAB passwords while at home (And I can&#8217;t get <a href="https://nzbdstatus.bountysource.com/">nzbdStatus</a> to work with a pass enabled).  The htpasswd also acts as a bit of camouflage and additional security.  There are some concepts which aren&#8217;t covered here which are required, you need to know how to configure your own SAB servers, Portforwarding or Firewall/iptables.</p>
<p>If you&#8217;re using a router, you&#8217;re going to want to make sure you&#8217;re not port forwarding the default SAB port of 8080 (which would make it wide open) and only are forwarding the apache2 port you setup for the SAB proxy.  If you&#8217;re not on an internal IP subnet and have a static IP assigned directly to the linux machine you&#8217;re doing this on then I expect you have enough knowledge of IPTables to block the SAB port and allow the proxy port.</p>
<p><span id="more-35"></span></p>
<p><strong>SABnzbd Daemon (optional)</strong></p>
<p>Download the latest SABnzbd version from http://www.sabnzbd.org/download/ to your favorite place to install python apps and optionally install a deamon to auto start SAB: <a href="http://artur.hefczyc.net/node/10">http://artur.hefczyc.net/node/10</a>.  Mine is modified to include a restart command:</p>
<p><code><br />
#!/bin/sh<br />
# Source: http://sabnzbd.wikidot.com/install-as-a-unix-daemon<br />
case "$1" in<br />
start)<br />
echo "Starting SABnzbd."<br />
/usr/bin/sudo -u sabuser -H /usr/local/src/SABnzbd/SABnzbd.py -d -f /home/sabuser/.sabnzbd/sabnzbd.ini<br />
;;<br />
stop)<br />
echo "Shutting down SABnzbd."<br />
/usr/bin/wget -q --delete-after "http://localhost:8080/sabnzbd/api?mode=shutdown"<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
exit 1<br />
esac<br />
exit 0<br />
</code><br />
At this point I&#8217;ll assume you have a working sabnzbd installation and have tested to confirm it&#8217;s working.</p>
<p><code>vi /home/sabuser/.sabnzbd/sabnzbd.ini</code><br />
Change <code>host = localhost</code> to <code>host = 192.168.0.53</code> to make it accessible from elsewhere besides the box running SAB.<br />
That&#8217;s all you need to do with SAB other than configure servers and preferences.</p>
<p><strong>Apache Proxy Setup</strong><br />
<code><br />
apt-get install apache2<br />
htpasswd -c /usr/local/src/SABnzbd/.htpasswd username # Enter your password when prompted<br />
a2enmod proxy<br />
a2enmod proxy_http<br />
a2enmod proxy_html</code></p>
<p>Ubuntu mod_proxy Denies all but default so you&#8217;ll need to make a similar modification to what follows &#8211; see your Apache error files for something like  if your proxy isn&#8217;t working.  You can either change <code>Deny from all</code> to <code>Allow from all</code> if you expect to be using it from any external IP address or individual IPs you&#8217;ll expect needing access (work IP).  In my case 192.168.0.1 port forwards so that&#8217;s the only one I need but I put in my entire internal subnet for testing purposes.<br />
<code>vi /etc/apache2/mods-enabled/proxy.conf</code><br />
<code>&lt;Proxy *&gt;<br />
  AddDefaultCharset off<br />
  Order deny,allow<br />
  Deny from all<br />
  Allow from 192.168.0.0/24<br />
&lt;Proxy&gt;</code></p>
<p>Add something like this to your apache2 vhost config (logs are optional)<br />
<code>vi /etc/apache2/conf.d/vhosts.conf</code><br />
<code><br />
Listen 8001 # Use whatever port you want, I usually use obscure ports that aren't regularly scanned.<br />
NameVirtualHost 192.168.0.53:8001  # Change 192.168.0.53 to whatever your SAB server's IP is (make sure it's static too).<br />
</code><code><br />
&lt;VirtualHost 192.168.0.53:8001&gt;<br />
ServerName sabuser.dyndns.org # Enter your hostname or <strong>static</strong> IP address here.  I use dyndns.org since I have a dynamic IP<br />
ProxyPass /sabnzbd http://192.168.0.53:8080/sabnzbd/<br />
ProxyPassReverse /sabnzbd http://192.168.0.53:8080/sabnzbd/<br />
ProxyPreserveHost On<br />
# Password Protect the external proxy only.<br />
&lt;Location /sabnzbd&gt;<br />
AuthUserFile /usr/local/src/SABnzbd/.htpasswd<br />
AuthName "Authenticate Yourself."<br />
AuthType Basic<br />
Require valid-user<br />
&lt;/Location&gt;<br />
# Alternate method, requires rewrite mod:<br />
#RewriteEngine   on<br />
#RewriteRule     (.*) http://192.168.0.53:8080/sabnzbd/$1 [P]<br />
&lt;/VirtualHost&gt;<br />
</code></p>
<p>References</p>
<p># Apache Proxy<br />
<a href="http://snippets.dzone.com/posts/show/1318">http://snippets.dzone.com/posts/show/1318</a><br />
<a href="http://mail-archives.apache.org/mod_mbox/httpd-users/200307.mbox/%3C20030723191854.43885.qmail@web40903.mail.yahoo.com%3E">http://mail-archives.apache.org/mod_mbox/httpd-users/200307.mbox/%3C20030723191854.43885.qmail@web40903.mail.yahoo.com%3E</a><br />
<a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">http://httpd.apache.org/docs/2.2/mod/mod_proxy.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
