Now, let's assume you've got a password file, 'mypasswd', and want to crack it. The simplest way is to let John use its default order of cracking modes: john mypasswd This will try 'single crack' mode first, then use a wordlist with rules, and finally go for 'incremental' mode. Please refer to MODES for more information on these modes. John the Ripper can also crack UNIX/Linux passwords. You need root access to your system and to the password (/etc/passwd) and shadow password (/etc/shadow) files. Perform the following steps for cracking UNIX/Linux passwords: Download the UNIX source files from www.openwall.com/john. Part 6 shows examiners how to crack passwords with a wordlist using John the Ripper and the hashes extracted in Part 2. Practice ntds.dit File Part 6: Password Cracking With John the Ripper – Wordlist Pingback by Week 29 – 2016 – This Week In 4n6 — Sunday 24 July 2016 @ 13:14.

From charlesreid1

  • 1The Basics of Password Generation with John
    • 1.4Rules
    • 1.5Defining Our Own Password Cracking Rules

This page will walk through some basic password cracking with John the Ripper. We'll go from wanting to test certain passwords to being able to generate a stream of them with John the Ripper. This is important to be able to do, so that we don't need to devote gigabytes of disk space to word files. Intelligent use of patterns can save us a whole lot of headaches.

John and Stdout

Note that if you're using Kali 2.0, you'll need to install John jumbo 1.8 from source, instead of using the Kali 2.0 repository version of John, if you want to use John the Ripper to guess passwords but not actually crack them. This is useful for sending John's password guesses to a file to see how John works, or for piping John password guesses to another cracking program like Aircrack.

Rules vs Modes

Rules and modes are ways of telling John how to guess passwords. John can be simplistic, only testing passwords that are in the wordfile, or sophisticated, doing letter/number substitutions, etc.

This page is going to cover some basic rules and modes for guessing passwords in John. We'll figure out how to start with low-hanging fruit, in terms of password guesses, and implementing those in John the Ripper.

First: No Rules

First, let's look at how we run John and generate passwords from a wordfile, with no rules at all specified. This is a kind of 'Hello World' for John the Ripper. We'll specify a 92-word list.

So far so good. Now let's look at how the rules will modify each entry in the wordfile.

Rules

The John_the_Ripper/Rules page has a guide for installing the KoreLogic password generation rules from the Defcon 2010 Crack Me If You Can.

Crack Password John The Ripper

What is a rule?

A rule is a way for John to create variations (rule-based generation of variations) on a wordlist, turning a short wordlist into a much more powerful cracking tool.

Password

Here's an example of a rule that appends years to passwords:

The rule is named KoreLogicRulesAppendYears.

Let's apply the rule to the rockyou password list. First, a quick look at that list:

Now we can call rules on this wordlist to create variations for password guesses.


KoreLogic Rules

Now, we want to be able to use some password cracking rules, so that our wordlists don't have to be terabytes to be effective. We can do that by telling John how to create password variations from the wordlist. This is where the rules come in.

KoreLogic provided a pretty amazingly comprehensive set of John the Ripper rules form the Defcon 2010 crack me if you can contest, with the set of rules being released as part of the terms of victory: http://openwall.info/wiki/_media/john/korelogic-rules-20100801.txt

A guide to installing those rules is here: John_the_Ripper/Rules

Using Rules

To use the rule, for exmaple the KoreLogicRulesAppendYears rule, we can call john with the --rules=KoreLogicRulesAppendYears argument, or with the -rules:KoreLogicRulesAppendYears argument (etiher works, but be consistent):

where we specify the wordlist, the encryption format of the john_password_file, the location of the john_password_file, and the rules to use. We'll cover how to get password files in a format John likes from programs like Airodump-ng and Aircrack below. But let's finish talking about the rules.

If we call John with the stdout flag, instead of a password file, we can see what John is doing:

Defining Our Own Password Cracking Rules

Initial Rule

Now we can add sections to the john.conf file we're using. Let's start with a simple one, that will append the numbers 1980-1989 to words in our wordfile. The syntax for this rule looks like this:

and we can call it thusly:

We can see from the output the way this syntax works.

The Az portion means, any word in the wordfile A, all the way to the end of the word z, then append our expression '198[0-9]', which appends the years 1980-1989 to each word in the wordfile.

here's the output:

Refining the Rule

If we want to capitalize the word in the wordfile (note that your wordfiles should all be lowercase to more efficiently use rules), you can capitalize the first letter like this:

Now we'll get the same output as before, but in addition, we'll get the capitalized word attempts:


Invert Case

We can also invert the case, so instead of the first letter uppercase and the rest lowercase, we do the first lowercase and the rest uppercase by replacing c with C:

Resulting in these passwords:

Moving the Number Around

We can move where we put the number, by changing z to something else (like 0):

and the results: at the beginning of the file, for rule A0'198[0-9]', the years 1980-1989 are prepended:

while at the end of the file, for rule Az'198[0-9]', the years are appended:

Builtin Rules

There are looooots of built-in rules, as seen in the default john.conf file.

You can find the rule names from the john.conf file, and then you can call then with the -rules:RuleName flag:

The o1 flag replaces each character in the wordlist, one at a time, with every single possible symbol/number/letter.

There's also the more exhaustive -o2, which will replace two characters at a time in each word in the wordlist, again using each possible symbol/number/letter.

