<?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>RandomStringOfWords &#187; htaccess</title>
	<atom:link href="http://randomstringofwords.com/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://randomstringofwords.com</link>
	<description>RandomStringOfWords.com &#124;&#124; RSoW.com</description>
	<lastBuildDate>Mon, 26 Mar 2012 20:35:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A bots route to localhost</title>
		<link>http://randomstringofwords.com/a-bots-route-to-localhost/</link>
		<comments>http://randomstringofwords.com/a-bots-route-to-localhost/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 19:26:44 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[RandomStrings]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://info.rsow.com/a-bots-route-to-localhost/</guid>
		<description><![CDATA[Recently my server came under what I can only describe as an attack. Clearly some poorly written bot was trying to slurp emails or some such and was sucking up bandwidth by repeatedly loading the same loop of pages. Normally this sort of thing comes and goes and really doesn&#8217;t cause much nuisance, but when [...]]]></description>
			<content:encoded><![CDATA[<p>Recently my server came under what I can only describe as an attack.  Clearly some poorly written bot was trying to slurp emails or some such and was sucking up bandwidth by repeatedly loading the same loop of pages.</p>
<p>Normally this sort of thing comes and goes and really doesn&#8217;t cause much nuisance, but when they broke the 50,000 page load mark in less than 24 hours I started to get annoyed.</p>
<p><span id="more-117"></span></p>
<p>My initial reaction was to complain to the ISP and simply block them with a .htaccess file.    I thought about it and realized that this isn&#8217;t a very good solution simply because that method still delivers to them my &#8220;Go away&#8221; page.</p>
<p>So I asked an admin buddy of mine what he thought I should do beyond the .htaccess or iptables.   Specifically if there was anything fun we could do back.  Something subtle that isn&#8217;t a direct hack back, but rather just something to get the message across.</p>
<p>He came up with this;</p>
<blockquote><p>route add -host {incoming.annoying.bots.ip}  gw 127.0.0.1</p></blockquote>
<p>Evidently this will route the bot directly back to itself ~ localhost.  Which just amuses the hell out of me.  What&#8217;s more is, it will likely take about 5 minutes per hit for the TCP/IP layer to time out.  So it will really slow their bot down, which I&#8217;m pretty sure the rest of the internet appreciates.</p>
]]></content:encoded>
			<wfw:commentRss>http://randomstringofwords.com/a-bots-route-to-localhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server hacked</title>
		<link>http://randomstringofwords.com/server-hacked/</link>
		<comments>http://randomstringofwords.com/server-hacked/#comments</comments>
		<pubDate>Tue, 15 Jan 2008 20:32:05 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[RSoW.com]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[FedoraCore]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://info.rsow.com/server-hacked/</guid>
		<description><![CDATA[Yay! Everything is back and working nicely. The nice thing about having your server hacked is that you end up having to put everything back &#8212; which yes is a colossal pain in the ass, but you will just about always put it back in better shape than it was in to begin with. My [...]]]></description>
			<content:encoded><![CDATA[<p>Yay! Everything is back and working nicely.  The nice thing about having your server hacked is that you end up having to put everything back &#8212; which yes is a colossal pain in the ass, but you will just about always put it back in better shape than it was in to begin with.</p>
<p><span id="more-106"></span>My old server was FedoraCore2.. *shudder*  I wasn&#8217;t given a choice there.. it was core2 or nothing. And since it was out of date pretty much the day I was given it, it was doomed to be hacked at some point.  I knew that going into it.. Eh what can ya do.</p>
<p>Well, it happened.  Sometime last week someone rooted the box.  They did a pretty thorough job of it too, though the more I looked at it the more I thought it was a script kiddie instead of someone that&#8217;s actually clever..</p>
<p>They went through and added a program that listened on port 50030 for some sort of command before it went out and did it&#8217;s misdeeds..  Then went through the trouble of replacing every tool that you would normally use to detect these things with their own custom version which hid the running process..</p>
<p>That&#8217;s not even the sneaky part..  they also went through and set the attrib of those files to make them undeletable even by root.  Annoying.</p>
<p>So instead of trying to save the box, and undo the fuckery that they had installed.  I just wiped it.  I installed a much later version of the OS and all new stuff.. restored the database, and all things are now happy.</p>
<p>It was a good learning experience and interesting for the most part.  It really went a long way to point out that I&#8217;m a software engineer, not a server admin.  And it really seems like the more you are one, the less you are the other..  I&#8217;m trying to learn this stuff, but its a lot of magic to me at this point.  I mean there is so much to know, I don&#8217;t see how anyone could know it all.</p>
<p>Add to the fact that the internet is by it very nature a warzone and this server/hacker thing is an eternal arms race and I begin to think, why the hell bother?   I want a server is the obvious answer..</p>
<p>As always I don&#8217;t blame the hacker .. its a game really.. I wish I knew how they got in, not so I could hack other boxes but so I could make it safe on mine &#8212; this is something I&#8217;ll likely never learn.</p>
<p>So this is what I did once I got a fresh install on the box &#8212; I put this here for me so I can do it quickly and easily next time;</p>
<p>less /etc/inittab &#8212; make sure we are in rc level 3, if not change it and reboot</p>
<p>chkconfig &#8211;list | grep 3:on  &#8212; Shows run level of services managed through init.d make sure everything is on you want on, and off that you don&#8217;t want.</p>
<blockquote><p>Only do this if you want sendmail off, which you likely wont want because PHP needs it.</p></blockquote>
<blockquote><p>chkconfig &#8211;level 3 sendmail off &#8212; turn off sendmail so it doesn&#8217;t start on boot and annoy me constantly<br />
service sendmail stop &#8212; turn off sendmail (smtp port 25 is now closed)</p></blockquote>
<p>cd /etc/cron.daily &#8212; turn off the annoying logwatch email spam which is again an annoyance.</p>
<p>netstat -pan | grep LIST  &#8212; Show a list of all open ports/listeners<br />
nmap localhost &#8212; does the same thing, make sure they don&#8217;t conflict</p>
<p>useradd [newuser]<br />
passwd [newuser]</p>
<p>visudo &#8212; Add [newuser] to the sudoers list<br />
log out as root and relog in as [newuser]</p>
<p>sudo yum install vim &#8212; install VIM because I prefer it as my remote editor<br />
sudo vim /etc/ssh/sshd_config &#8212; set PermitRootLogin to no so that root can&#8217;t SSH into the box</p>
<p>sudo yum list all &gt; ~/rpm-avail.txt &#8212; get a list of everything installable, its easier to get a grep on the file</p>
<p>sudo yum -y install httpd php mysql mysql-server php-mysql  &#8212; Install traditional LAMP setup</p>
<p>sudo /sbin/service mysqld start &#8212; Start up mysqld<br />
sudo /sbin/service httpd start &#8212; Start up apache</p>
<p>sudo /sbin/chkconfig &#8211;level 3 mysqld on &#8212; Make sure mysqld starts on reboot<br />
sudo /sbin/chkconfig &#8211;level 3 httpd on &#8212; Make sure apache starts on reboot</p>
<p>We don&#8217;t want people hitting our MySQL from out side so we need to make sure its only listening to the internal port.. Not sure why this isn&#8217;t the default setting.</p>
<p>sudo vim /etc/my.cnf  &#8212; Add &#8220;bind-address=127.0.0.1&#8243; to the [mysqld] block<br />
mysqladmin -u root password &#8216;new-password&#8217;</p>
<p>We want to keep people from using our apache as a proxy, so;<br />
sudo vim /etc/httpd/conf/httpd.conf<br />
Comment out LoadModule proxy_{anything} and restart apache<br />
Change the AllowOverride None to AllowOverride ALL in the root directory (this lets .htaccess changes work)</p>
<p>Now create the various databases and restore those bad boys using the database user/passwords appropriate for those.</p>
<p>Restore the files to their correct places and make sure the virtual host information is correct in httpd.conf</p>
<p>Also, change the logrotate.conf to rotate the httpd logs daily instead of weekly.. otherwise they get biggish..</p>
<p>aaaannd.. GO!</p>
]]></content:encoded>
			<wfw:commentRss>http://randomstringofwords.com/server-hacked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

