Project Report of The Virus Detector Final
Project Report of The Virus Detector Final
Engineering College-MCA,
Ghaziabad
Project Report
THE Virus Detector
Submitted in partial fulfillment of requirement
for the degree of MCA
I
ABSTRACT
Technology:
PYTHON
GROUP MEMBER –
iii
ACKNOWLEDGEMENT
ACKNOWLEDGEMENT
First of all we would like to thanks our Head of Department of MCA DR. B.K. SHARMA for
all facilities provided to us in carrying out this project.
With profound sense of gratitude and regard, I express my sincere thanks to my guide
and mentor “Ms. Deepti Arora” and “Ms. Aman Gupta” valuable guidance and the
confidence she instilled in me, that helped me in the successful completion of this
project report. Without their help, this project would have been adistant affair. It is
thorough understanding of the subject and professional guidance was indeed of
immense help to me. Also, this acknowledgement would remain incomplete without
thanking of THE Virus Detector. I am also greatly thankful to the faculty members
of our institute who cooperated with me and gave me their valuable time.
Then I would like thank my Teacher and friends who have helped me with their
valuable suggestions and guidance has been very helpful in various phase of the
completion of the project.
iv
COLLEGE CERTIFICATE
iv
Table Of Content
3 SRS 04
4 System architecture 16
5 Database Design 31
6 Source Code 32
7 Test Cases 64
iv
Chapter 1:-
INTRODUCTION
7
Significance of Virus Detector:
8
Chapter:-2
Problem Statement And Description
Problems faced:
Our computers and devices are under constant threat from viruses—
malicious software that can harm our systems and steal our information.
The current issue is that the software we use to detect and stop these
viruses is not keeping up with the clever tricks that hackers use.
Solution:
We need a new kind of virus detector software that is fast, smart,
doesn't slow down our devices, is easy for everyone to use, and
works on all our devices. This way, we can stay one step ahead of
the hackers and keep our digital lives safe and secure.
9
Chapter:-3
Software Requirements Specification
1. Introduction
In the rapidly evolving landscape of digital technology, the persistent
threat of malicious software, commonly known as viruses, remains a
critical concern for individuals and organizations alike. As our
dependence on digital platforms grows, so does the need for robust
cyber security measures to safeguard sensitive data, personal
information, and the overall integrity of computer systems. To address
this pressing need, the development of sophisticated and effective virus
detector software has become paramount. This software represents a
crucial line of defense against the ever-expanding array of digital threats
that seek to compromise the security and functionality of computers and
networks. A virus detector software, often referred to as antivirus or
anti-malware software, is designed with the primary objective of
identifying, preventing, and eliminating malicious software from a
computer system. This introduction provides an overview of the key
components, functionalities, and significance of virus detector software
in the realm of cybersecurity.
1.1 Purpose
1.2 Scope
10
1.3 Definition, Acronyms and abbreviations\
1.3 References
(1) Google
(2)Youtube
(3) IEEE. IEEE Std 830-1998 IEEE Recommended Practice for Software
Requirements Specifications. IEEE Computer Society, 1998.
1.4 Overview
11
2.2 Product Perspective
2.4 Constraints
Device Constraint
Food world core system and its user interfaces should be compatible with tablets.
However, running on small android mobile devices is not necessary.
12
2.5 Assumptions for dependencies
One assumption about the software is that it will always be used on tablets that
have enough resources to run the application. If the tablet does not have enough
hardware resources available for the application, there may be scenarios where the
application does not work as intended or not even at all. The application uses
database for online storage of information like orders and menu items that needs
to be in working state. If the interface changes the application needs to be adjusted
accordingly.
3 Specific Requirement:
Mouse
Software Requirements:
Operating System : Windows9,10
Technology : Python
13
IDE : Sublime,Visual
Studio code,Notepad+
+
Web Server : Chrome,firevox,internet
Explorer,Microsoftedge
Database : Xamp
14
(3)Hardware Interfaces
The hardware interface for a virus detector typically involves the integration of the software
with the underlying hardware components of a computer system. Here are some
considerations for the hardware interface of a virus detector:
1. Processor Utilization:
The virus detector should be optimized to use the processing power of the
CPU efficiently.
It should be designed to run in the background without significantly impacting
the overall performance of the system during regular operation.
2. Memory Usage:
Efficient memory management is crucial to prevent excessive memory
consumption.
The virus detector should be designed to use memory resources judiciously
and release memory when it is no longer needed.
3. Storage Access:
The virus detector needs to access files and storage devices for scanning
purposes.
It should interact with the file system in a way that is compatible with various
storage devices.
4. Network Interface:
If the virus detector involves features such as real-time scanning or cloud-
based threat detection, it may need to interact with the network interface.
Ensure compatibility with different network configurations and protocols.
5. Peripheral Devices:
The virus detector may need to interact with peripheral devices, such as
external drives or USB devices, to scan for potential threats.
Ensure compatibility with a variety of peripheral devices commonly used by
users.
6. Compatibility with Hardware Security Features:
Modern hardware often includes security features, such as hardware-based
encryption or secure boot options.
The virus detector should be compatible with and take advantage of these
hardware security features when available.
7. Power Management:
Consider power consumption and ensure that the virus detector does not
excessively drain the device's battery, especially in the case of portable
devices like laptops or mobile devices.
8. Notifications and Alerts:
If the virus detector needs to provide notifications or alerts, ensure
compatibility with hardware features like display interfaces, sound systems, or
LED indicators.
9. System Resources Monitoring:
The virus detector may include features to monitor system resources to ensure
it is not overloading the hardware. This may involve checking CPU usage,
memory usage, and other relevant metrics.
10. Configuration and Management Interfaces:
Consider hardware interfaces for configuration and management, such as
command-line interfaces (CLI) or graphical user interfaces (GUI), to allow
users to customize settings and monitor the virus detector's performance.
15
3.2 Functions
A virus detector typically performs various functions to identify and mitigate potential threats to a
computer system. Here are common functions that a virus detector might include:
1. Virus Scanning:
Function: Scans files, directories, and storage devices for the presence of viruses,
malware, or other malicious code.
Details: The virus detector should use signature-based detection, heuristic analysis, and
behavior analysis to identify known and unknown threats.
2. Real-Time Protection:
Function: Monitors system activities in real-time to detect and prevent the execution of
malicious code.
Details: This function involves scanning files and processes as they are accessed,
executed, or downloaded to prevent infections before they occur.
3. Quarantine and Removal:
Function: Isolates and contains detected malicious files to prevent them from causing
harm and removes or disinfects them.
Details: Infected files are moved to a quarantine area to prevent further spread, and the
user is alerted about the detection.
4. Automatic Updates:
Function: Regularly updates virus definitions, detection algorithms, and the software
itself to stay current with the latest threats.
Details: Ensures that the virus detector is equipped to identify and counter new and
evolving malware.
5. Scheduled Scans:
Function: Allows users to schedule periodic scans of the system to ensure
comprehensive coverage.
Details: Users can configure the virus detector to perform scans at specified intervals
(e.g., daily, weekly) to catch potential threats.
6. On-Demand Scans:
Function: Enables users to initiate manual scans on specific files, folders, or the entire
system.
Details: Provides flexibility for users to check specific areas of their system at their
discretion.
7. Behaviour Analysis:
Function: Analyses the behaviour of running processes to identify patterns indicative of
malicious activity.
Details: This function helps detect threats that may not be identified through signature-
based methods alone.
8. Email and Web Protection:
Function: Scans emails, attachments, and web content for potential threats.
Details: Protects users from malware distributed through email attachments, malicious
links, or drive-by downloads from websites.
9. Firewall Integration:
Function: Collaborates with the system's firewall to enhance network security.
Details: Helps in blocking incoming and outgoing network connections associated with
known malicious servers or suspicious activities.
10. Logging and Reporting:
Function: Keeps logs of detected threats, system activities, and other relevant events.
Details: Enables users to review and analyze security events, and provides reports on the
overall security status of the system.
11. User Notifications:
Function: Informs users about the status of scans, detected threats, and other security-
related events.
Details: Provides real-time alerts and notifications to keep users informed about potential
security issues.
12. Exclusion Lists:
16
Function: Allows users to exclude certain files, folders, or processes from scans to avoid
false positives.
Details: Users can customize the scanning behavior based on their preferences and
specific needs.
17
systems and hardware configurations.
Metric: Number of supported operating systems and hardware configurations.
12. Network Performance:
Requirement: Network-related functions, such as scanning email attachments or
checking for updates, should not cause significant delays.
Metric: Time taken for network-related operations.
13. User Interface Responsiveness:
Requirement: The user interface should respond promptly to user inputs.
Metric: User-perceived responsiveness of the graphical or command-line
interface.
14. Behavior Analysis Speed:
Requirement: Behavioral analysis should be performed efficiently to detect
emerging threats.
Metric: Time taken to analyze and identify potential threats based on behavior.
15. Minimum System Requirements:
Requirement: Specify the minimum hardware and software requirements for the
virus detector to run effectively.
Metric: Compatibility with systems meeting the specified minimum
requirements.
19
Chapter:-4
System Architecture
20
Chapter:- 4
TOOLS:
TECHNIQUES:
1. Python
21
Chapter:-4
The general use case diagram shows the main functions of the
system. The general use case is the most common application
of a use case diagram. The use case diagrams depict the
system’s main components as well as the flow of information
between them.
22
Chapter:- 4
23
24
Chapter:- 4
25
In this diagram:
User initiates a scan with the Virus Detector. The Virus Detector scans
files, and based on the result, it notifies the user. If a virus is detected,
the user takes necessary actions. If no virus is detected, the user is still
notified. The user can then view the scan report. The user can also check
for updates from Virus Definitions to update virus definitions.
26
Chapter:- 4
4.5 Collaboration Diagram
To develop a Online Food ordering website which shows the flows between the
order,delivery,food item,category and payment.Main features of food ordering
website are as follows:
-Its shows the full description and flow of order,category,payment,food item and
delivery.
27
Chapter:-4
4.6 Data Flow Diagram
Food Ordering Website is actually a type of software that allows the manager of
restaurants to manage and accept the placed orders over the Internet or in the
restaurant. Let us understand the working of the food ordering website by using data
flow diagram. DFD for Food Ordering System is shown above.
In the above diagram, the Input and Output of the system are shown. The system is
designed and established across the world with input and output at this level.
Food Ordering System has the following input :
-Food order is input as the user order for food it request to food system and then get
reponse and as output admin get all the details of food system and further response if
when needed. In the end, with the use of the amount of daily sold items and daily
inventory depletion, it is easy to prepare a report of management. Further, the admin
gets this report of management.
Generate
Report System Configure Settings
For processing the order, process 1.0 is responsible. For food, the housekeeping
activities involved are represented by processes 2.0, 3.0, and 4.0. The detailed
information about daily sold items should be available to create and report
management and the list of items that are available ‘in-stock’ should be kept by
maintaining the inventory data (describes the records of datasets such as their name,
their content, source, many useful information, etc.) at the same time.
28
DFD second level
29
Chapter:- 4
4.7 State Diagram
30
Chapter:-5
DATABASE DESIGN
31
Chapter:- 6
Source code
# imports
from fileinput import filename
from PyQt5 import QtCore, QtGui, QtWidgets
from virustotal_python import Virustotal
import configparser
import webbrowser
import requests
import hashlib
import sys
import os
# define config
config = configparser.ConfigParser()
config.read(settings_file_path)
# define Stuff
VERSION = "2.5"
DEV = "cookie0_o, Len-Stevens"
# url´s
Report_issues = "https://github.com/Len-Stevens/Python-Antivirus/issues/new"
Submit_sample = "https://github.com/Len-Stevens/Python-Antivirus/discussions/8"
virus_total_api = "https://www.virustotal.com/api/v3/files/report"
meta_defender_api = "https://api.metadefender.com/v4/hash/" # + hash
config['-settings-']['VirusTotalScan'] = str(virus_total_scan)
config['-settings-']['VirusTotalApiKey'] = str(api_key)
32
config["-settings-"]["MetaDefenderScan"] = str(meta_defender_scan)
config["-settings-"]["MetaDefenderApiKey"] = str(MetaDefenderApiKey)
if self.LightModeButton.text() == "Light Mode":
config["-settings-"]["Style"] = "Dark"
else:
config["-settings-"]["Style"] = "Light"
return
# remove file
def removeFile(file):
try:
os.remove(file)
except:
# file coudn't be deleted = show error message
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
File couldn't be deleted.
File: {file}"
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
finally:
# file deleted = show success message
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setText("Info")
msgBox.setInformativeText(f"""\
File successfully deleted.
File: {file}"
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
# display results
def displayResults_VIRUS(self, file):
self.Tabs.setCurrentIndex(2)
# check if virus total check if on and file is under 32mb
if self.UseVirusTotalApiCheckBox.isChecked() and os.path.getsize(file) < 32000000:
self.VirusTotalWidget.show()
else:
# hide Virus total results since it is not needed
self.VirusTotalWidget.hide()
33
# check if meta defender check if on and file is under 120mb
if self.UseMetaDefenderApiCheckBox.isChecked() and os.path.getsize(file) < 120000000:
self.MetaDefenderWidget.show()
else:
# hide meta defender results since it is not needed
self.MetaDefenderWidget.hide()
self.IsFileVirusY_N.setStyleSheet("color: red")
self.IsFileVirusY_N.setText("YES!")
# delete file button
self.DeleteFileButton.clicked.connect(lambda: removeFile(file))
# return button
self.ReturnToHomeTabButton.clicked.connect(lambda: self.Tabs.setCurrentIndex(0))
# display hash
self.FileHash.setText("File Hash: " + readable_hash)
34
with open(SHA256_HASHES_pack1,'r') as f:
lines = [line.rstrip() for line in f]
for line in lines:
if str(readable_hash) == str(line.split(";")[0]):
virus_found = True
f.close()
f.close()
# check if virus is found else pass
if virus_found == True:
pass
else:
pass
if virus_found == False:
# SHA256 HASHES check + pack 2
with open(SHA256_HASHES_pack2,'r') as f:
lines = [line.rstrip() for line in f]
for line in lines:
if str(readable_hash) == str(line.split(";")[0]):
virus_found = True
f.close()
f.close()
else:
pass
if virus_found == False:
# SHA256 HASHES check + pack 3
with open(SHA256_HASHES_pack3,'r') as f:
lines = [line.rstrip() for line in f]
for line in lines:
if str(readable_hash) == str(line.split(";")[0]):
virus_found = True
f.close()
f.close()
else:
pass
try:
# check if Virus total api is checked and file is under 32mb then scan the file with Virus total
if self.UseVirusTotalApiCheckBox.isChecked() and os.path.getsize(file) < 32000000:
# get api key
api_key = self.VirusTotalApiKey.text()
# check if api key is empty if yes then show error
if api_key == "":
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
Please enter a valid Virus Total API key.
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
# if api key is not empty then scan the file
else:
# Create dictionary containing the file to send for multipart encoding upload
files = {"file": (os.path.basename(file), open(os.path.abspath(file), "rb"))}
35
vtotal = Virustotal(API_KEY=api_key)
resp = vtotal.request("files", files=files, method="POST")
id = resp.data["id"]
headers = {"x-apikey": api_key}
analysis = requests.get(f"https://www.virustotal.com/api/v3/analyses/{id}", headers=headers)
analysis_json = analysis.json()
detections = analysis_json["data"]["attributes"]["stats"]["malicious"]
not_detections = analysis_json["data"]["attributes"]["stats"]["undetected"]
# show Virus total results
self.VirusTotalWidget.show()
# if detections more than half of not detections print red
if detections > not_detections:
self.DetectionsText.setStyleSheet("color: red")
self.DetectionsText.setText(f"{str(detections)}")
if virus_found == False:
self.IsFileVirusY_N.setFont(QtGui.QFont("Arial", 10))
self.IsFileVirusY_N.setText("Probably a virus!")
else:
displayResults_VIRUS(self, file)
else:
self.DetectionsText.setStyleSheet("color: green")
self.DetectionsText.setText(f"{str(detections)}")
if virus_found == False:
self.IsFileVirusY_N.setStyleSheet("color: green")
self.IsFileVirusY_N.setFont(QtGui.QFont("Arial", 12))
self.IsFileVirusY_N.setText("Probably clean")
else:
displayResults_VIRUS(self, file)
else:
pass
# show error when virus total api was not able to scan the file
except:
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
Cant scan file with Virus Total.
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
try:
# Meta Defender hash check
if self.UseMetaDefenderApiCheckBox.isChecked():
# get api key
MetaDefenderApiKey = self.MetaDefenderApiKey.text()
# check if api key is empty if yes then show error
if MetaDefenderApiKey == "":
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
36
Please enter a valid Meta Defender API key.
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
# if api key is not empty then scan the hash of the file
else:
M_header=({"apikey": MetaDefenderApiKey})
M_analysis = requests.get(meta_defender_api + readable_hash, headers=M_header)
M_analysis_json = M_analysis.json()
M_detections = M_analysis_json["scan_results"]["total_detected_avs"]
M_not_detections = M_analysis_json["scan_results"]["total_avs"]
half_M_not_detections = M_not_detections / 2
# show Meta Defender results
self.MetaDefenderWidget.show()
# if detections more than half of not detections print red
if M_detections > half_M_not_detections:
self.MetaDefenderDetectionsText.setStyleSheet("color: red")
self.MetaDefenderDetectionsText.setText(f"{str(M_detections)} | {str(M_not_detections)}")
self.IsFileVirusY_N.setStyleSheet("color: red")
if virus_found == False:
self.IsFileVirusY_N.setFont(QtGui.QFont("Arial", 10))
self.IsFileVirusY_N.setText("Probably a virus!")
else:
displayResults_VIRUS(self, file)
else:
self.MetaDefenderDetectionsText.setStyleSheet("color: green")
self.MetaDefenderDetectionsText.setText(f"{str(M_detections)} | {str(M_not_detections)}")
if virus_found == False:
self.IsFileVirusY_N.setStyleSheet("color: green")
self.IsFileVirusY_N.setFont(QtGui.QFont("Arial", 12))
self.IsFileVirusY_N.setText("Probably clean")
else:
displayResults_VIRUS(self, file)
else:
# goto hidden results tab
self.Tabs.setCurrentIndex(2)
if virus_found == True:
displayResults_VIRUS(self, file)
else:
displayResults_CLEAN(self, file)
# show error when Meta Defender api was not able to scan the file
except:
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
Cant scan file with Meta Defender.
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
37
finally:
# goto hidden results tab
self.Tabs.setCurrentIndex(2)
except:
# change tab to home tab
self.Tabs.setCurrentIndex(0)
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setText("Error")
msgBox.setInformativeText(f"""\
No file selected or \nProgram has no permission to access file.
""")
# remove window title bar
msgBox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint)
msgBox.exec_()
finally:
return
# BROWSE FILE
def browseFiles(MainWindow, self):
39
self.HomeTitle.setObjectName("HomeTitle")
self.SelectFileButton = QtWidgets.QPushButton(self.HomeTab)
self.SelectFileButton.setGeometry(QtCore.QRect(5, 45, 121, 31))
font = QtGui.QFont()
font.setPointSize(11)
self.SelectFileButton.setFont(font)
self.SelectFileButton.setFlat(False)
self.SelectFileButton.setObjectName("SelectFileButton")
self.ReportIssueButton = QtWidgets.QPushButton(self.HomeTab)
self.ReportIssueButton.setGeometry(QtCore.QRect(5, 85, 121, 31))
font = QtGui.QFont()
font.setPointSize(11)
self.ReportIssueButton.setFont(font)
self.ReportIssueButton.setFlat(False)
self.ReportIssueButton.setObjectName("ReportIssueButton")
self.Tabs.addWidget(self.HomeTab)
self.SettingsTab = QtWidgets.QWidget()
self.SettingsTab.setObjectName("SettingsTab")
self.SettingsTitle = QtWidgets.QLabel(self.SettingsTab)
self.SettingsTitle.setGeometry(QtCore.QRect(0, 0, 551, 41))
font = QtGui.QFont()
font.setPointSize(23)
self.SettingsTitle.setFont(font)
self.SettingsTitle.setAlignment(QtCore.Qt.AlignCenter)
self.SettingsTitle.setObjectName("SettingsTitle")
self.UseVirusTotalApiCheckBox = QtWidgets.QCheckBox(self.SettingsTab)
self.UseVirusTotalApiCheckBox.setGeometry(QtCore.QRect(5, 45, 451, 17))
font = QtGui.QFont()
font.setPointSize(10)
self.UseVirusTotalApiCheckBox.setFont(font)
self.UseVirusTotalApiCheckBox.setObjectName("UseVirusTotalApiCheckBox")
self.VirusTotalApiKey = QtWidgets.QLineEdit(self.SettingsTab)
self.VirusTotalApiKey.setGeometry(QtCore.QRect(5, 65, 391, 20))
font = QtGui.QFont()
font.setPointSize(7)
self.VirusTotalApiKey.setFont(font)
self.VirusTotalApiKey.setStyleSheet("")
self.VirusTotalApiKey.setInputMask("")
self.VirusTotalApiKey.setText("")
self.VirusTotalApiKey.setMaxLength(32767)
self.VirusTotalApiKey.setFrame(False)
self.VirusTotalApiKey.setEchoMode(QtWidgets.QLineEdit.Password)
self.VirusTotalApiKey.setAlignment(QtCore.Qt.AlignCenter)
self.VirusTotalApiKey.setObjectName("VirusTotalApiKey")
self.SaveSettingsButton = QtWidgets.QPushButton(self.SettingsTab)
self.SaveSettingsButton.setGeometry(QtCore.QRect(415, 265, 121, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.SaveSettingsButton.setFont(font)
self.SaveSettingsButton.setFlat(False)
self.SaveSettingsButton.setObjectName("SaveSettingsButton")
self.UseMetaDefenderApiCheckBox = QtWidgets.QCheckBox(self.SettingsTab)
self.UseMetaDefenderApiCheckBox.setGeometry(QtCore.QRect(5, 90, 481, 17))
font = QtGui.QFont()
font.setPointSize(10)
self.UseMetaDefenderApiCheckBox.setFont(font)
40
self.UseMetaDefenderApiCheckBox.setObjectName("UseMetaDefenderApiCheckBox")
self.MetaDefenderApiKey = QtWidgets.QLineEdit(self.SettingsTab)
self.MetaDefenderApiKey.setGeometry(QtCore.QRect(5, 110, 391, 20))
self.MetaDefenderApiKey.setStyleSheet("")
self.MetaDefenderApiKey.setInputMask("")
self.MetaDefenderApiKey.setText("")
self.MetaDefenderApiKey.setMaxLength(32767)
self.MetaDefenderApiKey.setFrame(False)
self.MetaDefenderApiKey.setEchoMode(QtWidgets.QLineEdit.Password)
self.MetaDefenderApiKey.setAlignment(QtCore.Qt.AlignCenter)
self.MetaDefenderApiKey.setObjectName("MetaDefenderApiKey")
self.LightModeButton = QtWidgets.QPushButton(self.SettingsTab)
self.LightModeButton.setGeometry(QtCore.QRect(280, 265, 121, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.LightModeButton.setFont(font)
self.LightModeButton.setFlat(False)
self.LightModeButton.setObjectName("LightModeButton")
self.Tabs.addWidget(self.SettingsTab)
self.VirusScanResults_hidden = QtWidgets.QWidget()
self.VirusScanResults_hidden.setObjectName("VirusScanResults_hidden")
self.VirusResultsTitle = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.VirusResultsTitle.setGeometry(QtCore.QRect(0, 0, 551, 41))
font = QtGui.QFont()
font.setPointSize(23)
self.VirusResultsTitle.setFont(font)
self.VirusResultsTitle.setAlignment(QtCore.Qt.AlignCenter)
self.VirusResultsTitle.setObjectName("VirusResultsTitle")
self.FileName = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.FileName.setGeometry(QtCore.QRect(5, 45, 541, 31))
font = QtGui.QFont()
font.setPointSize(9)
self.FileName.setFont(font)
self.FileName.setObjectName("FileName")
self.FilePath = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.FilePath.setGeometry(QtCore.QRect(5, 75, 541, 31))
font = QtGui.QFont()
font.setPointSize(9)
self.FilePath.setFont(font)
self.FilePath.setObjectName("FilePath")
self.FileHash = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.FileHash.setGeometry(QtCore.QRect(5, 110, 541, 31))
font = QtGui.QFont()
font.setPointSize(9)
self.FileHash.setFont(font)
self.FileHash.setObjectName("FileHash")
self.label = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.label.setGeometry(QtCore.QRect(5, 160, 111, 31))
font = QtGui.QFont()
font.setPointSize(9)
self.label.setFont(font)
self.label.setObjectName("label")
self.IsFileVirusY_N = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.IsFileVirusY_N.setGeometry(QtCore.QRect(5, 190, 101, 31))
font = QtGui.QFont()
font.setPointSize(18)
41
font.setBold(True)
font.setWeight(75)
self.IsFileVirusY_N.setFont(font)
self.IsFileVirusY_N.setStyleSheet("color: rgb(255, 0, 0);")
self.IsFileVirusY_N.setAlignment(QtCore.Qt.AlignCenter)
self.IsFileVirusY_N.setObjectName("IsFileVirusY_N")
self.ReturnToHomeTabButton = QtWidgets.QPushButton(self.VirusScanResults_hidden)
self.ReturnToHomeTabButton.setGeometry(QtCore.QRect(5, 265, 91, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.ReturnToHomeTabButton.setFont(font)
self.ReturnToHomeTabButton.setDefault(False)
self.ReturnToHomeTabButton.setFlat(False)
self.ReturnToHomeTabButton.setObjectName("ReturnToHomeTabButton")
self.DeleteFileButton = QtWidgets.QPushButton(self.VirusScanResults_hidden)
self.DeleteFileButton.setGeometry(QtCore.QRect(100, 265, 111, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.DeleteFileButton.setFont(font)
self.DeleteFileButton.setDefault(False)
self.DeleteFileButton.setFlat(False)
self.DeleteFileButton.setObjectName("DeleteFileButton")
self.line = QtWidgets.QLabel(self.VirusScanResults_hidden)
self.line.setGeometry(QtCore.QRect(0, 150, 540, 5))
self.line.setStyleSheet("background-color: rgb(74, 74, 74);")
self.line.setText("")
self.line.setIndent(-1)
self.line.setObjectName("line")
self.VirusTotalWidget = QtWidgets.QWidget(self.VirusScanResults_hidden)
self.VirusTotalWidget.setGeometry(QtCore.QRect(120, 160, 181, 71))
self.VirusTotalWidget.setObjectName("VirusTotalWidget")
self.label_3 = QtWidgets.QLabel(self.VirusTotalWidget)
self.label_3.setGeometry(QtCore.QRect(10, 9, 161, 21))
font = QtGui.QFont()
font.setPointSize(9)
self.label_3.setFont(font)
self.label_3.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
self.label_3.setObjectName("label_3")
self.DetectionsText = QtWidgets.QLabel(self.VirusTotalWidget)
self.DetectionsText.setGeometry(QtCore.QRect(10, 20, 161, 31))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.DetectionsText.setFont(font)
self.DetectionsText.setAlignment(QtCore.Qt.AlignCenter)
self.DetectionsText.setObjectName("DetectionsText")
self.label_5 = QtWidgets.QLabel(self.VirusTotalWidget)
self.label_5.setGeometry(QtCore.QRect(10, 47, 161, 16))
font = QtGui.QFont()
font.setPointSize(9)
self.label_5.setFont(font)
self.label_5.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
self.label_5.setObjectName("label_5")
self.label_3.raise_()
self.label_5.raise_()
42
self.DetectionsText.raise_()
self.MetaDefenderWidget = QtWidgets.QWidget(self.VirusScanResults_hidden)
self.MetaDefenderWidget.setGeometry(QtCore.QRect(310, 160, 221, 71))
self.MetaDefenderWidget.setObjectName("MetaDefenderWidget")
self.label_4 = QtWidgets.QLabel(self.MetaDefenderWidget)
self.label_4.setGeometry(QtCore.QRect(10, 9, 201, 21))
font = QtGui.QFont()
font.setPointSize(9)
self.label_4.setFont(font)
self.label_4.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
self.label_4.setObjectName("label_4")
self.MetaDefenderDetectionsText = QtWidgets.QLabel(self.MetaDefenderWidget)
self.MetaDefenderDetectionsText.setGeometry(QtCore.QRect(10, 20, 201, 31))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.MetaDefenderDetectionsText.setFont(font)
self.MetaDefenderDetectionsText.setAlignment(QtCore.Qt.AlignCenter)
self.MetaDefenderDetectionsText.setObjectName("MetaDefenderDetectionsText")
self.label_6 = QtWidgets.QLabel(self.MetaDefenderWidget)
self.label_6.setGeometry(QtCore.QRect(10, 47, 201, 21))
font = QtGui.QFont()
font.setPointSize(10)
self.label_6.setFont(font)
self.label_6.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
self.label_6.setObjectName("label_6")
self.label_4.raise_()
self.label_6.raise_()
self.MetaDefenderDetectionsText.raise_()
self.Tabs.addWidget(self.VirusScanResults_hidden)
self.LoadingPage = QtWidgets.QWidget()
self.LoadingPage.setObjectName("LoadingPage")
self.LoadingPageTitle = QtWidgets.QLabel(self.LoadingPage)
self.LoadingPageTitle.setGeometry(QtCore.QRect(-10, 0, 561, 41))
font = QtGui.QFont()
font.setPointSize(23)
self.LoadingPageTitle.setFont(font)
self.LoadingPageTitle.setAlignment(QtCore.Qt.AlignCenter)
self.LoadingPageTitle.setObjectName("LoadingPageTitle")
self.label_7 = QtWidgets.QLabel(self.LoadingPage)
self.label_7.setGeometry(QtCore.QRect(0, 0, 541, 301))
font = QtGui.QFont()
font.setPointSize(60)
font.setBold(True)
font.setWeight(75)
self.label_7.setFont(font)
self.label_7.setAlignment(QtCore.Qt.AlignCenter)
self.label_7.setObjectName("label_7")
self.label_7.raise_()
self.LoadingPageTitle.raise_()
self.Tabs.addWidget(self.LoadingPage)
self.version_display = QtWidgets.QLabel(MainWindow)
self.version_display.setGeometry(QtCore.QRect(1, 284, 47, 20))
self.version_display.setStyleSheet("background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5,
radius:0.5, fx:0.1468, fy:0.1468, stop:1 rgba(0, 0, 0, 0));")
43
self.version_display.setObjectName("version_display")
self.SideBar_2 = QtWidgets.QLabel(MainWindow)
self.SideBar_2.setGeometry(QtCore.QRect(-10, -10, 71, 51))
self.SideBar_2.setText("")
self.SideBar_2.setObjectName("SideBar_2")
self.CurrentTabHome = QtWidgets.QLabel(MainWindow)
self.CurrentTabHome.setGeometry(QtCore.QRect(0, 50, 3, 31))
self.CurrentTabHome.setText("")
self.CurrentTabHome.setObjectName("CurrentTabHome")
self.CurrentTabSettings = QtWidgets.QLabel(MainWindow)
self.CurrentTabSettings.setGeometry(QtCore.QRect(0, 90, 3, 31))
self.CurrentTabSettings.setText("")
self.CurrentTabSettings.setObjectName("CurrentTabSettings")
#
self.Tabs.setCurrentIndex(0)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
# Density Scale
'density_scale': '-2',
}
objects = [
# buttons
self.SelectFileButton,
self.ReportIssueButton,
self.LightModeButton,
self.SaveSettingsButton,
self.LightModeButton,
self.ReturnToHomeTabButton,
self.DeleteFileButton,
# line edits
self.MetaDefenderApiKey,
self.VirusTotalApiKey,
# check boxes
self.UseVirusTotalApiCheckBox,
self.UseMetaDefenderApiCheckBox,
# background
MainWindow,
# labels
]
44
if style == "Dark":
if sys.platform.startswith('win'):
apply_stylesheet(object, theme=f'{current_dir}\\res\\themes\\dark_red.xml', extra=extra)
else:
apply_stylesheet(object, theme=f'{current_dir}/res/themes/dark_red.xml', extra=extra)
self.SideBar.setStyleSheet("background-color: rgb(81, 89, 97);")
self.SideBar_2.setStyleSheet("background-color: rgb(81, 89, 97);")
self.HomeTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.SettingsTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.VirusResultsTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.LoadingPageTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.LightModeButton.setText("Light Mode")
if style == "Light":
if sys.platform.startswith('win'):
apply_stylesheet(object, theme=f'{current_dir}\\res\\themes\\light_pink.xml', extra=extra)
else:
apply_stylesheet(object, theme=f'{current_dir}/res/themes/light_pink.xml', extra=extra)
self.SideBar.setStyleSheet("background-color: rgb(182, 182, 182);")
self.SideBar_2.setStyleSheet("background-color: rgb(182, 182, 182);")
self.HomeTitle.setStyleSheet("background-color: rgb(182, 182, 182);")
self.SettingsTitle.setStyleSheet("background-color: rgb(182, 182, 182);")
self.VirusResultsTitle.setStyleSheet("background-color: rgb(182, 182, 182);")
self.LoadingPageTitle.setStyleSheet("background-color: rgb(182, 182, 182);")
self.LightModeButton.setText("Dark Mode")
45
self.CurrentTabHome.setStyleSheet("background-color: rgb(81, 89, 97);")
self.CurrentTabSettings.setStyleSheet("background-color: rgb(255, 0, 0);")
# set title backgrounds
self.HomeTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.SettingsTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.VirusResultsTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.LoadingPageTitle.setStyleSheet("background-color: rgb(81, 89, 97);")
self.LightModeButton.setText("Light Mode")
if VirustotalScan == 'True':
self.UseVirusTotalApiCheckBox.setChecked(True)
else:
self.UseVirusTotalApiCheckBox.setChecked(False)
self.VirusTotalApiKey.setText(api_key)
if MetaDefenderScan == 'True':
self.UseMetaDefenderApiCheckBox.setChecked(True)
else:
self.UseMetaDefenderApiCheckBox.setChecked(False)
self.MetaDefenderApiKey.setText(MetaDefenderApiKey)
def change_tab_settings(self):
self.Tabs.setCurrentIndex(0)
self.HomeTabButton.setStyleSheet("image: url(:/res/SideBar/home.svg);\n")
self.SettingsTabButton.setStyleSheet("image: url(:/res/SideBar/settings.svg);\n")
if self.LightModeButton.text() == "Light Mode":
self.CurrentTabSettings.setStyleSheet("background-color: rgb(81, 89, 97);")
self.CurrentTabHome.setStyleSheet("background-color: rgb(255, 0, 0);")
else:
# light mode
self.CurrentTabSettings.setStyleSheet("background-color: rgb(182, 182, 182);")
self.CurrentTabHome.setStyleSheet("background-color: rgb(231, 84, 128);")
return
def change_tab_home(self):
self.Tabs.setCurrentIndex(1)
self.SettingsTabButton.setStyleSheet("image: url(:/res/SideBar/settings.svg);\n")
self.HomeTabButton.setStyleSheet("image: url(:/res/SideBar/home.svg);\n")
if self.LightModeButton.text() == "Light Mode":
self.CurrentTabSettings.setStyleSheet("background-color: rgb(255, 0, 0);")
self.CurrentTabHome.setStyleSheet("background-color: rgb(81, 89, 97);")
else:
# light mode
self.CurrentTabSettings.setStyleSheet("background-color: rgb(231, 84, 128);")
self.CurrentTabHome.setStyleSheet("background-color: rgb(182, 182, 182);")
return
self.SettingsTabButton.clicked.connect(lambda: change_tab_home(self))
46
# report issue button
self.ReportIssueButton.clicked.connect(lambda: webbrowser.open_new(Report_issues))
if __name__ == "__main__":
# Handle high resolution displays:
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
47
# create application
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QWidget()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
light_pink.xml
<!--?xml version="1.0" encoding="UTF-8"?-->
<resources>
<color name="primaryColor">#ff4081</color>
<color name="primaryLightColor">#ff79b0</color>
<color name="secondaryColor">#f5f5f5</color>
<color name="secondaryLightColor">#ffffff</color>
<color name="secondaryDarkColor">#e6e6e6</color>
<color name="primaryTextColor">#3c3c3c</color>
<color name="secondaryTextColor">#555555</color>
</resources>
dark_red.xml
<!--?xml version="1.0" encoding="UTF-8"?-->
<resources>
<color name="primaryColor">#ff1744</color>
<color name="primaryLightColor">#ff616f</color>
<color name="secondaryColor">#232629</color>
<color name="secondaryLightColor">#4f5b62</color>
<color name="secondaryDarkColor">#31363b</color>
<color name="primaryTextColor">#000000</color>
<color name="secondaryTextColor">#ffffff</color>
</resource
48
CHAPTER :-7
TEST CASES
49
50
51