Password Cracker John The Ripper

A list of built-in rules:

Rule NameRule DescriptionRule NameCommand
NoneNo rules are applied, words are tested directly from the wordlist-rules:None
SingleExhaustive list of rules to try. This will create several thousand iterations from each password, and is exhasutive. Use for exhasutive password searches, or large password files.-rules:Single
WordlistMeant to be used with wordlists, this first tries every word in the list. It then tries upper and camel case, pluralization, duplicate words, digit appending, reversal, capitalization, and splitting passwords in half. Approx. 26 rules.-rules:Wordlist
Hash Runner 2014 o1Tries every password, but substituting every single possible character/number/symbol into the password, one character at a time, in every position.-rules:o1
Hash Runner 2014 o2Tries every password, but substituting every single possible character/number/symbol into the password, two characters at a time, in every position.-rules:o2
Hash Runner 2014 o3Warning: this is the ad absurdum method. Do not attempt unless you have a GPU. This will do the following, for every word in the wordlist:
  • Loop through every possible iteration of every character for the first position. password becomes #assword
  • For each of those possibilities, loop through every possible iteration of every other character, in every other position. password becomes #asXword
  • Then, for each possibility of those two characters, loop through every possible iteration of every other character, to create a third level of iteration, so password becomes #asXwor8. And so on. Ad absurdum.
-rules:o3
Hash Runner 2014 i1This inserts a lettetr into the wordlist, instead of replacing a letter, as the o rules do. password becomes #password. One character is tested at every position, #password through passwordZ, etc.-rules:i1
Hash Runner 2014 i2Similar to o2 above, except inserting instead of replacing. Insert two symbols everywhere. password becomes *#password, thru passwordZ~, etc.-rules:i2
Hash Runner 2014 i3Warning: see warning above. This will probably require a GPU to use. This inserts 0-3 symbols/characters/numbers at every possible combination of positions of every word in the wordlist.-rules:i2

Scripting with John the Ripper

It's pretty straightforward to script with John the Ripper. I find that the easiest way, since John the Ripper jobs can get pretty enormous, is to use a modular approach: keeping track of what password wordlists and what variations have been tried for a given password file manually, rather than trying to maintain consistency by using one enormous John command.

This also helps you assess the results of password cracking part of the way through, and improve your strategy based on your learnings.

I use Python to iterate through combinations and parse pieces and commands together into scripts. I don't have complex or fancy Bash scripts with nice menus and quick prompts. Too bad. Maybe soon. (The problem, though, is that every good library has to be installed first. And I want a tool that deploys without hassle on a bare box. No 'oops, forgot to install pandas, now I can't use any fo my scripts.')




Retrieved from 'https://charlesreid1.com/w/index.php?title=John_the_Ripper/Password_Generation&oldid=8044'

In this post I will show you how to crack Windows passwords using John The Ripper.

Crack Htpasswd John The Ripper No Password

John the Ripper is a fast password cracker, primarily for cracking Unix (shadow) passwords.Other than Unix-type encrypted passwords it also supports cracking Windows LM hashes and many more with open source contributed patches.

Now lets talk about the password protection method used by Windows. Windows user account passwords are typically stored in SAM hive of the registry (which corresponds to %SystemRoot%system32configSAM file), in the SAM file the password is kept encrypted using the NTLM hash is very well known for its cryptanalysis weaknesses.

The SAM file is further encrypted with the SysKey (Windows 2000 and above) which is stored in %SystemRoot%system32configsystem file.During the boot-time of Windows the hashes from the SAM file gets decrypted using the SysKey and the hashes are loaded to the registry is then used for authentication purpose. Both system and SAM files are unavailable (i.e, locked by kernel) to standard programs (like regedit) during Windows’ runtime .

As told earlier NTLM hash is very weak for encrypting passwords.The NTLM encryption algorithm is explained below :

  • ASCII password is converted to uppercase
  • Padding with null is done until 14 bytes
  • Split it in two 7-byte arrays
  • Pad both to make 64 bits (8-byte) which will be used to create a DES key
  • DES-encrypt the string “[email protected]#$%” using the array as key for each 7-byte array (results 8-byte stream)
  • Join 2 cipertexts which forms the NTLM hash (16-byte)
Major pitfals of NTLM hash
  • ASCII is not Unicode
  • Uppercase reduce complexity
  • LM fails with passwords length more than 14 characters
  • Salting is not available
  • It is easy to determine whether the password is less than or more than 7 characters
Cracking Windows Passwords John The Ripper

For the sake of demonstrating this I had already set a dummy account called demo and allotted a password iRock to it, which will be cracked later-on.


User Accounts showing demo user

Crack

Aircrack-ng

I booted using the Ubuntu LiveCD and mounted my Windows partition - /dev/sda1

Crack Htpasswd John The Ripper No Password Download

Then copied SAM and system files to /home/prakhar

John

Then installed samdump2 and John The Ripper :

Then dumped the syskey and NTLM hashes from system and SAM file, respectively :

Crack Htpasswd John The Ripper No Password Reset

NTLM hashes recovered from SAM file

Crack A Password With John The Ripper

I then bruteforced the password using John The Ripper :

You can clearly see above, JTR has cracked the password within matter of seconds, I aborted the session in between since password was already recovered. Mission accomplished !