<?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>Praetorian Prefect &#187; WMI</title>
	<atom:link href="http://praetorianprefect.com/archives/tag/wmi/feed/" rel="self" type="application/rss+xml" />
	<link>http://praetorianprefect.com</link>
	<description>Information security, a little slower...a little deeper</description>
	<lastBuildDate>Thu, 29 Jul 2010 16:38:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Who’s Being Promiscuous in Your Active Directory?</title>
		<link>http://praetorianprefect.com/archives/2009/09/whos-being-promiscuous-in-your-active-directory/</link>
		<comments>http://praetorianprefect.com/archives/2009/09/whos-being-promiscuous-in-your-active-directory/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:18:50 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=719</guid>
		<description><![CDATA[I’m always a fan of more queries and peaks at what is going on in my AD domain, especially at what is happening on the workstations. I was working on some WMI queries to get information about network interfaces using the Win32_NetworkAdapterConfiguration class, and thought about promqry.exe. Promqry is a tool provided by Microsoft to [...]]]></description>
			<content:encoded><![CDATA[<p>I’m always a fan of more queries and peaks at what is going on in my AD domain, especially at what is happening on the workstations. I was working on some WMI queries to get information about network interfaces using the Win32_NetworkAdapterConfiguration class, and thought about promqry.exe. <a href="http://support.microsoft.com/kb/892853" target="_blank">Promqry</a> is a tool provided by Microsoft to query a computer’s network interfaces and return if it is running in promiscuous mode.</p>

<p>This information can be handy for several reasons:</p>

<ul>
    <li>An interface running in promiscuous mode may be due to the user running network sniffer such as Wireshark.</li>
    <li>An interface running in promiscuous mode may be due to the user running virtualization software, such as Virtual PC.</li>
    <li>An interface running in promiscuous mode may be due to malicious code.</li>
</ul>

<p>I definitely want to know if users are running network sniffers, or virtualization software (likely the guests are not licensed or managed causing rogue workstations in the environment). Of course any potential activity that may be caused by malware or malicious code is a concern as well.</p>

<p>You could very easily download promqry and run a <em>for</em> loop against your machines. I wanted to use WMI for this task instead and rather than a text file, use the directoryservices object to query my AD for computers.</p>

<p>I couldn’t find any property in Win32_NetworkAdapterConfiguration to check for this, but I found <a href="http://windowsir.blogspot.com/2005/02/promqry-revisited.html" target="_blank">this post</a> on promqry which tracked down the WMI classes it uses. That led me in the right direction. The other key to this is what MSNdis_CurrentPacketFilter returns. Microsoft documents this <a href="http://msdn.microsoft.com/en-us/library/bb648512.aspx" target="_blank">here</a> and we are checking if the NDIS_PACKET_TYPE_PROMISCUOUS bit is enabled.</p>

<p>Below is a quick Powershell script which will grab computer objects from AD, then use WMI and the MSNdis_CurrentPacketFilter class to check for promiscuous mode. You can incorporate this WMI query with Win32_NetworkAdapterConfiguration and get a better picture of the interface network settings:
<pre><code>
$ErrorActionPreference = "SilentlyContinue"</p>

<p>$PingTest = New-Object System.Net.NetworkInformation.Ping
$Filter = "(&amp;(ObjectCategory=computer))"
$Searcher = New-Object System.DirectoryServices.DirectorySearcher($Filter)
ForEach ($comp in $Searcher.Findall()) {
    $strComputer = $comp.properties.item("Name")
    write-host "Checking: $strComputer"
    if ($PingTest.Send($strComputer).Status -eq "Success") {
        $colComputer = get-wmiObject -class "MSNdis_CurrentPacketFilter" -namespace "root\WMI" -comp $strComputer
        if ($colComputer -eq $null) {
            write-host "Couldn't connect to WMI" }
        else {
            foreach ($comp in $colcomputer) {
                $val = $comp.NdisCurrentPacketFilter
                if ($val -band 0x00000020) {
                    $inst = $comp.InstanceName
                    write-host "Interface: $inst"
                    write-host "The NDIS_PACKET_TYPE_PROMISCUOUS value is set" -foregroundcolor red -backgroundcolor yellow
                }
            }
        }
    }
    else { write-host "Could not ping, machine not queried." }
}</p>

<p></code></pre>
 </p>

<p>The following screenshot shows the results. I don’t like waiting for RPC to time out when the machine is off or not reachable, so a quick ping check before querying WMI speeds things up. Also, when an interface has the bit set, the output is highlighted with red text and a yellow foreground. You could wrap an email function and schedule this so that you are alerted when it comes up.</p>

<p><a href="http://praetorianprefect.com/wp-content/uploads/2009/10/ScreenHunter_06Oct.0120.51.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="ScreenHunter_06 Oct. 01 20.51" src="http://praetorianprefect.com/wp-content/uploads/2009/10/ScreenHunter_06Oct.0120.51_thumb.gif" border="0" alt="ScreenHunter_06 Oct. 01 20.51" width="244" height="173" /></a></p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p>You will need proper access to the workstations to query root\WMI so when you run this in a domain, your account should have local administrator privileges to the computers it will query. If it doesn’t, the command will return “Couldn’t connect to WMI”.</p>

<p>Finally, if you haven’t looked at the MSNdis class yet, I suggest taking a look, especially at MSNdis_80211 which will query various wireless information that may be of interest. There isn’t a whole lot of documentation on it, so I’ll work on getting some details together and maybe draft a Powershell script to find wireless adapters and networks they are connected to or available networks close enough to connect to. Until then, enjoy finding those promiscuous mode adapters in your domain.</p>

<p> </p>

<p><a title="http://windowsir.blogspot.com/2005/02/promqry-revisited.html" href="http://windowsir.blogspot.com/2005/02/promqry-revisited.html"> </a></p>

<p><strong>Related Posts:</strong></p>
<ul>
<li><a href="http://praetorianprefect.com/archives/2010/06/iphone-4-ordering-and-session-switching/">iPhone 4 Ordering and Session Switching</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/05/mays-patch-tuesday/">May&#8217;s Patch Tuesday</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/03/3473/">March&#8217;s Patch Tuesday</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/03/press-f1-for-help-pwned/">Press F1 for Help, pwned.</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/01/first-patch-tuesday-of-2010/">First Patch Tuesday of 2010</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/09/whos-being-promiscuous-in-your-active-directory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows Task Scheduler: Backwards Incompatibility</title>
		<link>http://praetorianprefect.com/archives/2009/09/windows-task-scheduler-backwards-incompatibility/</link>
		<comments>http://praetorianprefect.com/archives/2009/09/windows-task-scheduler-backwards-incompatibility/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 01:49:35 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows 7]]></category>
		<category><![CDATA[WMI]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=741</guid>
		<description><![CDATA[Scheduled tasks are plentiful in most environments. Managing them is typically a nightmare. You have some running to truncate and copy off logs someplace, or others to run a proprietary backup utility to dump a copy of your Quickbooks data; whatever the reason, over time there are more and they are everywhere. Typically, you want [...]]]></description>
			<content:encoded><![CDATA[<p>Scheduled tasks are plentiful in most environments. Managing them is typically a nightmare. You have some running to truncate and copy off logs someplace, or others to run a proprietary backup utility to dump a copy of your Quickbooks data; whatever the reason, over time there are more and they are everywhere. Typically, you want to know that they exist, when they are scheduled to run, and most importantly who they are going to run as. (Look our for password expirations!)</p>

<p>Unless you have invested in an enterprise solution for tasks, you are using Windows Task Scheduler and have the tools included with the Windows OS to do the trick. This article is to point out two major snafus you may come across when attempting to manage scheduled tasks across your environment:</p>

<ol>
<li><p>Using WMI class versus the task scheduler API and what effects it has.</p></li>
<li><p>New versions in Vista / Windows 7 / Windows 2008 that do not work with XP / 2003.</p></li>
</ol>

<p>The first item is more for those who attempt scripting and programming to manage the tasks across machines in the environment. WMI has a class called Win32_Scheduledjob which does quite a bit for managing tasks. However, any tasks created with or modified by the task scheduler API  (such as through the task scheduler GUI or schtasks.exe) will cause the tasks to no longer be managed by WMI. For example, if you create a task using schtasks.exe, this tasks will not be returned in a WMI query; or, if you create a task using WMI, but then modify it with the task scheduler GUI, it will also no longer turn up in WMI. </p>

<p>So, Win32_Schedulejob is not a great option and we go about our business using the GUI and schdtasks.exe. We move on to our second issue, which is the backwards incompatibility for those using Vista, Windows 7 or Windows 2008. For example, from my Windows 7 workstation, if I use schtasks.exe or the Task Schedule MMC snap-in, I can query, manipulate, create tasks on Vista, Windows 7 or Windows 2008. When I attempt to reach a Windows XP or Windows 2003 machine, I get Access Denied. Running the older XP version of schtasks.exe did not return errors when run against any version OS. This is painful. The solution is to run the management commands from an XP or 2003 machine, or to copy the schtasks.exe and schedsvc.dll files from those version into a directory on your Vista / Win7 machine and run it from there. See this screenshot using both versions of the tool from my  Windows 7 workstation, querying a Windows XP machine. I printed the file version each time to show the newer copy fails with Access is Denied.</p>

<p><a href="http://praetorianprefect.com/wp-content/uploads/2009/10/ScreenHunter_03Oct.0221.452.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="ScreenHunter_03 Oct. 02 21.45" src="http://praetorianprefect.com/wp-content/uploads/2009/10/ScreenHunter_03Oct.0221.45_thumb2.gif" border="0" alt="ScreenHunter_03 Oct. 02 21.45" width="244" height="158" align="left" /></a></p>

<blockquote> 

You may very well have proper access, but this Access Denied means you have a newer version of the tool.</blockquote>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p>

<p>This <a href="http://msdn.microsoft.com/en-us/library/bb756979.aspx" target="_blank">Technet article</a> explains what is new in Task Scheduler 2.0 (Vista and above) compared to 1.0. There are many new features, but I would have liked to have a schtasks.exe and a MMC snap-in that was backwards compatible to manage older versions.</p>

<p>One last note is that .job files from XP/2003 are not compatible with the newer Task Scheduler 2.0 (xml format). I’ve seen that folks used the older schtasks.exe to dump the task information in table format, than use Excel to properly edit it to the valid xml format.</p>

<p><strong>Related Posts:</strong></p>
<ul>
<li><a href="http://praetorianprefect.com/archives/2010/03/3473/">March&#8217;s Patch Tuesday</a></li>
<li><a href="http://praetorianprefect.com/archives/2009/12/regular-or-decaf-tool-launched-to-combat-cofee/">Regular or Decaf? Tool launched to combat COFEE</a></li>
<li><a href="http://praetorianprefect.com/archives/2009/12/six-bulletins-in-last-patch-tuesday-of-2009/">Six Bulletins in Last Patch Tuesday of 2009</a></li>
<li><a href="http://praetorianprefect.com/archives/2009/11/ossec-agentless-its-good-but-not-good-enough/">OSSEC: Agentless&#8230;It&#8217;s good, but not good enough</a></li>
<li><a href="http://praetorianprefect.com/archives/2009/11/ossec-agentless-scripts/">OSSEC: Agentless scripts</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/09/windows-task-scheduler-backwards-incompatibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
