Analysis of developers' basic knowledge about hash and cracking methods

Source: Internet
Author: User

Analysis of developers' basic knowledge about hash and cracking methods

A hash password refers to a messy string formed by one-time encryption of the password. This encryption process is considered irreversible, that is, the original password cannot be restored from the hash string.


Password hash is not a common topic, but it is becoming more and more popular now. Although it is not the only method that can ensure the security of your online applications, it is one of the many security measures. Every security-aware developer should consider this issue. In this article, we will discuss the knowledge about password hashing. We will explain the hash function and tell you why your application needs to use password hashing.
  

Whenever we want to discuss security issues, we always have a question: What are the security threats we want to defend against? For Password Hashing, The answer is certainly not satisfactory: what we are trying to do is: When all the passwords stored in your website database are stolen, how can we mitigate the impact of such incidents on people. Generally, if an attacker successfully enters the target database, many data in the database may be stolen, which is also a nightmare of every information security practitioner.
  

However, the most important thing for developers is not to forget that a dozen of related security functions need to be added to the program during software development. (For example, TLS encryption)
Attacks on passwords without hash Processing
Now let's discuss what will happen if attackers have obtained your password database? What can attackers do with this data? In fact, all related attacks are related to recovering the user password, because the attacker can perform the next step only after obtaining the user password.
If your database stores a plaintext password, you don't have to struggle. The attacker has obtained all user passwords and can start to do whatever he wants. This is terrible.
Try 1 #: simple password hash
You might think: "Hi, as long as we use SHA256 algorithms (or SHA-3, or some other secure hashing algorithms) to hash the passwords, then everything doesn't exist ." If you think so, problems will occur sooner or later. However, the real situation is often more complicated.
For example, we have made the current situation more concrete. What happens when you use the following hash function to process the Stored Password?
1p' = SHA256 (P )(*)
P indicates the password, and P indicates the password stored in the database.
Dictionary attack
Assume that the attacker has obtained all the passwords stored in the database, and the password in the database only uses SHA256 for hash encryption, as shown in the formula (*) listed above (*). So what can attackers do with the stolen password data?
First, he can obtain a dictionary file that records a large number of frequently-used passwords, and then use the passwords in the dictionary to try in sequence. That is to say, attackers can use the SHA256 algorithm to hash the passwords in the dictionary, and then compare the hash with the passwords stored in the database (this is what we call "dictionary attack ").
Note that using the simple P '= SHA256 (P) function for hash processing means that the same "P" value is calculated after the formula, the same "P" will be obtained '". That is to say, after the same password is hashed, the generated password hash is also the same.
In this way, attackers can use the SHA256 algorithm to hash all common passwords in advance, and then after the attacker successfully obtains the data in the database, we can use these pre-computed hash passwords for comparison. Compared with passwords without hash processing, password hash will increase the difficulty for attackers to crack passwords. Therefore, simple hash of passwords is always much safer than passwords without hash, but this technology still has a lot of room for improvement.
Try 2 #: Hash By Salted
After the same password is hashed, the obtained password hash is the same. To solve this problem, we need to Salted the password hash, that is, "hash and salt ".
The working mechanism of this method is: Before we calculate the corresponding "P", we store a corresponding "S" value (that is, the salt value) for each user's password ). Before we store the user password in the database, we need to use the following formula for calculation:
1p' = SHA256 (S | P)
"|" Indicates the connection (for example, cascade of strings or data blocks ).
As long as the user's "S" value is different from other users, even if different users use the same password, the calculated password hash value will not be the same. So this means that the hash of the password calculated by the attacker will not be available, and the dictionary attack will become invalid. In fact, the "hash and salt adding method" we introduced can also defend against some other "pre-computing" attacks, including the so-called "rainbow table attack.
Another question we need to consider is what kind of "Salt" is used ". First, the "S" value used by each user must be unique. This means that if the random Salt value you are using is long enough, you do not need to check the uniqueness of the Salt value.
  

Offline brute-force cracking attacks on Hash Functions
Even if we add "Salt" to hash the password, we only use the dictionary password. Attackers still have other methods to crack our password database.
I am referring to offline brute-force cracking attacks. Note that this method is different from online brute-force cracking. When attackers use online brute-force cracking to attack the database, they only need to constantly try to log on to the password. However, we can set the logon Failure count limit or the interval between password attempts to prevent such attacks.



To launch offline brute-force password cracking attacks, attackers must first obtain the database that stores passwords, or at least one of the user passwords or "salt" values. After obtaining the information, attackers can use the formula SHA256 (S | P) to calculate the passwords and Salt values. If the calculation result matches the "P" value, the attack succeeds. The "P" used in this calculation is the user's real password.
What will happen in the future
Everything may change in the future. Recently, a large number of security researchers are looking for a more effective way to hash passwords. In the near future, researchers are likely to propose a new cryptographic hash algorithm. If so, such a new hash algorithm may be more secure.
 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.