forked from theJaxon/unlocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This is a simple method to modify the hostd XML file | ||
Not using XML on ESXi Python as it does not preserve | ||
formatting or comments. | ||
(This could be sed but cannot find a suitable regex.) | ||
""" | ||
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' | ||
|
||
with open('/etc/vmware/hostd/config.xml', 'r+') as f: | ||
data = f.readlines() | ||
|
||
# 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 sandboxindex != 0 and sys.argv[1] == 'off': | ||
print('Removing useVmxSandbox') | ||
del data[sandboxindex] | ||
elif sandboxindex == 0 and sys.argv[1] == 'on': | ||
print('Adding useVmxSandbox') | ||
pad = len(data[vmsvcindex + 1]) - len(data[vmsvcindex + 1].lstrip()) | ||
data.insert(vmsvcindex + 1, (" " * pad) + sandbox) | ||
else: | ||
pass | ||
|
||
# Rewrite the config.xml file | ||
f.seek(0) | ||
f.write(''.join(data)) | ||
f.truncate() | ||
f.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo on | ||
rd /s /q build | ||
rd /s /q dist | ||
del *.spec | ||
pyinstaller --onefile dumpsmc.py | ||
pyinstaller --onefile gettools.py | ||
pyinstaller --onefile unlocker.py | ||
xcopy /y dist\*.exe . | ||
rd /s /q build | ||
rd /s /q dist | ||
del *.spec |