Cracking Passwords Version 1.1

by: J. Dravet

February 15, 2010

Abstract

This document is for people who want to learn to the how and why of password cracking. There is a lot of information being presented and you should read it all before you attempted doing anything documented here. I do my best to provide step by step instructions along with the reasons for doing it this way. Other times I will point to a particular website where you find the information. In those cases someone else has done what I attempting and did a good or great job and I did not want to steal their hard work. These instructions have several excerpts from a combination of posts from pureh@te , granger53 , irongeek , PrairieFire , RaginRob , stasik , and Solar Designer . I would also like to thank each of them and others for the help they have provided me on the BackTrack forum.

I will cover both getting the SAM from inside windows and from the BackTrack CD, DVD, or USB flash drive. The SAM is the Security Accounts Manager database where local usernames and passwords are stored. For legal purposes I am using my own system for this article. The first step is to get a copy of pwdump. You can choose one from http://en.wikipedia.org/wiki/Pwdump.

I used to use pwdump7 to dump my passwords, however I have come across a new utility called fgdump from http://www.foofus.net/fizzgig/fgdump/ This new utility will dump passwords from clients and Active Directory (Windows 2000 and 2003 for sure, not sure about Windows 2008) where pwdump7 only dumps client passwords. I have included a sample hash.txt that has simple passwords and should be cracked very easily.

Some anti-virus software packages flag pwdump* and fgdump as trojan horse programs or some other unwanted program. If necessary, you can add an exclusion for fgdump and/or pwdump to your anti-virus package so it won't flag them. However it is better for the community if you contact your anti-virus vendor and ask them to not flag the tool as a virus/malware/trojan horse.

You can find the latest version of this document at http://www.backtrack-linux.org/

Contents

  1. LM vs. NTLM
  2. Syskey
  3. Cracking Windows Passwords
    1. Extracting the hashes from the Windows SAM
      1. Using BackTrack Tools
        1. Using bkhive and samdump v1.1.1 (BT2 and BT3)
        2. Using samdump2 v2.0.1 (BT4)
        3. Cached Credentials
      2. Using Windows Tools
        1. Using fgdump
        2. Using gsecdump
        3. Using pwdump7
        4. Cached Credentials
    2. Extracting the hashes from the Windows SAM remotely
      1. Using BackTrack Tools
        1. ettercap
      2. Using Windows Tools
        1. Using fgdump
    3. Cracking Windows Passwords
      1. Using BackTrack Tools
        1. John the Ripper BT3 and BT4
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM using the cracked LM hash
          4. Cracking cached credentials
        2. John the Ripper - current
          1. Get and Compile
          2. Cracking the LM hash
          3. Cracking the LM hash using known letter(s) in known location(s) (knownforce)
          4. Cracking the NTLM hash
          5. Cracking the NTLM hash using the cracked LM hash (dumbforce)
          6. Cracking cached credentials
        3. Using MDCrack
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM hash using the cracked LM hash
        4. Using Ophcrack
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM hash using the cracked LM hash
      2. Using Windows Tools
        1. John the Ripper
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM hash using the cracked LM hash
          4. Cracking cached credentials
        2. Using MDCrack
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM hash using the cracked LM hash
        3. Using Ophcrack
          1. Cracking the LM hash
          2. Cracking the NTLM hash
          3. Cracking the NTLM hash using the cracked LM hash
        4. Using Cain and Abel
      3. Using a Live CD
        1. Ophcrack
  4. Changing Windows Passwords
    1. Changing Local User Passwords
      1. Using BackTrack Tools
        1. chntpw
      2. Using a Live CD
        1. chntpw
        2. System Rescue CD
    2. Changing Active Directory Passwords
  5. plain-text.info
  6. Cracking Novell NetWare Passwords
  7. Cracking Linux/Unix Passwords
  8. Cracking networking equipment passwords
    1. Using BackTrack tools
      1. Using Hydra
      2. Using Xhydra
      3. Using Medusa
      4. Using John the Ripper to crack a Cisco hash
    2. Using Windows tools
      1. Using Brutus
  9. Cracking Applications
    1. Cracking Oracle 11g (sha1)
    2. Cracking Oracle passwords over the wire
    3. Cracking Office passwords
    4. Cracking tar passwords
    5. Cracking zip passwords
    6. Cracking pdf passwords
  10. Wordlists aka Dictionary attack
    1. Using John the Ripper to generate a wordlist
    2. Configuring John the Ripper to use a wordlist
    3. Using crunch to generate a wordlist
    4. Generate a wordlist from a textfile or website
    5. Using premade wordlists
    6. Other wordlist generators
    7. Manipulating your wordlist
  11. Rainbow Tables
    1. What are they?
    2. Generating your own
      1. rcrack - obsolete but works
      2. rcracki
      3. rcracki - boinc client
      4. Generating a rainbow table
    3. WEP cracking
    4. WPA-PSK
      1. airolib
      2. pyrit
  12. Distributed Password cracking
    1. john
    2. medussa (not a typo this is not medusa)
  13. using a GPU
    1. cuda - nvidia
    2. stream - ati
  14. example hash.txt
  15. Version history

