(MySQL) UNION and breaking password hashes
Hash algorithms
Fortunately, it is now quite rare that applications store users' passwords in plain text in a database. In such a case, an attacker who manages to steal the database would have a bunch of passwords to try, for example, in users' accounts on other services (which is why passwords should not be reused).
Instead, passwords are usually "hashed", meaning they are run through a one-way hashing algorithm, such as MD5, SHA1, etc.
For example, the MD5 hash of the text "kissa123" is 13c3a117d0013ab22417c8edca354b76. The application could then save it to the user's database as follows:
Email: [email protected]
PasswordHash: 13c3a117d0013ab22417c8edca354b76
When Jaska Jokunen logs in, the application verifies if MD5(Jaska's entered password) is equal to the password hash saved in the database.
An attacker, on the other hand, cannot directly change the hash 13c3a117d0013ab22417c8edca354b76 back to the form "kissa123". Hash algorithms are one-way.
However, an attacker can guess with brute force and wordlists.
- Is "pokemon" hash 13c3a117d0013ab22417c8edca354b76? No.
- Is "kitara456" hash 13c3a117d0013ab22417c8edca354b76? No.
- Is "cat123" hash 13c3a117d0013ab22417c8edca354b76? Yes.
This kind of guessing is usually called password cracking.
Learn to hack — start here
Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.