<<

LAB 1 – Cracking weak

Introduction

Password-based authenticaiton is still the most popular metod of access control. Methods based on passwords have numerous advantages: low implementation cost, ease of passwords change, reconfigurability, lack of any external systems to depend on. Passwords can be memorized, so it is not easy to steal them, unlike tokens or ID cards. Passwords are hard to recover, for example by means of reverse engineering, on condition that the satisfies certain quality criteria. Passwords, which are short or too simple to guess, must not be used. This laboratory session aims to show the vulnerabilities to password-based authentication. We will evaluate passwords, which are too short or too simple. Short phrases or dictionary words must be avoided.

This laboratory is not a hacking tutorial – its sole objective is to show, that common software can be used to break a passwod by brute force atatck or to recover it by other means, such as a . The lab also aims to show that strong passwords need to be enforced in all systems as a common security control, by means of an appropriate security policy.

The methods and techniques presented here also aim to show administrators a few techniques to test the quality of a password, since a weak password presents considerable vulnerabiblity. Many network attacks follow some repetitive pattern:

1. Step 1: find login name and recover password of any user in the system. Contrary to many expectations, it is not difficult. Many users do not adhere to security principles, unless they are enforced. They rely on weak passwords, expose their passwords or put a note of it, do not use secure communications during the authentication procedure (as a result of that password can be sniffed by an attacker), use simple passwords, such as birth date, favourite pet name, friend name, etc.) 2. Once an attacker gets into the system, by using username and password of a reckless user, he or she is trying to retrieve password transforms (hash digests) of all other users, among them the password of a system administrator. 3. Once the password of the system administrator has been retrieved, it is hacked, for example with the use of tool. 4. After the password has been cracked, the attacker installs a backdoor, and removes all evidence or traces of the activity. The danger is that also when the sys admin replaces the password for a new one, the backdoor remains there …

In the lab we are going to use John the Ripper tool. It is a well known software, by many considered the best of all available in the public domain. The program can be used to break passwords for Windows and systems. The program uses command line as input. Run-time parameters can be provided as options as well as from file.

In Linux the password file uses the following format:

Login : Password : t1 : t2 : t3 : t4 : t5 : t6 :

In Windows, the format is PWDUMP:

Login : RID : LM-hash : NT-hash : : :

John the Ripper assumes one of the above formats for proper operation.

Initial steps

1. Please boot up your PC as Ubuntu 2. Create a new directory and download the new stable version of the programm from http://openwall.com/john/ (seek for version 1.8.0 or more recent files: sources, tar.gz, 4.3 MB). In the case of difficulty “John the Ripper” program can be downloaded from http://kt.agh.edu.pl/~niemiec/lab/lab3/lab3.html 3. Unpack the program, open the command line interface (use command prompt, since “John the Ripper is a command-line only). Program documentation is in john/doc 4. Please browse through the following: OPTIONS (program functionality), MODES (explains modes of operation), CONFIG (configuration, variables), RULES (how to define new rules for ), EXAMPLES (to see use cases). 5. Change directory to john/src, where installation files can be found. Install John the Ripper program with the following:

make clean generic

6. Change directory to john/run (a new file popped up in this directory). Download into this directory all the password files and dictionary files specific to some domain of interest. They can be found at http://kt.agh.edu.pl/~niemiec/lab/lab3/lab3.html

The files have been originally downloaded from: ftp://ftp.zedz.net/pub/crypto/wordlists/ You can also navigate to dictionary web pages from the home page of the “John the Ripper”  passwords  wordlists

Testing performance

Before you attempt cracking passwords, you should check the efficiency of John on your system by running it in a test mode. The report tells you how many username/password combinations per second (c/s) your system will approximately run for each password hash type. $ john --test

SINGLE CRACK mode

It is the easiest and the simplest mode of operation. The program verifies simple passwords only.

Please open password file: hasla.txt and analyse the enconding under Linux, and next try this SINGLE CRACK mode to break passwords from hasla.txt file

john –-single hasla.txt or ./john –-single hasla.txt

Q: Which rules are used in the SINGLE CRACK mode ?

Q: Are these passwords secure ?

Q: Why the program has identified password: ‘99999’ ?

WORDLIST mode

1. WORDLIST mode uses dictionary to crack passwords – the list in a dictionary contains potential user passwords. Dictionary words serve as a basis for mangling words. Word processing rules allow to modify (twist) words. Special characters are added in front of the word, which improves success rate for this mode of operation.

When an attacker knows professional interests or hobby of the victim he or she can use special purpose (subject-specific) dictionary. For example, a football fan may use his favourite football player name as password.

Please use the following dictionaries: asteroid.txt, shakespe.txt and tolkien.txt. to try to break passwords in file t_hasla.txt

./john ––wordlist=asteroid.txt t_hasla.txt

Q: what can you infer (deduce) about interests and hobbies of the users ?

Q: Why are the passwords insecure ?

2. In order to list all broken passwords from a file t_hasla.txt, use the following: ./john --show t_hasla.txt

Retrieved passwords are stored in a file: john.pot Please break any of the passwords for the second time. Q: Is this operation successful ? Please delete the passwords from john.pot. Is the program trying to break the password again ?

3. Good results can be obtained by trying various modifications of a dictionary word. With -- rules command line option one can break various types of passwords, which are modifications of a dictionary-based words. Please try to break passwords from r_hasla.txt file, by using shakespe.txt:

