Skip to content

Instantly share code, notes, and snippets.

@hykilpikonna
Forked from zhovner/TeamViewer-id-changer.py
Last active December 27, 2023 15:11
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save hykilpikonna/b00d00abae5ebe33a2f5aaf39e73e54b to your computer and use it in GitHub Desktop.
Save hykilpikonna/b00d00abae5ebe33a2f5aaf39e73e54b to your computer and use it in GitHub Desktop.
Update for 15.18.5
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import platform
import random
import re
import string
import sys
if sys.version_info[0] != 2:
print("Please use Python 2! (I'm too lazy to update xD")
quit()
print('''
--------------------------------
TeamViewer ID Changer for MAC OS
(Tested on TeamViewer 15.15.5 to 15.18.5)
--------------------------------
''')
if platform.system() != "Darwin":
print("This script can be run only on MAC OS.")
sys.exit()
if os.geteuid() != 0:
print("This script must be run form root.")
sys.exit()
if "SUDO_USER" in os.environ:
USERNAME = os.environ["SUDO_USER"]
if USERNAME == "root":
print("Can not find user name. Run this script via sudo from regular user")
sys.exit()
else:
print("Can not find user name. Run this script via sudo from regular user")
sys.exit()
HOMEDIRLIB = "/Users/" + USERNAME + "/library/preferences/"
GLOBALLIB = "/library/preferences/"
CONFIGS = []
# Find config files
def listdir_fullpath(d):
return [os.path.join(d, f) for f in os.listdir(d)]
for file in listdir_fullpath(HOMEDIRLIB):
if 'teamviewer' in file.lower():
CONFIGS.append(file)
for file in listdir_fullpath(GLOBALLIB):
if 'teamviewer' in file.lower():
CONFIGS.append(file)
if not CONFIGS:
print('''
There is no TemViewer configs found.
Maybe you have deleted it manualy or never run TeamViewer after installation.
Nothing to delete.
''')
else:
# Delete config files
print("Configs found:\n")
for file in CONFIGS: print(file)
print('''
This files will be DELETED permanently.
All TeamViewer settings will be lost
''')
raw_input("Press Enter to continue or CTR+C to abort...")
for file in CONFIGS:
try:
os.remove(file)
except:
print("Cannot delete config files. Permission denied?")
sys.exit()
print("Done.")
# Find binaryes
TMBINARYES = [
'/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
'/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
'/Applications/TeamViewer.app/Contents/Helpers/Restarter',
'/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment'
]
for file in TMBINARYES:
if os.path.exists(file):
pass
else:
print("File not found: " + file)
print ("Install TeamViewer correctly")
sys.exit()
# Patch files
def idpatch(fpath, platf, serial):
file = open(fpath, 'r+b')
binary = file.read()
PlatformPattern = "IOPlatformExpert.{6}"
SerialPattern = "IOPlatformSerialNumber%s%s%s"
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.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
RANDOMSERIAL = random_generator(8)
RANDOMPLATFORM = "IOPlatformExpert" + random_generator(6)
for file in TMBINARYES:
try:
idpatch(file, RANDOMPLATFORM, RANDOMSERIAL)
except:
print("Error: can not patch file " + file)
sys.exit()
print("PlatformDevice: " + RANDOMPLATFORM)
print("PlatformSerial: " + RANDOMSERIAL)
os.system("sudo codesign -f -s - /Applications/TeamViewer.app/")
print('''
ID changed sucessfully.
!!! Restart computer before using TeamViewer !!!!
''')
@manontop
Copy link

manontop commented Mar 31, 2021

--------------------------------
TeamViewer ID Changer for MAC OS
--------------------------------

Configs found:

/Users/Username/library/preferences/com.teamviewer.teamviewer.preferences.plist
/Users/Username/library/preferences/com.teamviewer.teamviewer.preferences.Machine.plist

This files will be DELETED permanently.
All TeamViewer settings will be lost

Press Enter to continue or CTR+C to abort...
Done.
File not found: /Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop
Install TeamViewer correctly

The teamviwer version I have: Version: 15.16.8 (b0756eefb01)
Installed correctly

@hykilpikonna
Copy link
Author

@manontop Are you sure you're using my version of the script rather than the original one? I already changed /Helpers/TeamViewer_Desktop to /Helpers/TeamViewer_Assignment in my script.

@manontop
Copy link

@manontop Are you sure you're using my version of the script rather than the original one? I already changed /Helpers/TeamViewer_Desktop to /Helpers/TeamViewer_Assignment in my script.

OK but now I am getting:

TeamViewer 15.16.8 ID Changer for MAC OS
--------------------------------

Configs found:

/Users/Abbas/library/preferences/com.teamviewer.teamviewer.preferences.plist
/Users/Abbas/library/preferences/com.teamviewer.teamviewer.preferences.Machine.plist

This files will be DELETED permanently.
All TeamViewer settings will be lost

Traceback (most recent call last):
  File "TeamViewer-id-changer.py", line 68, in <module>
    raw_input("Press Enter to continue or CTR+C to abort...")
NameError: name 'raw_input' is not defined
(base) MBP:

Any ideas?

@hykilpikonna
Copy link
Author

hykilpikonna commented Mar 31, 2021

@manontop Use python 2.

And I've added a version check:
image

@Mawe200
Copy link

Mawe200 commented Apr 8, 2021

Hi, I tried to change ID, but when I start the script, the program crashes. Do you know how to fix?

@TAMMYSTR
Copy link

TAMMYSTR commented May 11, 2021

I am not a coder, so i'm kind of lost here.

image

Any idea?

@andywang646691
Copy link

works from TV 15.17.6

@OMEGA-Y
Copy link

OMEGA-Y commented May 14, 2021

It's so wonderful!!
Thank you😄

@asvmasteras
Copy link

Works 15.18.5

@chenrico
Copy link

chenrico commented Jun 8, 2021

Hi, I tried to change ID, but when I start the script, the program crashes. Do you know how to fix?

You need to run

xcode-select --install

first.

@staysellingcarts
Copy link

it works on 15.18.5 then it gets flagged by their system and kicks the person off. Do we need to downgrade?

@chenrico
Copy link

I almost have to reset everytime after I connect to a different computer... is this normal? How did they detect the change

@flash66
Copy link

flash66 commented Jun 15, 2022

I keep getting permission denied running the script at root in terminal. Anyone? thanks!

@hykilpikonna
Copy link
Author

I keep getting permission denied running the script at root in terminal. Anyone? thanks!

You have to give it the permission to run first. sudo chmod +x script.py
Then you can try running it as root sudo ./script.py

@hykilpikonna
Copy link
Author

I keep getting permission denied running the script at root in terminal. Anyone? thanks!

Also you should look for an updated script, this is 1 year old and IDK if it still works.

@Arcuus
Copy link

Arcuus commented Nov 4, 2022

I keep getting permission denied running the script at root in terminal. Anyone? thanks!

Also you should look for an updated script, this is 1 year old and IDK if it still works.

Hi, sorry for disturbing you, but where I can find link for new script version?
Also when I try to use this script, I receive this error message:

/Users/arcus/.pyenv/versions/3.9.2/bin/python: can't find 'main' module in '/Users/arcus/Desktop/./'

Python version: Python 3.9.2 (default, Apr 18 2022, 12:51:47)

Thanks for reply in advance.

@delaprada
Copy link

It works!! Thanks a lot. version: 15.36.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment