Skip to content

Instantly share code, notes, and snippets.

@tsmolka
Created January 31, 2017 16:07
Show Gist options
  • Save tsmolka/bff25dcabfb98f55131f0dee91e6f2d1 to your computer and use it in GitHub Desktop.
Save tsmolka/bff25dcabfb98f55131f0dee91e6f2d1 to your computer and use it in GitHub Desktop.
Quick & dirty script for decrypting HP Bios passwords created by HpqPswd.exe
import argparse, struct
from Crypto.Cipher import AES
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='HpqPswd Decryptor')
parser.add_argument('-f', '--file', required=True, help='Input file')
parser.add_argument('-k', '--key', default='4a14........................................................1e33')
args = parser.parse_args()
f = open(args.file, 'rb')
if f.read(8) != '_HPPW12_':
raise Exception('Wrong magic')
cipher = AES.new(args.key.decode('hex'), AES.MODE_CBC, '\0'*AES.block_size)
length, = struct.unpack('<H', f.read(2))
print cipher.decrypt(f.read(length))
@doomfrawen
Copy link

For some reason, I am getting "TypeError: Non-hexadecimal digit found" when I try to decrypt the file.
Has the format of the file changed?

@tsmolka
Copy link
Author

tsmolka commented Sep 17, 2020

Please make sure you are passing correct key as an argument.

@accelerate-science
Copy link

Hi Tobias, I have an old HP Omnibook 300 that is password-locked. When I press Shift-F10 I get a scrambled version of the password. However HP can't descramble it due to this being an old laptop from 1993. Do you know how I could go about descrambling the password on this old machine? Thanks!

@tsmolka
Copy link
Author

tsmolka commented Jan 4, 2024

@accelerate-science , this script is for decrypting files that start with magic string HPPW12. Similar to the process in this writeup: https://www.serializing.me/2016/10/15/hpqpswd-encrypted-passwords-decryption/. I don't think it will apply to your situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment