{"id":4581,"date":"2009-01-17T15:07:34","date_gmt":"2009-01-17T15:07:34","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2009\/01\/17\/using-powershell-to-protect-against-conficker-enabling-and-disabling-autorun-inf\/"},"modified":"2019-02-18T13:12:51","modified_gmt":"2019-02-18T20:12:51","slug":"using-powershell-to-protect-against-conficker-enabling-and-disabling-autorun-inf","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/using-powershell-to-protect-against-conficker-enabling-and-disabling-autorun-inf\/","title":{"rendered":"Using PowerShell to Protect Against Conficker (Enabling and Disabling AutoRun.inf)"},"content":{"rendered":"<p>On the front page of MSN.com today, there\u2019s details about a new worm, <a href=\"http:\/\/tech.msn.com\/news\/articlepcw.aspx?cp-documentid=16883197&amp;GT1=40000\">Conficker<\/a>, that spreads using the good old fashioned autorun.inf tricks.&#160; It infects USB drives so that, when you plug the drive into another computer, it automatically runs and infects the machine.&#160; The article mentioned a post on <a href=\"http:\/\/nick.brown.free.fr\/blog\/2007\/10\/memory-stick-worms.html\">Nick Brown\u2019s blog<\/a> that instructs you on various ways to disable autorun.inf files and gives a .REG file for disabling autorun.inf.<\/p>\n<p>Here\u2019s the .REG file:<\/p>\n<blockquote>\n<pre>REGEDIT4\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\Autorun.inf]\n@=&quot;@SYS:DoesNotExist&quot;<\/pre>\n<\/blockquote>\n<p>Recently, I\u2019ve started to like taking small registry hacks and turning them into functions, so here\u2019s a pair of functions that I wrote to automate this registry setting with PowerShell.<\/p>\n<pre>function Disable-AutoRun\n{\n    $item = Get-Item `\n        &quot;REGISTRY::HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\AutoRun.inf&quot; `\n        -ErrorAction SilentlyContinue\n    if (-not $item) {\n        $item = New-Item &quot;REGISTRY::HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\AutoRun.inf&quot;\n    }\n    Set-ItemProperty $item.PSPath &quot;(default)&quot; &quot;@SYS:DoesNotExist&quot;\n}<\/pre>\n<p>Here&#8217;s Nick&#8217;s explanation of how it works: <\/p>\n<blockquote>\n<p>This hack tells Windows to treat AUTORUN.INF as if it were a configuration file from a pre-Windows 95 application. IniFileMapping is a key which tells Windows how to handle the .INI files which those applications typically used to store their configuration data (before the registry existed). In this case it says &quot;whenever you have to handle a file called AUTORUN.INF, don&#8217;t use the values from the file. You&#8217;ll find alternative values at HKEY_LOCAL_MACHINE\\SOFTWARE\\DoesNotExist.&quot; And since that key, er, does not exist, it&#8217;s as if AUTORUN.INF is completely empty, and so nothing autoruns, and nothing is added to the Explorer double-click action. Result: worms cannot get in &#8211; unless you start double-clicking executables to see what they do, in which case, you deserve to have your PC infected. <\/p>\n<\/blockquote>\n<p>In case you want to enable autorun again, you can use this function:<\/p>\n<pre>function Enable-AutoRun\n{\n    Remove-Item &quot;REGISTRY::HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\AutoRun.inf&quot; -Force\n}<\/pre>\n<p>Hope this Helps, <\/p>\n<p>James Brundage [MSFT] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the front page of MSN.com today, there\u2019s details about a new worm, Conficker, that spreads using the good old fashioned autorun.inf tricks.&#160; It infects USB drives so that, when you plug the drive into another computer, it automatically runs and infects the machine.&#160; The article mentioned a post on Nick Brown\u2019s blog that instructs [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>On the front page of MSN.com today, there\u2019s details about a new worm, Conficker, that spreads using the good old fashioned autorun.inf tricks.&#160; It infects USB drives so that, when you plug the drive into another computer, it automatically runs and infects the machine.&#160; The article mentioned a post on Nick Brown\u2019s blog that instructs [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/4581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=4581"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/4581\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=4581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=4581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=4581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}