0% found this document useful (0 votes)
234 views

Project Report of The Virus Detector Final

Uploaded by

Piyush Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
234 views

Project Report of The Virus Detector Final

Uploaded by

Piyush Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

Ajay Kumar Garg

Engineering College-MCA,
Ghaziabad

Dr. A.P.J. Abdul Kalam Technical


University, Uttar Pradesh, Lucknow

Project Report
THE Virus Detector
Submitted in partial fulfillment of requirement
for the degree of MCA

Under Guidance of Submitted By:


Peush Kumar (2200270140034)

Prerna Agarwal (2200270140039)

Ms. Deepti Arora Tarangini Rai (2200270140064)

I
ABSTRACT

THE VIRUS DETECTOR


Computer viruses are executable code programs that have a unique
ability to replicate themselves in computer system and spread rapidly
from one computer to another affecting file, documents and programs to
alter their normal running. Viruses are represented as patterns of
computer instructional codes that exist over time in computer systems.
Antiviruses on the other hand are programs specially developed to
counter challenges brought about by viruses as they protect the computer
systems from virus attacks by heavily relaying on the controls
enhanced in their databases. Antiviruses therefore scan the computer
using some specific patterns of bytes indicative of known viruses. To stay
current, they must be developers of these antiviruses update their
databases whenever new viral strains arise.
In the realm of cyber security, THE Virus Detector Program emerges
as a versatile and inclusive solution tailored to address a wide spectrum
of digital threats. This abstract introduces a program designed with a
focus on commonality, offering users a reliable and universally
applicable tool for detecting and mitigating prevalent viruses.

Technology:
PYTHON

GROUP MEMBER –

Peush Kumar (2200270140034)

Prerna Agarwal (2200270140039)

Tarangini Rai (2200270140064)

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.

Name of the Student:

Peush Kumar (2200270140034)

Prerna Agarwal (2200270140039)

Tarangini Rai (2200270140064)

iv
COLLEGE CERTIFICATE

This is to certify that project report entitled "THE Virus Detector"


which is submitted by Peush Kumar(2200270140034), Prerna
Agarwal (2200270140039), Tarangini Rai(2200270140064) in partial
fulfillment of the requirement for the award of degree Master of
Computer Application of Dr. A.P.J. Abdul Kalam Technical University,
Uttar Pradesh (AKTU), is a record of the candidates work carried out by
them under my supervision. The matter embodied in this report is
original and has not been submitted for the award of any other degree.

Date: (Ms Deepti Arora)


Supervisor

iv
Table Of Content

SN. No Title Page No.


1 Introduction. 01

2 Problem statement and description 03

3 SRS 04

4 System architecture 16

4.1:- Tools and Techniques identified to carry out 17


the proposed work

4.2 : -Architectural design of the proposed work 18

4.3 : - Use case design 19

4.4 :- Smart contracts design 23

4.5 :- Activity Diagram 24

4.6 :- Sequence diagram 25

4.7 :- Collaboration diagram 27


4.8 :- Data Flow diagram 28
4.9 :- State Diagram 30

5 Database Design 31

6 Source Code 32

7 Test Cases 64

iv
Chapter 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.

7
Significance of Virus Detector:

In an era where cyber threats are diverse, sophisticated, and ever-evolving,


the significance of robust virus detector software cannot be overstated.
This software serves as a proactive defense mechanism, mitigating the risk
of data breaches, system malfunctions, and other detrimental
consequences of cyber attacks. By providing a comprehensive shield
against viruses, malware, and other malicious entities, virus detector
software contributes to the overall resilience of digital ecosystems. Whether
utilized by individuals, businesses, or enterprises, the adoption of reliable
virus detector software is fundamental to maintaining the confidentiality,
integrity, and availability of digital assets. In conclusion, as we navigate the
complexities of the digital age, virus detector software stands as a crucial
ally in the ongoing battle against cyber threats. Its continuous evolution,
adaptability, and commitment to user security make it an indispensable tool
in the broader landscape of cybersecurity.

