<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>durdle.com &#187; Security</title>
	<atom:link href="http://durdle.com/archives/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://durdle.com</link>
	<description></description>
	<lastBuildDate>Thu, 12 Apr 2012 21:13:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>FindTheHole.vbs</title>
		<link>http://durdle.com/archives/2008/08/11/findtheholevbs/</link>
		<comments>http://durdle.com/archives/2008/08/11/findtheholevbs/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 09:59:39 +0000</pubDate>
		<dc:creator>Howard</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[effective permissions]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://blog.durdle.com/?p=388</guid>
		<description><![CDATA[Recently I needed to write a script that could locate a folder on a system that had particular characteristics.  I was looking for hidden folders that the logged on user had rights to read, write/append and execute on.  ie, they can drop a binary into the folder and then run it. This is the script...]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to write a script that could locate a folder on a system that had particular characteristics.  I was looking for hidden folders that the logged on user had rights to read, write/append and execute on.  ie, they can drop a binary into the folder and then run it.</p>
<p>This is the script I came up with.  It uses a WMI query and method to first locate all the hidden folders on the system, and then compare each ones effective permissions to a mask I created:</p>
<div class="wp_syntax">
<div class="code">
<pre class="vbnet" style="font-family:monospace;">strComputer <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;.&quot;</span>
<span style="color: #FF8000;">Set</span> objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:&quot;</span> _
<span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;{impersonationLevel=impersonate}!&quot;</span> <span style="color: #008000;">&amp;</span> strComputer <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;rootcimv2&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> colFiles <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span> _
<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * from Win32_Directory Where Hidden = True&quot;</span><span style="color: #000000;">&#41;</span>
wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Hidden folders which you can write to...&quot;</span>
intW <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #008080; font-style: italic;">' initialise Writable folder count</span>
<span style="color: #008080; font-style: italic;">' Iterate through each hidden folder on the computer</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objFile in colFiles
	<span style="color: #008080; font-style: italic;">' Ignore some well known hidden folders</span>
	<span style="color: #0600FF;">If</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;documents and settings&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;$nt&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;$hf_mig$&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;ie7updates&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;visual studio&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;dllcache&quot;</span><span style="color: #000000;">&#41;</span> or _
		<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;$patchcache$&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
	<span style="color: #FF8000;">Else</span>
		<span style="color: #008080; font-style: italic;">' Can we read (1), write (2, 4), and execute (32) in this folder?</span>
		intPermissions <span style="color: #008000;">=</span> <span style="color: #FF0000;">39</span>
		<span style="color: #008080; font-style: italic;">' Use WMI method to compare permissions</span>
		<span style="color: #0600FF;">If</span> objFile.<span style="color: #0000FF;">GetEffectivePermission</span><span style="color: #000000;">&#40;</span>intPermissions<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
			wscript.<span style="color: #0000FF;">echo</span> objFile.<span style="color: #0000FF;">Name</span>
			intW <span style="color: #008000;">=</span> intW <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span>
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
wscript.<span style="color: #0000FF;">echo</span> intW <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; vulnerable folders.&quot;</span></pre>
</div>
</div>
<p>This was important as part of a wider effort to prove a particular vulnerability existed.  Imagine the scenario where a standard user is prevented from running unknown binaries except for one hidden folder somewhere on the system which is excluded from this protection.  If one could quickly find that folder, the user could run whatever he liked.</p>
<p>I&#8217;m aware that there are plenty of command line tools that would have helped in this endeavour (such as AccessChk) but remember: this is a system where unauthorised apps can not be run.  It&#8217;s VBScript or nothing.</p>
]]></content:encoded>
			<wfw:commentRss>http://durdle.com/archives/2008/08/11/findtheholevbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

