<?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; Administration</title>
	<atom:link href="http://praetorianprefect.com/archives/category/administration/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>March&#8217;s Patch Tuesday</title>
		<link>http://praetorianprefect.com/archives/2010/03/3473/</link>
		<comments>http://praetorianprefect.com/archives/2010/03/3473/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 20:38:40 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Patch Management]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[office for mac]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[patch tuesday]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=3473</guid>
		<description><![CDATA[<a href="http://praetorianprefect.com/wp-content/uploads/2010/03/msft_logo.jpg"><img src="http://praetorianprefect.com/wp-content/uploads/2010/03/msft_logo.jpg" alt="msft_logo" title="msft_logo" width="150" height="150" class="alignleft size-full wp-image-3484" /></a>

Today is patch Tuesday for March 2010, and Microsoft has released two security bulletins for this round of updates, neither of which are deemed critical. The second bulletin addresses seven different vulnerabilities across various versions of Microsoft Office Excel.]]></description>
			<content:encoded><![CDATA[<p><a href="http://praetorianprefect.com/wp-content/uploads/2010/03/msft_logo.jpg"><img src="http://praetorianprefect.com/wp-content/uploads/2010/03/msft_logo.jpg" alt="msft_logo" title="msft_logo" width="150" height="150" class="alignleft size-full wp-image-3484" /></a></p>

<p>Today is patch Tuesday for March 2010, and Microsoft has released two security bulletins for this round of updates, neither of which are deemed critical. The second bulletin addresses seven different vulnerabilities across various versions of Microsoft Office Excel.</p>

<hr />

<p><strong>ID:</strong> <a href="http://www.microsoft.com/technet/security/bulletin/ms10-016.mspx">MS10-016</a><br />
<strong>Title:</strong> Vulnerabilities in in Windows Movie Maker Could Allow Remote Code Execution<br />
<strong>Microsoft Severity:</strong> Important<br /></p>

<p><strong>Summary:</strong> There is a buffer overflow in the Windows Movie Maker and MS Producer 2003 which can lead to code execution. Movie Maker 2.1 is included with Windows XP SP2 and SP3, and Movie Maker 6.0 is included with Vista. Movie Maker 2.6 is an optional download for Vista and Windows 7.<br /></p>

<p><strong>Praetorian&#8217;s Recommendation:</strong> This is deemed important instead of critical due to the user having to run content which exploits the vulnerability. A user would have to be tricked into opening a Movie Maker project file (mswmm) to be exploited. This can be updated in your next patch cycle, and is not considered urgent. <br /></p>

<hr />

<p><strong>ID:</strong> <a href="http://www.microsoft.com/technet/security/Bulletin/MS10-017.mspx">MS10-017</a><br />
<strong>Title:</strong> Vulnerability in Microsoft Office Excel Could Allow Remote Code Execution<br />
<strong>Microsoft Severity:</strong> Important<br /></p>

<p><strong>Summary:</strong> This update addresses seven different vulnerabilities related to Microsoft Office Excel. Each vulnerability may affect one or more of the following versions: Office Excel 2003 SP3, Office Excel 2003 SP3, Office Excel 2007 SP1 and SP2, Office 2004 for Mac, Office 2008 for Mac, Open XML File Format Converter for Mac, Office Excel Viewer SP1 and SP2, Office Compatibility Pack for Word, Excel, and Powerpoint 2007 File Formats SP1 and SP2, and Office SharePoint Server 2007 SP1 and SP2.<br /></p>

<p><strong>Praetorian&#8217;s Recommendation:</strong> Although the same requirement exists as MS10-016 for users to open malicious files, Excel formats are more recognizable and phishing and social engineering techniques can be more successful with a known or common file format. This can be updated in your next patch cycle, but should warrant more attention than MS10-017.<br /></p>

<hr />

<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/press-f1-for-help-pwned/">Press F1 for Help, pwned.</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/02/februarys-patch-tuesday/">February&#8217;s Patch Tuesday</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/01/disable-acrobat-reader-pdf-in-the-enterprise/">Using Group Policy to Disable JavaScript in Adobe PDF Files</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2010/03/3473/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Six Bulletins in Last Patch Tuesday of 2009</title>
		<link>http://praetorianprefect.com/archives/2009/12/six-bulletins-in-last-patch-tuesday-of-2009/</link>
		<comments>http://praetorianprefect.com/archives/2009/12/six-bulletins-in-last-patch-tuesday-of-2009/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 19:39:55 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[patch tuesday]]></category>
		<category><![CDATA[updates]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=2088</guid>
		<description><![CDATA[Today marks the last Microsoft patch Tuesday of 2009, and Microsoft has released patches to six bulletins:




MS09-071 &#8211; Vulnerabilities in Internet Authentication Service Could Allow Remote Code Execution (974318)
MS09-074 &#8211; Vulnerability in Microsoft Office Project Could Allow Remote Code Execution (967183) 
MS09-072 &#8211; Cumulative Security Update for Internet Explorer (976325) 
MS09-069 &#8211; Vulnerability in Local [...]]]></description>
			<content:encoded><![CDATA[<p>Today marks the last Microsoft patch Tuesday of 2009, and Microsoft has released patches to six bulletins:</p>

<p><a href="http://praetorianprefect.com/wp-content/uploads/2009/12/image_31_3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image_3[1]_3" border="0" alt="image_3[1]_3" src="http://praetorianprefect.com/wp-content/uploads/2009/12/image_31_3.png" width="69" height="81" /></a></p>

<ul>
<li><strong>MS09-071</strong> &#8211; Vulnerabilities in Internet Authentication Service Could Allow Remote Code Execution (974318)</li>
<li><strong>MS09-074</strong> &#8211; Vulnerability in Microsoft Office Project Could Allow Remote Code Execution (967183) </li>
<li><strong>MS09-072</strong> &#8211; Cumulative Security Update for Internet Explorer (976325) </li>
<li><strong>MS09-069</strong> &#8211; Vulnerability in Local Security Authority Subsystem Service Could Allow Denial of Service (974392) </li>
<li><strong>MS09-070</strong> &#8211; Vulnerabilities in Active Directory Federation Services Could Allow Remote Code Execution (971726) </li>
<li><strong>MS09-073</strong> &#8211; Vulnerability in WordPad and Office Text Converters Could Allow Remote Code Execution (975539) </li>
</ul>

<h3>Severity Levels</h3>

<p>Microsoft has a <a href="http://www.microsoft.com/technet/security/bulletin/rating.mspx" target="_blank">rating system</a> for bulletins which includes: Critical, Important, Moderate, and Low. The severity levels I provide below are not directly from Microsoft. For example, MS will give an important rating when exploitation could result in compromise of availability, as in a denial of service. MS09-069 can result in a denial of service, however, the attacker must already be authenticated. For this reason I drop the severity to Low.</p>

<h3>Bulletin Summaries</h3>

<hr />

<p><strong>Bulletin:</strong> MS09-071<br/>
<strong>Recommended Action:</strong> Update Windows 2008 Server (32-bit and 64-bit) which have IAS configured to use PEAP with MS-CHAP v2 authentication.<br/>
<strong>My Severity Rating:</strong> Moderate, should patch the above mentioned software.</p>

<p>This update addresses two vulnerabilities in the Internet Authentication Service (IAS). One is an IAS memory corruption vulnerability and the second is an authentication bypass vulnerability in MS-CHAP authentication. Client operating systems contain the vulnerable code but the components are not used in a way to make them vulnerable.</p>

<hr />

<p><strong>Bulletin:</strong> MS09-074<br/>
<strong>Recommended Action:</strong> Update MS Project 2000 SR-1.<br/>
<strong>My Severity Rating:</strong> Important for Project Software</p>

<p>This update addresses a vulnerability in Microsoft Project which can cause remote code execution when a specially crafted Project file is opened.&#160; Microsoft Project 2000 SR-1, Project 2002 SP1 and Project 2003 SP3 are affected.</p>

<hr />

<p><strong>Bulletin:</strong> MS09-074<br/>
<strong>Recommended Action:</strong> Update Internet Explorer<br/>
<strong>My Severity Rating</strong> Critical</p>

<p>This update addresses five difference vulnerabilities with at least one or more affected every version of Internet Explorer. Attackers can host malicious code which can lead remote code execution on vulnerable systems. Any issues that lead to remote execution in IE should be addressed immediately; even if you are confident about not browsing malicious sites, a known site, <a href="http://praetorianprefect.com/archives/2009/12/pentagon-web-pwned/">such as the Pentagon web site</a>, could be used to automatically execute or redirect you to malicious code using cross-site scripting.</p>

<hr />

<p><strong>Bulletin:</strong> MS09-069<br/>
<strong>Recommended Action:</strong> Update Windows 2000, Windows XP and Windows 2003<br/>
<strong>My Severity Rating:</strong> Low</p>

<p>A vulnerability in LSASS can cause a denial of service. The attacker must be authenticated and communicating through IPSEC.</p>

<hr />

<p><strong>Bulletin:</strong> MS09-070<br/>
<strong>Recommended Action:</strong> Update Windows 2003 and Windows 2008 Servers<br/>
<strong>My Severity Rating:</strong> Low</p>

<p>This update addresses two vulnerabilities in Active Directory Federation Services, one which can be used to spoof an authenticated user and the second which can cause remote code execution. The spoofing requires access to a workstation and browser recently used by a targeted user and the remote code execution requires the attacker to have valid logon credentials to the vulnerable server.</p>

<hr />

<p><strong>Bulletin:</strong> MS09-069     <br/>
<strong>Recommended Action:</strong> Update Windows XP SP3 and/or Office 2003 SP3<br/>
<strong>My Severity Rating:</strong> Moderate</p>

<p>A vulnerability in text converters in WordPad and Office can cause remote code execution. Malicious code can be hosted on a website to trigger an exploit, however, an attempt would cause a dialog box to appear prompting the user to open the file (unless the option to “Always ask before opening this type of file” has been unchecked).</p>

<hr />

<h3>Adobe</h3>

<p><a href="http://praetorianprefect.com/wp-content/uploads/2009/12/adobelq.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="adobe-lq" border="0" alt="adobe-lq" src="http://praetorianprefect.com/wp-content/uploads/2009/12/adobelq_thumb.png" width="47" height="76" /></a></p>

<p>Adobe has mirrored the patch Tuesday schedule of releasing patches on the first Tuesday of the month. The severity ratings also follow the same definitions a s Microsoft’s.</p>

<p>Adobe has two advisories for this month:</p>

<hr />

<p><strong>Bulletin:</strong> APSA09-06     <br />
<strong>Recommended Action:</strong> Update Adobe Illustrator CS4 and earlier. (Avail Jan 8)     <br />
<strong>My Severity Rating:</strong> Low</p>

<p>A vulnerability in Illustrator CS4 and earlier could lead to remote code execution. The target is required to open a malicious eps file.</p>

<hr />

<p><strong>Bulletin:</strong> APSA09-17     <br />
<strong>Recommended Action:</strong> Update Adobe Flash Player and Adobe AIR<br/>
<strong>My Severity Rating:</strong> Low</p>

<p>Adobe states this is a critical update and it is scheduled for release today, but does not provide details of the update.</p>

<h3>Updates</h3>

<p>Adobe has released details on the Flash Player update. The update addresses six vulnerabilities, five which can lead to remote execution and one to information disclosure. The vulnerabilities were identified in Flash Player version 10.0.32.18 and earlier.</p>

<h3>References</h3>

<ul>
<li><a href="http://www.microsoft.com/technet/security/Bulletin/MS09-dec.mspx">Microsoft&#8217;s December Bulletins</a></li>
<li><a href="http://www.adobe.com/support/security/">Adobe&#8217;s Security Advisories</a></li>
</ul>

<p><strong>Related Posts:</strong></p>
<ul>
<li><a href="http://praetorianprefect.com/archives/2010/07/turning-an-atm-into-a-slot-machine/">Turning an ATM into a Slot Machine</a></li>
<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>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/12/six-bulletins-in-last-patch-tuesday-of-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OSSEC: Agentless&#8230;It&#8217;s good, but not good enough</title>
		<link>http://praetorianprefect.com/archives/2009/11/ossec-agentless-its-good-but-not-good-enough/</link>
		<comments>http://praetorianprefect.com/archives/2009/11/ossec-agentless-its-good-but-not-good-enough/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 00:22:49 +0000</pubDate>
		<dc:creator>Jeremy Rossi</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[agentless]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openbsd]]></category>
		<category><![CDATA[ossec]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=1475</guid>
		<description><![CDATA[In working with OSSEC agentless for some time now I have come across some limitations in the implementation that I felt needed to be addressed.  As OSSEC agentless is designed to preform <code>syscheck</code> functions on remote hosts, more general features are hard (if not impossible) to write into a script. This post will demonstrate an alternative for adding additional features to the OSSEC standard build.]]></description>
			<content:encoded><![CDATA[<div class="wp-caption" style="float: right;margin: 5px;margin-left: 42px;margin-right: 21px;"><img src="http://praetorianprefect.com/wp-content/uploads/2009/11/Screen-shot-2009-11-02-at-8.06.14-PM.png" border="1" alt="ossec_logo" width="66" height="64" /></div>

<p>In working with OSSEC agentless for some time now I have come across some limitations in the implementation that I felt needed to be addressed.  As OSSEC agentless is designed to preform <code>syscheck</code> functions on remote hosts, more general features are hard (if not impossible) to write into a script.</p>

<p>Currently in OSSEC, agentless scripts are limited to the following commands:</p>

<table>
<thead>
<tr>
  <th>Command</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><code>INFO:</code></td>
  <td>The string following INFO will be logged to <code>/var/ossec/logs/ossec.log</code> by OSSEC for debugging.</td>
</tr>
<tr>
  <td><code>ERROR:</code></td>
  <td>Error needs to be reported.  The string following this command is forwarded to the OSSEC manager, and the OSSEC process closes down the script.</td>
</tr>
<tr>
  <td><code>STORE:</code></td>
  <td>All the lines that follow this command will be added, stored, and compared to previous runs of the script.</td>
</tr>
<tr>
  <td><code>FWD:</code></td>
  <td>The string following FWD is a colon delimited list of stats on a given file.  Example: <code>FWD: &lt;size&gt;:&lt;permissions&gt;:&lt;uid&gt;:&lt;gid&gt;:&lt;md5&gt;:&lt;sha1&gt; &lt;path &amp; file&gt;</code></td>
</tr>
</tbody>
</table>

<p>Given the choices listed here more advanced agentless scripts are just not reasonably possible.  I require the ability to pass more information to the OSSEC agentless process and have it raise alerts based on this information.</p>

<h3>Solution patch OSSEC</h3>

<p>So I starting digging into the OSSEC code.  I am not a C coder, I don&#8217;t even play one on TV, but the OSSEC&#8217;s code is clear and has just enough comments to allow me to understand how things function.  Once I saw where the communication happens between ossec-agentless and it&#8217;s subprocess I was quickly able to add a new OSSEC Agentless Command.</p>

<table>
<thead>
<tr>
  <th>Command</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><code>LOG:</code></td>
  <td>The string following LOG: will be passed into <code>ossec-analysisd</code> and processed like all other log messages.</td>
</tr>
</tbody>
</table>

<p>This simple command allow scripts to generate messages that will get processed by the standard OSSEC decoders and rules.</p>

<ul>
<li>Direct download of patch: <a href="http://praetorianprefect.com/wp-content/uploads/2009/11/agentless.patch.txt" title="agentless.patch.txt">agentless.patch.txt</a></li>
</ul>

<h3>Patching OSSEC</h3>

<p>The patch I created works with the current code release of OSSEC.  To apply the patch, first download OSSEC version 2.2 from the website.  In the instructions below, I have changed to the tmp directory first as we will be removing the source files once we have finished the install.</p>

<pre><code>obsd46# cd /tmp 
obsd46# ftp http://www.ossec.net/files/ossec-hids-2.2.tar.gz
Trying 75.126.165.213...
Requesting http://www.ossec.net/files/ossec-hids-2.2.tar.gz
100% |******************************************************************|   692 KB    00:03    
Successfully retrieved file.
</code></pre>

<p>Now expand the downloaded archive and change into the newly created directory <code>ossec-hids-2.2</code>.</p>

<pre><code>obsd46# tar xfz ossec-hids-2.2.tar.gz                                                                                                                                                   
obsd46# cd ossec-hids-2.2       
</code></pre>

<p>This is where most of the work will happen, but first we need to download the patch.</p>

<pre><code>obsd46# ftp http://praetorianprefect.com/wp-content/uploads/2009/11/agentless.patch.txt                             
Trying 75.101.150.229...
Requesting http://praetorianprefect.com/wp-content/uploads/2009/11/agentless.patch.txt
100% |******************************************************************| 10278       00:00    
Successfully retrieved file.
</code></pre>

<p>Now we just apply the patch.  We will use the <code>patch</code> command do this, but using the argument <code>-p1</code> to apply the patch cleanly to all sub-directories.</p>

<pre><code>obsd46# patch -p1 &lt; agentless.patch.txt  
Hmm... this looks like a unified diff to me...
The text leading up to this was:
 |-------------------------
 |diff -r 55072a52aaa4 -r 673c04be67e9 etc/decoder.xml
 |--- a/etc/decoder.xml  Wed Nov 04 20:51:36 2009 -0500
 |+++ b/etc/decoder.xml  Fri Nov 06 19:53:36 2009 +0000
 |-------------------------
Patching file etc/decoder.xml using Plan A...
Hunk #1 succeeded at 70.
Hunk #2 succeeded at 1498.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
 |-------------------------
 |diff -r 55072a52aaa4 -r 673c04be67e9 etc/rules/agentless_rules.xml
 |--- /dev/null  Thu Jan 01 00:00:00 1970 +0000
 |+++ b/etc/rules/agentless_rules.xml    Fri Nov 06 19:53:36 2009 +000 0
 |-------------------------
(Creating file etc/rules/agentless_rules.xml...)
Patching file etc/rules/agentless_rules.xml using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
 |-------------------------
 |diff -r 55072a52aaa4 -r 673c04be67e9 etc/rules/ossec_rules.xml
 |--- a/etc/rules/ossec_rules.xml        Wed Nov 04 20:51:36 2009 -0500
 |+++ b/etc/rules/ossec_rules.xml        Fri Nov 06 19:53:36 2009 +0000
 |-------------------------
Patching file etc/rules/ossec_rules.xml using Plan A...
Hunk #1 succeeded at 153.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
 |-------------------------
 |diff -r 55072a52aaa4 -r 673c04be67e9 etc/templates/config/rules.template
 |--- a/etc/templates/config/rules.template      Wed Nov 04 20:51:36 2009 -0500
 |+++ b/etc/templates/config/rules.template      Fri Nov 06 19:53:36 2009 +0000
 |-------------------------
Patching file etc/templates/config/rules.template using Plan A...
Hunk #1 succeeded at 44.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
 |-------------------------
 |diff -r 55072a52aaa4 -r 673c04be67e9 src/agentlessd/scripts/nmap_policy
 |--- /dev/null  Thu Jan 01 00:00:00 1970 +0000
 |+++ b/src/agentlessd/scripts/nmap_policy       Fri Nov 06 19:53:36 2009 +0000
 |-------------------------
(Creating file src/agentlessd/scripts/nmap_policy...)
Patching file src/agentlessd/scripts/nmap_policy using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
done 
</code></pre>

<p>Now we have a completed all the OSSEC 2.2 code patches for the expanded agentless features.  At this point you will need to compile and install OSSEC. For full details the main <a href="http://www.ossec.net/main/documentation/">OSSEC website</a> covers this topic in more detail.  A key thing to note here is that OSSEC has to be installed as a server or locally.</p>

<p>Please see my article on how to enable <a href="/archives/2009/11/ossec-agentless-to-save-the-day/">OSSEC agentless monitoring</a>.</p>

<h3>Making use of the new features</h3>

<p>Now that we have a patched and installed version of OSSEC we can take advantage of the newly added features.  Included with the patch is a new Agentless OSSEC script <code>nmap_policy</code>.  This script is really not designed for production use, rather it&#8217;s geared to show how to use the new agentless features.</p>

<p>Let&#8217;s get into the details. Start by running the new script and looking at the output.  I should note that this script uses <code>python</code> and needs at least version 2.5 in order to parse the xml output from <code>nmap</code>.</p>

<pre><code>obsd45# (cd /var/ossec &amp;&amp; ./agentless -b 21,23,80 -n 172.17.20.20/32 )
INFO: Starting
INFO: running `nmap -p 21,23,80 -oX - 172.17.20.0/24` command
INFO: completed `nmap -p 21,23,80 -oX - 172.17.20.0/24` command
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)
LOG:alert=11 Policy violation port 23 (telnet) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.19 (00:18:8B:1E:27:A5 Dell)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.20 (00:0C:29:84:72:11 VMware)
LOG:alert=11 Policy violation port 21 (ftp) is open on host 172.17.20.20 (00:0C:29:84:72:11 VMware)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.21 (00:0C:29:8D:39:E4 VMware)
LOG:alert=11 Policy violation port 21 (ftp) is open on host 172.17.20.21 (00:0C:29:8D:39:E4 VMware)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.31 (00:0C:29:29:CF:35 VMware)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.32 (00:0C:29:58:5F:C1 VMware)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.57 (00:1E:0B:9D:C0:03 Hewlett Packard)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.91 (00:14:38:D8:01:DD Hewlett Packard)
LOG:alert=11 Policy violation port 21 (ftp) is open on host 172.17.20.134 (00:1E:C2:03:2D:E8 Apple)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.202 (00:19:B9:24:7E:F2 Dell)
LOG:alert=11 Policy violation port 80 (http) is open on host 172.17.20.203 (00:19:B9:24:7E:F2 Dell)
INFO: Ending
</code></pre>

<p>So what this script does is run <code>nmap</code> and looks for ports that are open and not allowed per an internal policy.  In this example I checked for http, telnet, and ftp, but the selection of ports is configurable with the <code>-b</code>/<code>--badport</code> arguments.  The second argument <code>-n</code>/<code>--network</code> is used to specify which IP addresses to scan.  The format of this option is very liberal, in fact any valid <code>nmap</code> network specification will work.</p>

<p>Just as I specified above any string following the <code>LOG:</code> OSSEC agentless command will be pushed to the <code>ossec-analysisd</code> process for decoding and rules filtering.</p>

<p>As part of the patch I have also included an updated <code>decode.xml</code> and a new <code>agentless_rules.xml</code> to begin the first level of processing of output from the scripts.  Using <code>ossec-logtest</code> we can see this in action, but due to how <code>ossec-agentlessd</code> processes the messages we need to slightly modify the output for it to work with <code>ossec-logtest</code>.</p>

<pre><code>obsd46# (cd /var/ossec &amp;&amp; ./bin/ossec-logtest )                                                                                                                                                            
2009/11/06 20:48:28 ossec-testrule: INFO: Started (pid: 9789).
ossec-testrule: Type one log per line.

Agentless: Log:alert=11 Policy violation port 80 (http) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)


**Phase 1: Completed pre-decoding.
       full event: 'Agentless: Log:alert=11 Policy violation port 80 (http) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)'
       hostname: 'a'
       program_name: '(null)'
       log: 'Agentless: Log:alert=11 Policy violation port 80 (http) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)'

**Phase 2: Completed decoding.
       decoder: 'agentless'
       id: '11'
       extra_data: 'Policy violation port 80 (http) is open on host 172.17.20.1 (00:0E:83:A9:E6:80 Cisco Systems)'

**Phase 3: Completed filtering (rules).
       Rule id: '10011'
       Level: '11'
       Description: 'Agentless.'
**Alert to be generated.
</code></pre>

<p>You can see from the output that a level 11 alert would be generated for the line we just tested with <code>ossec-logtest</code>. In the case of the full output of the <code>nmap_policy</code> script it has 13 <code>LOG:</code> lines returned and would have generated 13 alerts. Needless to say this is a lot of alerts, so it&#8217;s up to you to tune and configure this correctly for your environment.</p>

<p>In our lab here at <a href="http://www.praetoriansecuritygroup.com">Praetorian</a> we don&#8217;t ever want to see the telnet port open.  So lets make this script live, but only checking for telnet.  I am going to once again make use of <a href="http://bitbucket.org/jrossi/ossec-hids-tools/">ossec-hids-tools</a> to add the new agentless monitoring.  As is always the case a restart of OSSEC will be needed.</p>

<pre><code>obsd46# ossec-config --section agentless --add --host jrossi@172.17.20.0 --type nmap_policy 
--frequency 86400 --state periodic --argv "-p 23 -n 172.17.20.0/24"
obsd46# (cd /var/ossec &amp;&amp; ./bin/ossec-control restart )
</code></pre>

<p>While adding this new agentless script I had to specify a <code>--host</code> argument. This is required for OSSEC agentless as the host field is <strong>NOT</strong> optional.  In the case of the script <code>nmap_policy</code> it will have no effect, but this needs to be taken into account when writing your own scripts as the first argument passed will always be what you specified as the host.</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/2010/01/the-aurora-ie-exploit-in-action/">The &#8220;Aurora&#8221; IE Exploit Used Against Google in Action</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/01/scareware-purveyors-spammers-and-crooks-take-advantage-of-haiti-earthquake/">Scareware Purveyors, Spammers, and Crooks Take Advantage of Haiti Earthquake</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/01/baidu-com-the-latest-victim-of-iranian-cyberarmy/">Baidu.com the Latest Victim of Iranian CyberArmy</a></li>
<li><a href="http://praetorianprefect.com/archives/2010/01/junos-juniper-flaw-exposes-core-routers-to-kernal-crash/">JUNOS (Juniper) Flaw Exposes Core Routers to Kernel Crash</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/11/ossec-agentless-its-good-but-not-good-enough/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSSEC: Agentless scripts</title>
		<link>http://praetorianprefect.com/archives/2009/11/ossec-agentless-scripts/</link>
		<comments>http://praetorianprefect.com/archives/2009/11/ossec-agentless-scripts/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 23:57:47 +0000</pubDate>
		<dc:creator>Jeremy Rossi</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[agentless]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openbsd]]></category>
		<category><![CDATA[ossec]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=1419</guid>
		<description><![CDATA[In my last OSSEC post "<a href="/archives/2009/11/ossec-agentless-to-save-the-day/">OSSEC: Agentless to save the day</a>" I went over how to setup agentless monitoring using the built in scripts.  With this post I am going to get into the details of how to modify the OSSEC supplied scripts to do your bidding.]]></description>
			<content:encoded><![CDATA[<p>In my last OSSEC post <a href="/archives/2009/11/ossec-agentless-to-save-the-day/">OSSEC: Agentless to save the day</a> I went over how to setup agentless monitoring using the built in scripts.  With this post I am going to get into the details of how to modify the OSSEC supplied scripts to do your bidding.</p>

<h2>Table of Contents</h2>

<div class="wp-caption" style="float: right;margin: 5px;margin-left: 42px;margin-right: 21px;"><img src="http://praetorianprefect.com/wp-content/uploads/2009/11/Screen-shot-2009-11-02-at-8.06.14-PM.png" border="1" alt="ossec_logo" width="66" height="64" /></div>

<ul>
<li><p><a href="#agentless_scripts">Agentless Scripts</a></p>

<ul>
<li><a href="#agentless_scripts_periodic_diff">Periodic diff Specification</a></li>
<li><a href="#agentless_scripts_periodic">Periodic Specification</a></li>
</ul></li>
<li><a href="#ssh_integrity_check_linux">Agentless Script: ssh_integrity_check_linux</a></li>
<li><p><a href="#ssh_dmz_linux">Our own Agentless Script: ssh_dmz_linux</a></p>

<ul>
<li><a href="#finding_setuid_setgid">Finding all setuid and setgid files</a></li>
<li><a href="#finding_app_files">Finding all authentication and applications specific files</a></li>
<li><a href="#merging_finds">Merging finds</a></li>
<li><a href="#creating_ssh_dmz_linux">Creating ssh_dmz_linux</a></li>
<li><a href="#testing_ssh_dmz_linux">Testing</a></li>
</ul></li>
</ul>

<h2 id="agentless_scripts">Agentless Scripts</h2>

<p>All scripts that work with OSSEC agentless security monitoring use <code>stdout</code> for communication and reporting to the OSSEC server.  This makes writing scripts for OSSEC simple as you do not need to do anything more then print or echo to <code>stdout</code>.  The format of the output does need to meet the OSSEC specification, but that is a very simple thing to do.</p>

<p>Before we move to the specification details I need to explain that OSSEC agentless runs to different types of scripts.  Namely the following:</p>

<table>
<thead>
<tr>
  <th>Type</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>periodic_diff</td>
  <td>Scripts output data to the OSSEC agentless process that will then be compared to past runs and if there are differences an OSSEC alert will be generated.</td>
</tr>
<tr>
  <td>periodic</td>
  <td>Scripts output controlled messages to the OSSEC agentless process that will then be processed accordingly.</td>
</tr>
</tbody>
</table>

<h4 id="agentless_scripts_periodic_diff">Periodic diff Specification</h4>

<p>The output for periodic_diff is very simple, any and all output after the agentless command &#8220;<code>STORE: now</code>&#8221; and before the next OSSEC Command will be stored and compared for differences.  This type of script is mostly used for hardware devices such as Cisco IOS, Juniper JunOS, and other products.</p>

<p>Scripts that use the <code>periodic_diff</code> make use of the following commands:</p>

<table>
<thead>
<tr>
  <th>Command</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>INFO:</td>
  <td>The string following INFO will be logged to <code>/var/ossec/logs/ossec.log</code> by OSSEC for debugging.</td>
</tr>
<tr>
  <td>ERROR:</td>
  <td>Error needs to be reported.  The string following this command is forwarded to the OSSEC manager, and the OSSEC process closes down the script.</td>
</tr>
<tr>
  <td>STORE:</td>
  <td>All the lines that follows this command will be added stored and compared to previous runs of the script</td>
</tr>
</tbody>
</table>

<p>Here is an example of a periodic_diff script that comes with OSSEC. (<em>Please note with all agentless scripts you must be in the root of the OSSEC install for them to function correctly</em>.)</p>

<pre><code>obsd46#( cd /var/ossec &amp;&amp; ./agentless/ssh_pixconfig_diff cisco@172.17.0.1 'show hardware' )
spawn ssh -c des cisco@172.17.0.1
No valid ciphers for protocol version 2 given, using defaults.
Password: 

a.zfw.tss&gt;INFO: Starting.
enable
Password: 
a.zfw.tss#ok on enable pass

STORE: now
no pager
             ^
% Invalid input detected at '^' marker.

a.zfw.tss#term len 0
a.zfw.tss#terminal pager 0
                     ^
% Invalid input detected at '^' marker.

a.zfw.tss#show version | grep -v Configuration last| up
                         ^
% Invalid input detected at '^' marker.

a.zfw.tss#show running-config
Building configuration...


Current configuration : 14631 bytes
!
version 12.4

[................SNIP CONFIG.................]

a.zfw.tss#show hardware
Cisco IOS Software, 3800 Software (C3845-ADVENTERPRISEK9-M), Version 12.4(24)T1, RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2009 by Cisco Systems, Inc.
Compiled Fri 19-Jun-09 19:21 by prod_rel_team

ROM: System Bootstrap, Version 12.3(11r)T2, RELEASE SOFTWARE (fc1)

a.zfw.tss uptime is 1 week, 5 days, 7 hours, 29 minutes
System returned to ROM by reload at 13:34:26 UTC Thu Oct 22 2009
System image file is "flash:c3845-adventerprisek9-mz.124-24.T1.bin"


This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:

http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco 3845 (revision 1.0) with 1007615K/40960K bytes of memory.
Processor board ID FTX1043A2CR
2 Gigabit Ethernet interfaces
1 ATM interface
1 Virtual Private Network (VPN) Module
4 CEM T1/E1 ports
DRAM configuration is 64 bits wide with parity enabled.
479K bytes of NVRAM.
492015K bytes of USB Flash usbflash0 (Read/Write)
62720K bytes of ATA System CompactFlash (Read/Write)

Configuration register is 0x2102


a.zfw.tss#exit
Connection to 172.17.0.1 closed by remote host.
Connection to 172.17.0.1 closed.

INFO: Finished.

</code></pre>

<p>In this example above the script would store the contents between &#8220;<code>STORE: now</code>&#8221; and &#8220;<code>INFO: Finished.</code>&#8220;.  If this is the first time that OSSEC agentless has run this command no alerts would be generated and the contents would have been saved for later comparisons.   If OSSEC agentless has a stored copy from a previous execution it will compare the files and if there are any differences it will generate an alert.</p>

<h4 id="agentless_scripts_periodic">Periodic Specification</h4>

<p>The periodic specification has more options and gives more control to the script writer on what actions OSSEC will take.  Once again <code>stdout</code> is used for communication so script writing is easy.</p>

<table>
<thead>
<tr>
  <th>Command</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td>INFO:</td>
  <td>The string following INFO will be logged to <code>/var/ossec/logs/ossec.log</code> by OSSEC for debugging.</td>
</tr>
<tr>
  <td>ERROR:</td>
  <td>Error needs to be reported.  The string following this command is forwarded to the OSSEC manager, and the OSSEC process closes down the script.</td>
</tr>
<tr>
  <td>FWD:</td>
  <td>The string following FWD is a colon delimited list of stats on a given file.</td>
</tr>
</tbody>
</table>

<p>Example of real <code>FWD:</code> command.</p>

<pre><code>FWD: 19419:600:0:0:fb30de5b02029950ae05885a3d407c8c:017cd6118cdc166ee8eba8af1b7fdad6763203d3 ./.bash_history
</code></pre>

<p>The Fields break down in to the following</p>

<table>
<thead>
<tr>
  <th>Field</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><code>FWD:</code></td>
  <td>The OSSEC Command</td>
</tr>
<tr>
  <td><code>19419</code></td>
  <td>Total size of file, in bytes</td>
</tr>
<tr>
  <td><code>600</code></td>
  <td>Access rights of file in octal</td>
</tr>
<tr>
  <td><code>0</code></td>
  <td>User ID of file owner</td>
</tr>
<tr>
  <td><code>0</code></td>
  <td>Group ID of file owner</td>
</tr>
<tr>
  <td><code>fb30de5b02029950ae05885a3d407c8c</code></td>
  <td>MD5 Hash of file</td>
</tr>
<tr>
  <td><code>017cd6118cdc166ee8eba8af1b7fdad6763203d3</code></td>
  <td>SHA1 Hash of file</td>
</tr>
<tr>
  <td>./.bash_history</td>
  <td>Path and name of file</td>
</tr>
</tbody>
</table>

<p>Using this format OSSEC can store the information about a file and then in the future run compare that they are the same.  If for some reason they are not the same an alert will be generated.  Here is an example of a password change on a linux system:</p>

<pre><code>OSSEC HIDS Notification.
2009 Sep 21 15:19:00

Received From: (ssh_integrity_check_linux) root@172.17.20.20-&gt;syscheck
Rule: 550 fired (level 7) -&gt; "Integrity checksum changed."
Portion of the log(s):

Integrity checksum changed for: '/etc/shadow'
Old md5sum was: '0d92e12c92f3edcf9d8876ea57c5f677'
New md5sum is : '2bd51b61dea17c5682fb2c0cf4f92c63'
Old sha1sum was: '2270c03a920ef8dd50e11cefdef046a8660f7a29'
New sha1sum is : 'd9518ea9022b10d07f81925c6d7f2abb4364b548'

--END OF NOTIFICATION
</code></pre>

<h2 id="ssh_integrity_check_linux">Agentless Script: ssh_integrity_check_linux</h2>

<p>Now that we have an understanding of how agentless scripts communicate with the parent OSSEC preocess, let&#8217;s move on to a working example.  The OSSEC supplied script <code>ssh_integrity_check_linux</code> is a great place to start, so lets open it up and see what is going on.</p>

<pre><code>obsd46# cat /var/ossec/agentless/ssh_integrity_check_linux
 #!/usr/bin/env expect

 # @(#) $Id: ssh_integrity_check_linux,v 1.11 2009/06/24 17:06:21 dcid Exp $
 # Agentless monitoring
 #
 # Copyright (C) 2009 Trend Micro Inc.
 # All rights reserved.
 #
 # This program is a free software; you can redistribute it
 # and/or modify it under the terms of the GNU General Public
 # License (version 3) as published by the FSF - Free Software
 # Foundation.


 # Main script.
source "agentless/main.exp"


 # SSHing to the box and passing the directories to check.
if [catch {
    spawn ssh $hostname
} loc_error] {
    send_user "ERROR: Opening connection: $loc_error.\n"
    exit 1;
}


source $sshsrc
source $susrc

set timeout 600
send "echo \"INFO: Starting.\"; for i in `find $args 2&gt;/dev/null`;do tail \$i &gt;/dev/null 2&gt;&amp;1 &amp;&amp; 
md5=`md5sum \$i | cut -d \" \" -f 1` &amp;&amp; sha1=`sha1sum \$i | cut -d \" \" -f
 1` &amp;&amp; echo FWD: `stat --printf \"%s:%a:%u:%g\" \$i`:\$md5:\$sha1 \$i; done; exit\r"
send "exit\r"

expect {
    timeout {
        send_user "ERROR: Timeout while running commands on host: $hostname .\n"
        exit 1;
    }
    eof {
        send_user "\nINFO: Finished.\n"
        exit 0;
    }
}

exit 0;
</code></pre>

<p>The comments in the script hints to what is going on, but everything up to and including <code>set timeout 600</code> is related to setting up the <code>expect</code> functions and code for handling the <code>ssh</code> subprocess and connecting to the remote host.  I am not going to spend any time with this section, I am just going to make use of it.</p>

<p>The meat of what is getting processed on the remote end all happens in two lines.</p>

<pre><code>send "echo \"INFO: Starting.\"; for i in `find $args 2&gt;/dev/null`;do tail \$i &gt;/dev/null 2&gt;&amp;1 &amp;&amp; 
md5=`md5sum \$i | cut -d \" \" -f 1` &amp;&amp; sha1=`sha1sum \$i | cut -d \" \" -f
 1` &amp;&amp; echo FWD: `stat --printf \"%s:%a:%u:%g\" \$i`:\$md5:\$sha1 \$i; done; exit\r"
send "exit\r"
</code></pre>

<p>Let&#8217;s break this down to see what is happening.</p>

<p>The <code>send</code> command pushes the following string to the ssh subprocess which gets run on the remote end of the connection.  Before the script is sent to the remote host <code>expect</code> internally processes the string.  This includes searching for variables and removing any control characters.</p>

<p>The control characters are first taken into account, and in the case of our example all escaped special characters are processed.  <code>\"</code>, <code>\r</code>, and <code>\$</code> would be replaced with <code>"</code>, &#8220;<code>carriage return</code>&#8220;, and <code>&amp;</code> respectively.  The reason the escape characters are needed so that they will not interfere with <code>expects</code> own string processing and control.  We will need to handle control characters in this way when we begin writing our own script.</p>

<p>While special characters were being handled by <code>expect</code> it also looked for variables to replace, in this case it will find <code>$args</code> and replace it with what ever arguments were passed to the script by the OSSEC agentless process.  If we specified the following in <code>/var/ossec/etc/ossec.conf</code> the <code>$args</code> variable would be replaced with &#8220;<code>/bin /etc /sbin</code>&#8220;.</p>

<pre><code>  &lt;agentless&gt;
    &lt;type&gt;ssh_integrity_check_linux&lt;/type&gt;
    &lt;frequency&gt;3600&lt;/frequency&gt;
    &lt;host&gt;root@172.17.20.20&lt;/host&gt;
    &lt;state&gt;periodic&lt;/state&gt;
    &lt;arguments&gt;/bin /etc /sbin&lt;/arguments&gt;
  &lt;/agentless&gt;
</code></pre>

<p>Back to the commands that get run.  Once <code>expect</code> has completed replacement we are left with this command.</p>

<pre><code>echo "INFO: Starting."; for i in `find /bin /etc /sbin 2&gt;/dev/null`;do tail $i &gt;/dev/null 2&gt;&amp;1 &amp;&amp; 
md5=`md5sum $i | cut -d " " -f 1` &amp;&amp; sha1=`sha1sum $i | cut -d " " -f
 1` &amp;&amp; echo FWD: `stat --printf "%s:%a:%u:%g" $i`:$md5:$sha1 $i; done; exit
exit
</code></pre>

<p>This script then goes and uses the Unix <code>find</code> command to locate all files in the specified path (from the arguments passed) and generates an OSSEC <code>FWD:</code> command for each one and prints it to <code>stdout</code>.  Making use of the commands <code>stat</code>, <code>md5sum</code>, and <code>sha1sum</code> to generate the data needed.  Here is an example of the output checking.</p>

<pre><code>spawn ssh root@172.17.20.20
Last login: Wed Nov  4 11:32:51 2009 from 172.17.20.131^M
[linux26 ~]# 
INFO: Started.
echo "INFO: Starting."; for i in `find {/bin /etc /sbin} 2&gt;/dev/null`;do tail $i &gt;/dev/null 2&gt;&amp;1 &amp;&amp; 
md5=`md5sum $i | cut -d " " -f 1` &amp;&amp; sha1=`sh a1sum $i | cut -d " " -f
 1` &amp;&amp; echo FWD: `stat --printf "%s:%a:%u:%g" $i`:$md5:$sha1 $i; done; exit
INFO: Starting.
FWD: 833:644:0:0:4148adea745af5121963f6b731b60013:60877a6f6981b16c0d53d32bcd3f07d41cfb5bd4 /etc/modprobe.d/
glib2.sh
[...........SNIP............]
FWD: 1696:644:0:0:c2bd306b205ad9e81fb02ce6b225d384:5244d65815cb228a4fac7bc4c1c7774508fb7505 /etc/nsswitch.conf
FWD: 85179:644:0:0:8db574225cd1068b47e77ceccd96f8ff:b5ef6183b35ee9d1b66ed2cefe98003c5bd99192 /etc/sensors.conf
FWD: 49:644:0:0:52c3df2f1edf30ca3db82174be3a68d2:1934648f2429b70b1f729d343a6956fb0ea73136 /etc/php.d/imap.ini
FWD: 873:644:0:0:04559d1fe27ecd079b69df8b319f937e:e5cab1bf1f9e4bc4386309f4e00a9b7be3e543a2 /etc/php.d/memcache.ini
FWD: 59:644:0:0:94636ba6c4bac9d8d49d9de1a513ae0c:41d5164a2c6e332e40edf55c59a2d0df8a260964 /etc/php.d/pdo_mysql.ini
FWD: 49:644:0:0:917dbbafbfaaa20f660063d627123dae:0e829d4ffc69f58dc258510b4b8452412e31ccc5 /etc/php.d/json.ini
FWD: 0:644:0:0:d41d8cd98f00b204e9800998ecf8427e:da39a3ee5e6b4b0d3255bfef95601890afd80709 /etc/wvdial.conf
logout
Connection to 172.17.20.20 closed.

INFO: Finished.
</code></pre>

<h2 id="ssh_dmz_linux">Our own Agentless Script: ssh_dmz_linux</h2>

<p>Using the built in OSSEC agentless scripts are great, but sometimes we need more focused scanning and checking.  So let&#8217;s modify the <code>ssh_integrity_check_linux</code> for our environment.</p>

<p>The goals for this new script will be to watch for changes to files based on the following criteria:</p>

<ul>
<li>All setuid and setgid files</li>
<li>All files related to authentication (including .htaccess and ssh files)</li>
<li>All application specific files (apache, ssh)</li>
</ul>

<h4 id="finding_setuid_setgid">Finding all setuid and setgid files</h4>

<p>Let&#8217;s first start by identifying a method to locate all files with their setuid or setgid bits enabled.  To do this we will ssh to the host <code>172.17.20.20</code> and use <code>find</code> to locate the files.</p>

<pre><code>obsd46# sudo -u ossec ssh root@172.17.20.20
[linux26 ~]# find / -type f \( -perm -4000 -o -perm -2000 \) 
/sbin/umount.nfs
/sbin/netreport
/sbin/unix_chkpwd
/sbin/mount.nfs
/sbin/pam_timestamp_check
/sbin/mount.nfs4
/sbin/umount.nfs4
/bin/ping6
/bin/su
/bin/umount
/bin/ping
/bin/mount
/lib/dbus-1/dbus-daemon-launch-helper
/usr/libexec/openssh/ssh-keysign
/usr/libexec/utempter/utempter
/usr/sbin/usernetctl
/usr/sbin/postqueue
/usr/sbin/userhelper
/usr/sbin/userisdnctl
/usr/sbin/postdrop
/usr/sbin/suexec
/usr/bin/chsh
/usr/bin/chfn
/usr/bin/sudo
/usr/bin/locate
/usr/bin/wall
/usr/bin/sudoedit
/usr/bin/gpasswd
/usr/bin/lockfile
/usr/bin/newgrp
/usr/bin/write
/usr/bin/screen
/usr/bin/passwd
/usr/bin/chage
/usr/bin/sperl5.8.8
/usr/bin/crontab
/usr/bin/ssh-agent
</code></pre>

<h4 id="finding_app_files">Finding all files related to authentication and applications specific files</h4>

<p>Finding all files with setuid and setgid was simple, but finding all files related to authentication is more invloved. This of course will vary from system to system, but this should be good starting point.</p>

<pre><code>obsd46# sudo -u ossec ssh root@172.17.20.20
[linux26 ~]# find / \( -name ".ssh" -o -name "ssh" -o -name "sshd" -o -name "httpd" -o -name ".htaccess" 
-o -name "pam.d" \) -exec find {} \;
/var/www/html/admin/modules/framework/var/www/html/admin/modules/.htaccess
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.d/proxy_ajp.conf
/etc/httpd/conf.d/README
/etc/httpd/conf.d/ssl.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
/etc/logrotate.d/httpd
/etc/pam.d
/etc/pam.d/authconfig
[...................SNIP PAM Files.....................]
/etc/pam.d/system-config-network-cmd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/httpd
/etc/rc.d/init.d/sshd
/etc/ssh
/etc/ssh/ssh_config
/etc/ssh/sshd_config
/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_dsa_key.pub
/etc/ssh/ssh_host_key
/etc/ssh/ssh_host_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_rsa_key.pub
/etc/sysconfig/httpd
/root/.ssh
/root/.ssh/authorized_keys
/usr/bin/ssh
/usr/lib/httpd
/usr/lib/httpd/modules
/usr/lib/httpd/modules/libphp5.so
[...................SNIP Apache modules................]

/usr/lib/httpd/modules/mod_vhost_alias.so
/usr/sbin/httpd
/usr/sbin/sshd
/usr/src/tbm-pbxconfig-5.5.1/amp_conf/htdocs/admin/modules/framework/htdocs/admin/modules/.htaccess
/usr/src/tbm-pbxconfig-5.5.1/amp_conf/htdocs/admin/modules/.htaccess
/var/empty/sshd
/var/empty/sshd/etc
/var/empty/sshd/etc/localtime
/var/www/html/admin/modules/framework/var/www/html/admin/modules/.htaccess
/var/www/html/admin/modules/.htaccess
</code></pre>

<h4 id="merging_finds">Merging finds</h4>

<p>Now we have two basic <code>find</code> methods that identify the files we want to monitor for changes, but our finds were a little greedy so we should create a way to strip out unwanted files from the list.  As this is a unix system <code>egrep</code> is the king for finding or removing items from a list.  To simplify things we can use <code>egrep</code> with the <code>-v</code> command line argument which tells <code>egrep</code> <strong>NOT</strong> to print any matching items.</p>

<p>Just to make sure that we do not end up double processing files we can make use of the <code>sort</code> command with <code>-u</code> argument to remove any duplicates.</p>

<p>Here is how we would put together both <code>find</code>s, <code>egrep</code>, and <code>sort</code> to locate and filter what is needed.</p>

<pre><code>(find / -type f \( -perm -4000 -o -perm -2000 \) &amp;&amp; \find / \( -name ".ssh" -o -name "ssh" -o -name "sshd" 
-o -name "httpd" -o -name ".htaccess" -o -name "pam.d" \) -exec find {} \; ) 2&gt;/dev/null | egrep 
-v "known_hosts|moduli|var\/log|var\/lock" | sort -u
</code></pre>

<p>The above command we have found all files and paths that we would like to monitor, but this still needs to be integrated into a script on the OSSEC server.</p>

<h2 id="creating_ssh_dmz_linux">Creating ssh_dmz_linux</h2>

<p>We don&#8217;t want to make changes to <code>ssh_integrity_check_linux</code> directly so we will need to make a copy.</p>

<pre><code>obsd46# (cd /var/ossec/agentless &amp;&amp; cp ssh_integrity_check_linux ssh_dmz_linux)
</code></pre>

<p>Integrating our new command line into the script we must pay close attention to special characters that <code>expect</code> will process.  Due to this we will need to escape all <code>/</code> and <code>"</code> by proceeding them with <code>\</code>.   Once we are done escaping we just insert our new line in place of <code>find $args 2&gt;/dev/null</code> in our new file.</p>

<p>Here is what the completed script will look like.</p>

<pre><code>obsd56# cat /var/ossec/agentless/ssh_dmz_linux
 #!/usr/bin/env expect

 # @(#) $Id: ssh_integrity_check_linux,v 1.11 2009/06/24 17:06:21 dcid Exp $
 # Agentless monitoring
 #
 # Copyright (C) 2009 Trend Micro Inc.
 # All rights reserved.
 # 
 # This program is a free software; you can redistribute it
 # and/or modify it under the terms of the GNU General Public
 # License (version 3) as published by the FSF - Free Software
 # Foundation.


 # Main script.
source "agentless/main.exp"


 # SSHing to the box and passing the directories to check.
if [catch {
    spawn ssh $hostname
} loc_error] {
    send_user "ERROR: Opening connection: $loc_error.\n"
    exit 1;
}


source $sshsrc
source $susrc

set timeout 600
send "echo \"INFO: Starting.\"; for i in `(find / \\( -name \".ssh\" -o -name \"ssh\" -o -name \"sshd\" 
-o -name \"httpd\" -o -name \".htaccess\" -o -name \"pam.d\" \\) -exec find {} \\; &amp;&amp; find / -type f 
\\( -perm -4000 -o -perm -2000 \\); ) 2&gt;/dev/null | egrep -v \"known_hosts|moduli|var\\/log|var\\/lock\" | sort -u`;
do tail \$i &gt;/dev/null 2&gt;&amp;1 &amp;&amp; md5=`md5sum \$i | cut -d \" \" -f 1` &amp;&amp; sha1=`sha1sum \$i | cut -d \" \" 
-f 1` &amp;&amp; echo FWD: `stat --printf \"%s:%a:%u:%g\" \$i`:\$md5:\$sha1 \$i; done; exit\r"
send "exit\r"

expect {
    timeout {
        send_user "ERROR: Timeout while running commands on host: $hostname .\n"
        exit 1;
    }
    eof {
        send_user "\nINFO: Finished.\n"
        exit 0;
    }
}

exit 0;
</code></pre>

<h4 id="testing_ssh_dmz_linux">Testing</h4>

<p>Before we add this new script to OSSEC configuration we need to test it.</p>

<pre><code>obsd46# (cd /var/ossec &amp;&amp; sudo -u ossec ./agentless/ssh_dmz_linux root@172.17.20.20 )

ERROR: ssh_integrity_check &lt;hostname&gt; &lt;arguments&gt;
</code></pre>

<p>Due to not making use of the of the <code>$arg</code> variable in the way that <code>ssh_integrity_check_linux</code> wants use too, this caused this the problem above.  Solving this problem would require making changes to files that will effect other built in scripts.  So a quick solution is to just pass anything as an argument to the script.  This will have no effect on our script as we do not make use of the <code>$arg</code> variable.</p>

<pre><code>obsd46# (cd /var/ossec &amp;&amp; sudo -u ossec ./agentless/ssh_dmz_linux root@172.17.20.20 NOTUSED)
spawn ssh root@172.17.20.20
Last login: Wed Nov  4 13:46:32 2009 from 172.17.20.131^M
[linux26 ~]#  
INFO: Started.
echo "INFO: Starting."; for i in `(find / \( -name ".ssh" -o -name "ssh" -o -name "sshd" -o -name "httpd" 
-o -name ".htaccess" -o -name "pam.d" \)  -exec find {} \; &amp;&amp; find / -type f \( -perm -4000 -o -perm -2000 
\); ) 2&gt;/dev/null | egrep -v "known_hosts|moduli|var\/log|var\/lock"`;do tail $i &gt;/dev/null 2&gt;&amp;1 &amp;&amp;
 md5=`md5s ^Mum $i | cut -d " " -f 1` &amp;&amp; sha1=`sha1sum $i | cut -d " " -f 1` &amp;&amp; echo FWD: `stat --printf 
"%s:%a:%u:%g" $i`:$md5:$sha1 $i; done; exit
INFO: Starting.
FWD: 14:775:100:101:3bc0a3e92f8170084dd102eda9a474b1:25a1783a3c6bdd9745ec245ec1bfa0414ee05d23 /var/www/html/admin/modules/.htaccessmodules/.htaccess
FWD: 3519:644:0:0:e4ca381035a34b7a852184cc0dd89baa:6e43d0b5a46ed5ba78da5c7e9dcf319b27d769e7 /var/empty/sshd/etc/localtime
FWD: 560:644:0:0:58370830ecfa056421ad21aff9c18905:d115bb5aeefaab97c53fbbd5df84ebcb9170d796 /etc/httpd/conf.d/php.conf
[...................SNIP.............................]
FWD: 392:644:0:0:e92bea7e9d70a9ecdc61edd7c0a2f59a:d77b61dac010c60589b4d8a2039e3b8a5bed18b2 /etc/httpd/conf.d/README
FWD: 70888:4711:0:0:9046bd13339e7ef22266067b633e601a:3fc41029ddb14fe4ed613f479fa9e89c944f04dd /usr/bin/sperl5.8.8
FWD: 315416:6755:0:0:4c63a9709fb7f0f97c30aa29d204859c:c379efa658de72866b8f6de5767906ff78d127b0 /usr/bin/crontab
FWD: 88964:2755:0:99:baf3ebef6377d6ef42858776c33621b0:62394bf57d18c3fd49adeb39a1da61661cabc3c8 /usr/bin/ssh-agent
logout
Connection to 172.17.20.20 closed.

INFO: Finished.

</code></pre>

<h4 id="going_live">Going live</h4>

<p>We have created a new OSSEC agentless script and I am going to enable this script using the <a href="http://bitbucket.org/jrossi/ossec-hids-tools/">ossec-hids-tools</a> that I introduced in my last post about ossec (<a href="/archives/2009/11/ossec-agentless-to-save-the-day/">OSSEC: Agentless to save the day</a>).   Also a restart of OSSEC will also be needed for the changes to take effect.</p>

<pre><code>obsd46# ossec-config --section agentless --add --host root@172.17.20.20 --type ssh_dmz_linux 
--state periodic --argv "NOTUSED"
obsd46# /var/ossec/bin/ossec-control restart                                                                                                        (root@jcli-1:/var/ossec)
Killing ossec-monitord .. 
Killing ossec-logcollector .. 
Killing ossec-remoted .. 
Killing ossec-syscheckd .. 
Killing ossec-analysisd .. 
Killing ossec-maild .. 
ossec-execd not running ..
Killing ossec-agentlessd .. 
OSSEC HIDS v2.2 Stopped
Starting OSSEC HIDS v2.2 (by Trend Micro Inc.)...
Started ossec-agentlessd...
Started ossec-maild...
Started ossec-execd...
Started ossec-analysisd...
Started ossec-logcollector...
Started ossec-remoted...
Started ossec-syscheckd...
Started ossec-monitord...
Completed.
</code></pre>

<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/11/ossec-agentless-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSSEC: Agentless to save the day</title>
		<link>http://praetorianprefect.com/archives/2009/11/ossec-agentless-to-save-the-day/</link>
		<comments>http://praetorianprefect.com/archives/2009/11/ossec-agentless-to-save-the-day/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 23:04:21 +0000</pubDate>
		<dc:creator>Jeremy Rossi</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[agentless]]></category>
		<category><![CDATA[hids]]></category>
		<category><![CDATA[lids]]></category>
		<category><![CDATA[ossec]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=1395</guid>
		<description><![CDATA[OSSEC is a Host Intrusion detection system (HIDS) in name, but in reality it is far more.  It's able to look for rootkits, monitor logs (LIDS), and even actively respond to defined events.  While all these features are great the unsung hero is agentless monitoring.]]></description>
			<content:encoded><![CDATA[<blockquote>
  <p>Lois, Clark Kent may seem like just a mild-mannered reporter, but listen, not only does he know how to treat his editor-in-chief with the proper respect, not only does he have a snappy, punchy prose style, but he is, in my forty years in this business, the fastest typist I&#8217;ve ever seen.</p>
  
  <p><code>Perry White</code></p>
</blockquote>

<p>Michael Starks from <a href="http://www.immutablesecurity.com/">Immutable Security</a> published the &#8220;Week of OSSEC&#8221; all last week (find their links at the end of article), and it was a great setup of posts.</p>

<p>With all the hard work done by Michael in his &#8220;Week of OSSEC&#8221;, I figured I should follow up with a few posts of my own about this great tool.  I am <strong>NOT</strong> going to do a week of posts, but will try to get as much information out as I can.</p>

<h3>OSSEC</h3>

<p><img src="http://praetorianprefect.com/wp-content/uploads/2009/11/Screen-shot-2009-11-02-at-8.06.14-PM.png" border="0" alt="Screen shot 2009-11-02 at 8.06.14 PM.png" width="66" height="64" /></p>

<p>OSSEC is a Host Intrusion Detection System (HIDS) in name, but in reality it is far more.  It&#8217;s able to look for rootkits, monitor logs (LIDS), and even actively respond to defined events.  While all these features are great, the unsung hero is agentless monitoring.</p>

<p>Agentless security monitoring is really a great feature that does not get explored often enough, so I am going to show how to get it up and running and then get it monitoring remote hosts.</p>

<h3 id="ossec-install">Installing OSSEC</h3>

<p>This is going to be one of the fastest OSSEC install instructions on the internet.  For full details the main <a href="http://www.ossec.net/main/documentation/">OSSEC website</a> which covers this topic with more detail.  Key things to note here is that I have installed it as a server.  I could have installed OSSEC locally and we would have still been able to do whatever was needed.</p>

<p>My install log for OSSEC 2.2 is <a title="install-ossec-v2.2.txt" href="http://praetorianprefect.com/wp-content/uploads/2009/10/install-ossec-v2.2.txt">here</a>.</p>

<h3 id="agentless-enable">Enabling agentless</h3>

<p>To make use of agentless security monitoring, it first needs to be enabled.  Full details also on the <a href="http://www.ossec.net/main/manual/manual-agentless-monitoring/">OSSEC webpage</a>.</p>

<h4>Agentless Requirements</h4>

<p>For most of the built-in agentless monitoring scripts, <code>expect</code> is needed to function.  In this example on OpenBSD 4.5, adding the <code>expect</code> package is simple with <code>pkg_add</code>.</p>

<pre><code>obsd46# pkg_add http://openbsd.mirror.frontiernet.net/pub/OpenBSD/4.5/packages/i386/expect-5.43.0p0-no_tk.tgz
tcl-8.4.19: complete
expect-5.43.0p0-no_tk: complete
--- tcl-8.4.19 -------------------
You may wish to add /usr/local/lib/tcl8.4/man to /etc/man.conf
</code></pre>

<h4>Turning on Agentless</h4>

<p>Now we need to enable agentless by running the following command:</p>

<pre><code>obsd46# /var/ossec/bin/ossec-control enable agentless
</code></pre>

<h4>Adding a host.</h4>

<p>We need to add a host to agentlessly monitor. If we were to authenticate using a password for host <code>172.17.20.20</code> we would use the following:</p>

<pre><code>obsd46# /var/ossec/agentless/register_host.sh add agentless@172.17.20.20
</code></pre>

<p>While using a password does work, the preferred method would be to use SSH keys to provide the access level needed.  To setup that method of access, you first need to create ssh keys for the user <code>ossec</code> which is the account the agentless scripts runs as.</p>

<pre><code>obsd46# sudo -u ossec ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/var/ossec/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/ossec/.ssh/id_rsa.
Your public key has been saved in /var/ossec/.ssh/id_rsa.pub.
The key fingerprint is:
b8:c3:47:9a:33:09:5c:eb:54:a0:82:39:a6:06:63:08 ossec@obsd45.ptnsecurity.com
The key's randomart image is:
+--[ RSA 2048]----+
|E     .          |
|oo   . .         |
|Bo. . . .        |
|=o o . +         |
|..  o + S        |
|.    = *         |
|      @ .        |
|       =         |
|                 |
+-----------------+
</code></pre>

<p>Now that the SSH keys are present, we can add the host without a password.  The special command line argument used with <code>register_host.sh</code> is <code>NOPASS</code> in all capitals, which will tell OSSEC supplied scripts to make use of SSH keys.</p>

<pre><code>obsd46# /var/ossec/agentless/register_host.sh add root@172.17.20.20 NOPASS
</code></pre>

<h4>Enabling SSH key on the host to be monitored.</h4>

<p>You will now need to securely get the contents of <code>/var/ossec/.ssh/id_rsa.pub</code> to 172.17.20.20.</p>

<p>Using SSH and the password for a single time will make this simple.  This will create the <code>/root/.ssh</code> if it is not already created, but might throw an error as it does if the directory is already present.  This is not a problem and can be ignored.</p>

<pre><code>obsd46# cat /var/ossec/.ssh/id_rsa.pub | ssh root@172.17.20.20 "( mkdir /root/.ssh/;  cat - &gt;&gt; /root/.ssh/authorized_keys )"
root@172.17.20.20's password:
mkdir: cannot create directory `/root/.ssh/': File exists
obsd46# ssh root@172.17.20.20 "cat  /root/.ssh/authorized_keys "
root@172.17.20.20's password:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzyTBo7CqkI0TISR9S+KPS/gYY60nkD7Qe8wTTXrAEFvPNFJ
NJJpVVKsij6zw86lvTZ6hx9ib1M+MXvt+70uF/z1hYwnYrczR2TR03Z5nwOUA9OK61nBWXVwCi9GsQs6Oeo
mY9vkBDoKzB52+TKKSk9ZoC+HYPiT5SaiHZvMOV7kWuwF67lnYwlG5FdkRdOiXp7DcRjje4/Hixg7RLLl7o
dEXpIakzGfalt3yQDmwvSUZhyg3OuoKimTeNiKU/jlHlmEPuDZpiQe6QhFH38EeEIZTdHsYITodl8sY+n9I
eNMalGIHPs+bph+qcK+6cOb1RGaeGqJBFjaqPUyismz0bw== ossec@obsd45.ptnsecurity.com
</code></pre>

<p>We can also verify that it worked with the following command.</p>

<pre><code>obsd46# sudo -u ossec ssh root@172.17.20.20
The authenticity of host '172.17.20.20 (172.17.20.20)' can't be established.
RSA key fingerprint is 14:cd:f2:e9:c3:5b:07:28:68:75:a7:b5:88:c2:6b:77.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.17.20.20' (RSA) to the list of known hosts.
Last login: Tue Oct  6 12:40:05 2009 from 172.17.20.154
[linux26.ptnsecurity.com ~]# exit
</code></pre>

<h4>Add the agentless host to ossec.conf</h4>

<p>While we have setup and prepared everything to allow agentless security monitoring of <code>172.17.20.20</code> we have not told ossec to make use of it.  To simplify adding agentless to the config, we are going to make use of the python library and tools I created <a href="http://bitbucket.org/jrossi/ossec-hids-tools/">ossec-hids-tools</a>.</p>

<p>First, let&#8217;s check to see what agentless hosts have been configured, and just like a good unix program, it should not output anything if nothing happens.</p>

<pre><code>obsd46# ossec-config --section agentless --show
</code></pre>

<p>Next, add our host to the configuration.  I am using the OSSEC supplied script <code>ssh_integrity_check_linux</code>.  This script will login to the remote host and send back to the OSSEC server via stdout an MD5 and SHA1 hash of every single file inside the paths specified in the arguments.  To demonstrate the output from the server, let&#8217;s test the script and review said output.</p>

<p>All testing of agentless scripts must be run from the directory <code>/var/ossec/</code> unless you compiled a different install location.</p>

<pre><code>obsd46# cd /var/ossec
obsd46# sudo -u ossec ./agentless/ssh_integrity_check_linux root@172.17.20.20 /etc
spawn ssh root@172.17.20.20
Last login: Mon Nov  2 17:53:23 2009 from 172.17.20.131
[tss-uvc-01v.ptn.local ~]#
INFO: Started.
t -d " " -f 1` &amp;&amp; echo FWD: `stat --printf "%s:%a:%u:%g" $i`:$md5:$sha1 $i; done; exit md5=`md5sum $i | cut -d " " -f 1` &amp;&amp; sha1=`sha1sum $i | cu
INFO: Starting.
FWD: 14612:644:0:0:509377d820692110c7a6cc83ef2c2da8:bf610c1fa14d84d8b3b44ec80b81788457f77420 /etc/sound/events/gtk-events-2.soundlist
FWD: 22291:644:0:0:d6139aa9554d4997ea25ec2d56095f51:26b9ae7784943eecaeb2dcd4b2ae3a32371d61c8 /etc/sound/events/gnome-2.soundlist
FWD: 83:644:0:0:9f87609f65b51761657c7d67881ae582:de82c03c535e9deb16aed94153883280891da2d7 /etc/modprobe.d/blacklist-firewire
^C^C#
</code></pre>

<p>I only let the script run for a few seconds to see the output, but the key things to notice are the lines beginning with &#8220;INFO&#8221; or &#8220;FWD&#8221;.</p>

<p>Anything that starts with &#8220;<code>INFO</code>&#8221; is logged to the <code>/var/ossec/logs/ossec.log</code> file for debugging and troubleshooting,  we will make use of this later on in this blog.  The &#8220;<code>FWD</code>&#8221; tag at the beginning of the line lets the OSSEC server store the HASH information.  Where this becomes useful is when a file&#8217;s contents change, the HASH will in turn change and OSSEC is able to notify you when this happens.</p>

<p>Now let&#8217;s complete adding our host to the OSSEC configuration.</p>

<pre><code>obsd46# ossec-config --section agentless --add --host root@172.17.20.20 --type ssh_integrity_check_linux \
--state periodic --argv "/bin /etc /sbin"
</code></pre>

<p>Let&#8217;s verify it&#8217;s what we expect.</p>

<pre><code><br /><h2>obsd46# ossec-config --section agentless --show</h2>

type: ssh_integrity_check_linux
frequency: 3600
host: root@172.17.20.20
state: periodic
arguments: /bin /etc /sbin
</code></pre>

<p>Time to restart the deamons for the changes to take effect.</p>

<pre><code>obsd46# /var/ossec/bin/ossec-control stop
Killing ossec-monitord ..
Killing ossec-logcollector ..
ossec-remoted not running ..
Killing ossec-syscheckd ..
Killing ossec-analysisd ..
Killing ossec-maild ..
ossec-execd not running ..
ossec-agentlessd not running ..
OSSEC HIDS v2.2 Stopped
obsd46# /var/ossec/bin/ossec-control start
Starting OSSEC HIDS v2.2 (by Trend Micro Inc.)...
Started ossec-agentlessd...
Started ossec-maild...
Started ossec-execd...
Started ossec-analysisd...
Started ossec-logcollector...
Started ossec-remoted...
Started ossec-syscheckd...
Started ossec-monitord...
Completed.
</code></pre>

<h3 id="agentless-test">Testing agentless</h3>

<p>Checking the log files, we can see what the agentless security monitor has done so far.</p>

<pre><code>obsd46# grep agentless logs/ossec.log
2009/09/21 14:59:49 ossec-agentlessd: INFO: Started (pid: 15320).
2009/09/21 14:59:51 ossec-agentlessd: INFO: Test passed for 'ssh_integrity_check_linux'.
2009/09/21 15:00:53 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Started.
2009/09/21 15:00:53 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Starting.
2009/09/21 15:01:34 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Finished.
</code></pre>

<p>Now we have one last thing to do to see that it&#8217;s working as expected, make a change to the file system on <code>172.17.20.20</code> that the ossec will notice on the next run.  I am going to change the root password for now.</p>

<pre><code>obsd46# ssh -i /var/ossec/.ssh/id_rsa root@172.17.20.20
Last login: Tue Oct  6 14:38:48 2009 from 172.17.20.154
[linux26.ptnsecurity.com ~]# passwd
Changing password for user root.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[linux26.ptnsecurity.com ~]# exit
</code></pre>

<p>Take a look at the logs for ossec-agentlessd to check the host. Again, we see that it completed another scan.</p>

<pre><code>obsd46# grep agentless logs/ossec.log
2009/09/21 15:18:27 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Started.
2009/09/21 15:18:27 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Starting.
2009/09/21 15:18:46 ossec-syscheckd: INFO: Finished creating syscheck database (pre-scan completed).
2009/09/21 15:19:06 ossec-agentlessd: INFO: ssh_integrity_check_linux: root@172.17.20.20: Finished.
</code></pre>

<p>Note that we also received the following email notifying that the password has changed, a message that is very useful to report.</p>

<pre><code>OSSEC HIDS Notification.
2009 Sep 21 15:19:00

Received From: (ssh_integrity_check_linux) root@172.17.20.20-&gt;syscheck
Rule: 550 fired (level 7) -&gt; "Integrity checksum changed."
Portion of the log(s):

Integrity checksum changed for: '/etc/shadow'
Old md5sum was: '0d92e12c92f3edcf9d8876ea57c5f677'
New md5sum is : '2bd51b61dea17c5682fb2c0cf4f92c63'
Old sha1sum was: '2270c03a920ef8dd50e11cefdef046a8660f7a29'
New sha1sum is : 'd9518ea9022b10d07f81925c6d7f2abb4364b548'

--END OF NOTIFICATION
</code></pre>

<hr />

<p>Week of OSSEC Links:</p>

<ul>
<li>Day 1: <a href="http://www.immutablesecurity.com/index.php/2009/10/25/week-of-ossec-day-1-detecting-world-writable-files/">Detecting World-Writable Files</a></li>
<li>Day 2: <a href="http://www.immutablesecurity.com/index.php/2009/10/26/week-of-ossec-day-2-detecting-new-files/">Detecting New Files</a></li>
<li>Day 3: <a href="http://www.immutablesecurity.com/index.php/2009/10/27/week-of-ossec-day-3-use-variables/">Using Variables</a></li>
<li>Day 4: <a href="http://www.immutablesecurity.com/index.php/2009/10/28/week-of-ossec-day-4-using-groups/">Using Groups</a></li>
<li>Day 5: <a href="http://www.immutablesecurity.com/index.php/2009/10/29/week-of-ossec-day-5-reusing-rule-ids/">Reusing Rule IDs</a></li>
<li>Day 6: <a href="http://www.immutablesecurity.com/index.php/2009/10/30/week-of-ossec-day-6-developing-a-tuning-strategy/">Developing a Tuning Strategy</a></li>
<li>Day 7: <a href="http://www.immutablesecurity.com/index.php/2009/10/31/week-of-ossec-day-7-developing-a-workflow/">Developing a Workflow</a></li>
</ul>

<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/11/ossec-agentless-to-save-the-day/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Where is your BES Policy?</title>
		<link>http://praetorianprefect.com/archives/2009/10/where-is-your-bes-policy/</link>
		<comments>http://praetorianprefect.com/archives/2009/10/where-is-your-bes-policy/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 16:23:52 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[data leak prevention]]></category>
		<category><![CDATA[BES]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=1139</guid>
		<description><![CDATA[Several months ago, users of a wireless carrier in the United Arab Emirates (UAE) were sent an SMS message to their Blackberry devices instructing them to install a software patch that would resolve recent network trouble they’ve been experiencing. The patch turned out to be spyware (Etisalat.A[MA]) and would intercept the user’s email, sending the [...]]]></description>
			<content:encoded><![CDATA[<p>Several months ago, users of a wireless carrier in the United Arab Emirates (UAE) were sent an SMS message to their Blackberry devices instructing them to install a software patch that would resolve recent network trouble they’ve been experiencing. The patch turned out to be spyware (<a href="http://threatcenter.smobilesystems.com/?p=1001" target="_blank">Etisalat.A[MA]</a>) and would intercept the user’s email, sending the messages to a listening agent inside the Etisalat network.</p>

<p>About one month ago, a problem in the Blackberry browser left devices open to attack due to a certificate notification flaw. An <a href="http://www.blackberry.com/btsc/viewContent.do?externalId=KB19552" target="_blank">advisory</a> from Research in Motion details how a malicious user could spoof a “trusted” website then use a phishing technique to send users to that site using SMS or email.</p>

<p>A malformed SMS message causing a memory corruption error could be used to cause a denial of service or execution of arbitrary code on Apple’s iPhone (<a href="http://support.apple.com/kb/HT3754" target="_blank">CVE-2009-2204</a>). Although not related to Blackberry, I wanted to get the point across that mobile devices are beginning to see their fair share of vulnerabilities which could lead to malicious activity.</p>

<p><img style="border-right-width: 0px; margin: 0px 20px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ScreenHunter_18 Oct. 26 10.36" border="0" alt="ScreenHunter_18 Oct. 26 10.36" align="left" src="http://praetorianprefect.com/wp-content/uploads/2009/10/ScreenHunter_18Oct.2610.36_thumb.gif" width="177" height="244" />Turning our focus back to the Blackberry, a director for Hermis Consulting in Jakarta, Indonesia recently wrote an application for the Blackberry which can turn the handheld into a remote bugging device.     <br />The software is called <a href="http://chirashi.zensay.com/2009/10/remote-listening-for-the-blackberry/" target="_blank">PhoneSnoop</a> and was written to demonstrate how an “attacker can activate the microphone of a Blackberry handheld and listen to sounds near or around it.” There are currently no stealth or spyware aspects of the software, but it shows how the capabilities of a Blackberry could be used for malicious purposes.</p>

<p>These issues remind me of my previous position, managing a global infrastructure team for a financial company.&#160; Exchange and Blackberry services were under our umbrella of responsibilities.&#160; When I first arrived many years ago, as with most companies that are victims of rapid growth, IT policies were non-existent.&#160; Though unpopular with the users, I had to have a BES policy implemented, and one that took quite a bit of control from the user. From password policies to WiFi disabling, where is your BES policy?</p>

<p>&#160;</p>

<p><img style="border-right-width: 0px; margin: 0px 20px 20px; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="blackberry-bold-att-single_tall" border="0" alt="blackberry-bold-att-single_tall" align="right" src="http://praetorianprefect.com/wp-content/uploads/2009/10/blackberryboldattsingle_tall.jpg" width="123" height="175" /></p>

<p><em>Note: A BES (Blackberry Enterprise Software) is middleware software which connects to your enterprise messaging solution (such as Microsoft Exchange or IBM Lotus Domino) and redirects email and PIM information to and from Blackberry mobile devices. </em></p>

<p><em>Note: A BES IT Policy is configured from the BES and are assigned to the Blackberry devices over the air.&#160; Policies can be assigned to users and user groups. The default installation does not enforce policies which should definitely be enabled and are best practices on any platform or device. See the bottom of this post for the KB with instructions on how to create and apply policies.</em></p>

<h4>At the bare minimum, you should have these basic policies set:</h4>

<ul>   <li>Password Required Rule – True </li>    <li>User Can Change Time – False </li>    <li>User Can Disable Password – False </li>    <li>Password Pattern Checks – Require at least 1 alpha and 1 numeric </li>    <li>Minimum Password Length – 7 characters </li>    <li>Maximum Password Age – 30 or 60 days </li>    <li>Set Password Timeout – 10 minutes </li>    <li>Set Maximum Password Attempts – 10 </li>    <li>Maximum Password History – 6 </li>    <li>Set Owner Info – Customize </li>    <li>Set Owner Name – Customize </li>    <li>Lock Owner Info – Customize </li>    <li>Remote Wipe Reset to Factory Defaults &#8211; True </li> </ul>

<h4>Control Upgrades:</h4>

<ul>   <li>Allow Non Enterprise Upgrade – False </li>    <li>Disallow Device User Requested Upgrade – True </li> </ul>

<h4>Camera Options:</h4>

<ul>   <li>Disable Photo Camera – True&#160; </li>    <li>Disable Video Camera – True </li> </ul>

<h4>Application Control:</h4>

<ul>   <li>Disable Application Center – True </li>    <li>Allow Application Down Services – False </li>    <li>Disallow Third Party Application Downloads – True </li> </ul>

<h4>Other Policies I Like:</h4>

<ul>   <li>Disable USB Mass Storage – True </li>    <li>Disable Blackberry Messenger – True </li>    <li>Disable Bluetooth – True </li>    <li>Allow Application Download Services – False </li>    <li>Allow Hotspot Browser – False </li>    <li>Allow IBS Browser – False </li> </ul>

<h4>Too Much?</h4>

<p>Now, these policies are starting to sound too strict at a glance; but, the purpose of the device is for users to have access to their email, contacts and calendars anywhere and to have a mobile phone they can be reached at any time.&#160; Cameras, Hotspots and transferring photos and music using USB mass storage are features that are not necessary. If you have legitimate business needs for these features, than you can enable them for certain user groups using a policy.</p>

<p>The policies mentioned are a very small fraction of what is available. I’d like to hear which policies you find useful in your environment, or which you find to be more harm than good.</p>

<p>For a complete list of policies, please see the <a href="http://docs.blackberry.com/eng/deliverables//3801/Policy_Reference_Guide.pdf" target="_blank">Policy Reference Guide</a>.</p>

<h4>&#160;</h4>

<h4>Howto</h4>

<p><b>     <br />Create, Assign, View, and Send IT policies</b>     <br /><b>Doc ID :</b> KB02022     <br /><b>Last Modified :</b> 2007-02-01     <br /><b>Document Type :</b> How To     <br /><b>Environment</b>     <br />This article applies to BlackBerry® Enterprise Server software versions 3.6, 4.0, and 4.1 for Microsoft® Exchange.     <br /><b>Procedure</b>     <br />The BlackBerry Enterprise Server uses an IT policy to control the behavior of the BlackBerry devices assigned to it. IT policies cover a wide range of BlackBerry device functions (for example, passwords, attachment viewing, and available browsers). Administrators can create custom IT policies in addition to the IT policies already present on the BlackBerry Enterprise Server.     <br /><b>Creating IT Policies</b>     <br />To create an IT policy, complete these steps:     <br />BlackBerry Enterprise Server software versions 3.6 and 4.0</p>

<ol>   <li>Depending on your version, open the BlackBerry Enterprise Server Management console or BlackBerry Manager. </li>    <li>Right-click the BlackBerry Enterprise Server name, then click <b>IT Policy</b>. </li>    <li>Click <b>New</b>, then create a name for the IT policy. </li>    <li>Select the check box beside each IT policy rules item you would like to assign. A description of the IT policy will appear. </li>    <li>To enable the selected IT policy, in the description window, click <b>TRUE</b>. </li>    <li>Click <b>Apply</b>, then click <b>OK</b>. </li> </ol>

<p>BlackBerry Enterprise Server software version 4.1</p>

<ol>   <li>In BlackBerry Manager, select <b>Servers</b>, then click the <b>Global</b> tab. </li>    <li>From the Tasks menu, click <b>Edit Properties</b>. </li>    <li>Select <b>IT Policy</b>, then double-click <b>IT Policies</b>. </li>    <li>Click <b>New</b>, then create a name for the IT policy. </li>    <li>Select an IT policy group to view the associated IT policy rules. </li>    <li>Select the appropriate IT policy rules. </li>    <li>Click <b>Apply</b>, then click <b>OK</b>. </li> </ol>

<p><b>Assigning IT Policies</b>     <br />To assign an IT policy to a BlackBerry device user, complete the following steps:     <br />BlackBerry Enterprise Server software versions 3.6 and 4.0</p>

<ol>   <li>Depending on your version, open the BlackBerry Enterprise Server Management console or BlackBerry Manager. </li>    <li>Right-click the BlackBerry Enterprise Server name, then click <b>IT Policy</b>. </li>    <li>Select an IT policy, then click <b>Edit User List</b>. </li>    <li>Click <b>Add Users to This Policy</b>. </li>    <li>Select a BlackBerry device user, then click <b>Add</b>. </li>    <li>Click <b>Close</b>, then click <b>OK</b> to close the Edit IT Policy Userlist window. </li>    <li>Click <b>OK</b> again. </li> </ol>

<p>BlackBerry Enterprise Server software version 4.1</p>

<ol>   <li>In BlackBerry Manager, select <b>Servers</b>, then click the <b>Global</b> tab. </li>    <li>From the Tasks menu, select <b>Edit Properties</b>. </li>    <li>Select <b>IT Policy</b>, then double click <b>IT Policy to User Mapping</b>. </li>    <li>Select a BlackBerry device user, then click the button next to the appropriate IT policy. </li>    <li>Click <b>OK</b> to close the IT policy to User Mapping window. </li>    <li>Click <b>Apply</b>, then click <b>OK</b>. </li> </ol>

<p><b>Viewing IT Policies</b>     <br />To view IT policies on the BlackBerry Enterprise Server, complete these steps:     <br />BlackBerry Enterprise Server software versions 3.6 and 4.0</p>

<ol>   <li>Depending on your version, open the BlackBerry Enterprise Server Management console or BlackBerry Manager </li>    <li>Right-click the BlackBerry Enterprise Server name, then click <b>IT Policy</b>. </li>    <li>Select an IT policy, then click <b>View</b> to see the BlackBerry device and Desktop Policy Settings that have been applied. </li>    <li>Click <b>OK</b> to close the View Policy window. </li>    <li>Click <b>OK</b> again. </li> </ol>

<p>BlackBerry Enterprise Server software version 4.1</p>

<ol>   <li>In BlackBerry Manager, click <b>Servers</b>, then click the <b>Global</b> tab. </li>    <li>From the Tasks menu, select <b>Edit Properties</b>. </li>    <li>Select <b>IT Policy</b>, then double-click <b>IT Policies</b>. </li>    <li>To view the IT policy rules, click <b>Properties</b>. </li>    <li>Click <b>OK</b>. </li> </ol>

<p>To view an IT policy on a BlackBerry device, complete these steps:</p>

<ol>   <li>From the Home screen, select <b>Options</b>. </li>    <li>Select <b>Security Options &gt; General Settings</b>. </li>    <li>The IT policy Name, Last Updated, and Time Stamp fields will be listed. </li> </ol>

<blockquote>   <p><b>Note:</b> Depending on the BlackBerry device and BlackBerry Device Software version, the instructions for viewing the IT policy on the BlackBerry device may vary. For example, on the BlackBerry 7100 series, the BlackBerry device user must select <b>Settings</b> or <b>Tools</b>, then select <b>Security</b>.</p> </blockquote>

<p><b>Sending IT Policies</b>     <br />To send an IT policy to a BlackBerry device user, complete the following steps:     <br /><b>Note:</b> By default, when you assign an IT policy to a BlackBerry device user, the IT policy is automatically sent to the BlackBerry device user.     <br /><b>Note:</b> When a change is made to an existing IT policy, it is automatically resent to all BlackBerry device users assigned to that IT policy.     <br />BlackBerry Enterprise Server software versions 3.6 and 4.0</p>

<ol>   <li>Depending on your version, open the BlackBerry Enterprise Server Management console or BlackBerry Manager </li>    <li>Select the BlackBerry Enterprise Server name, then right-click a BlackBerry device user name. </li>    <li>Click <b>Properties</b>. </li>    <li>On the IT Admin tab, click <b>Resend policy</b>. </li>    <li>Click <b>Apply</b>, then click <b>OK</b>. </li> </ol>

<p>BlackBerry Enterprise Server software version 4.1</p>

<ol>   <li>In BlackBerry Manager, select the BlackBerry Enterprise Server name. </li>    <li>Select a BlackBerry device user, then click the question mark ( <b>?</b> ) symbol beside <b>IT Admin</b>. </li>    <li>From the menu that appears, you can resend the IT policy or assign an IT policy to a BlackBerry device user. </li>    <li>Click <b>OK</b>. </li> </ol>

<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/10/where-is-your-bes-policy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Are Borderless Networks Possible?</title>
		<link>http://praetorianprefect.com/archives/2009/10/borderless-networks-yeah-but-wheres-my-border/</link>
		<comments>http://praetorianprefect.com/archives/2009/10/borderless-networks-yeah-but-wheres-my-border/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:27:33 +0000</pubDate>
		<dc:creator>Jeremy Rossi</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[borderless networks]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=980</guid>
		<description><![CDATA[I attended SC World Congress in New York this week and a keynote from Cisco caught my attention: Securing the Cloud: Building the Borderless Network.  I became fixated on the words used over and over by Joel McFarland. Borderless this, borderless that, borderless everything.  This campaign started to bother me as this was [...]]]></description>
			<content:encoded><![CDATA[<p>I attended <a href="http://www.scmagazineus.com/SC-World-Congress-2009/section/886/">SC World Congress</a> in New York this week and a keynote from Cisco caught my attention: <em>Securing the Cloud: Building the Borderless Network</em>.  I became fixated on the words used over and over by <a href="http://www.scmagazineus.com/Joel-McFarland-senior-manager-Product-Management-Security-Technology-Group-Cisco-Systems/article/149536/">Joel McFarland</a>. Borderless this, borderless that, borderless everything.  This campaign started to bother me as this was a security conference and a network company was pushing the idea of less borders.  It seemed off, wrong, and incomplete to me.</p>

<h2>Little Bit of History</h2>

<p>I am going to quickly cover some of the history of the Internet and how it grew borders, but please skip to the highlight of the article if you are familiar with this already: <a href="#borderless-what">Borderless Networks, What?</a></p>

<h5>ARPANET (&#8216;69-&#8217;91)</h5>

<p>In the beginning, there was <a href="http://en.wikipedia.org/wiki/ARPANET">ARPANET</a> which was the pioneer in packet switching networks and gave providers the choice of which method and hardware for communication it would use.  However, the base protocol used for devices to communicate in ARPANET was NCP.  The NCP  protocol could best be described as a network device driver and less as a network transport stack. It did not have any method for end-to-end error handling which was seen as a problem, but nothing was done about this until 1983.</p>

<p>In 1983, TCP/IP replaced NCP as the protocol for transport and ARPANET became a part of what was to become the Internet.  TCP/IP was a huge improvement over NCP in that it accounted for problems on the network and allowed the network not to come to a grinding halt when packets were lost.  It also achieved the concept of end-to-end connectivity between each host.  This meant that as long as two hosts were on the Internet they could reach each other by utilizing standard TCP/IP.  This standard framework also lead to the growth of many different applications as there was no longer any need to make changes to the network to add new applications/protocols.</p>

<h5>First Borders (&#8216;91-&#8217;94)</h5>

<p>All the building blocks were in place and  what formed was a large group of interconnected networks to share and exchange data. Then the first virus and worm hit in 1983 and 1988 respectively.  The <a href="http://en.wikipedia.org/wiki/Morris_worm">morris worm</a> gained a fair amount of media attention and in fact prompted the establishment of <a href="http://www.cert.org/">CERT</a>.  Even in this embryonic stage the vitality of the information being shared caused many researchers to begin placing limitations on the end-to-end connectivity of their hosts.  Thus began the <em>&#8216;Us&#8217;</em> and <em>&#8216;Them&#8217;</em> status of the Internet.</p>

<p><em>&#8216;Us&#8217;</em> and <em>&#8216;Them&#8217;</em> started out simple with a move to keep networks segregated-or put another way, adding a border between the networks.   At first, the borders were nothing more than routers that limited the effects from network <em>A</em> from spilling over into network <em>B</em>.  They were effective, but in 1991 <a href="http://en.wikipedia.org/wiki/Digital_Equipment_Corporation">DEC</a> released the first modern Firewall: SEAL.  This marked the first real security border on the Internet, where all packets were inspected and compared to a set of policy rules before being passed on.  These first security borders were instrumental in providing the trust and assurance in the network that companies and researchers required, speeding the growth of the Internet.  While intrusion was still possible, the bar of entry was raised beyond causal attacks and probes.</p>

<div class="wp-caption" style="float: right;margin: 5px;margin-left: 42px;margin-right: 21px;"><a title="Figure 1: Us vs. Them" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/us-them.png"><img src="http://praetorianprefect.com/wp-content/uploads/2009/10/us-them.png" border="1" alt="Us vs Them" width="300" height="233" /> </a>
<p class="wp-caption-text"><a title="Figure 1: Us vs. Them" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/04/man-example.png">Figure 1: Us vs. Them</a></p></div>

<p>In 1992, the dominant addressing of hosts was IPv4, where each host is a assigned a 32-bit address.  This assignment limited the total number of addressable hosts to 4,294,967,296, but, due to reservations and subnetting, this could never be fully utilized.  At this time, it was recognized that IPv4 limitations would be become a problem in the future, beginning the process of creating a new IP protocol with a much higher number of addressable hosts. IPv6 was born in 1994, based on a 128-bit address for each host.  This would effectively allow every man, woman, and child on Earth to be assigned an address many times over.  As a part of the formation of IPv6, security between networks was also taken into account and <a href="http://en.wikipedia.org/wiki/IPsec">IPSec</a> was created as a requirement of the IPv6 protocol.</p>

<p>IPv6&#8217;s creation gave the Internet a secure method of communications between networks via IPSEC and nearly unlimited address space, but IPv6 did not get off the ground quickly.  This was mostly due to the fact that all devices and operating systems would need to be upgraded to handle the new protocol, and there was little to no pressure from the market to push things forward.   IPSec on the other hand did take off, as it quickly became the standard method for interconnecting trusted networks over an untrusted medium (such as the Internet).</p>

<p>At the same time that IPv6 and IPSec were being developed, another group of people began working on an alternate method for dealing with the lack of addressable space in IPv4.  <a href="http://en.wikipedia.org/wiki/Network_address_translation">Network Address Translation (NAT)</a> was published in <a href="http://www.ietf.org/rfc/rfc1631.txt">RFC1631</a> in 1994 as a short term solution, while the larger problems were being addressed.  NAT became very successful quickly as it allows a very large number of hosts to access the larger Internet while using very few publicly addressable IP addresses.  As with most things, NAT came with some trade-offs.  One of the big ones was that hosts no longer had complete end-to-end connectivity.  Thus, another border on the network was created; in practice firewalls became the dominate NAT devices.  Nonetheless, the NAT border would create problems for applications developers for years to come.</p>

<h5>Present (&#8216;09)</h5>

<p>In 2009, the way Internet runs is really not very different from 1994;  IPv6 is just now getting underway, NAT is used everywhere, and IPSEC still secures networks over an untrusted medium. What has changed in a big way is the applications and uses of the Internet.  Telephone calls commonly use the Internet for transport, on demand video is a huge source of traffic, social media networks garner huge numbers of users, online shopping is an important revenue stream for companies, and most recently more and more services are being hosted elastically on demand via the Internet.</p>

<h2 id="borderless-what">Borderless Networks. What?</h2>

<p>Now let&#8217;s get back to Borderless Networks&#8230;</p>

<p>Cisco envisions a global network where you can go any place and access any data you could need at anytime.  John Chambers detailed the approach on a video at <a href="http://cisco.com">Cisco.com</a>:</p>

<div class="wp-caption" style="display: block;text-align: left;margin: 5px;margin-left: 10px;">
&#8220;In terms of what&#8217;s happening right now, I think the biggest market transition is the shift to a more collaborative world, which is only made possible by what we call an &#8220;intelligent, network-centric&#8221; world. This network-centric world encompasses the whole range of communication experiences and seamlessly delivers information. Consumers will access voice, the web, e-mail, and video by any of the 14 billion devices that we think will be connected to the internet by 2010, all loaded onto the network. In the very near future, for example, you won&#8217;t need to hang up your cell phone if you want to switch to a landline; you&#8217;ll stay connected as you change devices, as long as they&#8217;re all connected to a network.&#8221;
<p class="wp-caption-text"><a href="http://www.cisco.com/survey/exit.html?http://discussionleader.hbsp.com/hbreditors/2008/10/cisco_ceo_john_chambers_on_tea.html">Cisco CEO John Chambers talks about Cisco&#8217;s collaborative management model</a></P>
</div>

<p>Cisco also has a <a href="http://www.cisco.com/web/solutions/netsys/g2/index.html?POSITION=social+media&amp;COUNTRY_SITE=us&amp;CAMPAIGN=Transformers+Launch&amp;CREATIVE=Borderless+Networks+to+Index&amp;REFERRING_SITE=Twitter">Virtual event</a> on Oct 20th for Borderless Networks, and have been encouraging people to register via <a href="http://twitter.com/CiscoGeeks">twitter</a> and emails for the last two weeks.</p>

<div class="wp-caption" style="float: right;width: 450px;text-align: left;margin: 5px;margin-left: 20px;">

LUNCH &#8211; Securing the cloud: Building the borderless network
An exploration into the “cloud” revealing the power of choice in email security. Learn how to harness all the benefits that the cloud has to offer while avoiding common pitfalls for early SaaS solutions. The crumbling walls of network perimeters are forcing organizations to architect new network designs to address the evolution of borderless networks. <br />
<br />
Attend this session and learn:<br />
- Embracing the change to borderless networks<br />
- Understanding Cisco&#8217;s next-generation cloud security architecture<br />
- Realizing the power of choice in choosing an email security solution<br />
<br />
- Joel McFarland, senior manager in the product management team within the Security Technology Group at Cisco Systems<br />

<p class="wp-caption-text"><a href="http://www.scmagazineus.com/Agenda-Day-1-2009/section/888/">SC World Congress: Agenda Day 1</a></P>
</div>

<p>I first learned of the Borderless Networks push during the <a href="http://www.scmagazineus.com/SC-World-Congress-2009/section/886/">SC World Congress</a>.  I was there to get a preview of Borderless Networks as presented by Joel McFarland.  The session description sounded interesting and as it was a keynote there was nothing else to pull on my time.</p>

<p>Two co-workers and I attended the session, but being a little late we had to make our way to the very front of the room to find seats.  Up front we were able to hear and see everything in great detail, but in hindsight this might have not been the best place for us. There was no way Joel could have missed the looks of skepticism on all three of our faces.</p>

<p>Joel pushed the Cisco idea of Borderless Networks in many different ways, but pointed to the <a title="Figure 2: The iPhone" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/iphone_home.gif">iPhone</a> as the game changer, the beginning of things to come.  Then iPhone and salesforce.com became his prime example of how the mobile sales team are almost completely disconnected from the enterprise network.  They access leads, manage contacts, input orders, and exchange notes and information all without even logging into the corporate network.  At this point, I looked to my co-workers with a questioning expression and whispered the rhetorical question &#8220;<em>No corporate login?</em>&#8220;.</p>

<p>The example Joel used is common for a sales workforce, and is actively encouraged in many environments, but this was just something that I have always felt was wrong.  In many companies, sales leads are valuable information and something that competitors and even other sales people would actively try to gain access to.  When all access to this information is controlled by an external party you are no longer able to apply your own controls. In fact, you are beholden to the policies and procedures of the provider.  Joel was one step ahead of me on this.  He pointed out the problems that were playing through my head and countered that salesforce.com can be made to use a corporation&#8217;s internal authentication methods (Active Directory, RSA Token, etc.).  As such, your internal policies for access and removal of access are once again in your control.  I conceded. Joel is correct that salesforce.com can be brought into line with one&#8217;s internal security policy, but he does not address the issue of the remote device-the iPhone itself.</p>

<h4>Borderless</h4>

<p>Let me come back to the iPhone in a bit, I want to point out another slide that came up during this iPhone praise.  In <a title="Figure 2: Before &#038; After" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/iphone_home.gif">Figure 2</a> I have created a combined version of the two slides Joel was showing to demonstrate the future of networking (I have recreated them from memory, but its close enough for this post).</p>

<div class="wp-caption" style="float: right;margin: 5px;margin-left: 42px;margin-right: 21px;"><a title="Figure 2: Before &#038; After" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/before-after_borderless.png"><img src="http://praetorianprefect.com/wp-content/uploads/2009/10/before-after_borderless.png" border="1" alt="Us vs Them" width="500" height="400" /> </a>
<p class="wp-caption-text"><a title="Figure 2: Before &#038; After" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/iphone_home.gif">Figure 2: Before &#038; After</a></p></div>

<p>In Figure 2, we have the <strong>before</strong> and <strong>after</strong> sections.  According to Joel, currently the <strong>before</strong> example is a good summary of how most enterprises networks allow access into and between their networks.  This Joel and I agree on.</p>

<p>As seen in the <strong>before</strong> section, you have a defined entry point into the network from outside, where all external resources gain access.  This is your border between &#8220;<em>us</em>&#8221; and &#8220;<em>them</em>&#8220;.  In the examples, both the remote home desktop and iPhone access the network and are allowed across past the border only if proper authentication and authorization have take place.  Once completed, the remote device is granted access to the resources that are allowed for it to function as an effective job tool: access to to internet via internal proxy, access of files in the London office, or logging into the salesforce.com website.  The key thing is that all access flows through this single point of entry.</p>

<p>By restricting access for remote devices to a single point, we are able to overcome some technical shortcomings and greatly reduce the vectors of attack for the network.  NAT is required due to the limited number of publicly addressable addresses. Thus end-to-end connectivity is not an option for the remote devices.  The use of IPSec for transport and assigning a RFC1918 address to the remote device end of the IPSec tunnel allows one to overcome the NAT limitations.  This gives you remote device end-to-end connectivity within the enterprise network.  By using this method the network administrators are able to capture and monitor at a single point all access into and out of the network.  NAC, IPS/IDS, and other methods of monitoring are commonly deployed here.</p>

<p>With the <strong>after</strong> diagram of Figure 2, we see the future as Cisco/Joel see it.  This is where all resources are able to access all other resources; also known as complete end-to-end connectivity.  Joel did not say how this was to be achieved, but given the network diagram it&#8217;s not hard to surmise that Cisco is planning a big push for IPv6.  IPv6 will allow for this type of network, and will bring down the NAT boundary.  With it the technical limitation of too few addresses for end-to-end connectivity on the Internet is eliminated and things can get a lot more complex as we see in the <strong>after</strong> section of the diagram.</p>

<p>On the <strong>after</strong> diagram you see end-to-end connectivity to each resource both inside the network and outside.  We have an iPhone going directly to salesforce.com, directly accessing a file in the London office, and able to access all the data that it could ever need.  What about limiting access to resources? How do you make sure that a remote home desktop does not start copying all of the data from the London office, NYC office, and salesforce.com to a remote site?  What if the desktop is infected with malware?  How do you log the activity of the remote device access? All the questions become much harder when you have completed end-to-end connectivity, and historically we have learned it becomes an even larger problem when there are remote devices involved.</p>

<p>All the questions I have asked about the security of the <strong>after</strong> sections can be answered with products already on the market and in fact are recommended for use in both networks.  The problem becomes the scale that is needed to protect and defend a network that has complete end-to-end connectivity.  Once again, going back to the <strong>after</strong> diagram, only taking into account remote device access, the number of policies that needs to be maintained, protected, and monitored goes from 1 to 4.  Now a growth of 400% is big, but almost manageable. If you start to think about a small enterprise with 20 offices, 2 datacenters, and 200 remote users, the problem of scale is instantly untenable.</p>

<p>IPv6 will solve a lot of problems for networks as the need for NAT will go away and devices will be able to directly address each other across networks and boundaries, but as with just about everything there are side effects.  Keeping control of access into and out your network is the first line of defense and with IPv6 this becomes a policy and enforcement issue even if it is no longer a technical requirement.</p>

<h4>The iPhone, Key to the Borderless Network</h4>

<p>Joel said he likes his iPhone and from the huge number of videos from Cisco featuring an iPhone it&#8217;s safe to assume Cisco does too.  During the keynote Joel pointed out the iPhone a few times in a number examples and in general with heavy praise.  Joel and I agree the iPhone is an amazing device, an important step forward in mobile computing.  After this Joel and I begin to disagree, namely around one key point: &#8220;<em>The iPhone is a game changer.</em>&#8221;  I think that statement needs to add &#8220;<em>for the consumer market</em>&#8220;.</p>

<div class="wp-caption" style="float: left;margin: 5px;margin-left: 5px;margin-right: 21px;"><a title="Figure 3: The iPhone" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/us-them.png"><img src="http://praetorianprefect.com/wp-content/uploads/2009/10/iphone_home.gif" border="1" alt="Us vs Them" width="200" height="330" /> </a>
<p class="wp-caption-text"><a title="Figure 3: The iPhone" rel="lightbox" href="http://praetorianprefect.com/wp-content/uploads/2009/10/iphone_home.gif">Figure 3: The iPhone</a></p></div>

<p>iPhones are enabling users to use the Internet from almost anyplace; it&#8217;s one of the most popular cameras on <a href="http://www.flickr.com/cameras/">flickr</a>, has a huge list of applications, and, for some people, a complete replacement for the traditional computer.  While its strong points work well in the consumer market, in the enterprise markets it&#8217;s a very different beast.  In fact the strongest points for the iPhone in the consumer market are security concerns for the enterprise.  Application controls are limited, centralized control is even more limited, and encryption of the data residing on the devices is a <a href="http://www.wired.com/gadgetlab/2009/07/iphone-encryption/">problem</a> on the most fully featured phone to date.</p>

<p>Devices like the iPhone should be thought of less as a phone and more as a laptop. With that comes all the same protections and controls that we use to mitigate risk on an enterprise laptop. Here is a quick list of what I expect from a laptop and by extension from an iPhone for it to become a viable remote access device in the enterprise environment:</p>

<ul>
<li>Virus and Malware software with centralized reporting</li>
<li>Secure communications for the device; both internal resources and the ability to define policies</li>
<li>Strong Data Encryption on the device</li>
<li>Ability to do remote kill of device</li>
<li>Application installation and run controls</li>
<li>Web Filter/Proxy controls</li>
<li>Access controls, password complexity settings and password failure data destruction</li>
</ul>

<p>Some of the areas listed are available on the iPhone, but none of them are near complete and ready for everyday use in an enterprise.  <a href="http://www.rim.com/">Research In Motion</a> (RIM) dominates the enterprise market for the reasons I have listed here.  RIM via the BlackBerry Enterprise Server (BES) gives the enterprise complete control of every device that connects via a centralized management station.  BES also does network traffic correctly in that all devices came back to the BES at a single point of entry into the enterprise.  This allows an enterprise to place additional control directly attached to the BES and not with multiple devices all over the network.  RIM&#8217;s BES product represents the minimum level of security that should be expected for remote access of phone like devices. I would go so far as to say it should be the starting standard for how remote access devices should behave.</p>

<p>The iPhone might be the start of things to come, but in no way is it even close to ready for the enterprise market.</p>

<h2>Why?</h2>

<p>Cisco&#8217;s push with Borderless Networks is either something that they haven&#8217;t completely vetted from a security perspective or the security strategy isn&#8217;t completely explained in the marketing.  The huge increase in the number of points needing protection, the corresponding increase in the policy and management, and management data flow and access controls are areas that need addressing.  These are problems we still having troubles controlling with our current network deployments.  Unless Cisco has a magic bullet coming out of their research and development departments, I don&#8217;t see how this move to Borderless Networks is even possible.</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/the-aurora-ie-exploit-in-action/">The &#8220;Aurora&#8221; IE Exploit Used Against Google in Action</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/10/borderless-networks-yeah-but-wheres-my-border/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Server 2008 R2: Active Directory Functional Levels</title>
		<link>http://praetorianprefect.com/archives/2009/10/server-2008-r2-active-directory-functional-levels/</link>
		<comments>http://praetorianprefect.com/archives/2009/10/server-2008-r2-active-directory-functional-levels/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 09:12:14 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[federation services]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows 2008]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=758</guid>
		<description><![CDATA[Windows Server 2008 R2 was released in August, and it introduced new functional levels for Active Directory. This article takes a look back at the different functional levels of the past and what is new in the latest release of the server operating system for Active Directory (yes, a recycle bin for AD objects!).

Functional levels [...]]]></description>
			<content:encoded><![CDATA[<p>Windows Server 2008 R2 was released in August, and it introduced new functional levels for Active Directory. This article takes a look back at the different functional levels of the past and what is new in the latest release of the server operating system for Active Directory (yes, a recycle bin for AD objects!).</p>

<p>Functional levels were first introduced when Active Directory made its appearance in Windows 2000 Server. They allowed you to run different versions of domain controllers in your environment, and when all the domain controllers were brought up to a certain version of Windows, you could raise the functional levels to gain the added features of that operating system version. Now that Windows 2008 R2 is released, it is unlikely that you will mass deploy this new operating system to your entire forest or domain. Instead, you&#8217;ll deploy a single domain controller and kick the tires, so to speak. The time will eventually come when you&#8217;ve upgraded every domain controller to R2, and at that point you can raise the functional level to 2008 R2 to take advantage of the new features.</p>

<p>Functional levels can be raised in domains or, as of Windows 2003 Server, in the forest, providing different features in each. They are differentiated by labeling them Domain Functional Level and Forest Functional Level.</p>

<h3>What&#8217;s new in 2008 R2</h3>

<h4><u>Domain Functional Level</u></h4>

<p>There are two features added when raising the domain functional level to 2008 R2. They are Authentication Mechanism Assurance and Automatic SPN Management.</p>

<p><strong>Authentication mechanism assurance</strong> is meant for domains that utilize federation services (ADFS) or certificate-based authentication methods, such as smart card or token-based authentication. This mechanism adds information to the user&#8217;s kerberos token on the type of authentication used. This allows administrators to modify group membership based on how the user authenticates. For example, a user can have access to different resources if they log in with a certificate versus when they log in with just their username and password.</p>

<p><strong>Automatic SPN management</strong> provides a method for managing service accounts for applications such as Exchange, SQL and IIS. In the past, regular domain accounts were used for these purposes, adding management headaches in terms of password management and service principle names (SPNs). This new feature provides the following benefits:</p>

<ul>
<li>A class of domain accounts can be used to manage and maintain services on local computers.</li>
<li>Passwords for these accounts will be reset automatically.</li>
<li>Do not have to complete complex SPN management tasks to use managed service accounts.</li>
<li>Administrative tasks for managed service accounts can be delegated to non-administrators.</li>
</ul>

<h4><u>Forest Functional Level</u></h4>

<p>There is one new feature in raising the forest functional level to Server 2008 R2, and it is long overdue. It is the Active Directory recycle bin. In the days of old, when an IT administrator or help desk operator accidentally deleted an OU filled with user or computer objects (this has happened more times than you would think), there would be a scramble to perform a restore. The delete replicates to all domain controllers, so an authoritative restore in Active Directory restore mode from a good backup using NTDSutil would be in order. With 2008 R2 forest functional level, a powershell cmd-let will undo this instantly.</p>

<p>Note that this feature is not enabled automatically when raising forest functional level. Additionally, you must run the following command in the Active Directory Module for Powershell.</p>

<pre><code>Enable-ADOptionalFeature –Identity ‘CN=Recycle Bin Feature,CN=Optional Features,CN=Directory
Service,CN=Windows NT,CN=Services,CN=Configuration, DC=mydomain,DC=com’
–Scope ForestOrConfigurationSet –Target ‘mydomain.com’
</code></pre>

<h4>Functional levels of previous version</h4>

<p>The following are the previous functional levels and what features they added, as documented in <a href="http://technet.microsoft.com/en-us/library/cc771132(WS.10).aspx">Technet</a>.</p>

<hr />

<h3>Domain Functional Levels:</h3>

<h4>Windows 2000 Native:</h4>

<ul>
<li>Universal groups are enabled for both distribution groups and security groups.</li>
<li>Group nesting.</li>
<li>Group conversion is enabled, which makes conversion between security groups and distribution groups possible.</li>
<li>Security identifier (SID) history.</li>
</ul>

<h4>Windows Server 2003</h4>

<ul>
<li>The availability of the domain management tool, <code>Netdom.exe</code>, to prepare for domain controller rename.</li>
<li>Update of the logon time stamp. The <code>lastLogonTimestamp</code> attribute will be updated with the last logon time of the user or computer. This attribute is replicated within the domain.</li>
<li>The ability to set the <code>userPassword</code> attribute as the effective password on <code>inetOrgPerson</code> and user objects.</li>
<li>The ability to redirect Users and Computers containers. By default, two well-known containers are provided for housing computer and user/group accounts: namely, <code>cn=Computers</code>, and <code>cn=Users,</code>. This feature makes possible the definition of a new well-known location for these accounts.</li>
<li>Makes it possible for Authorization Manager to store its authorization policies in Active Directory Domain Services (AD DS).</li>
<li>Includes constrained delegation so that applications can take advantage of the secure delegation of user credentials by means of the Kerberos authentication protocol. Delegation can be configured to be allowed only to specific destination services.</li>
<li>Supports selective authentication, through which it is possible to specify the users and groups from a trusted forest who are allowed to authenticate to resource servers in a trusting forest.</li>
</ul>

<h4>Windows Server 2008</h4>

<ul>
<li>Distributed File System (DFS) Replication support for SYSVOL, which provides more robust and detailed replication of SYSVOL contents.</li>
<li>Advanced Encryption Services (AES 128 and 256) support for the Kerberos authentication protocol.</li>
<li>Last Interactive Logon Information, which displays the time of the last successful interactive logon for a user, from what workstation, and the number of failed logon attempts since the last logon.</li>
<li>Fine-grained password policies (FGPP), which make it possible for password and account lockout policies to be specified for users and global security groups in a domain.</li>
</ul>

<h3>Forest Functional Levels:</h3>

<h4>Windows 2000:</h4>

<p>There were no forest functional levels, just domain.</p>

<h4>Windows Server 2003:</h4>

<ul>
<li>Forest trust.</li>
<li>Domain rename.</li>
<li>Linked-value replication (changes in group membership store and replicate values for individual members instead of replicating the entire membership as a single unit). This change results in lower network bandwidth and processor usage during replication and eliminates the possibility of lost updates when different members are added or removed concurrently at different domain controllers.</li>
<li>The ability to deploy a read-only domain controller (RODC) that runs Windows Server 2008.</li>
<li>Improved Knowledge Consistency Checker (KCC) algorithms and scalability. The Intersite Topology Generator (ISTG) uses improved algorithms that scale to support forests with a greater number of sites than can be supported at the Windows 2000 forest functional level. The improved ISTG election algorithm is a less intrusive mechanism for choosing the ISTG at the Windows 2000 forest functional level.</li>
<li>An improved ISTG algorithm (better scaling of the algorithm that the ISTG uses to connect all sites in the forest).</li>
<li>The ability to create instances of the dynamic auxiliary class called dynamicObject in a domain directory partition.</li>
<li>The ability to convert an <code>inetOrgPerson</code> object instance into a User object instance, and the reverse.</li>
<li>The ability to create instances of the new group types, called application basic groups and Lightweight Directory Access Protocol (LDAP) query groups, to support role-based authorization.</li>
<li>Deactivation and redefinition of attributes and classes in the schema.</li>
</ul>

<h4>Windows Server 2008:</h4>

<p>No forest functional level changes occurred from Windows 2003 to Windows 2008.</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/disable-acrobat-reader-pdf-in-the-enterprise/">Using Group Policy to Disable JavaScript in Adobe PDF Files</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/10/server-2008-r2-active-directory-functional-levels/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>2008 Server to the Core</title>
		<link>http://praetorianprefect.com/archives/2009/09/2008-server-to-the-core/</link>
		<comments>http://praetorianprefect.com/archives/2009/09/2008-server-to-the-core/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 21:47:06 +0000</pubDate>
		<dc:creator>Simon Price</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows 2008]]></category>

		<guid isPermaLink="false">http://praetorianprefect.com/?p=398</guid>
		<description><![CDATA[One of my favorite websites in the days of Windows 2000 Server was a project from a group of system managers from the Department of Electrical Engineering at the Swiss Federal Institute of Technology; it was titled “Real Men Don&#8217;t Click”, and it was dedicated to accomplishing tasks solely using the command line interface (CLI). [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite websites in the days of Windows 2000 Server was a project from a group of system managers from the Department of Electrical Engineering at the Swiss Federal Institute of Technology; it was titled “Real Men Don&#8217;t Click”, and it was dedicated to accomplishing tasks solely using the command line interface (CLI). I was glad to see I wasn&#8217;t the only CLI fan in the Windows world who wasn&#8217;t inherently a former UNIX guy. Well, discounting the fact our friends at SFIT were inherently UNIX guys, they were very fair in their presentation of how to get around in the CLI.</p>

<p>This article is not just for the CLI fans like me, who snicker when forced to grab at the mouse for tasks they much prefer taking on in that wonderful black box with the blinking cursor; but for anyone who will deploy a core installation of Windows. This is not an anti-GUI rant, but a look into the CLI, and one that is much needed after Microsoft released Windows 2008 Server Core Edition.</p>

<p>Microsoft started to return CLI tools back to administrators in Windows 2000 when they released <code>netsh.exe</code>. More and more CLI options surfaced with releases of Support Tools, Resource Kits, and the popular PS suite from SysInternals (now Microsoft). The most recent evidence of the resurgence of the CLI is Windows 2008 Server Core Edition. This version is entirely driven with the command line interface.</p>

<p>The following roles are supported in a core installation:</p>

<ul>
    <li>Active Directory Certificate Services</li>
    <li>Active Directory Domain Services</li>
    <li>Active Directory Lightweight Directory Services (AD LDS)</li>
    <li>DHCP Server</li>
    <li>DNS Server</li>
    <li>File Services (including File Server Resource Manager)</li>
    <li>Hyper-V</li>
    <li>Print and Document Services</li>
    <li>Web Server (including a subset of ASP.NET)</li>
</ul>

<p>Why choose core over a standard installation? A core setup will only install the binaries needed by the server roles. Microsoft claims that if Windows 2000 Server had a core edition, it would have had a <strong>60% reduction</strong> in patches (40% in Windows 2003). This is a considerable amount of patches for critical servers such as domain controllers.</p>

<p>So let’s get started with some administration tasks in Windows 2008 Server Core Edition: getting things up and running, configuring roles, promoting to a domain controller, and essentially running a version of Microsoft&#8217;s OS that does not include explorer.exe. (What? No Desktop?)</p>

<p>The following commands were executed on an installation of Microsoft Windows 2008 Server Core Standard R2. For those who don&#8217;t have the time to muck with the CLI, R2 has included a new VBScript (<strong>sconfig.vbs</strong>) which provides a menu driven server configuration tool to quickly get through these steps. However, I recommend doing it the long way at least once to understand what&#8217;s happening in case you run into issues in the future. The install is straightforward, so details not needed. Most important is the option of which version of the OS to install, which I selected Windows 2008 R2 Standard (Server Core Installation). After a dialog to set the administrator password, I&#8217;m left with a DOS prompt.</p>

<p><strong><span style="text-decoration: underline;">GETTING STARTED</span></strong></p>

<p>First things first, IP connectivity. I&#8217;ll be using 192.168.1.0/24 for the network:</p>

<p><em><span style="font-size: xx-small;">Note: netsh.exe allows you to add all the options/parameters in one line, or you can run netsh.exe and go into each configuration category, (ie. interface), then eventually when deep enough into the options, execute the command, (ie. set). To keep it simple, I&#8217;ll write out the commands in single lines, but definitely run netsh.exe with no options and look into the many configuration areas available.</span></em></p>

<p>Let’s list available network interfaces to see which one we need to configure:</p>

<pre><code>netsh interface ipv4 show interfaces
</code></pre>

<p>Result:
<pre><code>
  Idx     Met        MTU           State                Name
  &ndash;--  ----------  ----------  ------------  ---------------------------
    3           5        1500  connected     Local Area Connection
    1          50  4294967295  connected     Loopback Pseudo-Interface 1
</code></pre>
Now, Local Area Connection is what I’m interested in, which Idx=3. Let&#8217;s set an IP to that interface:</p>

<pre><code>netsh int ipv4 set address name=3 source=static address=192.168.1.25 mask=255.255.255.0 gateway=192.168.1.1
</code></pre>

<p>Note the name=3 parameter; 3 was the IDX number retrieved in the previous step. You will not get a resulting output, but you can double check your settings by running <strong>ipconfig /all</strong>.</p>

<p>Next step is to add DNS servers for name resolution. If this will be the first Domain Controller in the Forest and will run DNS, you can skip this, otherwise, add your DNS servers now (the example assumes DNS servers 192.168.1.20 and 192.168.1.21):</p>

<pre><code>netsh interface ipv4 add dnsserver name=3 address=192.168.1.20 index=1
</code></pre>

<p>add a secondary dns server:</p>

<pre><code>netsh interface ipv4 add dnsserver name=3 address=192.168.1.21 index=2
</code></pre>

<p>Note that we used the name=3 parameter again to add these DNS entries to the network interface we are interested in. Once again, you can double check your settings with <strong>ipconfig /all</strong>.</p>

<p>Now we have connectivity. Let&#8217;s rename the computer and join a domain. Windows had assigned a random computer name, you can see what it is by typing <strong>hostname</strong>. Mine happened to be WIN-EPNB8G5FAUI. Let&#8217;s rename this to CORE-DEV:</p>

<pre><code>netdom renamecomputer %COMPUTERNAME% /NewName:CORE:DEV
</code></pre>

<p>You will be warned about the potential hazards of renaming the computer, not our concern since this is a brand new installation. Proceed, and you will have the following results:</p>

<pre><code>The computer needs to be restarted in order to complete the operation.

The command completed successfully.
</code></pre>

<p>Restart the computer by typing: <strong>shutdown /r /t 001</strong></p>

<p>After restarting, log back in, and let&#8217;s join a domain. Our test domain is called testdom.local. We will use an account called admin to join the domain:</p>

<pre><code>netdom join CORE-DEV /domain:testdom.local /userd:testdom\admin /passwordd:*
</code></pre>

<p align="left">The * for the password option will prompt you for the password. A reboot is again required.</p>

<p>Now you can log in with a domain account by choosing other user, then typing domain\user for the user.</p>

<p><strong><span style="text-decoration: underline;">ACTIVATION</span></strong></p>

<p>Now, let&#8217;s activate Windows. In R2, you enter the license key with slmgr.vbs (prior to R2, the installation setup prompted for the license key).</p>

<pre><code>slmgr.vbs –ipk ABCDE-FGHIJ-KLMNO-PQRST-UVWXY
</code></pre>

<p>Next, activate:</p>

<pre><code>slmgr.vbs -ato
</code></pre>

<p>If successful, you will not receive any messages back.</p>

<p><strong>
<span style="text-decoration: underline;">CONFIGURING AUTOMATIC UPDATES</span></strong></p>

<p>I recommend controlling the behavior of automatic updates with Group Policy, but if you need to toggle the settings, here are the commands:</p>

<p>To verify the current setting:</p>

<pre><code>cscript scregedit.wsf /AU /v
</code></pre>

<p>To enable automatic updates:</p>

<pre><code>cscript scregedit.wsf /AU 4
</code></pre>

<p>To disable automatic updates:</p>

<pre><code>cscript scregedit.wsf /AU 1
</code></pre>

<p>To check for updates:</p>

<pre><code>wuauclt /detectnow
</code></pre>

<p><strong><span style="text-decoration: underline;">
FIREWALL</span></strong></p>

<p>Let&#8217;s take a look at the firewall now, since we will want to open up some rules to perform remote administrations tasks, such as using Remote Desktop or MMC tools to manage the server.</p>

<p>We can take a look at the firewall profiles by typing:</p>

<pre><code>netsh advfirewall show allprofiles
</code></pre>

<p>If you have a domain profile applied via GPO, then those will apply. You can also look at all the rules by typing:</p>

<pre><code>netsh advfirewall firewall show rule name=all
</code></pre>

<p>That command will display quite a bit of information. I like to output it to a text file and view it with notepad.</p>

<p>Now, let&#8217;s make some changes to allow remote connections to the server. Here, I don&#8217;t exactly follow the steps documented in Technet or most web sources since the commands documented will open up the ports and allow any source address. Here, we open Remote Desktop (TCP-3389) only to our subnet.</p>

<pre><code>netsh advfirewall firewall set rule name="Remote Desktop (TCP-In)" new remoteip=192.168.1.0/24
</code></pre>

<p>This changes the firewall RDP rule to allow our subnet only. The default rule is Any. Now, let&#8217;s go ahead and enable this rule:</p>

<pre><code>netsh advfirewall firewall set rule name="Remote Desktop (TCP-In)" new enable=yes
</code></pre>

<p>The firewall is now open for RDP connections from our internal subnet, but we still have to enable Remote Desktop:</p>

<pre><code>cscript %windir%\system32\SCRegEdit.wsf /ar 0
</code></pre>

<p>Now you could Remote Desktop to the server. Of course you will only get a command prompt when you do.</p>

<p>Next, we’ll open up some rules to allow remote management using the MMC. This will allow using Computer Management, Shared Folders, Event Viewer, and other important snap-ins to manage your server. The process is the same as it was opening the Remote Desktop rule, but the rule names are different:</p>

<pre><code>netsh advfirewall firewall set rule name="Remote Administration (NP-In)" new remoteip=192.168.1.0/24
netsh advfirewall firewall set rule name="Remote Administration (NP-In)" new enable=yes
netsh advfirewall firewall set rule name="Remote Administration (RPC)" new remoteip=192.168.1.0/24
netsh advfirewall firewall set rule name="Remote Administration (RPC)" new enable=yes
netsh advfirewall firewall set rule name="Remote Administration (RPC-EPMAP)" new remoteip=192.168.1.0/24
netsh advfirewall firewall set rule name="Remote Administration (RPC-EPMAP)" new enable=yes
</code></pre>

<p>These three rules are in a group called “Remote Administration” and if you are not concerned about modifying the rules so that only the specific subnet is allowed, you can modify enable the group as-is which will allow connections from any IP:</p>

<pre><code>netsh advfirewall firewall set rule group="Remote Administration" new enable=yes
</code></pre>

<p><strong>
<span style="text-decoration: underline;">CONFIGURING ROLES</span></strong></p>

<p>There are two commands to use when dealing with server roles: <strong>oclist</strong> and <strong>ocsetup</strong>. Later, we will look at the new <strong>dism.exe</strong> If you type oclist, you will get a list of all the roles and their optional components. The list is pretty lengthy, so I like to use the <strong>find</strong> command to narrow my results. For example, if we wanted to add the DHCP server role, I would check for the precise name of the role by typing:</p>

<pre><code>oclist | find /i "dhcp"
</code></pre>

<p>Results:</p>

<pre><code>Not Installed: DHCPServerCore
</code></pre>

<p>Now I know the role name is specifically DHCPServerCore and that it is in fact not installed. So, we install the role by typing:</p>

<pre><code>ocsetup DHCPServerCore
</code></pre>

<p>Note that the above server role IS case sensitive. If I use oclist again to check for DHCP, I now see the following:</p>

<pre><code>oclist | find /i "dhcp"
</code></pre>

<p>Results:</p>

<pre><code>Installed: DHCPServerCore
</code></pre>

<p>If I wanted to remove the role, I&#8217;d use the uninstall switch with ocsetup:</p>

<pre><code>ocsetup DHCPServerCore /uninstall
</code></pre>

<p>Pretty straight forward. Now, with R2, there is a new CLI tool called <strong>dism.exe</strong>. This tool can also configure server roles, but it does much more. For now, we will use it to configure roles like we did with ocsetup/oclist.</p>

<p>To get a list of roles (called features in dism):</p>

<pre><code>dism /online /get-features
</code></pre>

<p>Let&#8217;s add that DHCPServerCore feature using dism:</p>

<pre><code>dism /online /enable-feature /featurename:DHCPServerCore
</code></pre>

<p>And then to remove it:</p>

<pre><code>dism /online /disable-feature /featurename:DHCPServerCore
</code></pre>

<p>So, what is the big deal? Same results as ocsetup, but, dism will replace it because it goes further than just toggling features. It will service WIM and VHD image files, allowing add/remove of drivers and features, especially useful if your server has the role of deploying images or runs Hyper-V.</p>

<p><strong><span style="text-decoration: underline;">PROMOTING TO A DC</span></strong></p>

<p><code>dcpromo</code> is still the way to handle promoting and demoting domain controllers, but in a Server Core installation, there is no GUI wizard that comes along with it. Instead, you use an answer file with the command to instruct how to promote your DC. The syntax to this is:</p>

<pre><code>dcpromo /unattend:c:\temp\answerfile.ini
</code></pre>

<p>I like to use ini for my answer file extension, but that&#8217;s a personal preference. Here are two examples of answer files to us with dcpromo:</p>

<p>To create the very first DC in a Forest:
<pre><code>[DCInstall]
ReplicaOrNewDomain=Domain
Installdns=Yes
confirmgc=yes
domainlevel=4
domainnetbiosname=TESTDOM
forestlevel=4
newdomain=forest
newdomaindnsname=testdom.local
safemodeadminpassword=password123
</code></pre>
Note that the forest level and domain level are set to 4. This option is for R2 only as it is the R2 functional level. For 2008 non-R2, this value needs to be 3 instead.</p>

<p>To add a replica domain controller in an existing domain:
<pre><code>[DCInstall]
ReplicaOrNewDomain=Replica
ReplicaDomainDNSName=testdom.int
Installdns=Yes
confirmgc=yes
safemodeadminpassword=password123
</code></pre>
There are quite a few configurable options to put in an answer file. You can check the help by typing: <strong>dcpromo /?:promotion</strong></p>

<p><strong><span style="text-decoration: underline;">MORE IN THE CLI</span></strong></p>

<p>Now you have a fully functioning server, are able to manage it with your MMC, and can connect via Remote Desktop. Although there are hundreds of commands you can use in the CLI, one that can do an enormous amount of tasks is <strong>wmic.exe</strong>. WMIC<strong> </strong>is a tool with hundreds of options for WMI. You can do just about anything here. A few examples:</p>

<pre><code>wmic useraccount list
wmic process list
wmic share list
</code></pre>

<p>The above examples are all very simple queries for information. You can also use wmic to add and modify (ie. not just list shares, but create or change them). To see a full list of options: <strong>wmic /?</strong></p>

<p><strong></p>

<p></strong></p>

<p><span style="text-decoration: underline;"><strong>POWERSHELL</strong></span></p>

<p>Powershell is now included with R2 and you can enable it just like any other feature. Powershell provides a shell and scripting language which will open up a world of options for administrating your Windows environment. What gives this shell its power is that it accepts and returns .NET objects. Instead of getting stdout, you can get an object and then perform actions with that object or get its properties. With a couple of lines of script code, you can pull all users from an OU and set their description field, or check when the passwords were last set. That is just one simple example working with objects using the DirectoryServices interface, and there are many others.</p>

<p><span style="text-decoration: underline;"><strong>CONCLUSION</strong></span></p>

<p>It is nice to see that the command line has made a return in the Windows world. If you’re unlike me, who typically has five or six command prompts open during a regular day, don’t be intimidated by it. Server Core can be a lean, secure, and well-managed option in your environment. It may take a little time getting used to not reaching for the mouse and clicking on the start button, but at the end of the day you will have that extra bit of satisfaction knowing exactly what occurred without a GUI keeping the details behind the scenes.</p>

<hr />

<p>References:</p>

<ul>
<li>Real Men Don&#8217;t Click&#8211;The Project: <a href="http://isg.ee.ethz.ch/tools/realmen/">http://isg.ee.ethz.ch/tools/realmen/</a></li>
<li>Server Core Installation: <a href="http://technet.microsoft.com/en-us/library/cc753802(WS.10).aspx">http://technet.microsoft.com/en-us/library/cc753802(WS.10).aspx</a></li>
<li>Using DISM: <a href="http://www.windowsnetworking.com/articles_tutorials/Deploying-Windows-7-Part2.html">http://www.windowsnetworking.com/articles_tutorials/Deploying-Windows-7-Part2.html</a></li>
<li>DISM Command Line Options: <a href="http://technet.microsoft.com/en-us/library/dd772580(WS.10).aspx">http://technet.microsoft.com/en-us/library/dd772580(WS.10).aspx</a></li>
<li>WMIC: <a href="http://technet.microsoft.com/en-us/library/bb742610.aspx">http://technet.microsoft.com/en-us/library/bb742610.aspx</a></li>
<li>Powershell: <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx</a></li>
<li>Windows 2008 Command Line List (A-Z): <a href=http://technet.microsoft.com/en-us/library/cc772390(WS.10).aspx>http://technet.microsoft.com/en-us/library/cc772390(WS.10).aspx</a>
</span></li>
</ul>

<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/the-aurora-ie-exploit-in-action/">The &#8220;Aurora&#8221; IE Exploit Used Against Google in Action</a></li>
</ul><br />
]]></content:encoded>
			<wfw:commentRss>http://praetorianprefect.com/archives/2009/09/2008-server-to-the-core/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