1 LM vs. NTLM

The LM hash is the old style hash used in MS operating systems before NT 3.1. It converts the password to uppercase, null-pads or truncates the password to 14 characters. The password is split into two 7 character halves and uses the DES algorithm. NT 3.1 to XP SP2 supports LM hashes for backward compatibility and is enabled by default. Vista supports LM hashes but is disabled by default. Given the weaknesses in the LM hash it is recommended to disable using LM hashes for all MS operating systems using the steps in http://support.microsoft.com/kb/299656

NTLM was introduced in NT 3.1 and does not convert the password to uppercase, does not break the password apart, and supports password lengths greater than 14. There are two versions of NTLM v1 and v2. Due to a weakness in NTLM v1 is should not be used. Microsoft has included support for NTLM v2 for all of its operating systems either via service pack or the Directory Services client (for windows 9X). You enable NTLM v2 by following the instructions at http://support.microsoft.com/kb/239869. For maximum security you should set the LMCompatibility to 3 for Windows 9X and LMCompatibilityLevel to 5 for NT, 2000, XP, and 2003. Of course you should test these changes before you put them into a production environment.

If LM hashes are disabled on your system the output of pwdump and/or the 127.0.0.1.pwdump text file will look like:

Administrator:500:NO PASSWORD*********************:00AB1D1285F410C30A83B435F2CA798D:::
Guest:501:NO PASSWORD*********************:31A6CAE0D36AD931B76C59D7E1C039C0:::
HelpAssistant:1000:NO PASSWORD*********************:BF23C2595478A6279F7CB53EF76E601F:::
SUPPORT_3845a0:1002:NO
PASSWORD*********************:0C8D62E10A6240BACD910C8AB295BB79:::
ASPNET:1005:9F07AE96CA4310752BDC083AAC960496:A99C1C3DB39E3C732EF5C2F63579AF96:::
        

The first field is the username. The second field is the last four numbers of the SID for that username. The SID is a security identifier that is unique to each username. The third field is the LM hash. The forth field is the NTLM hash.

If you do not have a ASPNET user account do not worry about it. If you do have a ASPNET user account do not change the password as I am told that will break something. What I did was delete the account and then recreate it using: %systemroot%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe /i

2 Syskey

