Skip to content

Instantly share code, notes, and snippets.

  • Star 15 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save STiXzoOR/ab46bfebcf6644d6f2aebb97d09cd6f9 to your computer and use it in GitHub Desktop.
Teamviewer 15 ID Changer for macOS (Python 3)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# System: macOS 12+
# Version: TeamViewer v15.x.x
# Python: 3.x.x
# Command: sudo python TeamViewer-15-id-changer.py
#
import os
import platform
import random
import re
import string
import sys
print(
"""
--------------------------------
TeamViewer 15 ID Changer for MAC OS
Version: 7 2022
--------------------------------
"""
)
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(
"""
No TeamViewer configs found.
Maybe you have deleted it manually or never run TeamViewer after installation.
Nothing to delete.
"""
)
else:
# Delete config files
print("Configs found:\n")
for file in CONFIGS:
print(file)
print(
"""
These files will be DELETED permanently.
All TeamViewer settings will be lost
"""
)
input("Press Enter to continue or CTR+C to abort...")
for file in CONFIGS:
try:
os.remove(file)
except OSError:
print("Cannot delete config files. Permission denied?")
sys.exit()
print("Done.")
# Find binaries
TMBINARIES = [
"/Applications/TeamViewer.app/Contents/MacOS/TeamViewer",
"/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service",
"/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop_Proxy",
"/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment",
"/Applications/TeamViewer.app/Contents/Helpers/Restarter",
]
for file in TMBINARIES:
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(str.encode(PlatformPattern), str.encode(platf), binary)
binary = re.sub(
str.encode(SerialPattern % (chr(0), "[0-9a-zA-Z]{8,8}", chr(0))),
str.encode(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 TMBINARIES:
try:
idpatch(file, RANDOMPLATFORM, RANDOMSERIAL)
except Exception as e:
print("Error: can not patch file " + file)
print(e)
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 !!!!
"""
)
@menoeng
Copy link

menoeng commented Dec 9, 2022

I got error as below...

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

Press Enter to continue or CTR+C to abort...
Done.
Error: can not patch file /Applications/TeamViewer.app/Contents/MacOS/TeamViewer
[Errno 1] Operation not permitted: '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer'

@nofrato
Copy link

nofrato commented Mar 27, 2023

Hi got an error :

No TeamViewer configs found.
Maybe you have deleted it manually or never run TeamViewer after installation.
Nothing to delete.

File not found: /Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop_Proxy
Install TeamViewer correctly

I removed "_Proxy" in the file and it works

@idarek
Copy link

idarek commented Apr 1, 2023

I got error as below...

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

Press Enter to continue or CTR+C to abort... Done. Error: can not patch file /Applications/TeamViewer.app/Contents/MacOS/TeamViewer [Errno 1] Operation not permitted: '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer'

You need to enable full disk permission for Terminal first.

Settings > Privacy & Security > Full Disk Access

And switch on the toggle for Terminal

Then it will work like a charm

sudo python3 TeamViewer-15-id-changer-for-mac.py

@idarek
Copy link

idarek commented Apr 1, 2023

Hi got an error :

No TeamViewer configs found. Maybe you have deleted it manually or never run TeamViewer after installation. Nothing to delete.

File not found: /Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop_Proxy Install TeamViewer correctly

I removed "_Proxy" in the file and it works

Reinstall latest version of Team Viewer and run it first, then close before running script.

@inundate0
Copy link

Getting following error even after reinstall latest version of Team Viewer and before

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

@idarek
Copy link

idarek commented Jun 4, 2023

Save the above script into TeamViewer-15-id-changer.py file

run the following command

sudo python3 TeamViewer-15-id-changer.py

follow instructions.

Re-run Team Viewer (no restart required)

When you running this script TeamViewer needs to be turned off and make sure is not active in the background.

Just tested on version 15.40.9 and is working as expected.

@idarek
Copy link

idarek commented Jun 4, 2023

Getting following error even after reinstall latest version of Team Viewer and before

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

Whats yous latest version?

@inundate0
Copy link

Thanks its worked.
Is there any way where we can use teamviewer without login ?

@idarek
Copy link

idarek commented Jun 5, 2023

Thanks its worked.
Is there any way where we can use teamviewer without login ?

They change it recently to have more control so I doubt that’s possible.

@puwooo
Copy link

puwooo commented Jul 6, 2023

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

Traceback (most recent call last):
File "/Users/zhubaiyue/Downloads/b1d72f3465c46e7b58a4ea42d625c3e8-77efcbb0af4b3cc9bb234c488dc8ae42e90aa7e6/TeamViewer-id-changer.py", line 69, in
raw_input("Press Enter to continue or CTR+C to abort...")
^^^^^^^^^
NameError: name 'raw_input' is not defined

@idarek
Copy link

idarek commented Jul 6, 2023

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

Traceback (most recent call last): File "/Users/zhubaiyue/Downloads/b1d72f3465c46e7b58a4ea42d625c3e8-77efcbb0af4b3cc9bb234c488dc8ae42e90aa7e6/TeamViewer-id-changer.py", line 69, in raw_input("Press Enter to continue or CTR+C to abort...") ^^^^^^^^^ NameError: name 'raw_input' is not defined

How you executing your command?

Use

sudo python3 TeamViewer-15-id-changer.py

@neenus
Copy link

neenus commented Dec 21, 2023

I keep getting this error

Error: can not patch file /Applications/TeamViewer.app/Contents/MacOS/TeamViewer

I'm on the most recent version of TeamViewer 15.49.2 is that why?

@mikimaine
Copy link

On your Mac, go to the system settings > Privacy & security> App Management and allow your terminal /iTem to change other apps.

@neenus
Copy link

neenus commented Dec 21, 2023

On your Mac, go to the system settings > Privacy & security> App Management and allow your terminal /iTem to change other apps.

Thanks for your reply ... Did that and I also gave full disk permission as mentioned in the comments above and now I'm getting the same error but with another message saying There is no TemViewer configs found. here is a screenshot

Screenshot 2023-12-21 at 17 17 50

This is a fresh install of TeamViewer and I did run it before 🤷🏻‍♂️

@mikimaine
Copy link

You have to reinstall TeamViewer and open it to generate the config files again. Then make sure you close the app before you run the script.

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