-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvscan
executable file
·98 lines (81 loc) · 2.94 KB
/
vscan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
"""
CLI (Command line interface for the virus scanner)
Parameters:
|
|__ Virus Scanner
|_ file name to scan
|_ URL to scan
"""
import click
# Importing file from different folders
import sys
import os
from os import path
import platform
import virus_scanner as vs
# Config file
if platform.system() == "Windows":
config_path = os.path.dirname(vs.__file__) + "\\config.yaml"
else:
config_path = os.path.dirname(vs.__file__) + "/config.yaml"
# checks if user has created a config file. If no config is present, it prompts the user for the API keys
if path.isfile(config_path) != True:
print("No config file")
f = open(config_path, "w+")
metakey = input("Enter API key for MetaDefender: ")
virusscankey = input("Enter API key for VirusTotal: ")
f.write("Meta_Defender_API_key: " + metakey + "\n")
f.write("Virus_Total_API_key: " + virusscankey + "\n")
f.close()
from virus_scanner.vscan_config import *
# Import the interactive main file from the Main directory
import virus_scanner.Main.main as m
# Import the metadefender file
import virus_scanner.Meta_Defender.MetaDefenderMain as meta
# Import the VirusTotal files
import virus_scanner.VirusTotal_API.VirusTotal_API_File as vfile
import virus_scanner.VirusTotal_API.VirusTotal_API_URL as vurl
@click.group()
def main():
pass
@main.command()
@click.option("--VirusTotalFile", "-VTF", help="Scan a file using the VirusTotal API")
@click.option("--VirusTotalURL", "-VTU", help="Scan a website using the VirusTotal API")
@click.option("--MetaDefender", "-M", help="Scan a file using the MetaDefender API")
@click.option("-i", is_flag=True, help="Opens in interactive command line mode")
@click.option("-e", is_flag=True, help="Opens a text editor to change API keys")
@click.option(
"-v",
is_flag=True,
help="Gives a verbose output which prints the scan result of each scanner",
)
def main(virustotalfile, virustotalurl, metadefender, i, e, v):
"""This is a CLI application to scan a file or a website using multiple scanners to check for any form of malware"""
verbose = False
if v:
verbose = True
if virustotalfile:
"""
Parameters (<file to scan>,<virus total api key>)
"""
vfile.ScanFile(virustotalfile, Virus_Total_API_key(), verbose)
elif virustotalurl:
"""
Parameters (<url to scan>,<virus total api key>)
"""
vurl.ScanURL(virustotalurl, Virus_Total_API_key(), verbose)
elif metadefender:
meta.scanFile(metadefender, Meta_Defender_API_key(), verbose)
elif i:
m.mainfile(verbose)
elif e:
if platform.system() == "Windows":
os.system(f"notepad {config_path}")
else:
os.system(f"nano {config_path}")
else: # shows help options if no options are input
ctx = click.get_current_context()
click.echo(ctx.get_help())
if __name__ == "__main__":
main()