Popular Tags:

A Hundred Domains and SHA-1 Depreciation

September 17, 2014 at 4:30 pm

Apparently I’ve been living under a rock for a while, because I didn’t know that SHA-1 was being phased out in the immediate future. Thank you, GoDaddy, for notifying me with a month and change to spare. As it turns out, Google will no longer be trusting certain SHA-1 signed SSL certificates with the release of Chrome 39, which is set for November. For details, see the following links.

Due to the fact that our clients often purchase their own SSL certificates, we have no internal records to check what algorithm was used to sign the certificates in use. So now we get to audit slightly over 100 domains to check and see what signature algorithm is in use. We could browse to each domain manually and take a look at their certificate but that would just take way too long. There were some web based tools around that could do it, but they also only worked on one site at a time.

So, instead, I looked to PowerShell to see what could be done… Unfortunately, there was no native cmdlet to do anything like this! I did find a module that had a lot of great PKI-related functionality, the Public Key Infrastructure PowerShell module, but it, too, didn’t have the much-needed signature algorithm. However, it did provide a very robust base on which to build. Below is the solution I came up with.

function get-SSLSigningAlgorithm {
[CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)]
        [string]$URL,
        [Parameter(Position = 1)]
        [ValidateRange(1,65535)]
        [int]$Port = 443,
        [Parameter(Position = 2)]
        [Net.WebProxy]$Proxy,
        [Parameter(Position = 3)]
        [int]$Timeout = 15000,
        [switch]$UseUserContext
    )
    $ConnectString = "https://$url`:$port"
    $WebRequest = [Net.WebRequest]::Create($ConnectString)
    $WebRequest.Proxy = $Proxy
    $WebRequest.Credentials = $null
    $WebRequest.Timeout = $Timeout
    $WebRequest.AllowAutoRedirect = $true
    [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
    try {$Response = $WebRequest.GetResponse()}
    catch {}
    if ($WebRequest.ServicePoint.Certificate -ne $null) {
        $Cert = [Security.Cryptography.X509Certificates.X509Certificate2]$WebRequest.ServicePoint.Certificate.Handle
	write-host $Cert.SignatureAlgorithm.FriendlyName;
    } else {
        Write-Error $Error[0]
    }
}

I’ll create a CSV of the domains that I need to check, and iterate over them in a for-each loop. That function will be used within the loop to check the sites, and the output will go into another CSV. We’ll use that to plan our re-keying.

Hide Disabled AD Accounts from the GAL using Powershell

September 8, 2014 at 10:48 am

Our account decommission process involves disabling a user and moving them to a “Disabled Domain Accounts” OU. Well, it turns out that our previous admin never actually hid these mailboxes from the Global Address List (GAL), so many of our offshore partners have still been sending emails to them. I decided to start cleaning this up a bit today with the following:

Search-ADAccount -SearchBase "ou=Disabled Domain Accounts,dc=example,dc=local" -AccountDisabled -UsersOnly |Set-ADUser  -Replace @{msExchHideFromAddressLists=$true}

Another simple bit of PowerShell. The first command searches within the disabled account OU, and looks for disabled user accounts only. That output is piped into the second command which replaces the Exchange attribute that hides that account from the GAL.

How to clear all Workstation DNS caches from PowerShell

September 4, 2014 at 2:32 pm

I recently found myself in need of the ability to clear the DNS cache of all the laptops in my company. I found a very powerful and simple way to do so and thought I would share.

$c = Get-ADComputer -Filter {operatingsystem -notlike "*server*" }
Invoke-Command -cn $c.name -SCRIPT { ipconfig /flushdns }

The first line queries Active Directory for all computers that are not servers. The second line simply invokes the normal windows command “ipconfig /flushdns” on all computers.

This technique could be used to run any command across all workstations. Very powerful, and dangerous. Use at your own risk!

Finding Expired User Accounts in AD and Resetting Their Passwords with PowerShell

June 2, 2014 at 4:01 pm

The Setup

I came into the office today and was bombarded with users not being able to access our TFS server. Now, before I get too far into this story, you have to understand: Technically I’m only responsible for client-facing infrastructure. However, over the years I’ve started wearing more of a devops hat because, apparently, I’m quite good at it. That means TFS is now largely my problem. Funny how that works, eh? Anyway, back to TFS.

There were a few odd things about this issue: the oddest being that some of our off-shore developers were having no problems and others just couldn’t get in. The users with issues also couldn’t access the web portal. We (at least me) hadn’t made any changes to TFS in about a month, so I started to investigate.

