Post Category: Security

I love cryptography, computer security, and physical security. So I write about it.

Secure Password Design

  • By Brad Conte, May 5, 2005
  • Post Categories: Security

Note: This article offered advice with the security concerns of 2005 in mind. Re-assessing this in 2013, some of the advice is still relevant, but significantly increased cost-effective computing power and smarter dictionary-mangling attacks render a good portion of this out-dated, or at least incomplete. The article is preserved below in it's original form for posterity.

Passwords should be the weakest link

Encryption programs can do a lot to secure your data. A lot of time, effort, and finances are spent researching and designing secure algorithms and protocols, and even more effort is put into implementing these ideas securely.

However, all good security systems follow Kerchoff's principle, meaning that they have one central focal point: the password. Kerchoff's principle is simple, it merely states that no aspect of a security system should be designed any weaker than the user's strongest available password/key, meaning that the password should always be the weakest link in the security chain. Using this principle, the user should be able to choose the level of security they have by creating a password of appropriate strength.

The password is what lets the legitimate user in, and it's what keeps the impostor out. The confidentiality of the password is life or death, as it is usually the only manner of authentication that is implemented. Once the password has been broken, there is rarely anything left to hinder an attacker from accessing or changing everything the password protected.

Brute-force attacks

From the attacker's perspective, it's always preferable launch a "whitebox" attack. A whitebox attack requires some knowledge of an exploit or security vulnerability and uses it to shortcut the attack process and make it as quick and clean as possible. Whitebox attacks against a password would include things like keyloggers, intercepting non-encrypted communications, etc.

But not all security systems have known vulnerabilities, or at least vulnerabilities that the attacker has the ability to exploit. In such situations, the attacker must resort to the oldest, simplest trick in the book: brute-forcing.

Brute-forcing is the act of trying to guess the password non-intelligently. (By "non-intelligently", I mean that the guesses do not have any personal significance to the user under attack. Basically, the guesses would be made no matter who was being attacked, and are not personalized for that specific user. Brute-force attacks that uses guess specifically crafted for the user is probably closer to a whitebox attack, depending on how how educated the guesses are.) The attacker will pick some range of characters and start combining them in every possible combination hoping to blindly stumble across the correct combination.

Sometimes the attacker will have a large dictionary of certain character combinations that have a greater likelihood of being used. For non-creative passwords that wind up being included in these dictionaries, this can significantly speed up the attack.

However, when their dictionary attack(s) fail, the attacker must resort to linear brute-forcing, that is, literally trying every possible combination of characters.

Creating a strong password

There are only two factors that influence the strength of a password: Included character sets and length.

There are four basic characters sets on the standard keyboard:

  • Lower case (26): a - z
  • Upper case (26): A - Z
  • Numbers (10): 0 - 9
  • Symbols (~32): !@#$%^&*()-_=+`~[]{}\/|;:'",<>.?

Simply put, your job in creating a password is to use characters from as many of these different character setsc as possible. For every character set that is represented in your password, your password becomes exponentially harder to brute-force.

