{"id":507,"date":"2013-09-18T09:01:32","date_gmt":"2013-09-18T09:01:32","guid":{"rendered":"http:\/\/www.gironsec.com\/blog\/?p=507"},"modified":"2013-09-18T09:09:18","modified_gmt":"2013-09-18T09:09:18","slug":"malware-ideas-and-concepts-rattling-in-my-head","status":"publish","type":"post","link":"https:\/\/www.gironsec.com\/blog\/2013\/09\/malware-ideas-and-concepts-rattling-in-my-head\/","title":{"rendered":"Malware Ideas and concepts rattling in my head"},"content":{"rendered":"<p>Hello again loyal readers.<\/p>\n<p>I&#8217;ve had a lot of ideas rattling around in my head lately. Malware related things. For example, what if someone used Gopher for C&#038;C? Who the hell uses gopher anymore?<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/gopher.gif\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/gopher.gif\" alt=\"gopher\" width=\"577\" height=\"481\" class=\"alignnone size-full wp-image-513\" \/><\/a><br \/>\nThe API&#8217;s for handling gopher, while deprecated, are still around. Though you would probably have to load it from an older Wininet.dll with LoadLibrary() from XP box.<\/p>\n<p>The API&#8217;s are still <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa384210%28v=vs.85%29.aspx\">referenced \/ documented<\/a>.<br \/>\nMaybe I&#8217;ll get bored one day and make use of it.<\/p>\n<p>Then I have this idea for a conceptual malware attack using a little known Win32 API called SetProcessShutdownParameters. What it does is change the order in which the calling process gets shut down. Here is where my idea comes into play:<\/p>\n<p>What if the antivirus program doesn&#8217;t call SetProcessShutdownParameters()&#8217;s dwLevel to be shut down last in the shutdown range? Theoretically malware could set the shutdown range to be shutdown AFTER the AV, but BEFORE the OS. All processes start at shutdown level 0x280 (640 in decimal) before modification. This would present a window of opportunity for a piece of malicious code to execute after the AV has been closed. No reporting  of this event would occur in the case of something like a Host Based Intrusion Detection System. The malware would need only sleep until the system is shutdown &#8211; I&#8217;ve already shown how this would be done with window hooks. <\/p>\n<p>Here is the code for messing with the function:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f0f0; 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: #007020\">#include &lt;windows.h&gt;<\/span>\r\n<span style=\"color: #007020\">#include &lt;stdio.h&gt;<\/span>\r\n\r\n<span style=\"color: #902000\">int<\/span> <span style=\"color: #06287e\">main<\/span>(<span style=\"color: #902000\">int<\/span> argc, <span style=\"color: #902000\">char<\/span> <span style=\"color: #666666\">*<\/span>argv[])\r\n{\t\r\n\tSetProcessShutdownParameters(<span style=\"color: #40a070\">134<\/span>,<span style=\"color: #40a070\">0<\/span>);\r\n\tDWORD iLevel, iFlags;\r\n\tGetProcessShutdownParameters(<span style=\"color: #666666\">&amp;<\/span>iLevel, <span style=\"color: #666666\">&amp;<\/span>iFlags);\r\n\tprintf(<span style=\"color: #4070a0\">&quot;Shutdown params level: 0x%X <\/span><span style=\"color: #4070a0; font-weight: bold\">\\t<\/span><span style=\"color: #4070a0\"> Flags: 0x%X<\/span><span style=\"color: #4070a0; font-weight: bold\">\\r\\n<\/span><span style=\"color: #4070a0\">&quot;<\/span>,iLevel, iFlags);\r\n\t<span style=\"color: #007020; font-weight: bold\">return<\/span> <span style=\"color: #40a070\">0<\/span>;\r\n}\r\n<\/pre>\n<\/div>\n<p>Caveat? Applications that run in the system security context are not shut down by the OS, instead they are notified of shutdown \/ logoff events via the callback function installable via SetConsoleCtrlHandler()&#8217;s callback function.I haven&#8217;t had a chance to test this theory yet on an AV, but hope to do so in the coming weeks. <\/p>\n<p>Happy Cracking!<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/1375869774481.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/1375869774481-300x282.png\" alt=\"1375869774481\" width=\"300\" height=\"282\" class=\"alignnone size-medium wp-image-511\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/1375869774481-300x282.png 300w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/1375869774481.png 977w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello again loyal readers. I&#8217;ve had a lot of ideas rattling around in my head lately. Malware related things. For example, what if someone used Gopher for C&#038;C? Who the hell uses gopher anymore? The API&#8217;s for handling gopher, while deprecated, are still around. Though you would probably have to load it from an older [&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":[48,67],"_links":{"self":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/507"}],"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=507"}],"version-history":[{"count":7,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"predecessor-version":[{"id":516,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/507\/revisions\/516"}],"wp:attachment":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}