Skip to content

Commit

Permalink
Work on a dynamic darwin.iso fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
I049299 authored and I049299 committed Oct 10, 2015
1 parent 153f0a5 commit 258b81c
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 45 deletions.
1 change: 1 addition & 0 deletions dumpsmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
sys.stderr.write('You need Python 2.7 or later\n')
sys.exit(1)


def bytetohex(bytestr):
return ''.join(['%02X ' % ord(x) for x in bytestr]).strip()

Expand Down
2 changes: 1 addition & 1 deletion esxi-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
2 changes: 1 addition & 1 deletion esxi-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
54 changes: 54 additions & 0 deletions gettools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import urllib
import urllib2
from HTMLParser import HTMLParser
import shutil
import tarfile
import zipfile


# Parse the Fusion directory page
class myHTMLParser(HTMLParser):

def __init__(self):
self.reset()
self.HTMLDATA = []

def handle_data(self, data):
if data.find("\n") == -1 :
if data[0].isdigit():
self.HTMLDATA.append(data)

def clean(self):
self.HTMLDATA = []


def main():
url = 'http://softwareupdate.vmware.com/cds/vmw-desktop/fusion/'
dir = os.path.dirname(os.path.abspath(__file__))
response = urllib2.urlopen(url)
html = response.read()
parser = myHTMLParser()
parser.feed(html)
url = url + parser.HTMLDATA[-1] + '/'
response = urllib2.urlopen(url)
html = response.read()
parser.clean()
parser.feed(html)
url = url + parser.HTMLDATA[-1] + '/packages/com.vmware.fusion.tools.darwin.zip.tar'
urllib.urlretrieve(url, 'tools/com.vmware.fusion.tools.darwin.zip.tar')
parser.clean()
tar = tarfile.open('tools/com.vmware.fusion.tools.darwin.zip.tar', 'r')
tar.extract('com.vmware.fusion.tools.darwin.zip', path='tools/')
zip = zipfile.ZipFile('tools/com.vmware.fusion.tools.darwin.zip', 'r')
zip.extract('payload/darwin.iso', path='tools/')
zip.extract('payload/darwin.iso.sig', path='tools/')
shutil.move(dir + '/tools/payload/darwin.iso', dir + '/tools/darwin.iso')
shutil.move(dir + '/tools/payload/darwin.iso.sig', dir + '/tools/darwin.iso.sig')
shutil.rmtree(dir + '/tools/payload', True)
os.remove(dir + '/tools/com.vmware.fusion.tools.darwin.zip.tar')
os.remove(dir + '/tools/com.vmware.fusion.tools.darwin.zip')


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion lnx-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
2 changes: 1 addition & 1 deletion lnx-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
2 changes: 1 addition & 1 deletion local-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e
set -x

echo VMware ESXi 6.x Unlocker 2.0.7
echo VMware ESXi 6.x Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
2 changes: 1 addition & 1 deletion osx-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
2 changes: 1 addition & 1 deletion osx-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo VMware Unlocker 2.0.7
echo VMware Unlocker 2.0.8
echo ===============================
echo Copyright: Dave Parsons 2011-15

Expand Down
34 changes: 19 additions & 15 deletions readme-bbcode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ If you are using an earlier product please continue using Unlocker 1