To make it more difficult to crack your passwords, use syskey. For more information on syskey see http://support.microsoft.com/kb/310105. The short version is syskey encrypts the SAM. The weakest option but most convenient is to store a system generated password locally; locally means the registry. The up side is the SAM gets encrypted and you can reboot the server remotely without extra equipment. The next option is password startup. This is slightly more difficult to get around, but if you remotely reboot the server, it will stop and wait for someone to enter the password. You will need a KVM over IP or a serial port concentrator so you can enter the password remotely. The most secure option is the system generated password stored on a floppy disk. The downside to this option is floppy disks fail, you misplace the floppy disk, newer equipment does not have a floppy disk drive, no remote reboots, and you will probably leave the floppy in the drive so you can remote reboot and that defeats security. I use a system generated password stored locally, weak but better than not doing it. To disable syskey use chntpw and follow its instructions.

3 Cracking Windows Passwords

3.1 Extracting the hashes from the Windows SAM

3.1.1 Using BackTrack Tools

3.1.1.1 Using bkhive and samdump2 v1.1.1 (BT2 and BT3)
  1. # mount /dev/hda1 /mnt/XXX

    mount your windows partition substituting hda1 for whatever your windows partition is

  2. if the syskey password is stored locally you need to extract it from the registry so you can decrypt the SAM. If syskey is setup to prompt for a password or the password is on a floppy, stop now and read the syskey documentation in this document for more information about syskey. If you installed windows to something other C:\WINDOWS please substitute the correct path.

    the path is case sensitive. The filenames of sam, security, and system are case sensitive. On my system these files are lowercase. I have come across other XP systems where they are uppercase. On the Vista system I have used the filenames are uppercase.

    BackTrack 2 users use the following:

    # bkhive-linux /mnt/XXX/WINDOWS/system32/config/system syskey.txt

    BackTrack 3 users use the following:

    # bkhive /mnt/XXX/WINDOWS/system32/config/system syskey.txt

  3. # samdump2 /mnt/XXX/WINDOWS/system32/config/sam syskey.txt >hash.txt

    samdump2 will dump the SAM to the screen and the > character redirects the output to a file called hash.txt you can also run samdump2 with the -o parameter to write the output to a file

    # samdump2 -o hash.txt /mnt/XXX/WINDOWS/system32/config/sam syskey.txt
3.3.1.1.3 Cracking the NTLM hash using the cracked LM hash

Stasik told me it is much easier to crack the NTLM hash if you know the character set. This way you do not need to bruteforce all possible characters combinations. Once you have TESTTEST, feed a custom character set of tesTES to john and it will return the proper case password much faster than if you did not limit the character set. The issue is john has no easy way to limit the character set. You will have to modify the john.conf file and include the following code that Solar Designer has kindly published to the john-users mail list:

[List.External:customcharset]
        
    int running;        // Are we already running?
    int last;       // Last character position, zero-based
    int c0, c[0x100];   // Cyclic charset

    void init()    
    {
        int length, cm, i;

        length = 10;         // password length
        c[c0 = 't'] = 'e';   // change the t and the e to the first and second letters of the custom character set
        c['e'] = 's';         // change the e and the s to the second and third letters of the character set
        c['s'] = 'T';         // change the s and T to the third and fourth letters
        c['T'] = 'E';         // etc
        c['E'] = 'S';         // etc
        c[cm = 'S'] = c0;     // change the S to the last letter of the character set

        // If you cannot see the pattern then do not bother with this trick.
        // If you can make the necessary changes to suit you environment.

        running = 0;

        last = length - 1;

        i = 0;

        while (i < length) word[i++] = cm; word[i] = 0;

    }

    void generate()
    {
        int i;
        i = last;
        while ((word[i] = c[word[i]]) == c0)
            if (!i--) {
                if (running++) word = 0;
                return;
            }
    }

Once you make the necessary changes begin cracking using:

# /usr/local/john/john -external=customcharset --format:NT hash.txt

Some notes from Solar Designer :

15 Version History

Changes from version 1.0

Changes from version 0.9

Changes from version 0.8

Changes from version 0.7

Changes from version 0.6

Changes from version 0.5

Changes from version 0.4

Changes from version 0.3

Changes from version 0.2

Changes from version 0.1