<?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; FTP</title>
	<atom:link href="http://growl.superhappykittymeow.com/hacks/category/ftp/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>How FTP injection compromises work</title>
		<link>http://growl.superhappykittymeow.com/hacks/2009/11/how-ftp-injection-compromises-work/</link>
		<comments>http://growl.superhappykittymeow.com/hacks/2009/11/how-ftp-injection-compromises-work/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 02:09:08 +0000</pubDate>
		<dc:creator>kale</dc:creator>
				<category><![CDATA[FTP]]></category>

		<guid isPermaLink="false">http://growl.superhappykittymeow.com/hacks/?p=38</guid>
		<description><![CDATA[Someone with FTP access to your site (you or your developers) has a virus on their workstations. This virus has installed a keylogger that is stealing credentials from your FTP client and sending this information back to the hacker.
The hacker collects hundreds of such credentials and then uses a program to log into each server, [...]]]></description>
			<content:encoded><![CDATA[<p>Someone with FTP access to your site (you or your developers) has a virus on their workstations. This virus has installed a keylogger that is stealing credentials from your FTP client and sending this information back to the hacker.</p>
<p>The hacker collects hundreds of such credentials and then uses a program to log into each server, download a file, modify it to append an iframe or block of obfuscated JavaScript or PHP, upload the file, download the next file, modify, upload, next, etc. The files downloaded may either match a set of names (such as only index., default., home.* etc) or just any html or PHP file.</p>
<p>The appended code is often either an iframe that is visibility: hidden or of 1&#215;1px size, a &lt;script&gt; sourcing a remote JavaScript file on a dubious domain, a collection of Javascript obfuscated by some clever str.CharCode&#8217;ing, or a block of base64_encode&#8217;d eval()&#8217;d code. Unobfuscating the code, the result is often an iframe. More recently, some clever attackers are inserting remote shells, granting them backdoor access to your server.</p>
<p>Once all the files have been modified, the attacker logs out. Visitors to your site will be subject to malicious code from the domain linked in the iframe with the intention of installing viruses and rootkits. Among other functions, these viruses will install a keylogger to sniff FTP credentials&#8230; and the virus continues spreading.</p>
<p>The attacker is using your credentials, so they can only access files that you have access to. Sometimes, they will upload an additional file in certain directories with an encoded shell, allowing them return access to the server (the common ones are _captcha.php in /forums directores and img.php or gifimg.php in /gallery directories). If you host other domains on your server, as long as the user for the affected domain has no access beyond their current domain, others will not be affected.</p>
<p>There are two ways to stop this sort of attack &#8212; prevention and proper antivirus. The attacks can be easily deflected by use of a firewall and limiting FTP access to only a few select IPs. The attackers are not attacking from your own workstation (yet), but rather a server elsewhere in the world. Using proper antivirus on all workstations with access to your FTP account &#8212; or, better yet, not using Windows XP &#8212; will help prevent the original infection from occurring.</p>
<p>If you are infected, it&#8217;s fairly easy to clean the messes up using a bit of clever sed, depending how good you are at spotting the injection and making effective regexes. Otherwise, backups backups backups &#8212; always have backups! &#8230;Oh, and change your FTP password or they&#8217;ll be back tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://growl.superhappykittymeow.com/hacks/2009/11/how-ftp-injection-compromises-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTP Compromises</title>
		<link>http://growl.superhappykittymeow.com/hacks/2009/09/ftp-compromises/</link>
		<comments>http://growl.superhappykittymeow.com/hacks/2009/09/ftp-compromises/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 05:34:06 +0000</pubDate>
		<dc:creator>kale</dc:creator>
				<category><![CDATA[FTP]]></category>

		<guid isPermaLink="false">http://growl.superhappykittymeow.com/hacks/?p=10</guid>
		<description><![CDATA[These compromises aren&#8217;t really &#8220;compromises&#8221; at all &#8212; the attacker already has a user/pass to log into the system.  The password is often gained illegitimately through a rootkit on the end-user&#8217;s computer, sniffing authentication credentials without the user&#8217;s knowledge, or through phishing scams.  With such access, it&#8217;s simple for the attacker to launch [...]]]></description>
			<content:encoded><![CDATA[<p>These compromises aren&#8217;t really &#8220;compromises&#8221; at all &#8212; the attacker already has a user/pass to log into the system.  The password is often gained illegitimately through a rootkit on the end-user&#8217;s computer, sniffing authentication credentials without the user&#8217;s knowledge, or through phishing scams.  With such access, it&#8217;s simple for the attacker to launch a mass infection by simply logging in via FTP and systematically downloading, modifying, and re-uploading website content pages.  The modifications are often hidden iframes (sometimes obfuscated by javascript) that redirect unsuspecting visitors to another site which pushes viruses (such as the same rootkit that originally compromised the account information).  Recently attackers have also been inserting code allowing remote code execution by an attacker, allowing them to weaponize the server for use in DoS attacks and spamming.</p>
<p>(Note: these commands contain a Plesk bias, as I see such compromises overwhelmingly on Plesk for some reason&#8230;)</p>
<p>Identify the files that have been modified:</p>
<pre>mkdir /home/rack/ticketnumber
cd !!$
cp /usr/local/psa/var/log/xferlog.* .
gunzip xferlog*
awk '$12 != prev {print $9; prev=$12}' xferlog* | egrep "\.php|\.htm|\.shtm|\.js" | sort |uniq > ftp_modified.out</pre>
<p>Search through the result set for common changes:</p>
<pre>cat ftp_modified.out |while read line; do grep -H iframe $line >> iframe.out ; done</pre>
<p>Review this output for suspicious iframes.  Often they have the visibility:hidden attribute, are Russian or Chinese, listen on odd ports, or point to a CGI script.  Once you&#8217;ve identified one of these, review the file it was found in for unmatched malicious content, usually in the form of obfuscated JavaScript.  Note each of these &#8220;signatures&#8221;.</p>
<p>Generate a regex tight enough to match only such malicious content, but be aware of random elements put into the signature so as to thwart cleanup attempts.</p>
<p>Run this regex against the modified files:</p>
<pre>cat iframe.out | awk -F\: '{print $1}' | while read line ; do sed -i 's/&lt;iframe src=.*\/in\.cgi\?.*&lt;\/iframe&gt;//g' $line ; done</pre>
<p>Immediately change the passwords for the affected domains, and be sure to advise the customer that the infection will recur lest they find the breach on their side &#8212; the infected desktop &#8212; and clean it up.  Most antivirus products can catch and clean the common rootkits and trojans, but be aware that each scans differently and will find different things.  If one scan comes up clean, scan again with another AV product, and likely triple-check as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://growl.superhappykittymeow.com/hacks/2009/09/ftp-compromises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
