Skip to content

Instantly share code, notes, and snippets.

@ao
Forked from nathany/decode_firmware_pwd.py
Created September 30, 2018 16:54
Show Gist options
  • Select an option

  • Save ao/eef2d3d6de4b6a3b8b70c533be121a87 to your computer and use it in GitHub Desktop.

Select an option

Save ao/eef2d3d6de4b6a3b8b70c533be121a87 to your computer and use it in GitHub Desktop.

Revisions

  1. @nathany nathany created this gist Jun 16, 2011.
    16 changes: 16 additions & 0 deletions decode_firmware_pwd.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # I forgot the firmware password on my MacBook Air and didn't want to take it in:
    # http://support.apple.com/kb/TS2391
    # info
    # http://paulmakowski.blogspot.com/2009/03/apple-efi-firmware-passwords.html

    # run the following command to retrieve your obfuscated firmware password:
    # sudo nvram -p | grep security-password
    security_password = "%..."

    # take the complement of every second bit:
    decode_byte = lambda byte: chr(int(byte, 16) ^ int('10101010',2))

    # decode the security password, which contains %-prefixed hex values:
    decode = lambda pwd: "".join([decode_byte(x) for x in pwd.split('%') if x != ''])

    print(decode(security_password))