<?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>Fooling Around &#187; security</title>
	<atom:link href="http://alax.info/blog/tag/security/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Wed, 02 May 2012 15:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc</title>
		<link>http://alax.info/blog/950</link>
		<comments>http://alax.info/blog/950#comments</comments>
		<pubDate>Mon, 22 Jun 2009 18:10:43 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CRegKey]]></category>
		<category><![CDATA[CSecurityDesc]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[RegSetKeySecurity]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SetKeySecurity]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=950</guid>
		<description><![CDATA[<a href="http://alax.info/blog/950" title="RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc"></a>One thing is worth special mentioning in connection with previous post on DirectShow Filter Graph Spy on Microsoft Vista system: ATL&#8217;s CSecurityDesc class caused to waste some time. CRegKey Key; ATLENSURE_SUCCEEDED(HRESULT_FROM_WIN32(Key.Open(HKEY_CLASSES_ROOT, pszKeyName, READ_CONTROL &#124; WRITE_OWNER))); CSecurityDesc AdministratorsOwnerSecurityDescriptor; AdministratorsOwnerSecurityDescriptor.SetOwner(Sids::Admins()); ATLENSURE_SUCCEEDED(HRESULT_FROM_WIN32(Key.SetKeySecurity(OWNER_SECURITY_INFORMATION, &#38;AdministratorsOwnerSecurityDescriptor))); &#8230;<p class="read-more"><a href="http://alax.info/blog/950">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/950" title="RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc"></a><p>One thing is worth special mentioning in connection with previous post on <a href="http://alax.info/blog/944">DirectShow Filter Graph Spy</a> on <a href="http://www.microsoft.com/windows/windows-vista/default.aspx">Microsoft Vista</a> system: ATL&#8217;s CSecurityDesc class caused to waste some time.</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">CRegKey Key<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>Open<span style="color: #808030;">(</span>HKEY_CLASSES_ROOT<span style="color: #808030;">,</span> pszKeyName<span style="color: #808030;">,</span> READ_CONTROL <span style="color: #808030;">|</span> WRITE_OWNER<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CSecurityDesc AdministratorsOwnerSecurityDescriptor<span style="color: #800080;">;</span>
AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">.</span>SetOwner<span style="color: #808030;">(</span>Sids<span style="color: #800080;">::</span>Admins<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>The code compiles fine, but on runtime it gives error <em>87</em> (<em>ERROR_INVALID_PARAMETER</em>, <em>E_INVALIDARG</em>) in the last line, returned from <a href="http://msdn.microsoft.com/en-us/library/aa379314(VS.85).aspx">RegSetKeySecurity</a> API call. My first guess was that ATL&#8217;s <a href="http://msdn.microsoft.com/en-us/library/k0c0e5w6.aspx">CSecurityDesc</a> class for some reason prepared wrong descriptor which resulted in rejecting it as an argument. From the first glance it looks (not sure) that this class deals, to some extent, with structures itself rather than using API functions, so it could be that it results in something looking differently from expected by API calls.</p>
<p>Still the problem is in class itself and its cast from <em>CSecurityDesc&amp;</em> to required <em>SECURITY_DESCRIPTOR*</em> type. The class only implements operator to automatically cast to <em><span style="color: #ff0000;">const</span> SECURITY_DESCRIPTOR*</em> type, so the following line would not be passed by compiler:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span></pre>
<p>However <em><span style="color: #ff0000;">&amp;</span>AdministratorsOwnerSecurityDescriptor</em> is another level of indirection and hence <em>SECURITY_DESCRIPTOR*</em><span style="color: #ff0000;">*</span> type, which is passed by compiler, but results in indeed invalid argument.</p>
<p>So in order to correctly convert <em>CSecurityDesc&amp;</em> to <em>SECURITY_DESCRIPTOR*</em> it can be done this way:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">CRegKey Key<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>Open<span style="color: #808030;">(</span>HKEY_CLASSES_ROOT<span style="color: #808030;">,</span> pszKeyName<span style="color: #808030;">,</span> READ_CONTROL <span style="color: #808030;">|</span> WRITE_OWNER<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CSecurityDesc AdministratorsOwnerSecurityDescriptor<span style="color: #800080;">;</span>
AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">.</span>SetOwner<span style="color: #808030;">(</span>Sids<span style="color: #800080;">::</span>Admins<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> const_cast<span style="color: #808030;">&lt;</span><span style="color: #603000;">SECURITY_DESCRIPTOR</span><span style="color: #808030;">*</span><span style="color: #808030;">&gt;</span><span style="color: #808030;">(</span><span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">SECURITY_DESCRIPTOR</span><span style="color: #808030;">*</span><span style="color: #808030;">)</span> AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/950/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow Filter Graph Spy on Vista</title>
		<link>http://alax.info/blog/944</link>
		<comments>http://alax.info/blog/944#comments</comments>
		<pubDate>Mon, 22 Jun 2009 08:36:15 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[spy]]></category>
		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=944</guid>
		<description><![CDATA[<a href="http://alax.info/blog/944" title="DirectShow Filter Graph Spy on Vista"></a>I have been receiving comments that Filter Graph Spy tool does not work with Microsoft Vista operating system. I never had a moment to check until recently, and this time I realized that it really does not work. I am &#8230;<p class="read-more"><a href="http://alax.info/blog/944">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/944" title="DirectShow Filter Graph Spy on Vista"></a><p>I have been receiving comments that <a href="http://alax.info/blog/777">Filter Graph Spy</a> tool does not work with Microsoft Vista operating system. I never had a moment to check until recently, and this time I realized that it really does not work. I am definitely aware of dramatic changes introduced with this operating system, and in particular UAC feature, virtualization and changes in security. No wonder this was the first guess that security was the cause, however the investigation showed there was a trail of issues underneath&#8230;</p>
<p>Investigation details deserve a separate post, while this one briefly outlines the issues and also accompany the repository update with a version compatible with Vista OS.</p>
<p>First of all, COM registration of the DLL (which definitely requires privilege elevation) succeeded on Vista. This means the registration procedure did not encounter any errors on the way, or poorly written code ignored the problem. It appeared that the source of the problem was <a href="http://msdn.microsoft.com/en-us/library/ms693452(VS.85).aspx">CoTreatAsClass</a> API, which failed to do the requested action, however returned status code indicating successful operation. This definitely looks like a bug and further comments on this particular behavior are expected to appear on <a href="http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/threads/">Windows Applications Security MSDN forum</a>, where I opened <a href="http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/583793b8-a73c-4cb5-ae8c-a3620203aed9">a topic on the matter</a>.</p>
<p>With a COM TreatAs feature activated, the class&#8217;s behavior to instantiate instead of DirectShow&#8217;s CLSID_FilterGraph is restored, and in particular the DLL generates <em>FilterGraphSpy.log</em> log file on filter graph activity. Note that log file location is OS dependent (due to Vista&#8217;s permissions and file system virtualization):</p>
<ul>
<li>pre-Vista OS: root of syste drive, typically <em>C:\</em></li>
<li>starting Vista, administrator with elevated privileges: <em>CSIDL_COMMON_APPDATA</em>, typically <em>C:\ProgramData</em> (note this directory is hidden by deafult)</li>
<li>starting Vista, without elevated administrator privileges: <em>CSIDL_LOCAL_APPDATA</em>, typically <em>C:\Users\$(UserName)\AppData\Local</em> (note that <em>AppData</em> directory is hidden by deafult)</li>
</ul>
<p>Still even with the log file generated and indicating activation of the spy, it was unable to connect to remote graph through the running object table (ROT). It appeared that the ROT entires are there where expected, it was OK to get an object from ROT and the problem came from QueryInterface code:</p>
<pre>CComPtr<span style="color: #800080;">&lt;</span>IUnknown<span style="color: #800080;">&gt;</span> pFilterGraphUnknown<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pRunningObjectTable<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span><span style="color: #400000;">GetObject</span><span style="color: #808030;">(</span>pMoniker<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>pFilterGraphUnknown<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CComQIPtr<span style="color: #800080;">&lt;</span>IMyFilterGraph<span style="color: #800080;">&gt;</span> pFilterGraph <span style="color: #808030;">=</span> pFilterGraphUnknown<span style="color: #800080;">;</span> <span style="color: #696969;">// <span style="color: #ff0000;">E_NOINTERFACE</span></span></pre>
<p>The call reached the original object but COM subsystem was unable to marshal the interface through apartments to enable interprocess communication on it. The reason for this is absence of <em>PSFactoryBuffer</em> class (CLSID {92A3A302-DA7C-4A1F-BA7E-1802BB5D2D02}), which provides proxy/stub pairs for marshaling well known DirectShow interfaces in the Vista&#8217;s version of <em>quartz.dll</em>. <a href="http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/5079f1c5-1275-4449-a11c-3cbb820e33eb">As mentioned by Microsoft&#8217;s Mike Wasson</a>, this class was moved from <em>quartz.dll</em> into Vista SDK&#8217;s <em>proppage.dll</em>, so in order to obtain connectivity to remote DirectShow graphs starting Vista, one needs to install this DLL with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en">Windows SDK</a>, or otherwise have it registered with the operating system.</p>
<p>Also note that DirectShow-enabled applications that have their filter graphs published on ROT will need an utility application such as <a href="http://msdn.microsoft.com/en-us/library/ms787460(VS.85).aspx">GraphEdit</a> started with the same permissions (elevated or not) in order to be able to access ROT entires.</p>
<div style="background-color: #efa; border: 1px solid #ffc; padding: 2px; ">To sum everything up, to install Alax.Info DirectShow Filter Graph Spy on Vista:<br/></p>
<ul>
<li>get the latest <em>FilterGraphSpy.dll</em></li>
<li>regsvr32 <em>FilterGraphSpy.dll</em> on target system from administrative command prompt, with elevated privileges (note you should have a log file <em>FilterGraphSpy.log</em> generated in CSIDL_COMMON_APPDATA directory, with a few lines indicating registration success)</li>
<li>get <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en">Windows SDK</a> and make <em>$(WindowsSDK)\Bin\proppage.dll</em> file registered on target system (also administrative regsvr32), note that it is necessary to restart DirectShow-enabled applications and GraphEdit after DLL registration to get graphs visible through ROT</li>
<li>mind the log file directories with <em>FilterGraphSpy.log</em> file</li>
</ul>
</div>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/944/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Essen 2008</title>
		<link>http://alax.info/blog/648</link>
		<comments>http://alax.info/blog/648#comments</comments>
		<pubDate>Wed, 24 Sep 2008 07:56:57 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[classified]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=648</guid>
		<description><![CDATA[<a href="http://alax.info/blog/648" title="Security Essen 2008"></a>Security Essen 2008 is a global event for securty industry. The website lists exhibitors, but I would rather it is more usable in sense of listing and filtering exhibitors. Luckily, the list is parsed out for a better manipulation: And &#8230;<p class="read-more"><a href="http://alax.info/blog/648">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/648" title="Security Essen 2008"></a><p>Security Essen 2008 is a global event for securty industry. <a href="http://www.security-messe.de/">The website</a> lists exhibitors, but I would rather it is more usable in sense of listing and filtering <a href="http://www.security-messe.de/index.php?mp_action=showlist&amp;lang=en&amp;content=90000000">exhibitors</a>. Luckily, the list is parsed out for a better manipulation:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2008/09/24-image002.png"><img class="alignnone size-medium wp-image-650" title="Exhibitors" src="http://alax.info/blog/wp-content/uploads/2008/09/24-image002-300x178.png" alt="" width="300" height="178" /></a></p>
<p>And also a product category filtering:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2008/09/24-image001.png"><img class="alignnone size-medium wp-image-649" title="Exhibitor Product Groups" src="http://alax.info/blog/wp-content/uploads/2008/09/24-image001-300x90.png" alt="" width="300" height="90" /></a></p>
<p>A categorized list of <strong>over 1000 exhibitors</strong> with addresses and public contact information is <a href="http://alax.info/blog/about">available</a> as <a href="http://openoffice.org/">Open Office</a> ODS and <a href="http://office.microsoft.com/">Microsoft Excel</a> XLS spreadsheets, as well as CSV formatted text.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/648/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

