Showing posts with label EXPLANATION ABOUT ENCRYPTION. Show all posts
Showing posts with label EXPLANATION ABOUT ENCRYPTION. Show all posts

Wednesday, 11 December 2013

How long would it take to brute force 256 bit AES passwords

The issue with AES-256 isn't in brute forcing strong passwords.  If you password is strong (not on any dictionary, longer than 8 char, mixed symbols, uses a large random salt) it can't be bruted forced at any reasonable cost.  If it is 12+ char includes all 4 symbol classes or simply is a random string it can't be brute forced at any cost.

The issue with AES-256 is it is a very faster cipher.  For weak (or marginal) passwords it can be bruted forced.  How complex of a password is vulnerable depends on the resources available to the attacker and how long they are willing to to wait.

So if we consider a weak password to be one that (at least in theory) could be compromised by a dictionary, modified dictionary, or brute force attack using a computing on the magnitude available:
1) anything found in a standard dictionary or leaked/common password list (various lists usually in the tens of millions of pwd range).
2) anything with less than 8 characters.
3) anything all lower case with less than 10 characters.
4) anything not encrypted using 64bit or larger salt.
5) anything which has less than 3 substitutions from something listed above (p@ssword! vs password)

The reality is end users likely don't know if their password is strong or not. So developers should prevent users from hurting themselves.  As a developer you can implement a large salt and could require a minimum of 8 characters (don't impose special char requirements).  At that point brute force and precomputation are off the table; so the largest risk comes from dictionary or modified dictionary attacks.  There are lists of millions of previously compromised passwords.  If the password used is on one of those lists it can be found in a matter of minutes.  If you are paranoid about your user's security you could check their password against a list of known compromised passwords.  An alternative would be for someone to develop a webservice which took a hash (HMAC) or all known/weak/compromised passwords.  Users could send a HMAC hash of their potential password and get a "known" or "good" response.

One further step you could take is key stretching using a key derivative function. The bitcoin wallet does this.  Rather than simply use the passphrase it takes multiple iterative hashes of the password (generally thousands of tens of thousands).   So instead of key = passphrase it is key = SHA256(SHA256(SHA256(passphrase))). This increases the length of time necessary to try one key and thus reduces the throughput of the attacker.   Understand that if user's password is very weak (under 6 char or on a dictionary list) this is unlikely to help because even 2000x a 1 sec search is unlikely to stop an attacker.

The key stretching function (hash) used by the wallet is SHA-256 which is well optimized due to this thing called mining.  Security could be enhanced by replacing the key strengthening function with another one (say bcrypt of even PBKDF2 using SHA-512 or RIPEMD).

http://en.wikipedia.org/wiki/Key_derivation_function
http://en.wikipedia.org/wiki/Key_stretching
http://en.wikipedia.org/wiki/PBKDF2
http://en.wikipedia.org/wiki/Bcrypt

TL/DR:
It depends. Using a combination of:
a) require at least 8 digits (makes brute force prohibitively expensive)
b) use a large (64bit+) random salt (prevents precomputation attacks)
c) check password against known/compromised password list that hackers are likely to be using (prevent quick dictionary based attacks)
d) use key strengthening (reduces the attackers throughput by a couple orders of magnitude).
e) use an algorithm other than SHA-256 in the KDF to prevent "re-use" or mining research

Thursday, 14 March 2013

EXPLANATION ABOUT ENCRYPTION,HASHING ALGORITHMS,SALTS AND DECRYPTION


EXPLANATION ABOUT ENCRYPTION,HASHING ALGORITHMS,SALTS AND DECRYPTION !!!!




1.Encryption&Hash

In cryptography, encryption is the process of transforming information (referred to as plaintext) using an algorithm (called cipher) to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key. The result of the process is encrypted information (in cryptography, referred to as ciphertext). In many contexts, the word encryption also implicitly refers to the reverse process, decryption (e.g. “software for encryption” can typically also perform decryption), to make the encrypted information readable again (i.e. to make it unencrypted). Hashing is a one way encryption. That means that it is not possible to use a reverse algorithm in order to come back from the hash to the password. Any way people found a way to crack hashes by using a bruteforce or dictionary attacks. Because of this hashing was made even more secure. After reading the whole tutorial you will get the point.

2.Hashing Algorithms

Cracking any hash is not that simple like running a bruteforcer. Sometimes a bruteforcer or a dictionary attack will do the job but only in a very rare situations where the algorithm is a plain md5 and where the hash is without salt. Plain md5 algorithm ? What does that mean ? Nowadays people use more complicated algorithms in order to increase the security. For example a plain md5 is an algorithm like this:


Code:
md5($pass)

What is this going to do ? This is going to make a md5 hash from the given pass. But what happens if you have something like this:

Code:
md5(md5($pass))

This makes first one md5 from the password and then another md5 hash from the new generated md5. So for example if the password is HI the results will be:

Code:
first one : md5("HI") = "bf8c144140b15befb8ce662632a7b76e"
second one: md5(md5"HI") = "ce8441edc9a85ed9839a849f99ed5ecc"

So as you can see for a same password we have two different MD5s. That is why when you are trying to crack a MD5 or any other hash ( the upper mentioned cases are the same for any other encryption out there ) it is very important to know the algorithm that was used to generate those hashes coz otherwise bruteforcing will have no sense and you will be stuck forever... There for always use a bruteforcer that allows you to enter the hash algorithm so that you can be sure that eventually you will find the password...

3. SALTS

What is a Salt ? Why do people use Salts ? Hashing became even more secure way of encrypting passwords with the use of Salts. Salt is actually a random pass phrase that is added to the main password. How it is added depends from the algorithm that was used. Salts are being used coz bruteforcing a salted hash without knowing the Salt is impossible. For example imagine that you have a password HI. See what happens in the next cases if we take 1234567890 for a salt:

Code:
md5($pass) => md5("HI") = "bf8c144140b15befb8ce662632a7b76e"
md5($pass,$salt) => md5("HI1234567890") = "4f4d880dbc772fb6acba84a98bce6136"

That is why cracking a salted hash without knowing the hash is impossible... But what happens if we know that salt ? Then we need to specify in our bruteforcer like previous mentioned the algorithm in our case => md5($pass,$salt) and we need to specify the salt. Knowing this the bruteforcer will perform the attack like a normal bruteforce except it will add the salt to every combination he makes. On the paper it goes like this :

Code:
A1234567890
AA1234567890
AAA1234567890
.
.
.

...and so on and so on. So basically every combination will end with 1234567890 and the only thing generated will be the thing before 1234567890. The use of Salts as you can see makes hashing even more secure.

4. Cracking

Cracking was mentioned during the whole tutorial but in here I will make a precise list of what you need to think before starting with decryption.

- First of all you need to figure out what type of hash do you have ( md5, sha1, mysql... )
- Then you need you need to see figure out if the hash is salted or not. If the hash is salted then you need the salt aswell
- Having the salt is not enough. You need to find the algorithm that was used. Only then you will be able to start with the decryption.
- If you came to all this things somehow you are ready to start with decryption.