8
Chapter:-2
Problem Statement And Description

In an era where cyber threats are diverse, sophisticated, and ever-


evolving, the significance of robust virus detector software cannot be
overstated. This software serves as a proactive defense mechanism,
mitigating the risk of data breaches, system malfunctions, and other
detrimental consequences of cyber attacks. By providing a
comprehensive shield against viruses, malware, and other malicious
entities, virus detector software contributes to the overall resilience of
digital ecosystems.

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

The purpose of the Virus Detector Software is to provide


effective and efficient detection, prevention, and removal of
malicious software, commonly known as viruses, to safeguard
the integrity and security of computer systems.

1.2 Scope

The software will be designed to work across various platforms and


devices, offering a comprehensive solution for both individual users
and enterprises.

10
1.3 Definition, Acronyms and abbreviations\

SRS: Software Requirement Specifications


GUI: Graphical User Interface
API: Application Programming Interface
AV: Anti Virus

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

Virus detector software, also known as antivirus or anti-malware


software, is a crucial component in the realm of cybersecurity, dedicated
to identifying, preventing, and eliminating malicious software threats
that can compromise the integrity and security of computer systems. The
overarching goal is to provide a robust defense against a wide array of
digital threats, including viruses, worms, trojans, and other forms of
malware.

11
2.2 Product Perspective

The product perspective of virus detector software encompasses its role


within the broader context of cybersecurity and its interaction with
users, systems, and the evolving threat landscape. This perspective
considers the software's relationships with external entities, its internal
components, and its adaptability to meet the dynamic challenges posed
by malicious actors.

2.1 Product Function


Virus detector software is designed to perform a range of functions
aimed at detecting, preventing, and mitigating the impact of malicious
software on computer systems. These functions contribute to the overall
security of the system and the protection of sensitive data.

2.3 User Characteristics


Understanding the characteristics and needs of users is crucial in
designing effective virus detector software. The user base for such
software is diverse, ranging from individual users with basic computing
skills to IT professionals managing network security in large
organizations.

2.4 Constraints

Operating System Constraint


System should be compatible and will smoothly run on Android version 6.0 or
Above.

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:

HARDWARE AND SOFTWARE REQUIREMENTS


Hardware Requirement:
 Speed : 3.5 GHz
 RAM : 5GB

 Hard Disk : 420 GB

 Floppy Drive : 1.44 MB

 Key Board : Standard Windows Keyboard

 Mouse : Two or Three Button

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

3.1 External Interfaces


(1) User Interfaces
Creating a user interface (UI) for a virus detector involves designing an interface that allows
users to interact with the system to perform actions such as initiating scans, viewing scan results,
and managing settings. Below is a simple example of a textual representation of a user interface
for a virus detector system:
This is a basic menu-based interface where users can choose options by entering corresponding
numbers. Here's a brief description of each option:
1. Start Virus Scan: Initiates the virus scanning process.
2. View Scan Results: Displays the results of the most recent scan.
3. Settings: Allows the user to configure settings such as scan preferences, update options,
etc.
4. Exit: Exits the virus detector program.

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.

3.3 Performance requirements


Performance requirements for a virus detector are crucial to ensure that the software operates
efficiently and effectively while minimizing resource usage. Here are key performance
requirements for a virus detector:
1. Scanning Speed:
 Requirement: The virus detector should perform scans quickly to minimize the
impact on system responsiveness.
 Metric: Average time taken to scan a specified amount of data.
2. Real-Time Protection Responsiveness:
 Requirement: Real-time protection mechanisms should respond promptly to
prevent the execution of malicious code.
 Metric: Time taken to detect and block a threat in real-time.
3. Resource Utilization:
 Requirement: The virus detector should use system resources (CPU, memory)
efficiently to avoid impacting overall system performance.
 Metric: CPU and memory usage during scans and real-time protection.
4. Update Speed:
 Requirement: Automatic updates of virus definitions and software should be