After a brief panic about SharePoint not being installed properly (Hey, I didn’t set up this system, I’m just its current keeper) I managed to trace the issue to network logons. Thank you Security log! Wait, what’s this? Turns out many, many users recently had their accounts marked as expired… Turns out we just implemented mandatory password rotation and guess what? Today – 90 days was the day that a large batch of offshore development accounts were created! So now I had to reset credentials on 35+ accounts, and I’ll be damned if I’m going to do that manually!

Enter PowerShell!

List all accounts in an OU that have expired passwords

Get-ADUser -searchbase "ou=contractors,dc=example,dc=com" -filter {Enabled -eq $True} -Prop PasswordExpired | Where {$_.PasswordExpired } |select-object -property SAMAccountName,Name,PasswordExpired |format-table

Get-ADUser

SearchBase tells the Get-ADUser command to limit the search to a specific OU. This is very handy since I only have admin access to the one OU anyway. I filtered only for enabled accounts since trying to filter on PasswordExpired here didn’t work for some reason. I also explicitly called out the PasswordExpired property.  This output was piped to the where-object commandlet.

Where-Object

This was where I filtered on the current object group. Since passwordExpired is a bool, no fanciness needed here. Then I piped the output to Select-Object.

Select-Object

I only cared about some specific data for the output. I used this to select the properties I needed. Finally, I piped to Format-Table to make everything display nicely.

Reset passwords for accounts in an OU with expired passwords

Get-ADUser -searchbase "ou=contractors,dc=example,dc=com" -filter {Enabled -eq $True} -Prop PasswordExpired | Where {$_.PasswordExpired } | ForEach-Object {Set-ADAccountPassword -Identity $_.SAMAccountName -NewPassword (ConvertTo-SecureString -AsPlainText "Changeme1" -Force) }

Get-ADUser & Where-Object

These are the same as in the section above. We are filtering for enabled accounts in the contractors OU. This was piped to one of my favorite commands on earth: ForEach-Object.

ForEach-Object

This is, hands down, one of the handiest commands in PowerShell. Or any language for that matter. In this particular instance, we are running the Set-ADAccountPassword option for each object that we pass in. We pass the object’s SAMAccountName as the identity. We then create a new secure string password and pass that to -NewPassword. Then you hit enter and the magic runs!

 

PermaEthos PDC

May 23, 2014 at 3:39 pm

PermaEthos LogoJack Spirko, of The Survival Podcast fame, is a visionary in many ways. His most recent endeavor is a little project called PermaEthos, which aims to create a worldwide network of farms based on Permaculture Principles and Libertarian Ideals. As part of this effort, Jack and his team will be putting on an online PDC at the first PermaEthos farm. Needless to say, the wife and I are taking a PDC!

For more information on the PermaEthos model, and how it came to be, listen to Episode 1335 The PermaEthos Model 3.0.

As part of this, I created a profile over at Permaculture Global to help track what I’ve done. If you’re on that network, feel free to connect with me!
Direct Link to Profile on Permaculture Global

Good Gear!

February 7, 2014 at 3:38 pm

Whether it’s camping gear, construction gear, kitchen gear or computer gear, I’ve always loved gear. From cheap doodads to expensive precision thing-a-ma-bobs, I’ve used a lot of gear over the years. Some of it has worked really well for me, and a lot of it has failed miserably. Strangely enough, price isn’t always a determining factor, either. In this blog series, I’m going to review some of the gear that I’ve used and tell you why I love or hate it. Stay tuned for the first post in the Good Gear series: Pots and Pans!

Learning to Cook

November 18, 2013 at 2:52 pm

A friend asked me at lunch today: “How do I learn to cook?” Since this question seems to come up a lot in my life, I figured I would write a post on the topic so I could easily answer the next person.

I am passionate about cooking. I learned to cook from my mother at a very young age. She would always encourage me to help cut the vegetables, or stir the soup. Some of my earliest memories are of helping out in the kitchen (the others are of taking things, usually expensive, apart). For me, cooking developed naturally as I absorbed what my mother taught me. When I hit college, I started collecting cookbooks trying to improve on my skills in earnest. However, I quickly became disappointed in what the average cookbook had to teach.

You see, the problem with most cookbooks is that they are just recipe collections. Sure, some good ones will give you a  few brief pointers on how to knead bread, or broil a steak, but most are just a list of recipes that throw terms at the reader that they might not be familiar with. “Saute one cup of chicken, diced into one inch cubes”. What’s a saute? What’s a dice? What temperature? What pan? Do I cover it?

