美文网首页
2019-07-25

2019-07-25

作者: Go_python_Linux | 来源:发表于2019-07-25 18:24 被阅读0次

#!/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 !!!!
''')

相关文章

  • 2019-07-27

    2019-07-25 毛雅亭 字数 558 · 阅读 8 2019-06-02 18:39 ...

  • Lan的ScalersTalk第四轮新概念朗读持续力训练Day

    练习材料: [Day 1763 2019-07-25] Lesson 25-3 Non-auditory effe...

  • 文先森的日常

    日精进打卡第359天 姓名:李文杰 (四爷); 公司:中国太平人寿; 日期:2019-07-25 【知~学习】 ...

  • 巧解妙析彰显和谐之风

    双阳148李春梅 字数 899 · 阅读 38 2019-07-25 21:26 ———观摩杭州师范学校王崧舟老师...

  • 【®感恩日记第1183篇》 - 夏令营第19天

    2019-07-25 05:02 读经人: 妈妈,冲冲 读经内容:《黄帝内经素问-上古天真论篇01》《孟子:公孙丑...

  • 14. 用户调研

    P2总结 逻辑分析能力 需求理解 项目推进屏幕快照 2019-07-25 下午6.53.17.png 专业职业才能...

  • 那一碗还没有下的饺子

    时间:2019-07-25 18:40 周四 地点:成都 天气:晴朗好热 心情:有些自豪 关键字:学会爱人 不知道...

  • 深度践行12/90

    2019-07-25 今日天气:早上阴,白天阵雨 【宣言】做更好的自己 #深度践行 教练姓名:谭福翠 孩子年龄+性...

  • 2019-07-25

    2019-07-25 姓名:郭祥华 组别:315期六项精进努力一组 【日精进打卡第566】 【知~学习】 背诵《...

  • 2019-07-25跑步记录

    时间:2019-07-25 20:30 线路:天马河绿道 成绩:5公里用时28分30秒 7月:112公里 感受:高...

网友评论

      本文标题:2019-07-25

      本文链接:https://www.haomeiwen.com/subject/ccrkrctx.html