performed quickly to respond to new threats.
 Metric: Time taken to download and apply updates.
5. Scan Customization Time:
 Requirement: Users should be able to initiate on-demand scans with specific
customization quickly.
 Metric: Time taken to start a user-initiated scan with customized settings.
6. Quarantine and Removal Speed:
 Requirement: Infected files should be quarantined or removed promptly to
prevent further harm.
 Metric: Time taken to quarantine or remove a detected threat.
7. False Positive Rate:
 Requirement: The virus detector should minimize false positives to avoid
unnecessary disruption for users.
 Metric: Percentage of false positives in the detection results.
8. System Impact During Scans:
 Requirement: Scans should have a minimal impact on system responsiveness
during normal use.
 Metric: User-perceived system responsiveness during a scan.
9. System Impact During Updates:
 Requirement: Updates should not significantly impact the system's performance.
 Metric: User-perceived system responsiveness during an update.
10. Logging Efficiency:
 Requirement: Logging should capture relevant information without causing a
significant performance overhead.
 Metric: Time taken to log security events and activities.
11. Compatibility:
 Requirement: The virus detector should be compatible with a range of operating

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.

3.4 Logical database


requirements
The logical database requirements for a virus detector refer to the specifications and
characteristics of the database used to store relevant information and data necessary for the
functioning of the virus detection system. Here are some logical database requirements for a
virus detector:
1.Signature Database:
Requirement: Maintain a comprehensive signature database of known viruses and malware.
Description: The signature database stores unique patterns or signatures associated with known
threats, allowing the virus detector to identify and match these patterns during scans.
2.Definition Update Repository:
Requirement: Store virus definition updates.
Description: The database should include a repository for storing the latest virus definitions,
ensuring that the virus detector is equipped to identify new threats.
3.Quarantine Database:
Requirement: Maintain a quarantine database.
Description: The quarantine database stores information about files identified as potentially
malicious, including their original locations, timestamps, and relevant details. This allows for
isolation and further analysis.
4.Scan History Database:
Requirement: Keep a record of scan histories.
Description: The database should store information about past scans, including dates, times,
scanned locations, and the results of the scans. This helps users review and analyze historical
security events.
5.User Configuration Database:
Requirement: Store user-specific configurations and preferences.
Description: Save user-defined settings, scan preferences, and custom configurations to provide
a personalized experience and maintain consistency across sessions.
6.Security Events Log:
18
Requirement: Log security events and activities.
Description: Maintain a log of detected threats, system activities, and other relevant security
events. This log is crucial for auditing, analysis, and compliance purposes.
7.Settings Database:
Requirement: Store application settings and parameters.
Description: This database contains various settings related to the operation of the virus
detector, such as update schedules, scanning options, and real-time protection configurations.
8.Behavioral Analysis Data Store:
Requirement: Store data for behavioral analysis.
Description: If the virus detector employs behavioral analysis, it should have a database to store
patterns, anomalies, and behaviors associated with potential threats.
9.User Authentication and Authorization Database:
Requirement: Manage user authentication and authorization.
Description: If the virus detector has user accounts with different levels of access, a database is
needed to store user credentials, roles, and permissions.
10.System Compatibility Database:
Requirement: Keep track of supported systems and configurations.
Description: Maintain information about supported operating systems, hardware configurations,
and other system requirements to ensure compatibility.

19
Chapter:-4
System Architecture

20
Chapter:- 4

4.1 Tools and Techniques identified to carry out


proposed work:

TOOLS:

1. Sublime Text Editor


2. Visual Studio Code
3. Google Chrome
4. Internet Explorer

TECHNIQUES:
1. Python

21
Chapter:-4

4.2 :- Use Case Diagram

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

4.3 :- Activity Diagram


An Activity Diagram is a behavioural diagram. It depicts the
behaviour of a system. Its primary use is to depict the
dynamic aspects of a system. The dynamic aspect of a system
specifies how the system operates to attain its function.

