Created
June 25, 2020 08:59
-
-
Save yamadaaaaaaa/a5b393b6cb13e69792b080024030104c to your computer and use it in GitHub Desktop.
maya_escapeMalware.py
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
import stat | |
import os | |
import re | |
import ctypes | |
from ctypes.wintypes import MAX_PATH | |
def maya_escapeMalware(): | |
# set read only animImportExport.pres.mel | |
adkPath = r'C:\Program Files\Autodesk' | |
if not os.path.exists(adkPath):return | |
for aaa in os.listdir(adkPath): | |
if not re.search('Maya(?P<n>\d+)',aaa):continue | |
dirA = os.path.join(adkPath,aaa,'resources','l10n') | |
if not os.path.exists(dirA):continue | |
for bbb in os.listdir(dirA): | |
path_aie = os.path.join(dirA,bbb,'plug-ins','animImportExport.pres.mel') | |
if not os.path.exists(path_aie):continue | |
if os.access(path_aie, os.W_OK): | |
os.chmod(path_aie, stat.S_IREAD) | |
# set read only userSetup.mel | |
home = os.path.join(os.getenv("HOMEDRIVE"),os.getenv("HOMEPATH"),"Documents") | |
dll = ctypes.windll.shell32 | |
buf = ctypes.create_unicode_buffer(MAX_PATH + 1) | |
if dll.SHGetSpecialFolderPathW(None, buf, 0x0005, False): | |
home = buf.value | |
path_usp = os.path.join(home,'maya','scripts','userSetup.mel') | |
# Just in case | |
#melText = '{' + os.linesep + \ | |
# 'global int $autoUpdateAttrEd_aoto_int;' + os.linesep + \ | |
# '$autoUpdateAttrEd_aoto_int = -1;' + os.linesep + \ | |
# '}' | |
melText = """{ | |
global int $autoUpdateAttrEd_aoto_int; | |
$autoUpdateAttrEd_aoto_int = -1; | |
}""" | |
if not os.path.exists(path_usp): | |
with open(path_usp, "w") as f: | |
f.write(melText) | |
os.chmod(path_usp, stat.S_IREAD) | |
else: | |
with open(path_usp, "r") as f: | |
s = f.read() | |
s += os.linesep + melText | |
if not os.access(path_aie, os.W_OK): | |
os.chmod(path_usp, stat.S_IWRITE) | |
with open(path_usp, "w") as f: | |
f.write(s) | |
os.chmod(path_usp, stat.S_IREAD) | |
# EOF Just in case | |
maya_escapeMalware() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
runBatch.bat