How do you spell "PSK"?

Published: 2013-09-23. Last Updated: 2013-09-24 01:42:40 UTC
by Rob VandenBrink (Version: 1)
17 comment(s)

In my line of work, there is a lot of uses for a random sting of text.  Things like:

  • VPN Preshared Keys
  • RADIUS or TACACS  "shared secrets"
  • Windows Service Account Passwords
  • Administrative accounts (Windows local or domain Administrator, in some cases root in *nix)

You get the picture.  Strings that you need to key once, or once per instance.  In most cases, these are strings that after creation, you don't neccesarily need to know what they are, you just need to know how to change them.

With this list of parameters, you'd think that folks would use random characters for these functions right - at least do the random keyboard walk for it?  In my experience, this is almost NEVER the case.  People try spell things - "l3tm31n", D0ntg0th3r3" and the like.  They'll use their Company name, or the street address of their organization, or some other "meaningful" string.  And after using "leet-speak" passwords, they then carefully record the password and save it to a text file, usually on the server that's using the password.  As a pentester, this is a win for me, I don't even need to crack the password, you just gave it away!  As a system administrator, this horrifies me!

So, what to do?  In the past, I've used an excel spreadsheet to generate a random string of "n" characters, selected from a set of characters that do not include the "confusing" ones (Oo01lIiL and so on).   The "randomness" was defined by how long I felt like leaning on the F9 key that day.  After creating the string, I would then try to get my client to NOT write down the string - this almost never works, but it's worth a try.

For today's story, I decided to improve on this a bit, and re-coded it in python.  This was a 5 minute script (as most of mine are), so if you see a way to improve or neaten this up in any way, please - don't be shy - use our comment form.

========================================= psk.py =========================================

from random import randint
import sys
if not (len(sys.argv) == 2):                                           # verify syntax
        print "Syntax PSK LENGTH_OF_PSK"

        exit()

rndstrlen = int(sys.argv[1])                                           # how long is the output string?
outstring=""

chars = "abcedfghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789"       # define the list of valid characters
charlist = list(chars)                                                 # change it to a list for lookups

numchars = len(charlist)  -1                                           # get length of string list, -1 for start from zero

for i in range (0, rndstrlen):
     c = charlist[randint(0,numchars)]                                 # pick a random char from the list
     outstring += c                                                    # append it to outstring

print outstring

==========================================================================================

Running this as "python psk 15" will create a 15 character pseudo-random string:

C:\> python psk.py 15
xnHDCcRGetuswhf

C:\> python psk.py 15
bvDJhrtRC4QMmks

C:\> python psk.py 15
nWChNxBPMVZbaDb

C:\> python psk.py 15
UXbcSm9Bk9RHTWc

C:\> python psk.py 15
uVs34MZuta9PFTk

You can change the values that are permitted to be in the string (to exclude lower case values, or to add special characters) by adding or removing characters in the "chars" string.  Changing the length of the string is as simple as changing the  value in the command line option:

C:> python psk.py 32
pPPhe6Pn9RbGN3gr6UZZfqZYt4ajSfjg

C:> python psk.py 64
xsk9rNaX77UtSNfCGVVgWeEm9xS7mgMwcbx4FaquPz9cpMJFqRC5YYrf5Wyp8mp7

And please, in most cases there is NO reason to write down this password.  Your "windows service password for whichever service" for instance should be changed periodically, but in most cases there is no reason that you should know what it is, you just need to be able to change it. 

Also, if you use this to create a random pre-shared-key for your ste-to-site VPN, emailing it in cleartext is what we call "a bad idea".  Not only is it open for theft as it transits the internet (and both internal networks), it's also stored (likely forever) in your sent mail and in the recipients inbox, and likely in the Exchange Server message store - the whole cleartext data at rest / cleartext data in transit concept should ring a bell, especially if you've been audited for PCI lately.

As always, in these days when brute-forcing is simple, quick and cheap, bigger is in fact better.  For pre-shared keys or "write only" passwords, I generally start at 32 characters and go up from there.  Since you never need to re-key the thing, after it's generated you can cut/paste it and forget it.

I hope that you find this simple bit of code useful.  If you've got a simpler way of getting to the same results, or if you can improve on my quick-and-dirty python, please post to the comment field below!

===============
Rob VandenBrink
Metafore

17 comment(s)

Am I using my Fingerprints yet?

Published: 2013-09-23. Last Updated: 2013-09-23 15:16:26 UTC
by Rob VandenBrink (Version: 1)
11 comment(s)

I came across an article today that demonstrates a compromise of the new Apple 5S fingerprint reader:
http://www.theguardian.com/technology/2013/sep/22/apple-iphone-fingerprint-scanner-hacked#!
http://www.ccc.de/en/updates/2013/ccc-breaks-apple-touchid

In other words, a copy of your fingerprint is your fingerprint.  And as Johannes discussed in the first article on this (https://isc.sans.edu/forums/diary/In+Defense+of+Biometrics/16553/), the screen on your phone is one of the better fingerprint collectors out there !
For me, this brings up both sides of "the fingerprint discussion"

  • You can't change your fingerprints - once a real copy of them are compromised, they are compromised forever
  • A representation of your fingerprint is stored on the device.  So if the device is lost or stolen, this representation could be used to compromise other things, if they use the same representation of your fingerprint (ie - any other device that uses the same manufacturer's hardware).  Again, once stolen, they are stolen forever.
  • After a couple of years, you'll likely trade your phone in for a new one, and today there isn't a way to know that a wipe of the phone wipes the saved representation of your fingerprint
  • Your fingerprint may be backed up with your phone backup.  Historically, your phone's backups have been easier to pillage than your phone.
  • If your phone is damaged, you may not have a way of wiping it


On the other hand:

  • On any given day, using your fingerprint is likely MUCH more secure for you than the 4 digit code you are likely using
  • Since your phone code likely matches either your phone number or your bank code, either it's very easy to guess, or compromising it might have other unpleasent consequences for you.


There's lots of discussion on this online, I think we're still waiting on Apple to respond definitively on any of them.

Anyway, none of these arguments are new, we've been round and round on them anytime these last 10 years, since they started putting readers on laptops for login.  What's changed is that there are way more phones than there are laptops, and in most cases the 4 digit unlock code on your phone is all that protects your chequing account, your facebook, paypal, twitter and email accounts.

So, am I using my fingerprints yet?  Not on any of my laptops, but once I upgrade my 4S to the new model, it'll be awfully tempting to take the plunge - I guess I'm still thinking about it.  If Apple would implement a "fingerprint + PIN" two factor authentication solution, it'd be an easier decision.

We welcome your comments in our discussion forum (comment button below).

===============
Rob VandenBrink
Metafore

Keywords:
11 comment(s)
ISC StormCast for Monday, September 23rd 2013 http://isc.sans.edu/podcastdetail.html?id=3554

Comments


Diary Archives