古力朱古力 2020-05-13 14:14 采纳率: 0%
浏览 1035

mac 系统中 teamviewer14、15提示商业用途利用修改ID最简单方法TeamViewer-id-changer.py 时显示Error: can not patch file /Applications/TeamViewer.app/Contents/MacOS/TeamViewer

我的mac系统中,最近用TeamViewer进行远程,用久了之后就提示提示商业用途,用网上的https://www.jianshu.com/p/9c2eb0dffeaf 进行修改ID,可是运行TeamViewer-id-changer.py老是显示Error: can not patch file /Applications/TeamViewer.app/Contents/MacOS/TeamViewer

请问有大神知道咋回事吗????

附上TeamViewer-id-changer.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

print('''
--------------------------------
TeamViewer 14 ID Changer for MAC OS
Version: 0.2 2019
--------------------------------
''')

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
''')
    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',
    #’/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()
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)

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

print('''
ID changed sucessfully.
!!! Restart computer before using TeamViewer !!!!
''')
  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog