We know that if the password is hashed directly, then the hacker can get a hash value by obtaining this password, and then by checking the hash value dictionary (for example, MD5 password cracking site), the password of a user.
Adding salt can solve this problem to some extent. The so-called salt method is adding "seasoning". The basic idea is this: when the user first provides the password (usually at the time of registration), the system automatically sprinkle some "seasoning" into this password, and then hash. When the user logs in, the system provides the user with the same "seasoning" code, then hash, and then compare the hash value, determined whether the password is correct.
The "seasoning" here is called the "salt value", which is generated randomly by the system and is only known to the system. This way, even if two users use the same password, their hash values are different because the system produces a different salt value for them. Even if a hacker can find a user with a specific password by their own password and the hash value they generate, the odds are too small (passwords and salt are just as good as hackers).
The following PHP example explains the MD5 ($pass. $salt) Cryptographic functions.
<?php
function hash ($a) {
$salt = "Random_kugbjvy"; Defines a salt value, a random string that the programmer prescribes
$b = $a. $salt; Connect the password and salt
$b =md5 ($b); Perform MD5 hashing
return $b; return Hash
}
?>
Call mode: $new _password=hash ($_post[password]); The form submission value is accepted here and encrypted
The process of adding salt hashes is described in more detail below. Before the introduction, it is emphasized that the "same" seasoning is used when verifying the password and initially hashing the password. So the salt value is to be stored in the database.
When the user registers,
- User input "account" and "password" (and other user information);
- The system generates a "salt value" for the user;
- The system connects the "salt value" and "User password" together;
- Hashes the concatenated values to obtain a "hash value";
- Place "Hash value 1" and "salt value" in the database respectively.
When a user logs on,
- User input "account" and "password";
- The system uses the user name to find the corresponding "hash value" and "Salt value";
- The system connects the "salt value" and "User entered password" together;
- Hash the concatenated values to get a "hash value of 2" (note that the value is calculated immediately);
- Compare "hash value 1" and "hash value 2" for equality, which means the password is correct, otherwise the password is incorrect.
Sometimes, in order to reduce development pressure, programmers use a single salt value (stored somewhere) instead of each user generating a private salt value.
--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------
Have you ever met a MD5 value that can't be cracked? Have you ever met the ' grotesque ' hash? These are very likely to be with salt (commonly known as salt value), this article will give you a brief introduction of the salt value of some information.
0x01. What is the salt-adding value?
In order to enhance the security of the MD5 (itself is irreversible), thus adding a new algorithm part is added salt value, the salt value is randomly generated a set of strings, can include random uppercase and lowercase letters, numbers, characters, the number of digits can be different according to the requirements, the use of salt value generated by the final ciphertext is not the same.
0x02. How do I use salt values in my code?
Because the use of salt value after the password is quite safe, even if you get the salt and the final ciphertext, the crack is also a time-consuming process, can be said to crack the simple MD5 several times, then the use of salt value after the ciphertext is how to produce it?
1). First we get the hash value of the plaintext.
2). Calculate to get MD5 plaintext hash value
3). Randomly generate salt values and insert
4). MD5 insert salt worth of hash
5). Get the final redaction
0x03. How to decipher a cipher with a salt value
Because like Windows hash (not SYSKEY encryption), non-salt value MD5, etc. can be compared by large password (such as Rainbow table) table for comparison and decryption, so relatively easy, and with salt value of the ciphertext is relatively more complex, now the MD5 table is probably 260+g, How to add salt value of the possibility of 10,000, then the password table should be MD5 size*10000, you can decrypt the original MD5 table can decrypt the password, some sites also provide the corresponding salt decryption, but the test after the effect is not very good, such as the regular admin888 is not decrypted , it is regrettable, after all, MD5 is irreversible, the probability of bringing in random values to decrypt the final password is even lower, at least relative to most people.
0x04. Application of MD5 algorithm with added salt value
Currently, a number of Web application companies have joined the algorithm, such as the Common VBB Forum, Discuz Forum and so on, and even the famous Linux open source operating system has been added to this encryption mode. This algorithm is bound to be used in more areas in the future.
*0x05. How do I penetrate a site with salt values (actual case)?
This piece of information is derived from my recent actual infiltration of fragments, because through a variety of ways can not be decrypted with salt value of the cipher, so can only be broken through other means, the change administrator password to operate, but the site is through a number of Web site comparison password form, such as station A and station B, if I modify the station a password, Once the comparison station A and station B, then will be prompted not to login, because I only have a station management permissions, then this is very troublesome, one is the ciphertext can not be cracked, but change the password is invalid. So what should we do with it? Here is a brief description of the method I applied here:
1). Modify the admin uid to a value that is not enabled
2). Change your registered user to the value of admin uid
Re-login, and successfully obtain permissions, because in the station a Chinese based on the UID to assign permissions, that is, to a UID administrator permissions, how to easily get to administrator rights.
(turn) A brief talk on salt-adding value in MD5 encryption Algorithm (SALT)