Created
April 22, 2019 13:37
-
-
Save BirkhoffLee/21afd447a7ec3083634058d6618117ab to your computer and use it in GitHub Desktop.
Change the ID of Teamviewer for macOS to circumvent "commercial use detected"
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import glob | |
import platform | |
import re | |
import random | |
import string | |
print('Change ID of Teamviewer for macOS') | |
if platform.system() != 'Darwin': | |
print('You are not running macOS. Aborting.') | |
sys.exit(); | |
if os.geteuid() != 0: | |
print('The script has to be run as root. Aborting.') | |
sys.exit(); | |
if os.environ.has_key('SUDO_USER'): | |
USERNAME = os.environ['SUDO_USER'] | |
if USERNAME == 'root': | |
print('Use sudo to run as root.') | |
sys.exit(); | |
else: | |
print('Use sudo to run as root.') | |
sys.exit(); | |
HOMEDIRLIB = '/Users/' + USERNAME + '/library/preferences/' | |
GLOBALLIB = '/library/preferences/' | |
CONFIGS = [] | |
def listdir_fullpath(d): | |
return [os.path.join(d, f) for f in os.listdir(d)] | |
for file in listdir_fullpath(HOMEDIRLIB): | |
if 'teamviewer'.lower() in file.lower(): | |
CONFIGS.append(file) | |
if not CONFIGS: | |
print ('There is nothing to be deleted.') | |
else: | |
print("Configuration files found:\n") | |
for file in CONFIGS: | |
print file | |
print('These files are going to be permanently deleted.') | |
raw_input("<Enter> Proceed, <Ctrl-C> Abort.") | |
for file in CONFIGS: | |
try: | |
os.remove(file) | |
except: | |
print("The file could not be deleted. Do you have the permissions?") | |
sys.exit(); | |
print("Done.") | |
TMBINARYES = [ | |
'/Applications/TeamViewer.app/Contents/MacOS/TeamViewer', | |
'/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service', | |
'/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop', | |
] | |
for file in TMBINARYES: | |
if os.path.exists(file): | |
pass | |
else: | |
print("File not found: " + file) | |
print("Install Teamviewer correctly.") | |
sys.exit(); | |
def idpatch(fpath,platf,serial): | |
file = open(fpath, 'r+b') | |
binary = file.read() | |
PlatformPattern = "IOPlatformExpert.{6}" | |
SerialPattern = "IOPlatformSerialNumber%s%s%sUUID" | |
binary = re.sub(PlatformPattern, platf, binary) | |
binary = re.sub(SerialPattern % (chr(0), "[0-9a-zA-Z]{8,8}", chr(0)), SerialPattern%(chr(0), serial, chr(0)), binary) | |
file = open(fpath,'wb').write(binary) | |
return True | |
def random_generator(size=8, chars=string.ascii_uppercase + string.digits): | |
return ''.join(random.choice(chars) for _ in range(size)) | |
RANDOMSERIAL = random_generator() | |
RANDOMPLATFORM = "IOPlatformExpert" + random_generator(6) | |
for file in TMBINARYES: | |
try: | |
idpatch(file,RANDOMPLATFORM,RANDOMSERIAL) | |
except: | |
print "Error: " + file + " could not be modified." | |
sys.exit(); | |
print "PlatformDevice: " + RANDOMPLATFORM | |
print "PlatformSerial: " + RANDOMSERIAL | |
print('The ID was successfully changed. A reboot is required to apply the changes.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: