Synthesia最新版patch脚本

#!/usr/bin/env python3
# coding=GBK
# Created at 2019/11/9 19:52

from __future__ import print_function
import ctypes, sys
import os,time

binpath= r"C:\Program Files (x86)\Synthesia"
filename = "Synthesia.exe"
backup_path = r"c:\backup"

if(os.path.isdir(backup_path)):
    print("Backup path already exsit!")
else:
    os.mkdir(backup_path)


def backfiles():
    os.system("copy " + filename + " " + backup_path)
    print("File has been backuped to " + backup_path)


def patch_exe():
    with open (backup_path+"\\" + filename,"rb") as fr:
        data = fr.read()
        data = data.replace(b'\x64\xA1\x2C\x00\x00\x00\x56\x8B\xF1', b'\xB8\x01\x00\x00\x00\xC3\x56\x8B\xF1')
        with open(binpath + '\\' + filename, "wb") as fw:
            fw.write(data)
            print(filename + " has been patached successfully!")

#获取administrator权限
def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

if is_admin():
    os.chdir(binpath)
    try:
        print("-------------First Step--------------\n")
        backfiles()
        time.sleep(3)
    except:
        print("Error occurred in backup procedure!")
    try:
        print("-------------Second Step--------------\n")
        patch_exe()
        time.sleep(3)
    except:
        print("Error occurred in patch procedure!\n")
else:
    if sys.version_info[0] == 3:
        ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)   #python3使用的函数及参数
    else:
        ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)   #python2使用的函数及参数
posted @ 2020-01-15 19:04  heycomputer  阅读(501)  评论(0编辑  收藏  举报