It is basically a flowchart to represent the flow from one activity


to another activity. Activity Diagrams are not exactly flowcharts
as they have some additional capabilities including branching,
parallel flow, swim lanes, etc.

In given diagram represents a simple flow where a user initiates


a virus scan, the virus detector scans files, quarantines infected
files if any, notifies the user, and optionally updates virus
definitions if needed. Finally, the user can view the scan report.

23
24
Chapter:- 4

4.4 :- Sequence Diagram

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

A collaboration diagram, also known as a communication diagram, is an illustration


of the relationships and interactions among software objects in the Unified Modeling
Language (UML). These diagrams can be used to portray the dynamic behavior of a
particular use case and define the role of each object.

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:

-Admin user can search order,view description of selected order,add order,update


order and delete order.

-Its shows the activity flow of editing,adding and updating of delivery.

-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.

DFD zero level

Detect Virus Update Definitions

Generate
Report System Configure Settings

DFD first level

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

State Transition Diagram are also known as Dynamic models. As the


name suggests, it is a type of diagram that is used to represent different transition
(changing) states of a System. It is generally used to graphically represent all
possible transition states a system can have and model such systems. It is very
essential and important and right for object-oriented modeling from the beginning.
The System consists of various states that are being represented using various
symbols in the state transition diagram. You can see the symbols and their
description given below :
Now let us see the State Transition Diagram of Food World Website. In this you will
see the processing when the customer enter the website comes to home page
directly,form their customer can see the order and can order the food they food
wanted and by filling the order form a customer can update, delete and view their
orders.
Also if customer wants to donate can donate from help page and can confirm the
order do payment and then logout.

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

# get current directory


current_dir = os.path.dirname(__file__)

# settings.ini file path


settings_file_path = current_dir + '/settings/settings.ini'

# define config
config = configparser.ConfigParser()
config.read(settings_file_path)

# get files with Virus hashes inside


SHA256_HASHES_pack1 = (current_dir + '\\hard_signatures\\SHA256-Hashes_pack1.txt')
SHA256_HASHES_pack2 = (current_dir + '\\hard_signatures\\SHA256-Hashes_pack2.txt')
SHA256_HASHES_pack3 = (current_dir + '\\hard_signatures\\SHA256-Hashes_pack3.txt')

# 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

# save settings to settings/settings.ini


def SaveSettings(self):
# get api keys
api_key = self.VirusTotalApiKey.text()
MetaDefenderApiKey = self.MetaDefenderApiKey.text()
# get VirusTotal scan checkbox status and meta defender scan checkbox status
virus_total_scan = self.UseVirusTotalApiCheckBox.isChecked()
meta_defender_scan = self.UseMetaDefenderApiCheckBox.isChecked()
self.VirusTotalApiKey.setText(api_key)

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"

with open(settings_file_path, 'w') as configfile: # save


config.write(configfile)

return

# removed thinker from project.


# program will now check if system is Win or Linux (if OS is Linux .ico files will not be used)

# 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))

def displayResults_CLEAN(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()
# 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()
# set text to clean
self.IsFileVirusY_N.setStyleSheet("color: green")
self.IsFileVirusY_N.setText("NO!")
# delete file button
self.DeleteFileButton.clicked.connect(lambda: removeFile(file))
# return button
self.ReturnToHomeTabButton.clicked.connect(lambda: self.Tabs.setCurrentIndex(0))

def scan(file, self, MainWindow):


try:

# default virus found to false


virus_found = False

# open file and get hash


with open(file,"rb") as f:
bytes = f.read()
readable_hash = hashlib.sha256(bytes).hexdigest();

# display hash
self.FileHash.setText("File Hash: " + readable_hash)

# check if from the selected is = to a hash in the virus hash list

# SHA256 HASHES check + pack 1

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)

# delete file button


self.DeleteFileButton.clicked.connect(lambda: removeFile(file))
# return button
self.ReturnToHomeTabButton.clicked.connect(lambda: self.Tabs.setCurrentIndex(0))

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):

