{"id":1292,"date":"2012-09-18T16:55:09","date_gmt":"2012-09-18T16:55:09","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=1292"},"modified":"2012-09-19T12:55:33","modified_gmt":"2012-09-19T12:55:33","slug":"zeroaccess-death-match-with-shell_notifyiconw","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2012\/09\/18\/zeroaccess-death-match-with-shell_notifyiconw\/","title":{"rendered":"ZeroAccess death match with Shell_NotifyIconW"},"content":{"rendered":"<p>There is a lot of ZeroAccess analysis all over the place, so not sure if anyone documented it before, but oh well&#8230;\u00a0 here it goes&#8230;<\/p>\n<p>I have been recently looking at a new <a href=\"https:\/\/www.virustotal.com\/file\/9afc5dfa30e7ab40ceac444230a1a1b5954173040226f9e68670a9d956305689\/analysis\/\">sample<\/a> of ZeroAccess and spotted that at an early stage of the infection, it injects a small code into Windows Explorer:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1293\" title=\"ZeroAccess_Shell_NotifyIconW_1\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_1-300x149.png\" alt=\"\" width=\"300\" height=\"149\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_1-300x149.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_1-1024x510.png 1024w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_1.png 1057w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The snippet is then executed via Asynchronous Procedure Call (NtQueueApcThread). Just looking at the size of the payload and the strings made me curious enough so I decided to have a quick look at the code.<\/p>\n<p>Turns out, this little snippet doesn&#8217;t like Shell_NotifyIconW API very much and it patches it in a very clever and selective way.<\/p>\n<p>The disassembled code of the main routine from the snippet looks like this:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1294\" title=\"ZeroAccess_Shell_NotifyIconW_2\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_2-250x300.png\" alt=\"\" width=\"250\" height=\"300\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_2-250x300.png 250w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_2.png 720w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>The <strong>PatchShell_NotifyIconW<\/strong> function shown on the screenshot is responsible for allocating a small buffer in memory (via ZwAllocateVirtualMemory) that will hold a code of the function modifying the standard behavior of Shell_NotifyIconW API.<\/p>\n<p>As per MSDN, the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/bb762159%28v=vs.85%29.aspx\">Shell_NotifyIconW<\/a> function takes 2 arguments:<\/p>\n<pre style=\"padding-left: 60px;\">BOOL Shell_NotifyIcon(\r\n\u00a0 _In_\u00a0 DWORD dwMessage,\r\n\u00a0 _In_\u00a0 PNOTIFYICONDATA lpdata\r\n);<\/pre>\n<p>The new function installed by ZeroAccess looks like this:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_31.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1296\" title=\"ZeroAccess_Shell_NotifyIconW_3\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_31-300x41.png\" alt=\"\" width=\"300\" height=\"41\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_31-300x41.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2012\/09\/ZeroAccess_Shell_NotifyIconW_31.png 478w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 33333333h is an address (patched at run-time) to the old unpatched version of the function, so that once ZeroAccess modifies the function&#8217;s behavior it can pass the control back to the original function.<\/p>\n<p>As you can see, the patch is simple &#8211; it only modifies a<strong> dwMessage<\/strong> value so that it is always equal to <strong>NIM_DELETE<\/strong>, which pretty much means that any attempts to add\/modify\/change status of an icon on the notification area (tray) will fail.<\/p>\n<p>While I have not tested it as I don&#8217;t have any image with all these security settings on, it seems to be a simple trick to prevent the &#8216;annoying&#8217;\u00a0 security notifications from happening while the malware is doing its evil thing. This is indirectly confirmed by the way the actual patch occurs. Instead of patching the entry code of Shell_NotifyIconW in a typical, process-global detour-like fashion, the malware walks through all DLLs loaded into Windows Explorer and finds addresses of Shell_NotifyIconW function only within the Import Address Tables\u00a0 of two DLLs: <a href=\"http:\/\/windows.microsoft.com\/is-IS\/windows7\/products\/features\/action-center\">ActionCenter.dll<\/a> and <a href=\"http:\/\/windows.microsoft.com\/en-AU\/windows-vista\/Using-Windows-Security-Center\">wscntfy.dl<\/a>l. These hold the code responsible for the system\/tray icon area notifications related to current security state of the system.<\/p>\n<p>Quite frankly, I like this piece of code as it is very neatly written (it even self-removes itself from memory after it is executed) but more importantly, these popups are actually quite annoying! \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a lot of ZeroAccess analysis all over the place, so not sure if anyone documented it before, but oh well&#8230;\u00a0 here it goes&#8230; I have been recently looking at a new sample of ZeroAccess and spotted that at &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2012\/09\/18\/zeroaccess-death-match-with-shell_notifyiconw\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/1292"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=1292"}],"version-history":[{"count":6,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/1292\/revisions"}],"predecessor-version":[{"id":1302,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/1292\/revisions\/1302"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=1292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=1292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=1292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}