{"id":688,"date":"2014-01-08T00:03:03","date_gmt":"2014-01-08T00:03:03","guid":{"rendered":"http:\/\/www.gironsec.com\/blog\/?p=688"},"modified":"2014-01-08T00:03:03","modified_gmt":"2014-01-08T00:03:03","slug":"virtualbox-detection","status":"publish","type":"post","link":"https:\/\/www.gironsec.com\/blog\/2014\/01\/virtualbox-detection\/","title":{"rendered":"VirtualBox Detection"},"content":{"rendered":"<p>Howdy fellow h4x0rs &#038; Cr4x0rs alike!<\/p>\n<p>Today I ran into some vmware aware malware and it threw me off until I ran procmon and apispy. I had to patch the program to skip the checks, but I don&#8217;t want to get into that. Instead, let&#8217;s cover what this malware was checking.<\/p>\n<p>First off, it was checking for VirtualBox specific registry key and hardware settings. This is easy to check for assuming you know some code:<\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops-300x245.png\" alt=\"oops\" width=\"300\" height=\"245\" class=\"alignnone size-medium wp-image-689\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops-300x245.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops-1024x838.png 1024w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops.png 1250w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>If you check the cdrom and hard drive for their device ID&#8217;s or merely look for the word &#8216;vbox&#8217; inside the HKLM\\systen\\currentcontrolset\\control\\deviceclasses\\ hive, chances are good you&#8217;re in a virtual machine like virtualbox. <\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops2.png\" alt=\"oops2\" width=\"404\" height=\"448\" class=\"alignnone size-full wp-image-690\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops2.png 404w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2014\/01\/oops2-270x300.png 270w\" sizes=\"(max-width: 404px) 100vw, 404px\" \/><\/a><\/p>\n<p>Too complicated? WMI and .NET to the rescue!<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">using<\/span> <span style=\"color: #0e84b5; font-weight: bold\">System<\/span>;\r\n<span style=\"color: #008800; font-weight: bold\">using<\/span> <span style=\"color: #0e84b5; font-weight: bold\">System.Management<\/span>;\r\n\r\n    <span style=\"color: #008800; font-weight: bold\">class<\/span> <span style=\"color: #BB0066; font-weight: bold\">Program<\/span>\r\n    {\r\n        <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #008800; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">Main<\/span>(<span style=\"color: #333399; font-weight: bold\">string<\/span>[] args)\r\n        {\r\n            ManagementObjectSearcher moSearch = <span style=\"color: #008800; font-weight: bold\">new<\/span> ManagementObjectSearcher(<span style=\"background-color: #fff0f0\">&quot;Select * from Win32_DiskDrive&quot;<\/span>);\r\n\t\t<span style=\"color: #888888\">\/\/ wanna search cd rom drives?<\/span>\r\n           <span style=\"color: #888888\">\/\/ ManagementObjectSearcher moSearch = new ManagementObjectSearcher(&quot;Select * from Win32_CDROMDrive&quot;);<\/span>\r\n             <span style=\"color: #008800; font-weight: bold\">foreach<\/span> (<span style=\"color: #333399; font-weight: bold\">var<\/span> mo <span style=\"color: #008800; font-weight: bold\">in<\/span> moSearch.Get())\r\n            {\r\n\r\n                Console.WriteLine(<span style=\"background-color: #fff0f0\">&quot;Device Instance Id: &quot;<\/span> + mo[<span style=\"background-color: #fff0f0\">&quot;PNPDeviceID&quot;<\/span>].ToString()); <span style=\"color: #888888\">\/\/ or mo[&quot;DeviceID&quot;]<\/span>\r\n                \r\n            }\r\n             Console.Read();\r\n        }\r\n      \r\n    }\r\n<\/pre>\n<\/div>\n<p>A simple WMI query can check against installed devices. A simple string.contains() comparison for &#8216;vbox&#8217; will suffice.<\/p>\n<p>There&#8217;s one other method worth pointing out. The shared folders method. VirtualBox creates a shared folder that&#8217;s navigable like a share.<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">if<\/span>(Directory.Exists(<span style=\"background-color: #fff0f0\">@&quot;\\\\VBOXSVR\\&quot;<\/span>))\r\n            {\r\n                Console.WriteLine(<span style=\"background-color: #fff0f0\">&quot;GTFO!&quot;<\/span>);\r\n            }\r\n<\/pre>\n<\/div>\n<p>Just check to see if you can access the &#8216;\\\\vboxsvr&#8217; share. Normally this folder is read write execute (777) and free reign for other programs by default. <\/p>\n<p>The malware I ran into also took it a step further by doing DNS queries to both google.com as well as sun.java.com before making its true call out. Clever, but ultimately pointless and easy to catch when you can just switch the host names out in the c:\\windows\\system32\\drivers\\etc\\hosts file. If it were me, I would take further precautions such as doing an md5 <a href=\"http:\/\/www.gironsec.com\/blog\/2013\/10\/anti-sandboxing-ideas\/\">checksum against a favicon<\/a> or something. Oh wait, I already suggested that.<\/p>\n<p>Oh well.<\/p>\n<p>Happy hacking!<br \/>\n<img decoding=\"async\" src=\"http:\/\/gironsec.com\/images\/albums\/bees\/1349067584776.jpg\"\/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Howdy fellow h4x0rs &#038; Cr4x0rs alike! Today I ran into some vmware aware malware and it threw me off until I ran procmon and apispy. I had to patch the program to skip the checks, but I don&#8217;t want to get into that. Instead, let&#8217;s cover what this malware was checking. First off, it was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[86,85],"_links":{"self":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/688"}],"collection":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/comments?post=688"}],"version-history":[{"count":1,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/688\/revisions"}],"predecessor-version":[{"id":691,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/688\/revisions\/691"}],"wp:attachment":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/media?parent=688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/categories?post=688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/tags?post=688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}