First, let's deal with the character range factor, as it will effect the length factor. What I mean by "character range" is the variety of keyboard characters that are used. For example, you could use the password "abc", but that is nothing but lowercase letters, meaning that if the cracker knows this, he only has 26 possible values for each character of your password. So instead you could use "aBc" as your password, and now there are 52 possible values per character because you've introduced the uppercase character set. Now start throwing in numbers, punctuation, and other oddball characters (like #, %, $) and you have roughly 100 possible values per character! This may not seem significant, but it can literally take what was just an arduous task for the brute-forcer, and make it humanly impossible. I recommend doing things like simply replacing normal letters with look-a-like symbols and such, like the following: "1 @m tHe '8eS7' @t Th1s!". Or use AOL speak, "1 @/\/\ 73h 8357 @7 7h15!" That kind of password has a very high character range and is the brute-forcer's nightmare.

A simple way to introduce abnormal characters and extra length to your password is to simply enclose what would by your normal password in the standard HTML end tag format, ie: </password>. So if your password was just "irock", you could make it "</irock>". By using this method, you add a bit of length to your password and introduce abnormal characters, and the idea is easy to remember if you are familiar with HTML.

Another simple advantage to using odd symbols is that few people do it, so brute-forcers, in an effort to shorten the brute-forcing process, often gamble that the password they're trying to break won't have them and will use a limited character set of lower/uppercase characters and numbers. Thus, simply by inserting a period or something similar in your password, you can instantly throw your password outside the range of characters that most brute-force attacks will include.

Now let's deal with the password length factor. Being as how there are a certain number of potential values per character, the total number of guesses that will have to be made to guess every possibility increases exponentially (literally) with every character that we add to the password length. Assume that we're using a 62 character value range for our brute-forcing (we're assuming that the user didn't use anything outside the upper and lower case alphabet, plus numbers). For a one character password, we will have to simply guess 62 times, but for a two character password, we will have to guess 62 values for the first character, but since there is a second one with an equal number of possible values, we will have to make 62 guesses at the first character for ALL of the 62 values of the second one! That means that when the second character is 1, the first one will have to cycle through all 62 different values, when the second character is 2, the first one will have to cycle through all 62 values again, and so on. This means that we have 62 * 62 (62 ^ 2) possibilities, which equals 3,844. This doesn't look too shabby, until you realize that my computer alone can make over 8,000,000 tries a second. So let's introduce a third character, now the number of possible combinations is at 62 * 62 * 62 (62^3) which equals 238,328. Ok, but still nothing really secure. Let's jump ahead and try 5, which results in 916,132,832 combinations. Not bad, but it could take me as little as 7.5 minutes to break that. Let's skip to 7 characters, which has 3,521,614,606,208 (over 3 thousand million, yes, that is correct, "thousand million") combinations. Not bad, eh? This could take days to break, which few brute-forcers are willing to do. But just for fun, let's bump the character range up to about 100 and our password length up to 24, so that we can see the number of combinations for the example I used earlier: "1 @m tHe '8eS7' @t Th1s!" This would generate a range of about 1,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 (one thousand billion billion billion billion billion) combinations. No computer now or anything along the lines of what we could soon have could ever come close to possibly breaking that! And not only do you have that total many combinations for that length of characters, but, assuming that the brute-forcer does not know the length of the password (they rarely do), they will have start with the least number of characters and work their way up, so they will have to generate all the combinations for a length of 1, and 2, and 3, etc, which adds up really big, really fast. Hopefully now you realize why longer passwords are so much more secure. Even one character on the end, like a period, helps tremendously, as it can throw millions of more possibility's onto the brute-forcer's shoulders. On a side note, I actually personally recommend adding periods on the end because periods are easy to remember, they add one character in length to your password, and very few people include punctuation when brute-forcing.

Keep this basic fact in mind: If you use a full ASCII character range for your password, for every character you add to your password's length, you make the password about 60 times more complex! This means that a password that would take one minute to brute-force, with the addition of another character, would take about an hour. (If you're using non-ASCII data (pure binary values with a full 256-value range) for the password, the result is even more dramatic. Every extra character makes the password 128 times more complex!)

Also, notice that the password I just used as an example is actually a short sentence, not really a word. This is commonly referred to as a "passphrase" rather than a "password", because you're using a phrase instead of a word. Passphrases are much better then plain passwords, because they are MUCH longer and make it easier to include punctuation and other odd characters. Plus, they can also be easier to remember. Try remembering "Brad" versus "I visited Brad's site" for a week and see which one phrase you remember best. You will likely be able to remember both, but which one is more secure by a very, very large factor? Use passphrases, they make getting length into your passwords a farily easy task. Plus most words out there are only 7 or 8 characters long, and all in the same case, do you know how easy that would be to brute-force? Passphrases aren't just a nice idea, with the speed of the computers that crackers have access to, they're starting to become a necessity.

Thwarting brute-forcing techniques

Crackers who are brute-forcing your password know that they are oftentimes up against a potentially endless problem. So they, like everyone else in the world, try to find shortcuts. The most common shortcut is simple, they generate "wordlists" of commonly used words and/or combinations of letters that they manipulate and use to provide their brute-force guesses. They figure, and rightly so, that not many people, realistically, use passwords such as "Aab89$skl", so instead of trying every possible combination of letters they will try only somewhat sensible combinations of letters and words. This can cut their work down by thousands of times, while still keeping a very good chance of finding the password. Your job, then, when creating a password, is to thwart this process. Make the attacker sweat for his money, don't give him anything easy. Make it a long passphrase and use characters instead of letters, inject numbers and punctuation, and avoid common words like "the" and common letter sequences like "tion". Use characters that make no sense in the order they appear in.


  • Use lots of different characters in your password, like ending it with a period and switching normal letters for numbers and/or symbols.
  • Use long passwords.
  • Don't use common words or phrases.

Follow these basic tips and you should have a password that you can engrave in stone (not literally, of course). Just don't make the mistake of using it too often in different places, so that if someone gets a hold of it, which usually by accident or chance, they don't have access to everything you have.