# change tab to loading tab


self.Tabs.setCurrentIndex(3)

filepath_raw, filename_raw = os.path.split(str(QtWidgets.QFileDialog.getOpenFileName(MainWindow,


"Select File",
"YOUR-FILE-PATH")))

filepath_raw = filepath_raw.replace("('", "")


filename = filename_raw.replace("', 'All Files (*)')", "")

# display file name


self.FileName.setText("File Name: " + filename)
# close thinker window

# get full path to file


filepath = (filepath_raw + "/" + filename)

# display file path


self.FilePath.setText("File Path: " + filepath)

scan(filepath, self, MainWindow)

# UI (made with pyqt5)


class Ui_MainWindow(object):
38
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(590, 300)
MainWindow.setMinimumSize(QtCore.QSize(590, 300))
MainWindow.setMaximumSize(QtCore.QSize(590, 300))
if sys.platform == "win32":
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/res/ico/AntiVirus_ico.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
# OS is not windows so don´t show icon since its a .ico file
else:
pass
MainWindow.setStyleSheet("")
self.SideBar = QtWidgets.QLabel(MainWindow)
self.SideBar.setGeometry(QtCore.QRect(-10, 45, 61, 271))
self.SideBar.setStyleSheet("background-color: rgb(81, 89, 97);")
self.SideBar.setText("")
self.SideBar.setObjectName("SideBar")
self.HomeTabButton = QtWidgets.QPushButton(MainWindow)
self.HomeTabButton.setGeometry(QtCore.QRect(0, 50, 51, 31))
font = QtGui.QFont()
font.setPointSize(15)
self.HomeTabButton.setFont(font)
self.HomeTabButton.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));\n"
"image: url(:/res/SideBar/home.svg);\n"
"")
self.HomeTabButton.setText("")
self.HomeTabButton.setFlat(True)
self.HomeTabButton.setObjectName("HomeTabButton")
self.SettingsTabButton = QtWidgets.QPushButton(MainWindow)
self.SettingsTabButton.setGeometry(QtCore.QRect(0, 90, 51, 31))
font = QtGui.QFont()
font.setPointSize(15)
self.SettingsTabButton.setFont(font)
self.SettingsTabButton.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));\n"
"image: url(:/res/SideBar/settings.svg);")
self.SettingsTabButton.setText("")
self.SettingsTabButton.setFlat(True)
self.SettingsTabButton.setObjectName("SettingsTabButton")
self.Tabs = QtWidgets.QStackedWidget(MainWindow)
self.Tabs.setGeometry(QtCore.QRect(50, 0, 591, 301))
font = QtGui.QFont()
font.setPointSize(10)
self.Tabs.setFont(font)
self.Tabs.setStyleSheet("")
self.Tabs.setObjectName("Tabs")
self.HomeTab = QtWidgets.QWidget()
self.HomeTab.setObjectName("HomeTab")
self.HomeTitle = QtWidgets.QLabel(self.HomeTab)
self.HomeTitle.setGeometry(QtCore.QRect(0, 0, 551, 41))
font = QtGui.QFont()
font.setPointSize(23)
self.HomeTitle.setFont(font)
self.HomeTitle.setAlignment(QtCore.Qt.AlignCenter)

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)

# read settings from ini file


VirustotalScan = config.get('-settings-', 'VirusTotalScan')
api_key = config.get('-settings-', 'VirusTotalApiKey')
MetaDefenderScan = config.get('-settings-', 'MetaDefenderScan')
MetaDefenderApiKey = config.get('-settings-', 'MetaDefenderApiKey')
style = config.get('-settings-', 'Style')

# apply dark default theme


from qt_material import apply_stylesheet
extra = {

# 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
]

# apply stylesheet in settings

for object in objects:

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

# if lightmode is enabled, apply light theme and change button text


