import subprocess
def scan_file_with_clamscan(file_path):
# 定义要执行的命令
command = ['clamscan', '-r', file_path]
# 执行命令并捕获输出
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
print(f"result: {result}")
# 检查输出中是否包含"Infected files: 1"
if 'Infected files: 1' in result.stdout:
return True # 文件被感染
else:
return False # 文件未被感染
# 要扫描的文件路径
file_path = '/home/leon/202405220925/eicar.com'
# 调用函数并打印结果
is_infected = scan_file_with_clamscan(file_path)
if is_infected:
print(f"The file {file_path} is infected with a virus.")
else:
print(f"The file {file_path} is clean.")
Virus Scanning with Clamscan
最新推荐文章于 2024-06-17 17:35:06 发布