Hopefully you can see that designing a secure password is not a daunting task, but neither is it a trivial one. You should spend a minute or two thinking about them before creating them. In fact, do that right now, so that next time you're in a hurry and need to create one you already have an idea started. If you currently have any insecure passwords, change them. It's usually far easier to change a password than to have it compromised.

Windows NT Password Cracking Via DOS

  • By Brad Conte, August 8, 2004
  • Post Categories: Security

Suppose there's a Windows NT-based machine that you (for some reason of no concern to me) want to access but: a) have not the necessary password, or b) you only have a limited account on the machine and want the administrative password. (This tutorial can be expanded to file recovery as well. Or perhaps you need to recover a file and the operating system is damaged, or whatnot. If this is the case, this article can help you.)

What we're going to do (in concept at least) is quite simple: Boot to DOS (instead of Windows), steal the necessary registry files, and crack them on a computer we have access to. Usually people boot to Linux LiveCDs and use those to swipe/crack the necessary files, but there are a million tutorials out there about doing that. This is a much more old-fashioned, retro way to do it.

All you need to start are the following:

  • A computer other than the one you're trying to get into (or at least an account on that one)
  • Internet access (to download some files)
  • Two floppy disks

You'll also need to know a couple basic DOS commands:

  • dir "__" -- This will list all the files in the specified directory.
  • copy "file" "location" -- This will copy the file to the specified location.
  • del "file" -- This will delete the specified file.
  • ctl+alt+del -- This well-known key combination instantly reboots the computer.

