we care because you do

EFIPW Apple EFI Firmware Password Changer 0.2a

EFIPW Apple EFI Firmware Password Changer 0.2a
Posted Jan 31, 2010
Authored by Paul Makowski | Site code.google.com

EFIPW is a tool that can be used to decode and modify Apple EFI firmware passwords via the command line. It is designed after the non open source OFPW utility and is designed to work on Intel machines running Leopard or newer. Useful for lab deployments (setting the firmware password of machines as a post install item) and pen tests (recovering the EFI firmware password).

Changes: Complete Python rewrite. Works on Snow Leopard again.
tags | tool
systems | unix, apple
MD5 | 6030703961e116d32142225363680439

EFIPW Apple EFI Firmware Password Changer 0.2a

Change Mirror Download
#!/usr/bin/env python
"""
EFIPW (C) 2010 by Paul Makowski (my.hndl@gmail.com)
http://code.google.com/p/efipw/
http://paulmakowski.wordpress.com/

License:
GPLv3

Warranty:
Unless otherwise stated, this software is distributed
in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THERE IS
NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS PROVIDE THE SOFTWARE "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD
THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

About:
EFIPW is a tool to modify and/or decode firmware passwords stored on EFI-based Apple
computers in nvram. It may be useful for both lab administrators and pen testers.
It was inspired by the OPFW tool. Requires root permissions.

If you find this software useful, I would appreciate it if you let me know, but
you're certainly not required to.

Usage:
./efipy.py -h

Modes:
none: Firmware password is ignored, all boot actions allowed (single user, boot off external, etc). This is the default.
command: Firmware password enforced if user requests to boot off another device by holding down 'alt' during boot.
Single user, target disk mode, etc disabled. This is the default when passwords are set.
full: All actions are disallowed, unless correct password is entered (including normal boot to blessed drive).

Changelog:
0.1: initial release
0.1a: re-release (i put the wrong binary in the .zip file)
0.2: complete rewrite in Python (for simplicity, maintainability & 10.6 support)
0.2a: if new password is set and mode is not, default mode to "command"
"""
from optparse import OptionParser
import os
import binascii

parser = OptionParser(version="%prog 0.2a")

if os.geteuid(): parser.error("Must be run as root. (e.g. sudo ./efipw.py [options])")

parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help="suppress confirmation messages")
parser.add_option("-d", "--decode", action="store_true", dest="decode", default=False, help="decode current EFI password")
parser.add_option("-p", "--password", dest="newPassword", metavar="PASSWORD", type="string", help="set new EFI password")
parser.add_option("-m", "--mode", dest="newMode", metavar="MODE", type="string", help="set new EFI mode [none, command, full]")

(options, args) = parser.parse_args()


# lolCrypt: Apple's lolzy encryption function
def lolCrypt(input):
output = ""
for i in range(0, len(input)): output += (chr(ord(input[i]) ^ 170)) # 170 in decimal is 10101010 in binary; this is the key...don't tell anyone ;)
return output

def splitLen(seq, length): return [seq[i:i+length] for i in range(0, len(seq), length)]


# REVEAL CURRENT PASSWORD
if options.decode:

# get the current (encoded) password
p = os.popen('nvram -p | grep security-password',"r")
curPassword = p.readline().strip()

print lolCrypt(binascii.unhexlify(curPassword[curPassword.find('%'):].replace('%', '')))



# SET NEW PASSWORD
if options.newPassword:

# set mode to command if not specified
if not options.newMode: options.newMode = "command"

if len(options.newPassword) > 48: print "Password cannot be longer than 48 characters; new password not set."

# set new password
else:

# prep the password
newPassword = splitLen(binascii.hexlify(lolCrypt(options.newPassword)), 2)
for i in range(len(newPassword)): newPassword[i] = '%' + newPassword[i]
newPassword = ''.join(newPassword)

# set the password
p = os.popen('nvram security-password=' + newPassword,"r")
if not options.quiet: print 'EFI password set.'



# SET NEW MODE
if options.newMode:

# validate mode
if options.newMode not in ["none", "command", "full"]: print "Invalid mode '" + options.newMode + "' specified; mode not set."

else:
p = os.popen('nvram security-mode=' + options.newMode,"r")
if not options.quiet: print 'EFI mode set.'



Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    11 Files
  • 27
    May 27th
    8 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close