./john ––wordlist=shakespe.txt ––rules r_hasla.txt

Q: What rules are used in this mode of operation ? Hint: look at the rules in john.conf file. (rules for the WORDLIST mode can be found below the line [List.Rules:Wordlist]).

4. Please delete rules for WORDLIST mode (they can be found below the line [List.Rules:Wordlist]) and define your own password breaking rules, knowing that many users often use the following methods to encrypt passwords:  Use ‘@’ instead of lowercase ‘a’ (example: lamp --> l@mp)  Use ‘0’ instead of lowercase ‘o’  Use ‘(‘ instead of lowercase ‘c’  Append the password with ‘2015’ or ‘15’ (or ‘2016’ , ‘16’)  Prepend a passwords with a ‘.’ (dot)

Now use the newly defined rules to break passwords from: s_hasla.txt for users s1, s2, and s3. For this, use shakespe.txt. Please assume, that a given user has used only one of the above-listed letter replacement methods.

Q: Which password has been broken ? Why ? What are the newly defined rules ?

Now assume that you know, that user s3 has applied all of the above listed replacement methods, except for a dot ‘.’ in front of the password. Please try to break that password.

Q: Which password is that ? Q: What was the newly defined rule ?

User s5 is using another method to replace letters. All you know is that she is only relacing ‘s’ with some special character. What character can it be and try to break password by modifying appropriate rules in john.conf.

Q. What special character is it ? What is the password ?

INCREMENTAL mode 1. INCREMENTAL mode breaks passwords based on brute force attack. It tries all the combinations of letters. By modifying: john.conf one can reduce the length of tested passwords, define characters that are used for passwords etc.

Please look at the configurations of INCREMENTAL mode in file john.conf

2. Assume that passwords in n_hasla.txt file are made of digits only, while passwords in p_hasla.txt file are made of letters only. In addtion assume, that user number matches the number of digits or letters (respectively) in a password. For example user n4 has a four- digit password while user p2 has a password comprised of two letters. Use modes: [Incremental:Digits] and [Incremental:Alpha] please try to break the paswords by typing in passwords of appropriate length for each user.

Run the program and watch execution time:

time ./john –inremental:Digits –user:n1 n_hasla.txt

Please put down in your personal notes the time elapse for each password and draw a plot, where the time required against password length (for numeric passwords and for letter- based passwords).

Q: For what password length, brute force attack becomes impractical ? What password lengths can be considered secure ?

3. The duration of password quessing is variable: it is possible that a password is found instantaneously (at first shot), but it is also possible that valid password will be retrieved at the last try. In probabilistic terms, the password hit is after testing half of all candidates (statistically). Assuming, that the password is of length k-characters, where each character is part of n- element set, and that the characters in a password can be repeated, all the combinations is given as variation with repetitions:

k Vn,k=n

When one knows the time to break a password and a c/s parameter one can compute the number of tries required to break the password. Please check how many time the password has been broken before testing 50% of all variations ? What is the c/s parameter ? Use the plot from the prevous experiment to draw the theoretical time to break the password as a function of password length (assume that the passsword is found after exactly 50% of all variations)

Creating usernames and passwords

Use the su ommand to get root priviliges in command line and create a few new usernames. adduser usernameXX

Use usernameXX to set passwords for the newly created usernames and copy the /etc/shadow to a directory John the Ripper.

Now, . try to break passwords for the users by adding new words to a dictionary (WORDLIST mode), . try to break them in SINGLE mode etc.

Breaking passwords in Windows

1. Reboot your computer in Windows 2. Create “security” folder on your Dektop. Download John the Ripper for Windows. Unpack the compressed file and use command line to change directory to john/run

3. Create a few new users in the system („Panel sterowania” -> „Konta użytkowników”) and set passwords for them (use a few simple passwords –for the sake of experimentation in SINGLE mode, and a few more difficult for dictionary based attack). 4. Access to encrypted password digests in Windows is more difficult than in Linux, we will use a special program SAMInside for NT, 2000, XP i 2003 (recent version is 2.7.0.1 but it is not required here). Please download the program from http://kt.agh.edu.pl/~niemiec/lab. Unpack and run SAMInside.exe 5. Use graphical interface of that program to import users („File” -> „Import local users using LSASS” ) Please export data which is displayed to an ascii file. Use PWDUMP file format. Save the file in john/run and try to break passwords.

When finished, please remmove the new directory from Desktop

Alternative tools for Windows:

Ophcrack is a Windows password cracker based on rainbow tables (https://en.wikipedia.org/wiki/Rainbow_table).

Windows Password Key Professional (9.6.2.0)- popular tool to bypass Windows 10/8.1/8/7 password. No need to re-install system or re-format hard drive.

Report: Briefly describe all the completeed tasks and the results. In particular report on the successful password retrieval and conscise answers to questions. At the end please recapitulate major observations and conclusions.

Supplementary information

Dumping Windows password hashes, bypassing login prompt and password reset: http://bernardodamele.blogspot.com/2011/12/dump-windows-password-hashes.html

Optional work (for students willing to carry out more experiments) - Use EXTERNAL mode in John the Ripper - Use other programs: L0phtrack (ver. 6.0.20), Jane, … - use “Rainbow tables” and the salt value for passwords