<?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>[R&#124;H]ack &#187; Apache</title>
	<atom:link href="http://growl.superhappykittymeow.com/hacks/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://growl.superhappykittymeow.com/hacks</link>
	<description>Investigating compromises and cleaning up the internet</description>
	<lastBuildDate>Mon, 16 Nov 2009 02:09:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Identifying the Security Hole</title>
		<link>http://growl.superhappykittymeow.com/hacks/2009/09/identifying-the-security-hole/</link>
		<comments>http://growl.superhappykittymeow.com/hacks/2009/09/identifying-the-security-hole/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 05:33:45 +0000</pubDate>
		<dc:creator>kale</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://growl.superhappykittymeow.com/hacks/?p=8</guid>
		<description><![CDATA[For an Apache compromise, note the domain the attack was coming from and review the logs.  This can be tedious if you don&#8217;t quite know what you&#8217;re looking for &#8212; a lot of the attacks have gotten quite a bit smarter, using tor and proxies to randomize IPs, and using scripts that redeploy or [...]]]></description>
			<content:encoded><![CDATA[<p>For an Apache compromise, note the domain the attack was coming from and review the logs.  This can be tedious if you don&#8217;t quite know what you&#8217;re looking for &#8212; a lot of the attacks have gotten quite a bit smarter, using tor and proxies to randomize IPs, and using scripts that redeploy or change names to further confuse things.</p>
<p>Look for hits on the script that was running in the logs; search again for IPs that hit that script.  Try to find out where they came in on the site &#8212; did they hit the front page first?  Did they hit any pages besides the script?  Look for common threads and try to trace your way back to the earliest instances of hits on the attack scripts.  See what they accessed just before.</p>
<p>Often times, these &#8220;first hits&#8221; are POSTs against a legit script on the site.  For example, a recent ZenCart (shopping cart software) exploit starts out like this:</p>
<p>/admin/record_company.php/ password_forgotten.php?action=insert</p>
<p>This particular exploit is from:</p>
<p>http://www.milw0rm.com/exploits/9004</p>
<p>And the client ought follow the instructions from ZenCart here:</p>
<p>http://www.zen-cart.com/forum/showthread.php?t=130161</p>
<p>Keep abreast of the hacks as they come out &#8212; it&#8217;s always cat and mouse, but there&#8217;s no reason to lag too far behind!</p>
]]></content:encoded>
			<wfw:commentRss>http://growl.superhappykittymeow.com/hacks/2009/09/identifying-the-security-hole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Compromises</title>
		<link>http://growl.superhappykittymeow.com/hacks/2009/09/apache-compromises/</link>
		<comments>http://growl.superhappykittymeow.com/hacks/2009/09/apache-compromises/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 05:33:25 +0000</pubDate>
		<dc:creator>kale</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://growl.superhappykittymeow.com/hacks/?p=6</guid>
		<description><![CDATA[ps auxwww &#124;grep apache
Examine the output for the user apache running anything but the correct apache binary (/usr/sbin/httpd or /usr/local/bin/apachectl -k startssl).  Also look for children processes running with extremely high CPU time (if most children are running with 1:20 or so, and one is running at 60:42, note hte pid of the latter).
Closely [...]]]></description>
			<content:encoded><![CDATA[<pre>ps auxwww |grep apache</pre>
<p>Examine the output for the user apache running anything but the correct apache binary (/usr/sbin/httpd or /usr/local/bin/apachectl -k startssl).  Also look for children processes running with extremely high CPU time (if most children are running with 1:20 or so, and one is running at 60:42, note hte pid of the latter).</p>
<p>Closely examine the child process that is unusual with lsof.</p>
<pre>lsof -p 19232</pre>
<p>Note any network connections:</p>
<pre>lsof -p 19232 |grep IPv4</pre>
<p>and note the current working directory of the process:</p>
<pre>lsof -p 19232 |grep cwd</pre>
<p>It is in this directory that we start the search.  Review other files in that directory &#8212; look specifically for files owned by apache, files with a much newer modification time than other files in the directory, and hidden directories (named &#8221;  &#8221; or &#8220;&#8230;&#8221; etc) or unfairly-named files (&#8221;å¥∂øƒø∂ç.php&#8221; for example).  Investigate suspicious files themselves and use discretion as to whether it is legit or not &#8212; it helps to know a bit of PHP or coding here.  Note the modification times of the files as well. If you&#8217;re certain a file is not part of the site and decidedly malicious, move it away:</p>
<pre>mkdir /home/rack/ticketnumber/comp
mv c99.php !!$</pre>
<p>Often attackers will hide other shells around the web roots if the apache user can access them (777 dirs).  Look for apache-owned scripts to aid the search:</p>
<pre>cd /home/rack/ticketnumber
find /home/httpd/vhosts/ -user apache -mtime 365 |egrep "\.php|\.cgi|\.pl" >> newfiles.out</pre>
<p>You will have to manually review newfiles.out and each file to tell if a file is malicious.  Give the code the benefit of the doubt, but look for tell-tale shells, obfuscated code, and vandalism.</p>
<p>Once files are identified, cull out the legitimate-looking files from the list.  Move the malicious files out of the webroots:</p>
<pre>alias mv='mv'
cat newfiles.out |while read line ; do mv $line comp ; done</pre>
<p>Again review newfiles.out and manually review the directories that contained the malicious scripts.  Look for hidden directories, suspicious files that didn&#8217;t match the filter (c code, binaries, etc).  Remove this content as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://growl.superhappykittymeow.com/hacks/2009/09/apache-compromises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting the first signs of a compromise</title>
		<link>http://growl.superhappykittymeow.com/hacks/2009/09/detecting-the-first-signs-of-a-compromise/</link>
		<comments>http://growl.superhappykittymeow.com/hacks/2009/09/detecting-the-first-signs-of-a-compromise/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 05:32:15 +0000</pubDate>
		<dc:creator>kale</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://growl.superhappykittymeow.com/hacks/?p=3</guid>
		<description><![CDATA[When logging into a server, the first few seconds at the command prompt can offer general health information.  Did it take a long time to get a command prompt after authenticating?  Are there delays when typing in characters at the prompt?  Are you getting disconnected often?
If you have even the inkling of [...]]]></description>
			<content:encoded><![CDATA[<p>When logging into a server, the first few seconds at the command prompt can offer general health information.  Did it take a long time to get a command prompt after authenticating?  Are there delays when typing in characters at the prompt?  Are you getting disconnected often?</p>
<p>If you have even the inkling of suspicion, there&#8217;s no harm in getting a &#8220;feel&#8221; for your environment.  Note anything that feels unusual; look for anything that stands out.  Unless it&#8217;s root compromised, there are always breadcrumbs.</p>
<p>Document the environment as it is active:</p>
<pre>mkdir /home/rack/ticketnumber
cd !!$
script !!$.out
ps auxwww >> psauxwww.out
pstree >> pstree.out
netstat -plan >> netstat-plan.out
lsof -i >> lsof-i.out
lsof >> lsof.out</pre>
<p>Here we determine what kind of compromise it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://growl.superhappykittymeow.com/hacks/2009/09/detecting-the-first-signs-of-a-compromise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
