Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Teamviewer id changer for Python3 version in the Mac OS
#Python3 version
#!/usr/bin/env python
#coding:utf-8
import sys
import os
import glob
import platform
import re
import random
import string
print('''
--------------------------------
TeamViewer ID Changer for MAC OS
--------------------------------
''')
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'.lower() 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.
''')
# Delete config files
else:
print("Configs found:\n")
for file in CONFIGS:
print (file)
print('''
This 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:
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/TeamViewer_Desktop',
]
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}".encode('utf-8')
SerialPattern = "IOPlatformSerialNumber%s%s%sUUID"
ResultSerial1 = SerialPattern % (chr(0), "[0-9a-zA-Z]{8,8}", chr(0))
ResultSerial2 = SerialPattern%(chr(0), serial, chr(0))
binary = re.sub(PlatformPattern, platf.encode('utf-8'), binary)
binary = re.sub(ResultSerial1.encode('utf-8'), ResultSerial2.encode('utf-8'), 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 Exception as ex:
print(ex)
print("Error: can not patch file " + file)
print("Wrong version?")
sys.exit();
print('''
ID changed sucessfully.
!!! Restart computer before using TeamViewer !!!!
''')
@julik272237

This comment has been minimized.

Copy link

@julik272237 julik272237 commented Jul 8, 2018

Can't run the script! Tried regular user , tried root

@julik272237

This comment has been minimized.

Copy link

@julik272237 julik272237 commented Jul 8, 2018

iMac-Boris:~ julik$ su root
Password:
sh-3.2# python3 team.py
(null): can't open file 'team.py': [Errno 2] No such file or directory
sh-3.2# cd Desktop
sh-3.2# python team.py


TeamViewer ID Changer for MAC OS

Can not find user name. Run this script via sudo from regular user
sh-3.2#

@julik272237

This comment has been minimized.

Copy link

@julik272237 julik272237 commented Jul 8, 2018

Last login: Sun Jul 8 19:42:51 on ttys001
iMac-Boris:~ julik$ sudo ./team.py
Password:
sudo: ./team.py: command not found
iMac-Boris:~ julik$

@LonelyWolfJH

This comment has been minimized.

Copy link
Owner Author

@LonelyWolfJH LonelyWolfJH commented Jul 13, 2018

@julik272237
I think you don't have Python in your MAC.
Check "python --version" in terminal, please.
If there is no any answer, you must have install python. And then, run with root account

@kenjdcee

This comment has been minimized.

Copy link

@kenjdcee kenjdcee commented Jul 18, 2018

Hi Sir,

Got an error running this script

./TeamViewer-id-changer-py3.py: line 5: import: command not found
./TeamViewer-id-changer-py3.py: line 6: import: command not found
./TeamViewer-id-changer-py3.py: line 7: import: command not found
./TeamViewer-id-changer-py3.py: line 8: import: command not found
./TeamViewer-id-changer-py3.py: line 9: import: command not found
./TeamViewer-id-changer-py3.py: line 10: import: command not found
./TeamViewer-id-changer-py3.py: line 11: import: command not found
./TeamViewer-id-changer-py3.py: line 17: syntax error near unexpected token `'''

TeamViewer ID Changer for MAC OS

''''
./TeamViewer-id-changer-py3.py: line 17: `''')'

I have TeamViewer ver. 13.1.4170

@Ivy286

This comment has been minimized.

Copy link

@Ivy286 Ivy286 commented Oct 17, 2018

Perfectly solved, thanks very much!

@Python2K

This comment has been minimized.

Copy link

@Python2K Python2K commented Oct 18, 2018

thanks, it's awesome !~

@charlyborwn

This comment has been minimized.

Copy link

@charlyborwn charlyborwn commented Oct 18, 2018

you are awesome
I can't believe it absolutely awesome

thank you so much!

@nuggy875

This comment has been minimized.

Copy link

@nuggy875 nuggy875 commented Feb 11, 2019

Hi Sir,

Got an error running this script

./TeamViewer-id-changer-py3.py: line 5: import: command not found

./TeamViewer-id-changer-py3.py: line 6: import: command not found
./TeamViewer-id-changer-py3.py: line 7: import: command not found
./TeamViewer-id-changer-py3.py: line 8: import: command not found
./TeamViewer-id-changer-py3.py: line 9: import: command not found
./TeamViewer-id-changer-py3.py: line 10: import: command not found
./TeamViewer-id-changer-py3.py: line 11: import: command not found
./TeamViewer-id-changer-py3.py: line 17: syntax error near unexpected token `'''

TeamViewer ID Changer for MAC OS

''''
./TeamViewer-id-changer-py3.py: line 17: `''')'

I have TeamViewer ver. 13.1.4170

Same Problem here...
My Team Viewer version is 14.1.9025
My Python version is 3.6.6

@TAMMYSTR

This comment has been minimized.

Copy link

@TAMMYSTR TAMMYSTR commented May 11, 2021

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

image

Any idea?

@nits42

This comment has been minimized.

Copy link

@nits42 nits42 commented Jun 13, 2021

I am getting error while trying to execute script my Teamviewer version is 15

sh-3.2# sudo ./TeamViewer-id-changer.py
sudo: ./TeamViewer-id-changer.py: command not found

Please someone help me.
Thanks in advance.

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