{"id":4942,"date":"2011-09-13T06:44:39","date_gmt":"2011-09-13T12:44:39","guid":{"rendered":"http:\/\/blog.webroot.com\/?p=4942"},"modified":"2024-03-29T10:48:37","modified_gmt":"2024-03-29T16:48:37","slug":"mebromi-the-first-bios-rootkit-in-the-wild","status":"publish","type":"post","link":"https://www.webroot.com/blog/2011\/09\/13\/mebromi-the-first-bios-rootkit-in-the-wild\/","title":{"rendered":"Mebromi: the first BIOS rootkit in the wild"},"content":{"rendered":"<p><strong>By Marco Giuliani<\/strong><\/p>\n<p><a href=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_ioctl.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-thumbnail wp-image-4939\" title=\"Bios.sys's IOCTL codes\" src=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_ioctl.jpg?w=150\" alt=\"\" width=\"150\" height=\"54\" \/><\/a><\/p>\n<p>In the past few weeks a Chinese security company called\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Qihoo_360\"><strong>Qihoo 360<\/strong><\/a> blogged about a new BIOS rootkit hitting Chinese computers. This turned to be a very interesting discovery as it appears to be the first real malware targeting system BIOS\u00a0since a well-known proof of concept called <strong>IceLord<\/strong> in 2007.\u00a0The malware is called <strong>Mebromi<\/strong> and contains a bit of everything: a BIOS rootkit specifically targeting Award BIOS, a MBR rootkit, a kernel mode rootkit, a PE file infector and a Trojan downloader. At this time, Mebromi is not designed to infect 64-bit operating system and it is not able to infect the system if run with limited privileges.<\/p>\n<p>The infection starts with a small encrypted dropper that contains five crypted resource files: <em>hook.rom<\/em>, <em>flash.dll<\/em>, <em>cbrom.exe<\/em>, <em>my.sys<\/em>, <em>bios.sys<\/em>. The goal of these files will be presented later in this analysis.<\/p>\n<p>The infection is clearly focused on Chinese users, because the dropper is carefully checking if the system it&#8217;s going to infect is protected by Chinese security software <strong>Rising Antivirus<\/strong> and <strong>Jiangmin KV Antivirus<\/strong>. To gain access to the BIOS, the infection first needs to get loaded in kernel\u00a0mode so that it can handle with physical memory instead of virtual memory.<\/p>\n<p>Many of you may\u00a0recall the old <strong>CIH\/Chernobyl<\/strong> infection, the infamous virus discovered in 1998 that was able to flash the motherboard BIOS, erasing it. Even CIH needed to gain kernel mode access to reach the BIOS, though at the time the virus was exploiting a privilege escalation bug in Windows 9x operating system which allowed it to overwrite the Interrupt Descriptor Table with its own payload from user mode, then triggering the overwritten interrupt handler and its malicious code is executed in kernel mode. Mebromi does not use such kind of privilege escalation trick anymore, it just needs to load its own kernel mode driver which will handle the BIOS infection. To do so, it uses two methods: it could either extract and load the flash.dll library which will load the bios.sys driver, or it stops the beep.sys service key, overwriting the beep.sys driver with its own bios.sys code, restart the service key and restore the original beep.sys code.<\/p>\n<p>The bios.sys driver is the code which handle the BIOS infection. To read the BIOS code, it needs to map the physical memory located at physical memory address <em>0xF0000<\/em>, this is where the BIOS ROM usually resides. Once read, the driver verifies if the BIOS ROM is Award BIOS, by checking the presence of the string: <em>$@AWDFLA<\/em>. If found, the driver tries to locate the <strong>SMI port<\/strong>\u00a0that will be used by the rootkit to flash the BIOS ROM.<\/p>\n<p><a href=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_infect.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4937\" title=\"Bios infection routine\" src=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_infect.jpg?w=300\" alt=\"\" width=\"300\" height=\"62\" \/><\/a><\/p>\n<p>If the BIOS ROM matches the string, the rootkit saves a copy of the BIOS to the file C:bios.bin and pass the next step to the user mode component of the infection. The dropper extracts two files: cbrom.exe and hook.rom. Cbrom.exe is a legitimate tool developed by Phoenix Technologies, used to modify the Award\/Phoenix BIOS ROM binaries. Hook.rom is the rootkit ISA BIOS ROM that is added to the BIOS binary, containing the rootkit infection. The dropper executes cbrom.exe with the \/isa switch parameter, passing the hook.rom file. Before actually injecting the malicious ISA ROM, the dropper checks the BIOS ROM code looking for the &#8220;<em>hook rom<\/em>&#8221; string, used as a marker\u00a0of the infection. If found, it means that the BIOS is already infected and it doesn&#8217;t need to be infected again.<\/p>\n<p><a href=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_infected.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4938\" title=\"Mebromi checks if the BIOS is already infected\" src=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_infected.jpg?w=300\" alt=\"\" width=\"300\" height=\"196\" \/><\/a><\/p>\n<p>After that the bios.bin file has been modified, the bios.sys driver send to the BIOS SMI port the command <em>0x29<\/em>, used to erase the BIOS flash, and then the command <em>0x2F<\/em> used to write the new BIOS ROM code to the BIOS ROM.<\/p>\n<p>The BIOS is now infected, and the dropper goes to\u00a0its next step: <strong>infecting the Master Boot Record<\/strong>. The infection is 14 sectors long and the original MBR is stored to the sector 7. To avoid potential startup issues, the infected MBR stores a copy of the original MBR&#8217;s partition table. Finally\u00a0the dropper extracts the my.sys driver on the root of the C: drive. My.sys is a kernel mode rootkit that hijacks disk.sys&#8217;s IRP major functions, by redirecting the <em>IRP_MJ_READ\/WRITE<\/em> and<em> IRP_MJ_DEVICE_CONTROL<\/em> native functions. It is used to hide the infection on the disk. Even if the BIOS infection doesn&#8217;t succeed, the rootkit does infect the MBR.<\/p>\n<p>At the next system startup, after the BIOS POST phase, the malicious code injected inside it prepares the full MBR infection (all the first 14 sectors are stored inside the malicious BIOS rom, 7168 bytes in total) and checks the MBR code of the hard drive looking if the infection is already present.\u00a0To do it, the BIOS malicious code checks for the presence of the string &#8220;<em>int1<\/em>&#8221; at the offset 0x92. If the string is not found, the BIOS malicious rom will overwrite all the first 14 sectors of the hard drive, thus restoring the MBR infection.<\/p>\n<p><a href=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_marker.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4940\" title=\"Mebromi's BIOS payload checks if the MBR is already infected\" src=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_marker.jpg?w=300\" alt=\"\" width=\"300\" height=\"93\" \/><\/a><\/p>\n<p>The system startup procedure continues and the control now passes to the malicious master boot record. Here the malicious payload analyzes the original MBR partition table and looks for the active partition, checking if it&#8217;s using a NTFS or FAT32 file system. The malicious MBR code <strong>contains indeed NTFS\/FAT32 parser routines<\/strong>, used to get inside the file system\u00a0to look\u00a0for <em>winlogon.exe<\/em> or <em>wininit.exe<\/em> file. When found, the malicious code contains a file infection payload, able to inject malicious code inside the specified file and hijack the entry point of it. Before infecting the file, the MBR malicious code checks if it is already infected, by looking for the string &#8220;<em>cnns<\/em>&#8221; at the offset 0x50 from the beginning of the PE file. This is the infection marker. If the string is not found, the infection stores a crypted payload &#8211; about 600 bytes of code &#8211; inside winlogon.exe or wininit.exe and hijacks the PE entry point to the beginning of it, saving the original entry point at the offset 0x60.<\/p>\n<p><a href=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_pe_infection.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4941\" title=\"Mebromi PE infection\" src=\"http:\/\/webrootblog.files.wordpress.com\/2011\/09\/bios_pe_infection.jpg?w=300\" alt=\"\" width=\"300\" height=\"137\" \/><\/a><\/p>\n<p>The job of the MBR infection ends here, waiting for the Windows startup which will load the \u00a0patched executable. When loaded, the payload self-decrypt its malicious code and loads in memory the my.sys driver. Then it tries to download an additional infection from the (now unavailable)\u00a0URL address: http:\/\/dh.3515.info:806\/test\/91\/calc[removed].<\/p>\n<p>The concept behind Mebromi is not new. In fact <strong>we must recall the IceLord BIOS rootkit published in 2007<\/strong>, a public proof of concept able to target Award BIOS rom, using an approach very similar to the Mebromi one &#8211; or should we\u00a0say that Mebromi is more than just inspired by the IceLord rootkit?<\/p>\n<p>Storing the malicious code inside the BIOS ROM could actually become more than just a problem for security software, giving the fact that even if an antivirus detect and clean the MBR infection, it will be restored at the next system startup when the malicious BIOS payload would overwrite the MBR code again. Developing an antivirus utility able to clean the BIOS code is a challenge, because it\u00a0needs to\u00a0be totally error-proof, to avoid rendering the system unbootable at all. The job of handling with such specific system codes should be left to the developers of the specific motherboard model,\u00a0who release BIOS updates along with specific tool to update the BIOS code.<\/p>\n<p>On the other hand, although this kind of infection is potentially one of the most persistent infections known out there in the wild, it will hardly become a major threat because of the level of complexity needed to achieve the goal. While a kernel mode infection or a MBR infection could still work in a generic way among all the PC out there &#8211; and they still have a huge\u00a0available free space to play with, a BIOS-based rootkit needs to be fully compatible with all major BIOS rom out there, it should be able to infect all the different releases of Award, Phoenix, AMI BIOS&#8217;s out there; <strong>a level of complexity that is simply unasked for writing a good persistent infection<\/strong>\u00a0(e.g. TDL rootkit, various Rustock releases, ZeroAccess rootkit among all). In fact, why is Mebromi only targetting Award BIOS rom? Perhaps because there was already a known proof of concept that is 5 years old targeting Award BIOS ROM available online.<\/p>\n<p>Are BIOS rootkits a real threat? Yes, we can consider Mebromi the first real BIOS rootkit incident discovered in the wild &#8211; let&#8217;s consider IceLord BIOS rootkit more a proof of concept. Should we be concerned about BIOS rootkits? Well, while we try to discover whether our PC is infected by an unknown and super-stealth BIOS rootkit, let&#8217;s try and look if there is a more &#8220;humble&#8221; kernel mode rootkit which is already infecting our PC, allowing a remote attacker to silently own our system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Marco Giuliani In the past few weeks a Chinese security company called\u00a0Qihoo 360 blogged about a new BIOS rootkit hitting Chinese computers. This turned to be a very interesting discovery as it appears to be the first real malware targeting system BIOS\u00a0since a well-known proof of concept called IceLord in 2007.\u00a0The malware is called [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3005],"tags":[],"yst_prominent_words":[6133,6125,6115,6141,6127,5137,6131,6149,6121,6117,6123,6119,6145,6147,6143,6135,6129,6137,5865,6139],"acf":[],"_links":{"self":[{"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/posts\/4942"}],"collection":[{"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/comments?post=4942"}],"version-history":[{"count":3,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/posts\/4942\/revisions"}],"predecessor-version":[{"id":32799,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/posts\/4942\/revisions\/32799"}],"wp:attachment":[{"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/media?parent=4942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/categories?post=4942"},{"taxonomy":"post_tag","embeddable":true,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/tags?post=4942"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https://www.webroot.com/blog/wp-json\/wp\/v2\/yst_prominent_words?post=4942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}