(Tutorial note: If the computer you are using is Windows NT or 2000, use the WINNT/system32 directory where ever the Windows/system32 directory is listed in this article.)

  1. Download DOS 6.22. This specific file is a self-extracting boot-disk creator. Just stick your floppy in the drive, double-click it, and it will create the DOS 6.22 boot disk. Once it's done, delete the file "edit.hlp" on the disk to make room for future files we'll be putting on there.
  2. Download himem.sys and copy it do your disk. Open your "config.sys" file (you may have to enable the viewing of Operating System protected files to find it) and add the following two lines, preferably at the top:

    dos = high, umb

    Having completed this, you have now enabled DOS to view more RAM than it originally could -- by nature DOS can only see 640K worth of RAM. Doing this tho won't necessarily let DOS see everything the machine has to offer, but it should get up to about an extra 32MB (called extended memory), more than enough for what we're going to do. In the future, once you're in DOS, for your reference, you can type "mem" and get a synopsis of your RAM supply.

  3. Now you need to get yourself a shiny little compression program for DOS so you can compress and swipe the registry files you're after. I recommend PKZip 2.50 because it's small and works very nicely, and is also Windows compatible, although you don't need that feature. I'll assume that's what you're using from here on, as it's what you should be. After you download it, unzip it and copy all the files to your SECOND floppy disk. Now take the disk out, as you won't need it for a few more steps.

    At this point, you will need to know if the operating system containing the files you want is on a FAT32 or NTFS formatted partition. It is most likely that it be NTFS, which will make our life harder, but not impossible. To determine which, simply boot to the DOS disk and see if you can find the drive it's one (use "dir C:", "dir D:", etc to find a drive with the "Windows" directory on it). If don't see it, it's on NTFS. If you can, it's FAT32 and you can skip down to the "FAT32" section.


    1. Now, since we know that DOS cannot read from NTFS formatted drives, we will need to find a way to make it. Download NTFSDOS and copy it to your DOS disk. Open your "autoexec.bat" file and add the simple following line, preferably at the end of the file:


      Now when you boot to DOS, it will run the NTFSDOS program, which allows DOS to read NTFS partitions. It will come up and inform you which drives it is mounting and what drive letter it is assigning to each. For some reason, it usually mounts the first one as 'D', so I'll assume it does the same for you in the following steps. Unfortunately, NTFSDOS only allows us to read NTFS partitions, we still can't write to them.

    2. Later on when we try to zip the registry files we'll find that, although the resulting zip file would be small enough to fit onto the disk, it won't ever appear. This is because PKZip will try to create temporary files for the process, and because you're zipping to the floppy, you'll run out of space to work with. And we can't zip the files to the hard drive because, as I already said, we can't write to an NTFS partition using NTFSDOS, we can only read from it. The solution is to create another drive, one that is big enough to house both the temp files and the final zip file that will contain the compressed registry files. Creating this drive may not seem as hard as it sounds. Once again, you'll have to download a special program, this time it's RAMDRIVE.SYS. Copy this to your DOS floppy, and once again open config.sys, this time add the following line (preferably above the bottom one that contains "lastdrive"):

      devicehigh = ramdrive.sys /E 5120

      The number "5120" is the size of the drive that it will create, in KB. You can set it at anything you want so long as you have the RAM to do it, but don't underestimate what you'll need. 5120KB equals 5MB, and that will be ample for our needs. If you're worrying that a RAMdrive will be harder to use than a normal drive, don't worry at all. Once it's been created you can write to and from it as easily as anything else -- as far as you are concerned, it IS a normal drive, only the computer knows better.

      CHECKPOINT: Now, to summarize: You should have one DOS boot disk that has the the extra files himem.sys, NTFSDOS.EXE, and RAMDRIVE.SYS, and should have added their respective lines of code to the appropriate files. Your second disk should strictly contain PKZip files.

    3. "Buckle your seatbelt Dorothy, 'cause Kansas is going bye-bye" -- we are now about to *gasp* actually use DOS. Place your boot disk in the computer you wish to gain access to and boot it. After the preliminary BIOS checking and stuff by the computer, DOS will load. Watch what's going on and you will see, for just a second, a block of text that reflects the RAMdrive being created. If you see "RAMdrive mounted as X" then it's been successfully created! Remember the letter used, I'll assume from here on that it's drive C because that's what mine always does. (If the RAMdrive does not work, you probably either inserted the line of code in config.sys wrong, or have a bad copy of RAMDRIVE.SYS (doubtful).) Then the screen will continue scrolling down as more stuff is loaded. When NTFSDOS is loaded, you will see a list of the drives it's mounting and corresponding letters that they have been mounted as. These are NTFS partitions that NTFSDOS has found. The first one should be the one with Windows on it (it's usually 'D' for me).
    4. Now we're done with all the preparation and can get down to the real business. When you boot to DOS, it's actually loaded into memory, so you can issue most commands without even needing the disk in there. This will work to our advantage in a moment. Right now, take the DOS disk out and replace it with the disk containing PKZip. Then enter the following line of code:

      pkzip c:\ d:\windows\system32\config\SAM d:\windows\system32\config\system

      The first word, "pkzip", simply addressed the PKZip program, the next one "c:\" tells PKZip where to place the ZIP file and what to name it, the next two are the locations of the registery files you want to take. In all, this will take the SAM and SYSTEM registery files that you need and zip them to your RAMdrive. This should take about a minute, so be patient, DOS isn't quite as fast as Windows. When it's done, it'll ask you to insert the disk with "/", this is your DOS disk, so re-insert it and "press any key", then remove the DOS disk again and put the PKZip disk back in. Next copy the file to your PKZip disk with the following command:

      copy c:\ a:\


    1. FAT32 is much easier to work with than NTFS. Simply insert your DOS disk and boot the computer. Once it's loaded, find the drive with Windows on it (should be 'C'). Then take the DOS disk out and replace it with the disk containing PKZip. Then enter the following line of code:

      pkzip c:\ c:\windows\system32\config\SAM c:\windows\system32\config\system

      The first word, "pkzip", simply addressed the PKZip program, the next one "c:\" tells PKZip where to place the ZIP file and what to name it, the next two are the locations of the registry files you want to take. In all, this will take the SAM and SYSTEM registry files that you need and zip them to your RAMdrive. This should take about a minute, so be patient, DOS isn't quite as fast as Windows. When it's done, it'll ask you to insert the disk with "/", this is your DOS disk, so re-insert it and "press any key", then remove the DOS disk again and put the PKZip disk back in. Next copy the file to your PKZip disk with the following command:

      copy c:\ a:\

      Then get rid of the file your just created on the hard drive so you can eliminate the "evidence", do this by entering:

      del c:\
  4. Congratulations! If you executed the second to last command correctly, you now have swiped the needed files and are close to being done. Just to be sure, though, that you do have the precious file on your floppy, type

    dir a:\

    and look for it in the listing. If it's there, all is well (it will only be missing if you screwed up somewhere along the line).

  5. Now take the PKZip disk to a machine that you have an account on, and copy the file off of it to your desktop, then unzip it.
  6. Now you'll need a way to actually crack the files (assuming that's what you're doing). For this, you will need the program PWSEX. Download it and install it, don't worry that it's only the trial version. Once it's installed, open it and don't touch any of the options except the button next to "Registry files (SAM, SYSTEM)", check that one and click the "Dump from memory" button. Then find the locations of the SYSTEM file for the top input, and the location for the SAM file for the bottom one. Then click the "Dump" button. PWSEX will then crack the usernames and corresponding passwords for the machine that the files came from. Simply look at the list it generates and, well, you should be able to figure that part out.

This entire process is much easier if you just use a Linux LiveCD and a USB flash drive, but this way is more intriguing and amusing.