Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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 os.environ.has_key('SUDO_USER'):
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
''')
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/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}"
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: can not patch file " + file
print "Wrong version?"
sys.exit();
print "PlatformDevice: " + RANDOMPLATFORM
print "PlatformSerial: " + RANDOMSERIAL
print('''
ID changed sucessfully.
!!! Restart computer before using TeamViewer !!!!
''')
@Firues

This comment has been minimized.

Firues commented Jul 29, 2017

Thank you!

@ryutao

This comment has been minimized.

ryutao commented Mar 31, 2018

Thank you very much!

@SoniyaSmug

This comment has been minimized.

SoniyaSmug commented Apr 7, 2018

This is not working for me. Showing the following error.
Traceback (most recent call last):
File "./TeamViewer-id-changer.py", line 26, in
if os.environ.has_key('SUDO_USER'):
AttributeError: '_Environ' object has no attribute 'has_key.

Please anybody help

@flash66

This comment has been minimized.

flash66 commented Apr 9, 2018

Absolutely brilliant! Where can I donate?

@konredi

This comment has been minimized.

konredi commented Apr 22, 2018

Thank you Thank you Thank you Thank you !

@flip68

This comment has been minimized.

flip68 commented May 8, 2018

This doesn't appear to work for Teamviewer 13 releases?

@pingod

This comment has been minimized.

pingod commented May 15, 2018

@flip68 try it,you will get what you want

@pingod

This comment has been minimized.

pingod commented May 15, 2018

Thank you Thank you Thank you Thank you !

@yuuzhang

This comment has been minimized.

yuuzhang commented Jun 5, 2018

Perfectly work on release 13.14170, Thank your brilliant job!

@alluminator

This comment has been minimized.

alluminator commented Jun 9, 2018

how does it run? I do not understand. I installed pyton, but the script is executed and nothing happens. Can someone record a video?

@wzrzt

This comment has been minimized.

wzrzt commented Jun 13, 2018

@SoniyaSmug, try run it with /usr/bin/python *.py
You should use python2

@LonelyWolfJH

This comment has been minimized.

LonelyWolfJH commented Jun 22, 2018

@SoniyaSmug, @alluminator
There is a revised version as Python 3 in here
just do "sudo ./filename.py" in the Terminal.
Thank you for Pavel Zhovner

@julik272237

This comment has been minimized.

julik272237 commented Jul 8, 2018

I do not understand, how to do it!
Can someone record a video, please?

@julik272237

This comment has been minimized.

julik272237 commented Jul 8, 2018

Could somebody help with this ? Can't run the script

This script must be run form root.
Exit status: 0
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Процесс завершен]

@kenjdcee

This comment has been minimized.

kenjdcee commented Jul 19, 2018

hi guys,

got an error running this script.

Traceback (most recent call last):
File "./TeamViewer-id-changer.py", line 45, in
for file in listdir_fullpath(HOMEDIRLIB):
File "./TeamViewer-id-changer.py", line 43, in listdir_fullpath
return [os.path.join(d, f) for f in os.listdir(d)]
OSError: [Errno 2] No such file or directory: '/Users/username of my pc/library/Preferences/

Thank youm

@zibot

This comment has been minimized.

zibot commented Aug 9, 2018

Да

@WorldWideWebDev

This comment has been minimized.

WorldWideWebDev commented Aug 9, 2018

How can i sue this to re-instate an old "ID" such as the original "ID" i registered with? Can anyone help? Its an important question.
Regards Anthony.

@slashtiger

This comment has been minimized.

slashtiger commented Aug 11, 2018

@WorldWodeWeb sorry, you can’t… This script generates a random ID and resets various identifiers with which TeamViewer presents itself to the server, such as the Platform Serial Number. I myself actually would’ve liked the script to have been able to let you specify an ID, bit that wouldn’t have worked anyway. This is because doing so would automatically block that ID on TeamViewer’s server-end. I would have loved to have been able to use my own older ID, purely because I know it off by heart.The reason I myself am looking into changing my ID is because I have been wrongly accused of using the product commercially, twice in a row. At first, they cleared me; then they decided just now to do it again. I’m under the impression that my current ID is also being used elsewhere, because there is no factor nearby me that could’ve triggered a flag in their system. So I’m currently first trying to play nice by sending in a form where you can state your case into using the software non-commercially as intended (you can find that here:
(click))

If they decide my case is not valid, for some reason, then I might try it through this route. It can take anywhere from a week to two months to have the ‘Commercial Use’ flag taken off your ID if you go the intended route, but it actually is the only foolproof route there is. Changing your ID but then continuing not to use TeamViewer according to its non-commercial use guidelines, will have you flagged again in no time.

@jat-x

This comment has been minimized.

jat-x commented Aug 15, 2018

It`s work with TeamViewer 13.
Thank You!

@lyon007

This comment has been minimized.

lyon007 commented Aug 24, 2018

You are great !!!!!!!

@nguyenbathanh

This comment has been minimized.

nguyenbathanh commented Aug 25, 2018

Oh my god! It works perfectly.

@carythesaddler

This comment has been minimized.

carythesaddler commented Aug 25, 2018

i am NOT a coder. however i'm trying to run this script in terminal. i keep getting command not found. i set it to sudo the root etc and just cannot execute this script. any help for a non techie?

@juato4

This comment has been minimized.

juato4 commented Sep 4, 2018

WONDERFULLLLLLL

@chatiking

This comment has been minimized.

chatiking commented Sep 8, 2018

I am getting this error, could somebody help me for finding out what I am doing wrong?

if platform.system() != 'Darwin':
-bash: syntax error near unexpected token !=' ~ print('This script can be run only on MAC OS.') -bash: syntax error near unexpected token 'This script can be run only on MAC OS.''
~ sys.exit();
-bash: syntax error near unexpected token `;'
~
~ if os.geteuid() != 0

@chatiking

This comment has been minimized.

chatiking commented Sep 8, 2018

it is working now!
just using :
sudo python ./TeamViewer-id-changer.py

@xtechgamer735

This comment has been minimized.

xtechgamer735 commented Sep 15, 2018

@WorldWodeWeb sorry, you can’t… This script generates a random ID and resets various identifiers with which TeamViewer presents itself to the server, such as the Platform Serial Number. I myself actually would’ve liked the script to have been able to let you specify an ID, bit that wouldn’t have worked anyway. This is because doing so would automatically block that ID on TeamViewer’s server-end. I would have loved to have been able to use my own older ID, purely because I know it off by heart.The reason I myself am looking into changing my ID is because I have been wrongly accused of using the product commercially, twice in a row. At first, they cleared me; then they decided just now to do it again. I’m under the impression that my current ID is also being used elsewhere, because there is no factor nearby me that could’ve triggered a flag in their system. So I’m currently first trying to play nice by sending in a form where you can state your case into using the software non-commercially as intended (you can find that here:
(click))

If they decide my case is not valid, for some reason, then I might try it through this route. It can take anywhere from a week to two months to have the ‘Commercial Use’ flag taken off your ID if you go the intended route, but it actually is the only foolproof route there is. Changing your ID but then continuing not to use TeamViewer according to its non-commercial use guidelines, will have you flagged again in no time.

Did you ever get the flag removed? In the same boat with the commercial pop up. Thanks!

@Kangqj

This comment has been minimized.

Kangqj commented Oct 8, 2018

good!
it is work, thank you very much!

@liujie-gd

This comment has been minimized.

liujie-gd commented Oct 12, 2018

Cool!
Thanks very much!

@JimLee1996

This comment has been minimized.

JimLee1996 commented Oct 16, 2018

It's very awesome! Is there any python3 version?

@trahtenberg68

This comment has been minimized.

trahtenberg68 commented Oct 16, 2018

Hi. I've try it on TV10 on mac 10.7.4 and it didn't work, because serial pattern little bit different, to work correctly you need replace
SerialPattern = "IOPlatformSerialNumber%s%s%sUUID"
to SerialPattern = "IOPlatformSerialNumber%s%s%s"
Thank you!

@charlyborwn

This comment has been minimized.

charlyborwn commented Oct 18, 2018

Thank you so much!

@jazzygff

This comment has been minimized.

jazzygff commented Oct 30, 2018

Anyone having issues with latest teamviewer beta? I had updated on other pcs but when trying to connect to one of those pcs I get prompted to update. Once update the app just crashes over and over. Tried full uninstall etc removing via terminal using rm commands. no luck. Wondering if the use of this script has caused it?

@tranthaihoang

This comment has been minimized.

tranthaihoang commented Oct 31, 2018

Good! thank you

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