Skip to content

Commit

Permalink
Updates for 2.0.9 RC3
Browse files Browse the repository at this point in the history
  • Loading branch information
David Parsons committed Sep 27, 2017
1 parent 409f9a9 commit fcc21ab
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dumpsmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def dumpsmc(name):
print('appleSMCTableV0 Table : ' + hex(smc_key1))
dumpkeys(f, smc_key1)

print('xxxx')
print()

# Print vSMC1 tables and keys
print('appleSMCTableV1 (smc.version = "1")')
Expand Down
1 change: 1 addition & 0 deletions esxi-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Copy patch to local.sh
rm -fv local.sh
cp local-prefix.sh local.sh
cat unlocker.py >> local.sh
cat local-suffix.sh >> local.sh
Expand Down
50 changes: 37 additions & 13 deletions esxi-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def testline(line, test):

def main():
vmsvc = '<vmsvc>\n'
sandbox = '<useVmxSandbox>false</useVmxSandbox>\n'
starttag = '<useVmxSandbox>'
endtag = '</useVmxSandbox>'

with open('/etc/vmware/hostd/config.xml', 'r+') as f:
# with open('/etc/vmware/hostd/config.xml', 'r+') as f:
with open('samples/config.xml', 'r+') as f:
data = f.readlines()

# Search for the relevant XML tags
Expand All @@ -35,29 +37,51 @@ def main():
if testline(line, vmsvc):
vmsvcindex = i

if testline(line, sandbox):
if testline(line, starttag):
sandboxindex = i

# print(line, end='')
i += 1

# Simple toggle on or off depending if found
if sandboxindex != 0 and sys.argv[1] == 'delete':
print('Removing useVmxSandbox')
del data[sandboxindex]
elif sandboxindex == 0 and sys.argv[1] == 'insert':
print('Adding useVmxSandbox')
pad = len(data[vmsvcindex + 1]) - len(data[vmsvcindex + 1].lstrip())
data.insert(vmsvcindex + 1, (" " * pad) + sandbox)
else:
# If vmsvc tag not found then file is probably corrupt
if vmsvcindex is None:
print('ESXi Config - config.xml is corrupt')
return False

# Remove the existing line if prsent
del data[sandboxindex]

# Now add line with correct flag
pad = len(data[vmsvcindex + 1]) - len(data[vmsvcindex + 1].lstrip())

if sys.argv[1] in ['on', 'off']:
pass

if sys.argv[1] == 'off':
print('ESXi Config - useVmxSandbox off')
data.insert(vmsvcindex + 1, (" " * pad) + sandboxoff)

elif sys.argv[1] == 'on':
print('ESXi Config - useVmxSandbox on')
data.insert(vmsvcindex + 1, (" " * pad) + sandboxon)

else:
print('ESXi Config - Incorrect paramter passed')
return False

# Rewrite the config.xml file
f.seek(0)
f.write(''.join(data))
f.truncate()
f.close()
return True


if __name__ == '__main__':
main()

if len(sys.argv) == 1:
sys.exit(1)
if main():
sys.exit(0)
else:
sys.exit(1)
2 changes: 1 addition & 1 deletion local-prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Exit if boot option specified
if bootOption -o | grep -q 'nounlocker'; then
logger -t unlocker Disbaled via nounlocker boot option
logger -t unlocker disabled via nounlocker boot option
exit 0
fi

Expand Down
11 changes: 6 additions & 5 deletions local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Exit if boot option specified
if bootOption -o | grep -q 'nounlocker'; then
logger -t unlocker Disbaled via nounlocker boot option
logger -t unlocker disabled via nounlocker boot option
exit 0
fi

Expand Down Expand Up @@ -107,6 +107,7 @@ Offset Length Struct Type Description
"""
from __future__ import print_function
import codecs
import os
import sys
import struct
Expand All @@ -125,8 +126,8 @@ if sys.platform == 'win32' \
def rot13(s):
chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
trans = chars[26:] + chars[:26]
rot_char = lambda c: trans[chars.find(c)] if chars.find(c) > -1 else c
return ''.join(rot_char(c) for c in s)
rotchar = lambda c: trans[chars.find(c)] if chars.find(c) > -1 else c
return ''.join(rotchar(c) for c in s)
def bytetohex(data):
Expand Down Expand Up @@ -237,7 +238,7 @@ def patchkeys(f, key):
# Write new data for key
f.seek(offset + 24)
smc_new_data = rot13('bheuneqjbexolgurfrjbeqfthneqrqcy')
smc_new_data = codecs.encode('bheuneqjbexolgurfrjbeqfthneqrqcy', 'rot_13')
f.write(smc_new_data.encode('UTF-8'))
f.flush()
Expand All @@ -259,7 +260,7 @@ def patchkeys(f, key):
# Write new data for key
f.seek(offset + 24)
smc_new_data = rot13('rnfrqbagfgrny(p)NccyrPbzchgreVap')
smc_new_data = codecs.encode('rnfrqbagfgrny(p)NccyrPbzchgreVap', 'rot_13')
f.write(smc_new_data.encode('UTF-8'))
f.flush()
Expand Down
9 changes: 5 additions & 4 deletions unlocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"""

from __future__ import print_function
import codecs
import os
import sys
import struct
Expand All @@ -60,8 +61,8 @@
def rot13(s):
chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
trans = chars[26:] + chars[:26]
rot_char = lambda c: trans[chars.find(c)] if chars.find(c) > -1 else c
return ''.join(rot_char(c) for c in s)
rotchar = lambda c: trans[chars.find(c)] if chars.find(c) > -1 else c
return ''.join(rotchar(c) for c in s)


def bytetohex(data):
Expand Down Expand Up @@ -172,7 +173,7 @@ def patchkeys(f, key):

# Write new data for key
f.seek(offset + 24)
smc_new_data = rot13('bheuneqjbexolgurfrjbeqfthneqrqcy')
smc_new_data = codecs.encode('bheuneqjbexolgurfrjbeqfthneqrqcy', 'rot_13')
f.write(smc_new_data.encode('UTF-8'))
f.flush()

Expand All @@ -194,7 +195,7 @@ def patchkeys(f, key):

# Write new data for key
f.seek(offset + 24)
smc_new_data = rot13('rnfrqbagfgrny(p)NccyrPbzchgreVap')
smc_new_data = codecs.encode('rnfrqbagfgrny(p)NccyrPbzchgreVap', 'rot_13')
f.write(smc_new_data.encode('UTF-8'))
f.flush()

Expand Down

0 comments on commit fcc21ab

Please sign in to comment.