Re-worked based on discovery of VMX sandbox

This commit is contained in:
David Parsons 2016-12-29 13:34:56 +00:00
parent 7524b414cf
commit dba3097137
6 changed files with 37 additions and 12 deletions

BIN
dumpsmc.exe Executable file

Binary file not shown.

View File

@ -8,25 +8,49 @@ formatting or comments.
"""
from __future__ import print_function
import sys
def testline(line, test):
sline = line.lstrip()
if sline == test:
return True
else:
return False
def main():
vmsvc = ' <vmsvc>\n'
sandbox = ' <useVmxSandbox>false</useVmxSandbox>\n'
vmsvc = '<vmsvc>\n'
sandbox = '<useVmxSandbox>false</useVmxSandbox>\n'
with open('/etc/vmware/hostd/config.xml', 'r+') as f:
data = f.readlines()
i = data.index(vmsvc)
try:
j = data.index(sandbox)
except ValueError:
j = 0
# Search for the relevant XML tags
i = 0
vmsvcindex = 0
sandboxindex = 0
for line in data:
if testline(line, vmsvc):
vmsvcindex = i
if testline(line, sandbox):
sandboxindex = i
# print(line, end='')
i += 1
# Simple toggle on or off depending if found
if j == 0:
data.insert(i+1, sandbox)
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:
del data[j]
pass
# Rewrite the config.xml file
f.seek(0)
@ -34,5 +58,6 @@ def main():
f.truncate()
f.close()
if __name__ == '__main__':
main()

View File

@ -13,6 +13,6 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
echo Installing local.sh
chmod +x local.sh
cp local.sh /etc/rc.local.d/local.sh
python esxi-config.py
python esxi-config.py insert
backup.sh 0
echo Success - please now restart the server!

View File

@ -11,6 +11,6 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
echo Uninstalling local.sh
cp /etc/rc.local.d/.#local.sh /etc/rc.local.d/local.sh
python esxi-config.py
python esxi-config.py delete
backup.sh 0
echo Success - please now restart the server!

BIN
gettools.exe Executable file

Binary file not shown.

BIN
unlocker.exe Executable file

Binary file not shown.