Make sure the wallet is in Bitcoin Core or any other wallet software while you work with the file, as the program may lock the file and prevent access.
:
Always perform these operations offline to prevent your extracted hash—and potential password—from being stolen.
python3 wallet2john.py old_walletbackup.dat >> hashes.txt
Place your wallet.dat and bitcoin2john.py in the same folder to make the command line work easier. Step B: Run the Script
To extract a password hash from a wallet.dat file for recovery or auditing, you typically use a specialized script to convert the binary file into a format readable by tools like John the Ripper Stack Overflow Top Tools for Hash Extraction bitcoin2john.py : Part of the John the Ripper (JtR)
python3 bitcoin2john.py wallet.dat > wallet.hash