Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save idarek/10cbc4fc28dd6a9db146122a1fe520a2 to your computer and use it in GitHub Desktop.
Save idarek/10cbc4fc28dd6a9db146122a1fe520a2 to your computer and use it in GitHub Desktop.

Revisions

  1. idarek revised this gist Nov 26, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # System: macOS 12+
    # Version: TeamViewer v15.x.x
    # Python: 3.x.x
    # Command: sudo python TeamViewer-15-id-changer.py
    # Command: sudo python3 TeamViewer-15-id-changer.py
    #

    import os
  2. @STiXzoOR STiXzoOR revised this gist Nov 18, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -138,7 +138,7 @@ def random_generator(
    RANDOMSERIAL = random_generator(8)
    RANDOMPLATFORM = "IOPlatformExpert" + random_generator(6)

    for file in TMBINARYES:
    for file in TMBINARIES:
    try:
    idpatch(file, RANDOMPLATFORM, RANDOMSERIAL)
    except Exception as e:
  3. @STiXzoOR STiXzoOR revised this gist Nov 18, 2022. No changes.
  4. @STiXzoOR STiXzoOR revised this gist Nov 18, 2022. No changes.
  5. @STiXzoOR STiXzoOR revised this gist Nov 18, 2022. 1 changed file with 59 additions and 44 deletions.
    103 changes: 59 additions & 44 deletions TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    #
    # System: macOS Mojave 10.14.6
    # Version: TeamViewer v15.2.2756
    # Python: 2.7.10
    # Command: sudo python TeamViewer-15-id-changer-for-mac.py
    # System: macOS 12+
    # Version: TeamViewer v15.x.x
    # Python: 3.x.x
    # Command: sudo python TeamViewer-15-id-changer.py
    #

    import os
    @@ -14,15 +14,14 @@
    import string
    import sys

    print('''
    print(
    """
    --------------------------------
    TeamViewer ID Changer for MAC OS
    TeamViewer 15 ID Changer for MAC OS
    Version: 7 2022
    --------------------------------
    ''')

    if sys.version[0:1] != "2":
    print("This script can be run only on Python27.")
    sys.exit()
    """
    )

    if platform.system() != "Darwin":
    print("This script can be run only on MAC OS.")
    @@ -41,86 +40,99 @@
    print("Can not find user name. Run this script via sudo from regular user")
    sys.exit()

    HOMEDIRLIB = "/Users/" + USERNAME + "/Library/Preferences/"
    GLOBALLIB = "/Library/Preferences/"
    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():
    if "teamviewer" in file.lower():
    CONFIGS.append(file)

    for file in listdir_fullpath(GLOBALLIB):
    if 'teamviewer' in file.lower():
    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.
    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('''
    This files will be DELETED permanently.
    for file in CONFIGS:
    print(file)
    print(
    """
    These files will be DELETED permanently.
    All TeamViewer settings will be lost
    ''')
    raw_input("Press Enter to continue or CTR+C to abort...")
    """
    )
    input("Press Enter to continue or CTR+C to abort...")

    for file in CONFIGS:
    try:
    os.remove(file)
    except:
    except OSError:
    print("Cannot delete config files. Permission denied?")
    sys.exit()
    print("Done.")

    # Find binaryes
    # Find binaries

    TMBINARYES = [
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop',
    '/Applications/TeamViewer.app/Contents/Helpers/Helper',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment'
    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 TMBINARYES:
    for file in TMBINARIES:
    if os.path.exists(file):
    pass
    else:
    print("File not found: " + file)
    print ("Install TeamViewer correctly")
    print("Install TeamViewer correctly")
    sys.exit()


    # Patch files


    def idpatch(fpath, platf, serial):
    file = open(fpath, 'r+b')
    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)
    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)
    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))
    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)
    @@ -129,16 +141,19 @@ def random_generator(size=8, chars=string.ascii_uppercase + string.ascii_lowerca
    for file in TMBINARYES:
    try:
    idpatch(file, RANDOMPLATFORM, RANDOMSERIAL)
    except:
    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 --force --deep --sign - /Applications/TeamViewer.app/")
    os.system("sudo codesign -f -s - /Applications/TeamViewer.app/")

    print('''
    print(
    """
    ID changed sucessfully.
    !!! Restart computer before using TeamViewer !!!!
    ''')
    """
    )
  6. @0x2a94b5 0x2a94b5 revised this gist Jun 1, 2020. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -41,8 +41,8 @@
    print("Can not find user name. Run this script via sudo from regular user")
    sys.exit()

    HOMEDIRLIB = "/Users/" + USERNAME + "/library/preferences/"
    GLOBALLIB = "/library/preferences/"
    HOMEDIRLIB = "/Users/" + USERNAME + "/Library/Preferences/"
    GLOBALLIB = "/Library/Preferences/"

    CONFIGS = []

    @@ -90,7 +90,9 @@ def listdir_fullpath(d):
    TMBINARYES = [
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop'
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop',
    '/Applications/TeamViewer.app/Contents/Helpers/Helper',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment'
    ]

    for file in TMBINARYES:
    @@ -134,9 +136,9 @@ def random_generator(size=8, chars=string.ascii_uppercase + string.ascii_lowerca
    print("PlatformDevice: " + RANDOMPLATFORM)
    print("PlatformSerial: " + RANDOMSERIAL)

    os.system("sudo codesign -f -s - /Applications/TeamViewer.app/")
    os.system("sudo codesign --force --deep --sign - /Applications/TeamViewer.app/")

    print('''
    ID changed sucessfully.
    !!! Restart computer before using TeamViewer !!!!
    ''')
    ''')
  7. @0x2a94b5 0x2a94b5 revised this gist May 5, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    #
    # System: macOS Mojave 10.14.6
    # Version: TeamViewer v15.2.2756
    # Python: 2.7.10
    # Command: sudo python TeamViewer-15-id-changer-for-mac.py
    #

    import os
    import platform
  8. @zhenhappy zhenhappy revised this gist Dec 24, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TeamViewer-15-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ def listdir_fullpath(d):
    TMBINARYES = [
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop'
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Desktop'
    ]

    for file in TMBINARYES:
  9. @zhenhappy zhenhappy revised this gist Dec 24, 2019. No changes.
  10. @zhenhappy zhenhappy renamed this gist Dec 24, 2019. 1 changed file with 0 additions and 0 deletions.
  11. @zhenhappy zhenhappy revised this gist Nov 24, 2019. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions TeamViewer-14-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,10 @@
    --------------------------------
    ''')

    if sys.version[0:1] != "2":
    print("This script can be run only on Python27.")
    sys.exit()

    if platform.system() != "Darwin":
    print("This script can be run only on MAC OS.")
    sys.exit()
    @@ -80,8 +84,7 @@ def listdir_fullpath(d):
    TMBINARYES = [
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment'
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop'
    ]

    for file in TMBINARYES:
  12. @zhenhappy zhenhappy revised this gist Nov 24, 2019. No changes.
  13. @zhenhappy zhenhappy revised this gist Jun 27, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion TeamViewer-14-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -80,7 +80,8 @@ def listdir_fullpath(d):
    TMBINARYES = [
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer',
    '/Applications/TeamViewer.app/Contents/MacOS/TeamViewer_Service',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop'
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Desktop',
    '/Applications/TeamViewer.app/Contents/Helpers/TeamViewer_Assignment'
    ]

    for file in TMBINARYES:
  14. @zhenhappy zhenhappy revised this gist May 8, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions TeamViewer-14-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -121,11 +121,11 @@ def random_generator(size=8, chars=string.ascii_uppercase + string.ascii_lowerca
    print("Error: can not patch file " + file)
    sys.exit()

    os.system("sudo codesign -f -s - /Applications/TeamViewer.app/Contents/MacOS/TeamViewer")

    print("PlatformDevice: " + RANDOMPLATFORM)
    print("PlatformSerial: " + RANDOMSERIAL)

    os.system("sudo codesign -f -s - /Applications/TeamViewer.app/")

    print('''
    ID changed sucessfully.
    !!! Restart computer before using TeamViewer !!!!
  15. @zhenhappy zhenhappy created this gist Mar 28, 2019.
    132 changes: 132 additions & 0 deletions TeamViewer-14-id-changer-for-mac.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,132 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    import os
    import platform
    import random
    import re
    import string
    import sys

    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' 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/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%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()

    os.system("sudo codesign -f -s - /Applications/TeamViewer.app/Contents/MacOS/TeamViewer")

    print("PlatformDevice: " + RANDOMPLATFORM)
    print("PlatformSerial: " + RANDOMSERIAL)

    print('''
    ID changed sucessfully.
    !!! Restart computer before using TeamViewer !!!!
    ''')