Python 3.x Python:扫描文件数据

Python 3.x Python:扫描文件数据,python-3.x,antivirus,virus-scanning,Python 3.x,Antivirus,Virus Scanning,我计划用Python创建一个防病毒程序。我目前正在尝试扫描恶意文件数据,而不是恶意文件名称,但不确定如何实现它。我有要扫描的病毒样本文件VirusSample.exe和VirusSample.bat。如何在Python中实现这一点?如果有人能帮助我,我将不胜感激。我知道如何处理批处理文件(*.bat)。 您可以使用 split函数(batchString.split(“\n”))。 如果在批处理文件中发现此类代码之一,则该代码是恶意的 detection = False malicious =

我计划用Python创建一个防病毒程序。我目前正在尝试扫描恶意文件数据,而不是恶意文件名称,但不确定如何实现它。我有要扫描的病毒样本文件
VirusSample.exe
VirusSample.bat
。如何在Python中实现这一点?如果有人能帮助我,我将不胜感激。

我知道如何处理批处理文件(*.bat)。 您可以使用 split函数(batchString.split(“\n”))。 如果在批处理文件中发现此类代码之一,则该代码是恶意的

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!")

你会扫描什么?@MaartenFabré谢谢你的回复。我正在尝试扫描病毒文件的内容。