Most folks think that they know the vocab, and throw the recipe together in a way that makes sense to them. This usually results in an edible meal that roughly approximates the recipe, so most people leave it at that. Presto! We’re cooking now! Never mind the fact that our ragu is now more of a vegetable stew and our bread is completely crumbly without any of that nice chewy texture we were looking for… Cooking not only throws an entirely new vocabulary at you, it also throws you a new grammar and syntax, which most books don’t even touch on. By following the average cookbook, we are merely parroting back what we are reading and failing to understand why we’re doing any of it. This isn’t how you learn.

So how would I recommend you learn to cook? Learn the vocab, learn the grammar, and learn the syntax.

The vocab is basic, and fairly easy. It’s not like you are becoming a doctor and need to learn latin. To take our earlier example, sauteing involves cooking meat in a pan with oil while braising uses some other water based liquid. Most folks at home braise meats unintentionally when they cover their frying pans. The Professional Chef and Jacques Pépin’s Complete Techniques do a great job of going over the vocabulary of cooking, while illustrating it with both recipes and pictures.

Grammar is a bit more tricky. The rules are hinted at, and even discussed in a high level, in The Professional Chef. However, pick up a copy of Ratio: The Simple Codes Behind the Craft of Everyday Cooking and you will really get a feeling for the power of culinary grammar. For a full review of Ratio, see this article I wrote a while back. To summarize it, though, imagine knowing the base ratio for a cake and then being able to make any cake you can imagine. Then imagine changing the ratio of the exact same ingredients and coming out with a scone instead. This is the power of culinary ratios. They free you from ratios and let your imagination take flight.

Finally come syntax, and this is one of the harder things to learn. Syntax, in the cooking world, is the fingerprint of a particular cuisine. More accurately, it is the flavorprint of a particular cuisine. What makes American BBQ unique when compared to, say, Vietnamese BBQ? If you look at the recipes, you will notice that it is all in the specific ingredients and flavoring agents that are available to each culture. Unfortunately though no-one, to my knowledge, has written a good book on the flavor prints of the world. The only way to learn syntax is by reviewing recipe collections on specific cuisines, looking at the ingredients in ethnic markets, and analysing the flavors when you eat out at a restaurant that specializes in that type of cuisine. It may not be easy to learn syntax, but it can be fun and filling!

Since this is an article on learning to cook, I want to share my favorite cooking show as well. Good Eats is a fantastic show by the mad scientist of the culinary world, Alton Brown. It gives great examples of all of the above material and does so in a fascinating, highly entertaining way. Truth be told, Good Eats was one of the reasons I started looking in to the whys and wherefores of the cooking world. You can pick up the DVDs of the show on Amazon, and I’m sure you can find episodes streaming online if you look on the search engine of your choice.

Was this article helpful? Did you find it interesting or disagree with it? Please post in the comments below!

Edited to add: Turns out there are a few cheatsheets floating around on flavor profiles. Have a look.

Character

August 13, 2013 at 11:51 am

When you look at dishonesty as a social disease, things get very interesting. I always believed that “The true test of a man’s character is what he does when no one is watching” (John Wooden), but perhaps there’s more to it than that. Character is also standing up for what you believe in the face of social pressure. Tricky double-edged sword, that is. However, it is worth careful consideration. This article gives some great food for thought along these lines.

http://www.artofmanliness.com/2013/08/12/what-strengthens-and-weakens-our-integrity-part-iii-how-to-stop-the-spread-of-the-immorality-virus/

Monitors and Caching DNS

June 20, 2013 at 4:53 pm

Had an interesting issue today. One of the production systems suddenly went dark, and we found out about it from the client. This is never a good way to start a Thursday. It turns out that the client was having DNS issues and the domain was no longer valid. Relatively simple fix, crisis averted…

But why didn’t the monitoring system pick it up?

We use Dotcom-Monitor to check each of our sites on a regular basis. The monitor actually logs in to each website to verify functionality. What in the DNS world could cause this issue in such a scenario? How about a caching nameserver? Turns out, to limit the stress on their nameserver, Dotcom Monitor set up a standard caching nameserver that keeps a record in cache until the record expires. So even though DNS was no longer working for this site, the monitor thought everything was A-OK.

What can we do to fix this issue? Not much unfortunately. Dotcom Monitor will have to implement a change in their infrastructure which will likely increase the load on their DNS servers significantly. Since that’s not likely, it looks like I’ll have to build a service into our internal monitor (Zabbix based) to check for the domain against the SOA for it.

PageSpeed score of 96/100!

June 12, 2013 at 5:21 pm

PageSpeed Insights ScreenshotAfter configuring W3 Total Cache and playing around with google’s free PageSpeed Insights tool, I was able to increase The End of the Tunnel’s score from 49 to 96! This is impressive to me because this site currently runs on the basic DreamHost shared environment plan. No dedicated servers, no fancy configurations, just good cache management. Fantastic!