Hướng dẫn how to decrypt hash password in php - cách giải mã mật khẩu băm trong php

Tôi cần giải mã mật khẩu. Mật khẩu được mật mã với chức năng password_hash.

$password = 'examplepassword';
$crypted = password_hash($password, PASSWORD_DEFAULT);

Tôi không rõ nếu bạn cần password_verify hoặc bạn đang cố gắng truy cập trái phép vào ứng dụng hoặc cơ sở dữ liệu. Những người khác đã nói về password_verify, vì vậy đây là cách bạn có thể truy cập trái phép. Đó là những gì kẻ xấu thường làm khi họ cố gắng truy cập vào một hệ thống.

Đầu tiên, tạo một danh sách các mật khẩu văn bản đơn giản. Một danh sách văn bản đơn giản có thể được tìm thấy ở một số nơi do vi phạm dữ liệu lớn từ các công ty như Adobe. Sắp xếp danh sách và sau đó chiếm 10.000 hoặc 100.000 hoặc hơn.

Thứ hai, tạo một danh sách các mật khẩu tiêu hóa. Chỉ cần mã hóa hoặc băm mật khẩu. Dựa trên mã của bạn ở trên, nó không giống như một loại muối đang được sử dụng (hoặc muối cố định). Điều này làm cho cuộc tấn công rất dễ dàng.

Thứ ba, đối với mỗi mật khẩu được tiêu hóa trong danh sách, hãy thực hiện chọn trong nỗ lực tìm người dùng đang sử dụng mật khẩu:

$sql_script = 'select * from USERS where password="'.$digested_password.'"'

Thứ tư, lợi nhuận.

Vì vậy, thay vì chọn người dùng và cố gắng đảo ngược mật khẩu của họ, kẻ xấu chọn mật khẩu chung và cố gắng tìm người dùng đang sử dụng nó. Tỷ lệ cược đứng về phía kẻ xấu ...

Bởi vì kẻ xấu làm những việc này, nó sẽ khiến bạn không cho phép người dùng chọn mật khẩu thông thường. Trong trường hợp này, hãy xem Procheck, Enfilter hoặc Hyppocrates (et al). Họ đang lọc các thư viện từ chối mật khẩu xấu. ProCheck đạt được nén rất cao và có thể tiêu hóa danh sách mật khẩu từ nhiều triệu từ vào tệp dữ liệu 30kb.not let users choose common passwords. In this case, take a look at ProCheck, EnFilter or Hyppocrates (et al). They are filtering libraries that reject bad passwords. ProCheck achieves very high compression, and can digest multi-million word password lists into a 30KB data file.

Giải mã mật khẩu: Để giải mã mật khẩu băm và truy xuất chuỗi gốc, chúng tôi sử dụng hàm password_verify (). Hàm password_verify () xác minh rằng băm đã cho khớp với mật khẩu đã cho, được tạo bởi hàm password_hash ().

Làm cách nào để xem mật khẩu được mã hóa? This uses the PHP Password API available in version 5.5.0 and above.

Bắt đầu bằng base64 giải mã mật khẩu được mã hóa và lưu nó vào một tệp mới: sau đó giải mã phiên bản được giải mã base64 của mật khẩu được mã hóa bằng OpenSSL: Cuối cùng, xem đầu ra được giải mã trong tệp văn bản: mật khẩu được giải mã (ABC123 trong trường hợp này) sẽ Ở gần đầu tệp trong Plaintext. To generate a hash from the string, we use the password_hash() function.

Syntax:

string password_hash(string $password, 
          mixed $algo, [array $options])

Mật khẩu_bcrypt là gì?password_hash() function creates a new password hash of the string using one of the available hashing algorithm. It returns the hash that is currently 60 character long, however, as new and stronger algorithms will be added to PHP, the length of the hash may increase. It is therefore recommended to allocate 255 characters for the column that may be used to store the hash in database.

Các thuật toán sau đây hiện đang được hỗ trợ khi sử dụng chức năng này:

  • PASSWORD_DEFAULT
  • PASSWORD_BCRYPT
  • PASSWORD_ARGON2I
  • PASSWORD_ARGON2ID

Các tùy chọn bổ sung có thể được chuyển cho chức năng này có thể được sử dụng để đặt chi phí mã hóa, muối sẽ được sử dụng trong quá trình băm, vv trong mảng Tùy chọn $.$options array.

Ví dụ dưới đây hiển thị phương thức sử dụng phương thức password_hash ():password_hash() method:

Example:

PHP

