Last active
February 11, 2021 05:21
-
-
Save the-eric-kwok/729934700d1ce1d804530d08573dcc48 to your computer and use it in GitHub Desktop.
A script to modify VirtualSMC.kext or FakeSMC.kext for faking non-apple mouse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import plistlib | |
from shutil import copyfile | |
files = ["/Volumes/EFI/EFI/OC/Kexts/VirtualSMC.kext/Contents/Info.plist", | |
"/Volumes/EFI/EFI/OC/Kexts/FakeSMC.kext/Contents/Info.plist"] | |
idProduct = 9486 | |
idVendor = 16700 | |
print("\nThis scipt modifies [%s] \nor [%s] \nfor fake apple mouse, if there is something wrong with the path, please edit this script.\n" % | |
(files[0], files[1])) | |
print("idProduct is [%d] \nidVendor is [%d]\nIf there is anything wrong with these IDs, please edit this script\n" % ( | |
idProduct, idVendor)) | |
print("Press ENTER to continue...") | |
input() | |
insert_dict = { | |
'WiredMouse-1': { | |
'CFBundleIdentifier': 'com.apple.driver.AppleUSBHIDMouse', | |
'HIDDefaultBehavior': 'Mouse', | |
'IOClass': 'AppleHIDMouse', | |
'IOProviderClass': 'IOUSBInterface', | |
'bConfigurationValue': 1, | |
'bInterfaceNumber': 0, | |
'idProduct': idProduct, | |
'idVendor': idVendor | |
}, | |
'WiredMouseAccel-1': { | |
'AppleHIDMouseVersion': | |
256, | |
'CFBundleIdentifier': | |
'com.apple.iokit.IOHIDFamily', | |
'HIDAccelCurves': [{ | |
'HIDAccelGainLinear': 65536, | |
'HIDAccelIndex': 0, | |
'HIDAccelTangentSpeedLinear': 524288 | |
}, { | |
'HIDAccelGainCubic': 5243, | |
'HIDAccelGainLinear': 70124, | |
'HIDAccelGainParabolic': 26214, | |
'HIDAccelIndex': 8192, | |
'HIDAccelTangentSpeedLinear': 537395, | |
'HIDAccelTangentSpeedParabolicRoot': 1245184 | |
}, { | |
'HIDAccelGainCubic': 6554, | |
'HIDAccelGainLinear': 74711, | |
'HIDAccelGainParabolic': 36045, | |
'HIDAccelIndex': 32768, | |
'HIDAccelTangentSpeedLinear': 543949, | |
'HIDAccelTangentSpeedParabolicRoot': 1179648 | |
}, { | |
'HIDAccelGainCubic': 7864, | |
'HIDAccelGainLinear': 79299, | |
'HIDAccelGainParabolic': 46531, | |
'HIDAccelIndex': 45056, | |
'HIDAccelTangentSpeedLinear': 550502, | |
'HIDAccelTangentSpeedParabolicRoot': 1114112 | |
}, { | |
'HIDAccelGainCubic': 9830, | |
'HIDAccelGainLinear': 83886, | |
'HIDAccelGainParabolic': 57672, | |
'HIDAccelIndex': 57344, | |
'HIDAccelTangentSpeedLinear': 557056, | |
'HIDAccelTangentSpeedParabolicRoot': 1048576 | |
}, { | |
'HIDAccelGainCubic': 11796, | |
'HIDAccelGainLinear': 88474, | |
'HIDAccelGainParabolic': 69468, | |
'HIDAccelIndex': 65536, | |
'HIDAccelTangentSpeedLinear': 563610, | |
'HIDAccelTangentSpeedParabolicRoot': 983040 | |
}, { | |
'HIDAccelGainCubic': 14418, | |
'HIDAccelGainLinear': 93061, | |
'HIDAccelGainParabolic': 81920, | |
'HIDAccelIndex': 98304, | |
'HIDAccelTangentSpeedLinear': 570163, | |
'HIDAccelTangentSpeedParabolicRoot': 917504 | |
}, { | |
'HIDAccelGainCubic': 17695, | |
'HIDAccelGainLinear': 97649, | |
'HIDAccelGainParabolic': 95027, | |
'HIDAccelIndex': 131072, | |
'HIDAccelTangentSpeedLinear': 576717, | |
'HIDAccelTangentSpeedParabolicRoot': 851968 | |
}, { | |
'HIDAccelGainCubic': 21627, | |
'HIDAccelGainLinear': 102236, | |
'HIDAccelGainParabolic': 108790, | |
'HIDAccelIndex': 163840, | |
'HIDAccelTangentSpeedLinear': 583270, | |
'HIDAccelTangentSpeedParabolicRoot': 786432 | |
}, { | |
'HIDAccelGainCubic': 26214, | |
'HIDAccelGainLinear': 104858, | |
'HIDAccelGainParabolic': 123208, | |
'HIDAccelIndex': 196608, | |
'HIDAccelTangentSpeedLinear': 589824, | |
'HIDAccelTangentSpeedParabolicRoot': 786432 | |
}], | |
'HIDDisallowRemappingOfPrimaryClick': | |
True, | |
'HIDScrollAccelerationTable': | |
b'\x00\x00\x80\x00USB*\x00\x08\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\xa0\x00\x00\x00 \x00\x00\x11\x00\x00\x80\x00\x00\x01!8\x00\x00\xf7w\x00\x03\x04\x85\x00\x01\x91\x11\x00\x05\xb35\x00\x0233\x00\x08\x8c\xcf\x00\x03\x19\x9a\x00\r>\x82\x00\x04\x08\x89\x00\x13\x1c\xa1\x00\x04\xf7w\x00\x19\xd1W\x00\x06""\x00"\xb3\xfc\x00\x07\x9b\xb9\x00/\xad+\x00\t\x0b\xe4\x00@\x94u\x00\n\xe6\xf1\x00Y\xb7\xe8\x00\x0c\xcd\xf5\x00q\x00\xa2\x00\x0f\'\x9b\x00\x8a\xbcX\x00\x11\xd4>\x00\xa3Y\xa1\x00\x14\xc8:\x00\xc0\xe0\x04\x00\x17\xd4\'\x00\xd8\xa2\x91\x00\x1bO\x97\x00\xf0\x8c\xc0\x00\x00P\x00\x00\x11\x00\x00\x80\x00\x00\x02H\x0b\x00\x00\xee\xef\x00\x05\x07\x89\x00\x01ff\x00\x086\xf9\x00\x02\x19\x9a\x00\r\x13\x97\x00\x02\xc4D\x00\x11\x9a^\x00\x03\x91\x11\x00\x17"\xa8\x00\x04\xaa\xab\x00\x1f\x84\x8c\x00\x05\xd5U\x00)\x12\xdc\x00\x07X/\x009M\xb0\x00\x08\xfa\x01\x00J\xc6\'\x00\n\xe6\xf1\x00d|\x0e\x00\x0c\xcd\xf5\x00~\x90\x12\x00\x0f\'\x9b\x00\x9bbN\x00\x11\xd4>\x00\xb6\xf3\xbf\x00\x15\x01\x9c\x00\xdc\x94\xb6\x00\x18\x16\x80\x00\xf9\x15;\x00\x1bO\x97\x01\rjp\x00\x00\x80\x00\x00\x11\x00\x00ww\x00\x03\xfc\x8b\x00\x00\xe6f\x00\x07gK\x00\x01L\xcd\x00\x0bc\xd5\x00\x01\xcc\xcd\x00\x0f\xa9E\x00\x02\x80\x00\x00\x15\xec\xfb\x00\x03UU\x00\x1cy\x95\x00\x04\xcc\xcd\x00(\xdc\x8d\x00\x06DD\x005\xf5V\x00\x07ww\x00B\xdc\x87\x00\x08\xf7w\x00S\xfaF\x00\n\xe6\xf1\x00p\x8a\xf1\x00\x0c\xcd\xf5\x00\x8d\xc0\x14\x00\x0f\'\x9b\x00\xae\x07\xb4\x00\x11\xd4>\x00\xcc\xe8\t\x00\x15\x0e\xc2\x00\xf6\x9a\xc0\x00\x18#\xa6\x01\x15\x95\xc0\x00\x1bO\x97\x01-\xbe\xe4\x00\x00\xb0\x00\x00\x11\x00\x00\x88\x89\x00\x07\xad\xb6\x00\x00\xf7w\x00\r>\x82\x00\x01ww\x00\x13\x1c\xa1\x00\x02\x08\x89\x00\x19P\x96\x00\x02\xcc\xcd\x00!\xb2z\x00\x03\xcc\xcd\x00+\x15\xe0\x00\x04\xee\xef\x005\xa5\xb2\x00\x06\x11\x11\x00@\xe10\x00\x07\x99\xef\x00Q\xc9\xd7\x00\t\x10\xab\x00c\xc8\x83\x00\n\xcf\xe1\x00\x81!\x9a\x00\x0c\xcd\xf5\x00\x9e\xc2\xa6\x00\x0f\'\x9b\x00\xc2\xe9\xe8\x00\x12\x07\x04\x00\xec\xb0\xd5\x00\x15\x0e\xc2\x01\x13\x1bF\x00\x18<u\x016\xcd\xfa\x00\x1b\x06>\x01K\xf4:\x00\x00\xe0\x00\x00\x11\x00\x00\x80\x00\x00\x0b%\xc1\x00\x00\xfa\xb1\x00\x17\xc2\x8e\x00\x01x\t\x00 %V\x00\x02\x1f*\x00);\x05\x00\x02\xf0\x13\x003\xb6\x7f\x00\x03\xf8\xb1\x00?\x97\xc6\x00\x05\x01P\x00J\x13A\x00\x063\xb6\x00U\xf4\x88\x00\x07X/\x00c;\x9a\x00\x08\xdd\xde\x00v\xf7\t\x00\n\xb33\x00\x95\xf2\t\x00\x0c\xe42\x00\xb9\xe1\xfe\x00\x0f\'\x9b\x00\xdaM\xa8\x00\x11\xd4>\x01\x01\x08\xda\x00\x14\xfd[\x01)\x86\xba\x00\x18&y\x01R\x04\x9e\x00\x1a\xe9\xa7\x01c\xa7\xde\x00\x01\x00\x00\x00\x11\x00\x00*\xab\x00\r\x9a*\x00\x00n\xef\x00\x1bT\x92\x00\x00\xdd\xde\x00)\x0e\xfa\x00\x01\x88\x89\x005\x05\xfd\x00\x02\x96a\x00@^)\x00\x03\x8b^\x00LRd\x00\x04\xa4\xa6\x00Y2\x06\x00\x05\xd0\x15\x00e&A\x00\x071\xf4\x00v\x9e\xe6\x00\x08\xaf\xb9\x00\x89\x02\xf1\x00\n\xb33\x00\xa7\xf0\\\x00\x0c\xe42\x00\xd00P\x00\x0f\'\x9b\x00\xf4\x7f\xef\x00\x11\xd4>\x01\x1f\xe0\xf4\x00\x14\xfd[\x01M:\xbc\x00\x18&y\x01z\x94\x88\x00\x1a\xe9\xa7\x01\x8eU\x9c\x00\x01\xb33\x00\x11\x00\x00*\xab\x00\x0f<\x06\x00\x00n\xef\x00\x1e\x9c)\x00\x00\xdd\xde\x00-\xfcK\x00\x01\x88\x89\x00;b\xde\x00\x02\x96a\x00H\x17\x8a\x00\x03\x8b^\x00U{\x00\x00\x04\xa4\xa6\x00c\xe6\x1b\x00\x05\xd0\x15\x00qI\x91\x00\x071\xf4\x00\x84\xda\xed\x00\x08\xaf\xb9\x00\x99s\xef\x00\n\xb33\x00\xbc\x17q\x00\x0c\xe42\x00\xe9+\xdf\x00\x0f\'\x9b\x01\x11\xd6\xf8\x00\x11\xd4>\x01Bl\x96\x00\x14\xfd[\x01u7\x8a\x00\x18&y\x01\xa8\x02\x84\x00\x1a\xe9\xa7\x01\xbe"r', | |
'HIDScrollAccelerationTableX': | |
b'\x00\x00\x80\x00USB*\x00\x08\x00\x00\x00\x00\x00\x01\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00 \x00\x00\x11\x00\x00\x80\x00\x00\x02\x19\xc3\x00\x01\x00\x00\x00\x04*\xdb\x00\x01ww\x00\x07\x80W\x00\x0233\x00\x0f}\xb3\x00\x03*\xab\x00\x19"\xe9\x00\x04\x11\x11\x00!\xe7\xa5\x00\x05\x19\x9a\x00*a\x8e\x00\x06ff\x005\xfbn\x00\x07\xcc\xcd\x00CzI\x00\tUU\x00T6O\x00\x0b\x00\x00\x00g\xa5M\x00\x0c\xdd\xde\x00}\xcc#\x00\x0f33\x00\x9ax\xc9\x00\x11\xdd\xde\x00\xba\x96\xdc\x00\x14\xe6f\x00\xdbwr\x00\x17\xdd\xde\x00\xf9e\xc1\x00\x1b""\x01\x18\x8e\x1c\x00\x00P\x00\x00\x0f\x00\x00\x80\x00\x00\x043\x87\x00\x01\x00\x00\x00\nt(\x00\x02\x00\x00\x00\x19\x1c\t\x00\x03DD\x00(\x84\x83\x00\x04\xa2"\x005\x12\x88\x00\x06\x11\x11\x00D{\x02\x00\x07\xcc\xcd\x00V+\xda\x00\t\x19\x9a\x00f&l\x00\n\xa2"\x00z\xb1\xb9\x00\x0cff\x00\x91\x85d\x00\x0e\xf7w\x00\xb0\xe8o\x00\x11\x91\x11\x00\xd0\xdd\x92\x00\x15\x08\x89\x00\xf8=\xe7\x00\x18\x11\x11\x01\x17\xa0\xf2\x00\x1b\x19\x9a\x016\xa46\x00\x00\x80\x00\x00\x0f\x00\x00\x80\x00\x00\x08\x1a:\x00\x01\x08\x89\x00\x14z\xcc\x00\x01\xf7w\x00#k\x0b\x00\x03\x11\x11\x003t\xe0\x00\x04L\xcd\x00B\xd3\xa1\x00\x05\xc4D\x00T3\x9d\x00\x07ff\x00f>\xad\x00\t;\xbc\x00|L1\x00\x0b\x11\x11\x00\x94Z\xf0\x00\r\x19\x9a\x00\xaf\x15\xfd\x00\x0f;\xbc\x00\xca|\x1e\x00\x12\x11\x11\x00\xef\xe8d\x00\x15\x19\x9a\x01\x15T\xaa\x00\x18""\x015hR\x00\x1b\x19\x9a\x01T\xbaP\x00\x00\xb0\x00\x00\x0f\x00\x00\x80\x00\x00\x104u\x00\x01\x08\x89\x00\x1eW\x1b\x00\x01\xcc\xcd\x00-\x82\xa9\x00\x02\xd5U\x00>\xf4\xbf\x00\x03\xf7w\x00Q)\x03\x00\x05\x80\x00\x00fe\xfc\x00\x07UU\x00}\xe9~\x00\t;\xbc\x00\x96\xf1[\x00\n\xf7w\x00\xac\xf0\x82\x00\x0c\xf7w\x00\xc8>\xe7\x00\x0fDD\x00\xe5\xd3\xd5\x00\x12\x08\x89\x01\x0c\x82\xe4\x00\x15\x11\x11\x0131\xf4\x00\x18\x08\x89\x01S\rj\x00\x1b\x19\x9a\x01r\xd0j\x00\x00\xe0\x00\x00\x0f\x00\x00\x80\x00\x00\x18\x01\xdc\x00\x01\x08\x89\x00(6Q\x00\x01\xaa\xab\x008!&\x00\x02\x99\x9a\x00K\xd9\xc4\x00\x03\xb33\x00a\x16\xbe\x00\x0533\x00y\\m\x00\x06\xe6f\x00\x93&x\x00\x08\x99\x9a\x00\xac.T\x00\n\x88\x89\x00\xc7|\xba\x00\x0c\xa2"\x00\xe5\x11\xa8\x00\x0f\x11\x11\x01\x04*\xf0\x00\x12\x00\x00\x01,^Z\x00\x15\x11\x11\x01Q\x89\x10\x00\x1833\x01tm<\x00\x1b\x11\x11\x01\x90\xe6\x84\x00\x01\x00\x00\x00\x0f\x00\x00\x80\x00\x00 \x1c\x17\x00\x01\x00\x00\x0047?\x00\x01\x99\x9a\x00Ep\x0b\x00\x02ww\x00ZD\xdb\x00\x03ww\x00o\x19\xab\x00\x04\xf7w\x00\x8ck\x1b\x00\x06\x99\x9a\x00\xa8\xf7\x08\x00\x08n\xef\x00\xc7\r\xfc\x00\nDD\x00\xe2\xd4g\x00\x0cff\x01\x03;\xe2\x00\x0f\x19\x9a\x01*\x94\xfa\x00\x12\x08\x89\x01U\x04\x1c\x00\x15\x19\x9a\x01}"\xb6\x00\x18;\xbc\x01\xa4{\xce\x00\x1b\x00\x00\x01\xc2\x8a\xfc\x00\x01\xb33\x00\x10\x00\x00\x80\x00\x00(\x1dW\x00\x01\x00\x00\x00@.\xf2\x00\x01ww\x00R\xbc\xc9\x00\x02\x11\x11\x00d\x18t\x00\x03\x19\x9a\x00\x7f\xdd\xf0\x00\x04ww\x00\x9d3}\x00\x05\x99\x9a\x00\xb4\x84\x9e\x00\x06\xc4D\x00\xcc\x96L\x00\x08""\x00\xe6\xe9\xa3\x00\t\xd5U\x01\x04?0\x00\x0c""\x01+[\xec\x00\x0e\xaa\xab\x01Ovr\x00\x11\xb33\x01|\x97\x9a\x00\x14\xf7x\x01\xa9\xb8\xc0\x00\x17\xee\xef\x01\xd0\xd5|\x00\x1b\x00\x00\x01\xf4/t', | |
'HIDScrollResolution': | |
2818048, | |
'HIDScrollResolutionX': | |
2818048, | |
'IOClass': | |
'IOHIDEventDriver', | |
'IOHIDScrollReportRate': | |
8192000, | |
'IOProviderClass': | |
'IOHIDInterface', | |
'ProductID': | |
idProduct, | |
'VendorID': | |
idVendor | |
} | |
} | |
# Check filename | |
for fn in files: | |
try: | |
f = open(fn) | |
flag = True | |
f.close() | |
except FileNotFoundError: | |
flag == False | |
break | |
except PermissionError: | |
print("I can't read this file: %s\nPlease ensure the permission.\nTry to run this script with root permission maybe?" % fn) | |
exit(3) | |
if flag == True: | |
filename = fn | |
try: | |
filename | |
except: | |
print("Both VirtualSMC and FakeSMC not found") | |
exit(1) | |
# Stop if backup already exist | |
try: | |
f = open(filename+".bak") | |
f.close() | |
print("Backup file exists, exiting!") | |
exit(2) | |
except FileNotFoundError: | |
print("No backup file, backing up...") | |
except PermissionError: | |
print("Backup file exists, exiting!") | |
exit(2) | |
# Backup original file | |
try: | |
copyfile(filename, filename + '.bak') | |
except IOError as e: | |
print("Unable to copy file. %s" % e) | |
exit(1) | |
except Exception as e: | |
print("Unexpected error: " + e) | |
exit(1) | |
# Modify plist for fake mouse | |
with open(filename, 'rb') as file: | |
try: | |
dic = plistlib.load(file) | |
print("Reading from file: " + filename) | |
dic["IOKitPersonalities"]["WiredMouse-1"] = insert_dict["WiredMouse-1"] | |
dic["IOKitPersonalities"]["WiredMouseAccel-1"] = insert_dict["WiredMouseAccel-1"] | |
except PermissionError: | |
print("I can't read this file: %s\nPlease ensure the permission.\nTry to run this script with root permission maybe?" % filename) | |
exit(3) | |
except Exception as e: | |
print("Unexpected error: " + e) | |
exit(4) | |
with open(filename, "wb") as file: | |
try: | |
plistlib.dump(dic, file) | |
print("Write to file: " + filename) | |
except PermissionError: | |
print("I can't write this file: %s\nPlease ensure the permission.\nTry to run this script with root permission maybe?" % filename) | |
exit(3) | |
except Exception as e: | |
print("Unexpected error: " + e) | |
exit(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment