我正计划在 Python 中创建一个防病毒程序。我目前正在尝试扫描恶意文件数据而不是恶意文件名,但不确定如何实现它。我有病毒样本文件VirusSample.exe
并VirusSample.bat
进行扫描。我如何在 Python 中实现它?如果有人可以提供帮助,我将不胜感激。
问问题
1836 次
1 回答
0
我知道如何处理批处理文件 (*.bat)。您可以使用拆分功能(batchString.split("\n") )扫描恶意代码,例如rd c:\system32。如果在批处理文件中找到此类代码之一,则它是恶意的。
detection = False
malicious = ("rd c:\system32", "del c:\", "rd c:\")
filename = input("Batch File >> ")
fs = open(filename, 'r')
batch = fs.read()
fs.close()
codes = batch.split("\n")
for line in codes:
for maliciouscode in malicious:
if maliciouscode.lower() == line.lower():
detection = True
if detection == True:
print("Virus detected!")
于 2018-04-01T10:43:10.713 回答