<?php

  $plaintext_password

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
0
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
1
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

  

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
4
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
5$plaintext_password
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
7

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
8
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
9

  

string password_hash(string $password, 
          mixed $algo, [array $options])
1
string password_hash(string $password, 
          mixed $algo, [array $options])
2
string password_hash(string $password, 
          mixed $algo, [array $options])
3
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
4
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

string password_hash(string $password, 
          mixed $algo, [array $options])
6

Output:

Tạo hàm băm: $ 2Y $ 10 $ 7RLSVRVYTQORAPKDOQMKHETJF6H9LJHNGR4HJMSM2LHOBJBW5EQH6

Giải mã mật khẩu: Để giải mã mật khẩu băm và truy xuất chuỗi gốc, chúng tôi sử dụng hàm password_verify (). To decrypt a password hash and retrieve the original string, we use the password_verify() function.

Syntax:

bool password_verify(string $password, string $hash)

Hàm password_verify () xác minh rằng băm đã cho khớp với mật khẩu đã cho, được tạo bởi hàm password_hash (). Nó trả về đúng nếu mật khẩu và băm phù hợp, hoặc sai.password_verify() function verifies that the given hash matches the given password, generated by the password_hash() function. It returns true if the password and hash match, or false otherwise.

PHP

<?php

  $plaintext_password

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
0
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
1
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

  

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
4
bool password_verify(string $password, string $hash)
5

bool password_verify(string $password, string $hash)
6
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

  

bool password_verify(string $password, string $hash)
9
Password Verified!
0$plaintext_password
Password Verified!
2
$sql_script = 'select * from USERS where password="'.$digested_password.'"'
4
Password Verified!
4

  

Password Verified!
6
Password Verified!
7
bool password_verify(string $password, string $hash)
9
Password Verified!
9

password_verify0____21 password_verify2

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

  password_verify55____56 password_verify7

password_verify0____21 password_verify0

$sql_script = 'select * from USERS where password="'.$digested_password.'"'
2

  password_verify3

string password_hash(string $password, 
          mixed $algo, [array $options])
6

Output:

Password Verified!

PHP là ngôn ngữ kịch bản phía máy chủ được thiết kế dành riêng cho phát triển web. Bạn có thể học PHP từ đầu bằng cách làm theo hướng dẫn PHP và các ví dụ PHP này.


Bạn có thể giải mã mật khẩu băm không?

Thuật toán mật mã MD5 không thể đảo ngược, tức là chúng ta không thể giải mã được giá trị băm do MD5 tạo ra để đưa đầu vào trở lại giá trị ban đầu của nó. Vì vậy, không có cách nào để giải mã mật khẩu MD5.there is no way to decrypt an MD5 password.

Bạn có thể bỏ mật khẩu trong PHP không?

Giải mã mật khẩu: Để giải mã mật khẩu băm và truy xuất chuỗi gốc, chúng tôi sử dụng hàm password_verify ().Hàm password_verify () xác minh rằng băm đã cho khớp với mật khẩu đã cho, được tạo bởi hàm password_hash ().To decrypt a password hash and retrieve the original string, we use the password_verify() function. The password_verify() function verifies that the given hash matches the given password, generated by the password_hash() function.

Làm cách nào để xem mật khẩu được mã hóa?

Bắt đầu bằng base64 giải mã mật khẩu được mã hóa và lưu nó vào một tệp mới: sau đó giải mã phiên bản được giải mã base64 của mật khẩu được mã hóa bằng OpenSSL: Cuối cùng, xem đầu ra được giải mã trong tệp văn bản: mật khẩu được giải mã (ABC123 trong trường hợp này) sẽỞ gần đầu tệp trong Plaintext. Then decrypt this base64 decoded version of the encrypted password using openssl: Finally, view the decrypted output in a text file: The decrypted password (abc123 in this case) will be near the start of the file in plaintext.

Mật khẩu_bcrypt là gì?

Mật khẩu_bcrypt được sử dụng để tạo băm mật khẩu mới bằng thuật toán Crypt_blowfish.Điều này sẽ luôn dẫn đến một hàm băm sử dụng định dạng mật mã "$ 2y $", luôn rộng 60 ký tự.Tùy chọn được hỗ trợ: Muối (chuỗi) - Để cung cấp muối theo cách thủ công khi sử dụng khi băm mật khẩu.used to create new password hashes using the CRYPT_BLOWFISH algorithm. This will always result in a hash using the "$2y$" crypt format, which is always 60 characters wide. Supported Options: salt (string) - to manually provide a salt to use when hashing the password.