def style_mode(self):
if self.LightModeButton.text() == "Light Mode":
for object in objects:
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.CurrentTabHome.setStyleSheet("background-color: rgb(182, 182, 182);")
self.CurrentTabSettings.setStyleSheet("background-color: rgb(255, 0, 0);")
self.SideBar.setStyleSheet("background-color: rgb(182, 182, 182);")
self.SideBar_2.setStyleSheet("background-color: rgb(182, 182, 182);")
self.CurrentTabHome.setStyleSheet("background-color: rgb(182, 182, 182);")
self.CurrentTabSettings.setStyleSheet("background-color: rgb(231, 84, 128);")
# set title backgrounds
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")
else:
for object in objects:
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.CurrentTabHome.setStyleSheet("background-color: rgb(81, 89, 97);")
self.CurrentTabSettings.setStyleSheet("background-color: rgb(255,192,203);")
self.SideBar.setStyleSheet("background-color: rgb(81, 89, 97);")
self.SideBar_2.setStyleSheet("background-color: rgb(81, 89, 97);")

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

# change tabs buttons


self.HomeTabButton.clicked.connect(lambda: change_tab_settings(self))

self.SettingsTabButton.clicked.connect(lambda: change_tab_home(self))
46
# report issue button
self.ReportIssueButton.clicked.connect(lambda: webbrowser.open_new(Report_issues))

# open file dialog and scan file


self.SelectFileButton.clicked.connect(lambda: browseFiles(MainWindow, self))

# save settings button


self.SaveSettingsButton.clicked.connect(lambda: SaveSettings(self))

# style mode button


self.LightModeButton.clicked.connect(lambda: style_mode(self))

def retranslateUi(self, MainWindow):


_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", f"-AntiVirus- [v{VERSION}] [dev; {DEV}]"))
self.HomeTitle.setText(_translate("MainWindow", "Home"))
self.SelectFileButton.setText(_translate("MainWindow", "Scan File"))
self.ReportIssueButton.setText(_translate("MainWindow", "report issue"))
self.SettingsTitle.setText(_translate("MainWindow", "Settings"))
self.UseVirusTotalApiCheckBox.setText(_translate("MainWindow", "Use Virus Total api (only files under
32MB) (files will be uploaded publicly)"))
self.VirusTotalApiKey.setPlaceholderText(_translate("MainWindow", "Enter your Virus Total api Key
here"))
self.SaveSettingsButton.setText(_translate("MainWindow", "Save Config"))
self.UseMetaDefenderApiCheckBox.setText(_translate("MainWindow", "Use Meta Defender api to check
hash"))
self.MetaDefenderApiKey.setPlaceholderText(_translate("MainWindow", "Enter your Meta Defender api
Key here"))
self.VirusResultsTitle.setText(_translate("MainWindow", "Virus Scan Results"))
self.FileName.setText(_translate("MainWindow", "File Name: "))
self.FilePath.setText(_translate("MainWindow", "File Path: "))
self.FileHash.setText(_translate("MainWindow", "File Hash: "))
self.label.setText(_translate("MainWindow", "Is This File A Virus?"))
self.IsFileVirusY_N.setText(_translate("MainWindow", "YES"))
self.ReturnToHomeTabButton.setText(_translate("MainWindow", "Return"))
self.DeleteFileButton.setText(_translate("MainWindow", "Delete File"))
self.label_3.setText(_translate("MainWindow", "Virus Total score"))
self.DetectionsText.setText(_translate("MainWindow", "0 | 0"))
self.label_5.setText(_translate("MainWindow", "Detections"))
self.label_4.setText(_translate("MainWindow", "Meta Defender score"))
self.MetaDefenderDetectionsText.setText(_translate("MainWindow", "0 | 0"))
self.label_6.setText(_translate("MainWindow", "Detections"))
self.LoadingPageTitle.setText(_translate("MainWindow", "..."))
self.label_7.setText(_translate("MainWindow", "loading..."))
self.version_display.setText(_translate("MainWindow", f"v{VERSION}"))
# import resources
import res.res_rc

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

You might also like