Skip to content

Commit

Permalink
Re-worked based on discovery of VMX sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDonk committed Dec 28, 2016
1 parent b13e0dd commit 22003b1
Show file tree
Hide file tree
Showing 11 changed files with 627 additions and 81 deletions.
5 changes: 3 additions & 2 deletions dumpsmc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
The MIT License (MIT)
Expand All @@ -22,14 +23,14 @@
THE SOFTWARE.
vSMC Header Structure
Offset Length struct Type Description
Offset Length Struct Type Description
----------------------------------------
0x00/00 0x08/08 Q ptr Offset to key table
0x08/08 0x04/4 I int Number of private keys
0x0C/12 0x04/4 I int Number of public keys
vSMC Key Data Structure
Offset Length struct Type Description
Offset Length Struct Type Description
----------------------------------------
0x00/00 0x04/04 4s int Key name (byte reversed e.g. #KEY is YEK#)
0x04/04 0x01/01 B byte Length of returned data
Expand Down
12 changes: 12 additions & 0 deletions esxi-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e
#set -x

# Ensure we only use unmodified commands
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Copy patch to local.sh
cp local-prefix.sh local.sh
cat unlocker.py >> local.sh
cat local-suffix.sh >> local.sh
chmod +x local.sh
38 changes: 38 additions & 0 deletions esxi-config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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


def main():
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

# Simple toggle on or off depending if found
if j == 0:
data.insert(i+1, sandbox)
else:
del data[j]

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

if __name__ == '__main__':
main()
49 changes: 5 additions & 44 deletions esxi-install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
set -e
set -x
#set -x

echo VMware Unlocker 2.0.9
echo ===============================
Expand All @@ -9,49 +9,10 @@ echo Copyright: Dave Parsons 2011-16
# Ensure we only use unmodified commands
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Ensure we run from the patcher directory
cd "`dirname $0`"

# Create tmp folder for patching the files
echo Creating unlocker vmtar disk

# Create tmp folder for patching the files
mkdir -p tmp/bin
mkdir -p tmp/lib

cp -v /bin/vmx tmp/bin
cp -v /bin/vmx-debug tmp/bin
cp -v /bin/vmx-stats tmp/bin

# Now using sed in the local.sh script
#cp -v /lib/libvmkctl.so tmp/lib
#
#if [ -f /lib64/libvmkctl.so ]; then
# mkdir -p tmp/lib64
# cp -v /lib64/libvmkctl.so tmp/lib64
#fi

# Patch the files
python unlocker.py

# Create the vmtar file for ESXi kernel
#if [ -f /lib64/libvmkctl.so ]; then
# tar cvf tmp/unlocker.tar -C tmp bin lib lib64
#else
# tar cvf tmp/unlocker.tar -C tmp bin lib
#fi
tar cvf tmp/unlocker.tar -C tmp bin
vmtar -c tmp/unlocker.tar -v -o tmp/unlocker.vmtar
gzip tmp/unlocker.vmtar
mv tmp/unlocker.vmtar.gz tmp/unlocker.vgz

# Copy to bootbank and setup local.sh
echo Copying unlocker.vgz to bootbank...
cp tmp/unlocker.vgz /bootbank
# Copy patch to local.sh
echo Installing local.sh
chmod +x local.sh
cp local.sh /etc/rc.local.d/local.sh

# Clean up
#rm -rfv tmp

python esxi-config.py
backup.sh 0
echo Success - please now restart the server!
13 changes: 6 additions & 7 deletions esxi-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
set -e
set -x
#set -x

echo VMware Unlocker 2.0.9
echo ===============================
Expand All @@ -9,9 +9,8 @@ echo Copyright: Dave Parsons 2011-16
# Ensure we only use unmodified commands
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

# Remove entry from the boot configuration file
echo Deleting unlocker.vgz from bootbank...
rm /bootbank/unlocker.vgz
rm /etc/rc.local.d/local.sh

echo Please now reboot the host system!
echo Uninstalling local.sh
cp /etc/rc.local.d/.#local.sh /etc/rc.local.d/local.sh
python esxi-config.py
backup.sh 0
echo Success - please now restart the server!
1 change: 1 addition & 0 deletions gettools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
The MIT License (MIT)
Expand Down
65 changes: 65 additions & 0 deletions local-prefix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh
set -e
set -x

echo VMware ESXi 6.x Unlocker 2.0.9
echo ===============================
echo Copyright: Dave Parsons 2011-16

# Ensure we only use unmodified commands
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
exit 0
fi

# Make sure working files are removed
if [ -d /unlocker ]; then
logger -t unlocker Removing current patches
rm -rfv /unlocker
fi

# Create new RAM disk and map to /unlocker
logger -t unlocker Creating RAM disk
mkdir /unlocker
localcli system visorfs ramdisk add -m 200 -M 200 -n unlocker -p 0755 -t /unlocker
logger -t unlocker Stopping hostd daemon
/etc/init.d/hostd stop

# Copy the vmx files
logger -t unlocker Copying vmx files
mkdir /unlocker/bin
cp /bin/vmx /unlocker/bin/
cp /bin/vmx-debug /unlocker/bin/
cp /bin/vmx-stats /unlocker/bin/

# Setup symlink from /bin
logger -t unlocker Setup vmx sym links
rm -fv /bin/vmx
ln -s /unlocker/bin/vmx /bin/vmx
rm -fv /bin/vmx-debug
ln -s /unlocker/bin/vmx-debug /bin/vmx-debug
rm -fv /bin/vmx-stats
ln -s /unlocker/bin/vmx-stats /bin/vmx-stats

# Copy the libvmkctl.so files
logger -t unlocker Copying 32-bit lib files
mkdir /unlocker/lib
cp /lib/libvmkctl.so /unlocker/lib/
logger -t unlocker Setup 32-bit lib sym links
rm -fv /lib/libvmkctl.so
ln -s /unlocker/lib/libvmkctl.so /lib/libvmkctl.so
if [ -f /lib64/libvmkctl.so ]; then
logger -t unlocker Copying 64-bit lib files
mkdir /unlocker/lib64
cp /lib64/libvmkctl.so /unlocker/lib64/
logger -t unlocker Setup 64-bit lib sym links
rm -fv /lib64/libvmkctl.so
ln -s /unlocker/lib64/libvmkctl.so /lib64/libvmkctl.so
fi

# Patch the vmx files
logger -t unlocker Patching vmx files
python <<END
4 changes: 4 additions & 0 deletions local-suffix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
END
logger -t unlocker Starting hostd daemon
/etc/init.d/hostd start
exit 0
Loading

0 comments on commit 22003b1

Please sign in to comment.