<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>random dross : De-obfuscation</title><link>http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx</link><description>Tags: De-obfuscation</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>De-obfuscation using a standalone Javascript interpreter</title><link>http://blogs.msdn.com/dross/archive/2006/12/08/de-obfuscation-using-a-standalone-javascript-interpreter.aspx</link><pubDate>Sat, 09 Dec 2006 03:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1242785</guid><dc:creator>dross</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dross/comments/1242785.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=1242785</wfw:commentRss><description>Mark Wodrich forwarded me &lt;A class="" title="this Websense blog post" href="http://www.websense.com/securitylabs/blog/blog.php?BlogID=98" mce_href="http://www.websense.com/securitylabs/blog/blog.php?BlogID=98"&gt;this Websense blog post&lt;/A&gt;&amp;nbsp;describing how to&amp;nbsp;use a standalone Javascript interpreter&amp;nbsp;to de-obfuscate some script.&amp;nbsp; Thanks Mark!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1242785" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item><item><title>eval() and document.write(), meet Execute and ExecuteGlobal</title><link>http://blogs.msdn.com/dross/archive/2006/11/16/eval-and-document-write-meet-execute-and-executeglobal.aspx</link><pubDate>Fri, 17 Nov 2006 00:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1089017</guid><dc:creator>dross</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dross/comments/1089017.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=1089017</wfw:commentRss><description>&lt;P&gt;Be on the lookout for these two VBScript statements that can be used&amp;nbsp;to achieve the same effect as&amp;nbsp;eval() and document.write(): &lt;A class="" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/c9cddcbd-2d2b-4139-bb21-c21136f2df81.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/c9cddcbd-2d2b-4139-bb21-c21136f2df81.asp"&gt;Execute&lt;/A&gt; and &lt;A class="" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/25ebfa26-d3b9-4f82-b3c9-a8568a389dbc.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/25ebfa26-d3b9-4f82-b3c9-a8568a389dbc.asp"&gt;ExecuteGlobal&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Jonathan Ness pointed me to an exploit&amp;nbsp;sample that was using Execute, presumably to trip up any eval() or document.write() dependent detection logic or automatic de-obfuscation.&amp;nbsp; Thanks JNess!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1089017" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item><item><title>Recursive Obfuscation</title><link>http://blogs.msdn.com/dross/archive/2006/10/05/Recursive-Obfuscation.aspx</link><pubDate>Thu, 05 Oct 2006 22:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:794426</guid><dc:creator>dross</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dross/comments/794426.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=794426</wfw:commentRss><description>&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Thanks to &lt;?XML:NAMESPACE PREFIX = U1 /&gt;&lt;U1:PERSONNAME u2:st="on"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:PersonName w:st="on"&gt;Jonathan Ness&lt;/U1:PERSONNAME&gt;&lt;/st1:PersonName&gt; for pointing me to an example of a new obfuscation technique that attempts to thwart the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Wingdings size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Wingdings"&gt;à&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;alert()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; trick&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;.&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Take a look at the following obfuscation script:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;1&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;2&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;function N(F,D)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;3&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;4&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;if (!D) D = ' "#%()-./012348:;&amp;lt;=&amp;gt;@ACEGHILMOPRTVWY\\]_abcdefghijlmnopqrstuvwxyz';&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;5&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;6&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;var f;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;7&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;var V='';&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;8&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;9&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;for (var c=0;c&amp;lt;F.length;c+=&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/B&gt;.length-380)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;10&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;11&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;f = ( (D.indexOf(F.charAt(c))&amp;amp;255)&amp;lt;&amp;lt;18) | &lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;12&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;((D.indexOf(F.charAt(c+1))&amp;amp;255)&amp;lt;&amp;lt;12) |&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;((D.indexOf(F.charAt(c+2))&amp;amp;255)&amp;lt;&amp;lt;6) | &lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;14&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;(D.indexOf(F.charAt(c+3))&amp;amp;255);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;V += String.fromCharCode((f&amp;amp;16711680)&amp;gt;&amp;gt;16,(f&amp;amp;65280)&amp;gt;&amp;gt;8,f&amp;amp;255);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;16&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;17&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;18&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval(V);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;19&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;20&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;21&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;22&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;N('[obfuscated goo &lt;STRONG&gt;v1&lt;/STRONG&gt;]')&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=blue size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;23&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The first thing you'll notice is&amp;nbsp;&lt;A title="http://blogs.msdn.com/dross/archive/2006/09/28/776208.aspx&amp;#10;Code Length Dependent Obfuscation" href="http://blogs.msdn.com/dross/archive/2006/09/28/776208.aspx" mce_href="http://blogs.msdn.com/dross/archive/2006/09/28/776208.aspx"&gt;code length dependent obfuscation&lt;/A&gt; – observe the use of&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&amp;nbsp; You can use the trick I described in my previous blog entry to deal with this.&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;But what you can’t really see from the script above is that when you &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;alert()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; instead of &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;, the string you get is:&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;N('[obfuscated goo &lt;STRONG&gt;v2&lt;/STRONG&gt;]')&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So it would seem that &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; is necessary in order to execute N() again to continue the de-obfuscation.&amp;nbsp; However, when analyzing any exploit you want to stay away from &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; at all costs to avoid inadvertently executing exploit script that hasn’t been analyzed yet.&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So to de-obfuscate this, &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;carefully&lt;/SPAN&gt;&lt;/B&gt; perform the steps below.&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=red&gt;&lt;SPAN style="COLOR: red"&gt;Warning: Executing malicious script without properly neutering it is dangerous.&amp;nbsp; Proceed with caution!&amp;nbsp; Be sure to read the safety guidance&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;A title="http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability%20Analysis%20Paper/Analyzing%20Browser%20Based%20Vulnerability%20Exploitation%20Incidents.htm&amp;#10;blocked::http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability Analysis Paper/Analyzing Browser Based Vulnerability Exploitation Incidents.htm" href="http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability%20Analysis%20Paper/Analyzing%20Browser%20Based%20Vulnerability%20Exploitation%20Incidents.htm"&gt;&lt;FONT title=http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability%20Analysis%20Paper/Analyzing%20Browser%20Based%20Vulnerability%20Exploitation%20Incidents.htm color=purple&gt;&lt;SPAN title=http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability%20Analysis%20Paper/Analyzing%20Browser%20Based%20Vulnerability%20Exploitation%20Incidents.htm style="COLOR: purple"&gt;here&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt;.&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Copy the malicious script to a standalone HTML document.&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Replace all instances of&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; with &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;pval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;, making sure that the obfuscated script block itself doesn’t implement &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;pval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;There is one instance of &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; on line 18 of the example above.&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Make sure there are no other extraneous &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;document.write()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; calls, &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; calls, or anything else that appears to run script or inject script into the DOM.&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Drop the definition of &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;pval()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; at the top of the file:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN lang=EN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;&lt;BR&gt;function pval(e) { alert(e); }&lt;BR&gt;&amp;lt;/script&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN lang=EN&gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;BR&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Run through the HTML and copy the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;N('[obfuscated goo &lt;STRONG&gt;v2&lt;/STRONG&gt;]')&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; from the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;alert()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;Press Ctrl-C to copy the contents of the alert dialog to the clipboard.&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Paste &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;N('[obfuscated goo &lt;STRONG&gt;v2&lt;/STRONG&gt;]')&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; over &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;N('[obfuscated goo &lt;STRONG&gt;v1&lt;/STRONG&gt;]')&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&amp;nbsp; on line 22 above.&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Go back to step 5 and continue as necessary until the ultimate de-obfuscated script is shown in the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;alert()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; &lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So far I’ve only seen recursion one-level deep so I don’t yet have a need for a more sophisticated solution.&amp;nbsp; If things get out of hand and I start to see multi-pass obfuscation I’ll post a more elegant technique.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=794426" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item><item><title>High-bit ASCII obfuscation</title><link>http://blogs.msdn.com/dross/archive/2006/10/01/780339.aspx</link><pubDate>Mon, 02 Oct 2006 06:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:780339</guid><dc:creator>dross</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dross/comments/780339.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=780339</wfw:commentRss><description>&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Here’s another new obfuscation technique I’ve seen in use on malicious web sites recently.&amp;nbsp; Check out the following HTML:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;html&amp;gt;&amp;lt;meta http-equiv=content-type content='text/html; charset=us-ascii'&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;¼óãòéðô¾áìåòô¨¢Ôèéó&amp;nbsp;éó&amp;nbsp;óïíå&amp;nbsp;ïâæõóãáôåä&amp;nbsp;óãòéðô¡¢©»¼¯óãòéðô¾&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Those funny characters are actually standard ASCII characters with the high-bit of each byte set.&amp;nbsp; If the high-bit ASCII managed to get posted properly to this blog without getting mangled, you should be able to drop the obfuscated HTML into a file on a web server and observe that browsing to the file results in execution of the following script:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;alert("This is some obfuscated script!");&amp;lt;/script&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Here’s some quick and dirty C# code that will&amp;nbsp;clear&amp;nbsp;the high-bit&amp;nbsp;of each input byte:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;&lt;/FONT&gt; char1;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;Char&lt;/SPAN&gt;&lt;/FONT&gt; c1;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;FileStream&lt;/SPAN&gt;&lt;/FONT&gt; fs = &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;FileStream&lt;/SPAN&gt;&lt;/FONT&gt;(&lt;FONT color=maroon&gt;&lt;SPAN style="COLOR: maroon"&gt;&lt;EM&gt;[file path]&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;, &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;FileMode&lt;/SPAN&gt;&lt;/FONT&gt;.Open);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;BinaryReader&lt;/SPAN&gt;&lt;/FONT&gt; r = &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;BinaryReader&lt;/SPAN&gt;&lt;/FONT&gt;(fs);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r.BaseStream.Seek(0, &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;SeekOrigin&lt;/SPAN&gt;&lt;/FONT&gt;.Begin);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;while&lt;/SPAN&gt;&lt;/FONT&gt; (r.BaseStream.Position &amp;lt; r.BaseStream.Length)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char1 = r.ReadByte();&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char1 = char1 - 0x80;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c1 = (&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;Char&lt;/SPAN&gt;&lt;/FONT&gt;)char1;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;Console&lt;/SPAN&gt;&lt;/FONT&gt;.Write(c1);&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Drop this code into a console app and you’ll have a nice de-obfuscator.&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This interesting behavior of US-ASCII in IE was &lt;A title=http://www.securityfocus.com/archive/1/437948/30/0/threaded href="http://www.securityfocus.com/archive/1/437948/30/0/threaded"&gt;noted by Kurt Huwig&lt;/A&gt; on BugTraq a few months ago.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=780339" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item><item><title>Code length dependent obfuscation</title><link>http://blogs.msdn.com/dross/archive/2006/09/28/776208.aspx</link><pubDate>Fri, 29 Sep 2006 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:776208</guid><dc:creator>dross</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dross/comments/776208.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=776208</wfw:commentRss><description>&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Wow, it’s been a long time!&amp;nbsp; Hopefully I can find more time to blog over the next couple of months.&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;In any event, my paper from last year really could use some updates.&amp;nbsp; Among other things there are a whole new slew of “Usual Suspect” vulnerabilities to document.&amp;nbsp; For this post I’ll focus on documenting an interesting new exploit obfuscation technique I’ve run across recently -- &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;code length dependent obfuscation&lt;/SPAN&gt;&lt;/B&gt;.&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Take a look at this obfuscated script&amp;nbsp;from a malicious web site:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;function x(UW,P)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!P)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;P='&lt;I&gt;&lt;SPAN style="FONT-STYLE: italic"&gt;[obfuscated data]&lt;/SPAN&gt;&lt;/I&gt;';&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;var W;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;var VM='';&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;for(var G=0;G&amp;lt;UW.length;G+=&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/B&gt;.replace(/\s/g,'').length-535)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;W=(P.indexOf(UW.charAt(G))&amp;amp;255)&amp;lt;&amp;lt;18|(P.indexOf(UW.charAt(G+1))&amp;amp;255)&amp;lt;&amp;lt;12|(P.indexOf(UW.charAt(G+2))&amp;amp;255)&amp;lt;&amp;lt;(&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/B&gt;.replace(/\s/g,'').length-533)|P.indexOf(UW.charAt(G+3))&amp;amp;255;VM+=String.fromCharCode((W&amp;amp;16711680)&amp;gt;&amp;gt;16,(W&amp;amp;65280)&amp;gt;&amp;gt;8,W&amp;amp;255);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;eval(VM.substring(0,VM.length-(&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/B&gt;.replace(/\s/g,'').length-537)));&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;x('&lt;I&gt;&lt;SPAN style="FONT-STYLE: italic"&gt;[obfuscated data]&lt;/SPAN&gt;&lt;/I&gt;');&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/script&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Note the use of &lt;/SPAN&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;arguments.callee.toString()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&amp;nbsp; This effectively returns the text of the current script block.&amp;nbsp; The script calculates the length of the text and actually &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;uses this length to produce the correct de-obfuscated script to evaluate&lt;/SPAN&gt;&lt;/B&gt;.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;If you’ve read &lt;A title=http://blogs.msdn.com/dross/archive/2005/06/13/428590.aspx href="http://blogs.msdn.com/dross/archive/2005/06/13/428590.aspx"&gt;Analyzing Browser Based Vulnerability Exploitation Incidents&lt;/A&gt; then you already know how to replace the “eval()” statement in the script above with an alert() to get the de-obfuscated text without executing it.&amp;nbsp; However as you can probably guess, the technique above defeats this trick because alert() is one character longer than eval().&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This isn't hard to circumvent once you know what's going on.&amp;nbsp; Simply change “eval” to “pval” and add the following script block before the primary script block on your test page:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;script&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;function pval(e) { alert(e); }&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/script&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Just make sure that the obfuscated script block itself doesn’t implement “pval” to try to trip you up!&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Tip of the day:&lt;/SPAN&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; Try &lt;FONT face="Courier New"&gt;Prompt(0,&lt;EM&gt;[string]&lt;/EM&gt;)&lt;/FONT&gt;&amp;nbsp;in place of&amp;nbsp;&lt;FONT face="Courier New"&gt;alert(&lt;EM&gt;[string]&lt;/EM&gt;)&lt;/FONT&gt;&lt;FONT face=Arial&gt;.&amp;nbsp; This will&amp;nbsp;allow you to easily copy de-obfuscated data to the clipboard.&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Also, &lt;A href="http://blogs.technet.com/robert_hensing/default.aspx"&gt;Rob Hensing&lt;/A&gt; let me know that pressing Ctrl-C on an alert() window will copy the contents of the alert box to the clipboard.&amp;nbsp; Thanks Rob!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=776208" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item><item><title>Analyzing Browser Based Vulnerability Exploitation Incidents</title><link>http://blogs.msdn.com/dross/archive/2005/06/13/428590.aspx</link><pubDate>Mon, 13 Jun 2005 21:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428590</guid><dc:creator>dross</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dross/comments/428590.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dross/commentrss.aspx?PostID=428590</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;I've written up a paper&amp;nbsp;that describes some useful tools/techniques for deconstructing&amp;nbsp;web based exploits:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&lt;A href="http://dr00.sts.winisp.net/VulnAnalysisPaper/Vulnerability%20Analysis%20Paper/Analyzing%20Browser%20Based%20Vulnerability%20Exploitation%20Incidents.htm"&gt;Analyzing Browser Based Vulnerability Exploitation Incidents&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The paper started as a blog entry and it remains a blog entry at its core.&amp;nbsp; But since really huge blog entries are uncool (so I hear), and for other logistical reasons, the paper itself is hosted elsewhere.&amp;nbsp; Future research from other members of my team will likely be collected in some central spot, stay tuned...&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428590" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dross/archive/tags/Computer+Security/default.aspx">Computer Security</category><category domain="http://blogs.msdn.com/dross/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/dross/archive/tags/De-obfuscation/default.aspx">De-obfuscation</category></item></channel></rss>