Version 2 has been tested against:
[LIST]
[*]Workstation 11/12 on Windows and Linux[/*]
[*]Player 7 & Workstation Player 12 on Windows and Linux[/*]
[*]Workstation 11/12 Pro on Windows and Linux[/*]
[*]Player 7 & Workstation Player 12 on Windows and Linux[/*]
[*]Fusion 7/8 on Mavericks and Yosemite[/*]
[*]ESXi 6.0[/*]
[/LIST]
Expand All @@ -22,7 +22,6 @@ being patched:
[*]Fix libvmkctl.so on ESXi 6 to allow use with vCenter[/*]
[*]A copy of the latest VMware Tools for OS X is included[/*]
[/LIST]

Note that not all products recognise the darwin.iso via install tools menu item.
You will have to manually mount the darwin.iso for example on Workstation and Player.

Expand Down Expand Up @@ -50,16 +49,16 @@ If you are using VMware Player or Workstation on Windows you may get a core dump

Latest Linux and ESXi products are OK and do not show this problem.

[color=#ff0000][u][b]IMPORTANT:[/b][/u]
[color=#ff0000][u][b] IMPORTANT:[/b][/u]

If you create a new VM using version 11 hardware VMware will stop and
create a core dump.There are two options to work around this issue:
 If you create a new VM using version 11 hardware VMware will stop and 
 create a core dump.There are two options to work around this issue:

1. Change the VM to be HW 10 - this does not affect performance.
2. Edit the VMX file and add:[/color]
[code=auto:0]smc.version = "0" |[/code]
 1. Change the VM to be HW 10 - this does not affect performance.
 2. Edit the VMX file and add: [/color]
 
[code=auto:0] smc.version = "0" |[/code]
 

To remove the check for server versions for OS X Leopard and Snow Leopard
(10.5 and 10.6) you must use a replacement EFI firwmare module from the firmware
Expand All @@ -69,16 +68,16 @@ If you are using a 32-bit installation of OS X:

1. Copy efi32-srvr.rom to guest folder.
2. Edit the vmx file and add:
 
[code=auto:0]efi32.filename = "efi32-srvr.rom"[/code]
 
If you are using a 64-bit installation of OS X:

1. Copy efi64-srvr.rom to guest folder.
2. Edit the vmx file and add:
 
[code=auto:0]efi64.filename = "efi64-srvr.rom"[/code]
 
[u]4. Windows[/u]

On Windows you will need to either run cmd.exe as Administrator or using
Expand Down Expand Up @@ -178,4 +177,9 @@ debugging expertise. Sam also wrote the code for patching ESXi ELF files.
[LIST]
[*]Workstation 12 on Linux fixes[/*]
[/LIST]
[/LIST]
16/09/15 2.0.8
[LIST]
[*]Player 12 on Linux fixes[/*]
[/LIST]
(c) 2011-2015 Dave Parsons
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ History
- Latest tools from Fusion 7.1.2
20/06/15 2.0.6 - ESXi 6 patch for smcPresent vCenter compatibility
16/09/15 2.0.7 - Workstation 12 on Linux fixes

19/09/15 2.0.8 - Player 12 on Linux fixes

(c) 2011-2015 Dave Parsons
Empty file modified tools/darwin.iso
100755 → 100644
Empty file.
Empty file modified tools/darwin.iso.sig
100755 → 100644
Empty file.
55 changes: 33 additions & 22 deletions unlocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
sys.exit(1)

# Setup imports depending on whether IronPython or CPython
if sys.platform == 'win32' \
or sys.platform == 'cli':
from _winreg import *

try:
import _winreg
except ImportError:
pass

def rot13(s):
chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
Expand All @@ -67,17 +67,19 @@ def bytetohex(bytestr):


def printkey(i, offset, smc_key, smc_data):
print str(i+1).zfill(3) \
+ ' ' + hex(offset) \
+ ' ' + smc_key[0][::-1] \
+ ' ' + str(smc_key[1]).zfill(2) \
+ ' ' + smc_key[2][::-1].replace('\x00', ' ') \
+ ' ' + '{0:#0{1}x}'.format(smc_key[3], 4) \
+ ' ' + hex(smc_key[4]) \
+ ' ' + bytetohex(smc_data)

E_CLASS64 = 2;
E_SHT_RELA = 4;
print str(i + 1).zfill(3) \
+ ' ' + hex(offset) \
+ ' ' + smc_key[0][::-1] \
+ ' ' + str(smc_key[1]).zfill(2) \
+ ' ' + smc_key[2][::-1].replace('\x00', ' ') \
+ ' ' + '{0:#0{1}x}'.format(smc_key[3], 4) \
+ ' ' + hex(smc_key[4]) \
+ ' ' + bytetohex(smc_data)


E_CLASS64 = 2
E_SHT_RELA = 4


def patchELF(f, oldOffset, newOffset):
f.seek(0)
Expand All @@ -87,7 +89,7 @@ def patchELF(f, oldOffset, newOffset):

ei_class = struct.unpack('=B', f.read(1))[0]
if ei_class != E_CLASS64:
raise Exception('Not 64bit elf header: ' + ei_class)
raise Exception('Not 64bit elf header: ' + ei_class)

f.seek(40)
e_shoff = struct.unpack('=Q', f.read(8))[0]
Expand All @@ -96,7 +98,7 @@ def patchELF(f, oldOffset, newOffset):
e_shnum = struct.unpack('=H', f.read(2))[0]
e_shstrndx = struct.unpack('=H', f.read(2))[0]

#print 'e_shoff: 0x{:x} e_shentsize: 0x{:x} e_shnum:0x{:x} e_shstrndx:0x{:x}'.format(e_shoff, e_shentsize, e_shnum, e_shstrndx)
# print 'e_shoff: 0x{:x} e_shentsize: 0x{:x} e_shnum:0x{:x} e_shstrndx:0x{:x}'.format(e_shoff, e_shentsize, e_shnum, e_shstrndx)

for i in range(0, e_shnum):
f.seek(e_shoff + i * e_shentsize)
Expand All @@ -108,15 +110,15 @@ def patchELF(f, oldOffset, newOffset):
e_sh_entsize = e_sh[9]
if e_sh_type == E_SHT_RELA:
e_sh_nument = e_sh_size / e_sh_entsize
#print 'RELA at 0x{:x} with {:d} entries'.format(e_sh_offset, e_sh_nument)
# print 'RELA at 0x{:x} with {:d} entries'.format(e_sh_offset, e_sh_nument)
for j in range(0, e_sh_nument):
f.seek(e_sh_offset + e_sh_entsize * j)
rela = struct.unpack('=QQq', f.read(e_sh_entsize))
r_offset = rela[0]
r_info = rela[1]
r_addend = rela[2]
if r_addend == oldOffset:
r_addend = newOffset;
r_addend = newOffset
f.seek(e_sh_offset + e_sh_entsize * j)
f.write(struct.pack('=QQq', r_offset, r_info, r_addend))
print 'Relocation modified at: ' + hex(e_sh_offset + e_sh_entsize * j)
Expand All @@ -125,6 +127,8 @@ def patchELF(f, oldOffset, newOffset):
def patchkeys(f, vmx, key, osname):
# Setup struct pack string
key_pack = '=4sB4sB6xQ'
smc_old_memptr = 0
smc_new_memptr = 0

# Do Until OSK1 read
i = 0
Expand Down Expand Up @@ -198,9 +202,13 @@ def patchkeys(f, vmx, key, osname):
i += 1
return smc_old_memptr, smc_new_memptr


def patchsmc(name, osname, sharedobj):
with open(name, 'r+b') as f:

smc_old_memptr = 0
smc_new_memptr = 0

# Read file into string variable
vmx = f.read()

Expand Down Expand Up @@ -326,8 +334,8 @@ def patchvmkctl(name):
f.close()
print 'smcPresent Patched: ' + name

def main():

def main():
# Work around absent Platform module on VMkernel
if os.name == 'nt' or os.name == 'cli':
osname = 'windows'
Expand All @@ -343,18 +351,20 @@ def main():
vmx_debug = vmx_path + 'vmware-vmx-debug'
vmx_stats = vmx_path + 'vmware-vmx-stats'
vmwarebase = ''
libvmkctl = ''

elif osname == 'linux':
vmx_path = '/usr/lib/vmware/bin/'
vmx = vmx_path + 'vmware-vmx'
vmx_debug = vmx_path + 'vmware-vmx-debug'
vmx_stats = vmx_path + 'vmware-vmx-stats'
vmx_version = subprocess.check_output(["vmware", "-v"])
if vmx_version.startswith('VMware Workstation 12'):
vmx_version = subprocess.check_output(["vmplayer", "-v"])
if vmx_version.startswith('VMware Player 12'):
vmx_so = True
vmwarebase = '/usr/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so'
else:
vmwarebase = '/usr/lib/vmware/lib/libvmwarebase.so.0/libvmwarebase.so.0'
libvmkctl = ''

elif osname == 'vmkernel':
vmx_path = '/unlocker/'
Expand All @@ -374,6 +384,7 @@ def main():
vmx_debug = vmx_path + 'vmware-vmx-debug.exe'
vmx_stats = vmx_path + 'vmware-vmx-stats.exe'
vmwarebase = vmwarebase_path + 'vmwarebase.dll'
libvmkctl = ''

else:
print('Unknown Operating System: ' + osname)
Expand Down

0 comments on commit 258b81c

Please sign in to comment.