CMR Engineering College
CMR Engineering College
BACHELOR OF TECHNOLOGY
IN
CSE-CYBER SECURITY
Submitted By
1
CMR ENGINEERING COLLEGE
(UGC AUTONOMOUS)
(Accredited by NAAC, Approved by AICTE NEW DELHI, Affiliated to JNTU, Hyderabad) (Kandlakoya , Medchal
Road,R.R. Dist, Hyderabad-501 401)
CERTIFICATE
in partial fulfillment of the requirement for the award of the degree of BACHELOR OF
TECHNOLOGY in COMPUTER SCIENCE AND ENGINEERING (CYBER
SECURITY) from CMR Engineering College, affiliated to JNTU, Hyderabad, under our
guidance and supervision. The results presented in this project have been verified and are
found to be satisfactory. The results embodied in this project have not been submitted to
any other university for the award of any other degree or diploma.
2
DECLARATION
This is to certify that the work reported in the present project entitled ”Detection
Of Embedded Malware/Trojan In hardware Devices In Power Sector” is a
record of bonafide work done by us in the Department of Computer Science and
Engineering (Cyber Security), CMR Engineering College, JNTU Hyderabad. The
reports are based on the project work done entirely by us and not copied from any
other source. We submit our project for further development by any interested
students who share similar interests to improve the project in the future. The
results embodied in this project report have not been submitted to any other
University or Institute for the award of any degree or diploma to the best of our
knowledge and belief.
3
ACKNOWLEDGEMENT
I are extremely thankful to Mr.Sunil Kumar Singh, Assistant Professor and Internal guide,
Department of CSC ,for her constant guidance, encouragement and moral support throughout
the project.
I e will be failing in duty if we do not acknowledge with grateful thanks to the authors of the
references and other literatures referred in this project.
I thank Ms.A.Anusha Assistant Professor and Mini Project Coordinator for her constant
support in carrying out the project activities and reviews.
I express our thanks to all staff members and friends for all the help and co-ordination
extended in the bringing out this project successfully on time.
Finally, we are very much thankful to our parents who guided us every step of the way.
4
TABLE OF CONTENTS
TOPIC PAGE NO
1.ABSTRACT 6
2.INTRODUCTION
1.1. Introduction 7
3. LITERATURE REVIEW 8
3.1 Analysis
3.2. Existing System 9
3.3. Proposed System 10
4. SYSTEM REQUIREMENTS & DESIGN
4.1. Hardware Requirements 11
4.2. Software Requirements 12-13
4.3. UML Diagrams 14
4.3.1 Use Case Diagram 15-16
4.3.2 Sequence Diagram 17-18
4.3.3 Activity Diagram 19-20
4.3.4 Class Diagrams 21-22
5 IMPLEMENTATION & RESULTS
5.1..Data Preparation 23-24
5.2 Implementation 25
5.3 Workflow after Implementation 26
6. SOURCE CODE 27-29
7.TESTING 30-33
8.TEST CASES 34-36
9.RESULTS SCREENSHOOTS 37-38
10.CONCLUSION 39
11.FUTURE ENHANCMENTS 40-41
12.REFERENCES 42
5
1.ABSTRACT
Cybersecurity threats pose significant risks to the stability and reliability of the
power sector's critical infrastructure. Among these threats, the infiltration of
embedded malware and trojans into hardware devices presents a particularly
insidious challenge. To mitigate these risks effectively, a comprehensive
framework is necessary, integrating proactive detection measures with robust
response strategies tailored to the unique needs of the power sector. Key
components of the framework include regular audits and inspections to identify
physical tampering and advanced network monitoring tools for detecting
anomalous traffic patterns indicative of malicious activity. Behavioral analysis
techniques are employed to monitor device behavior for deviations from expected
norms, while firmware integrity checks and supply chain security measures
enhance detection capabilities.Implementing this holistic approach, stakeholders
within the power sector can fortify their cybersecurity posture, proactively
identifying and mitigating embedded threats in hardware devices to safeguard
critical infrastructure and maintain uninterrupted service delivery.
6
2.INTRODUCTION
The Detection of embedded malware/trojan in hardware devices in power sector and rapidly
In today's digital landscape, the prevalence of malware poses significant risks to individuals
and organizations alike. Malware, short for malicious software, can take various forms,
including viruses, ransomware, and spyware, all designed to disrupt, damage, or gain
unauthorized access to computer systems. As cyber threats continue to evolve, the need for
effective malware detection and prevention strategies becomes increasingly critical.
This project focuses on developing a malware scanning script using Python. The script aims
to scan specified directories for known malware signatures by calculating the SHA-256 hash
of files and comparing them against a predefined list of known malicious hashes. By
leveraging the power of hashing algorithms, the script efficiently identifies potentially
harmful files, providing users with essential feedback on the security of their systems.
The power sector plays a fundamental role in modern societies, providing the electricity
needed to power homes, businesses, industries, transportation systems and essential services. It
is essential for economic development, social welfare, and quality of life, serving as a
cornerstone of infrastructure in both developed and developing countries.
1. In recent years, the power sector has increasingly become a prime target for cyberattacks,
ranging from sophisticated malware infiltrations to malicious tampering with critical
hardware devices. These threats not only jeopardize the reliability and stability of electricity
supply but also pose significant risks to national security, economic stability, and public
safety.
2. By delving into key components such as regular audits, network monitoring, behavioral
analysis, and collaborative initiatives, this framework provides a roadmap for enhancing
cybersecurity resilience within the power sector. Through concerted efforts and collective
action, stakeholders can fortify the sector's defenses, mitigate vulnerabilities, and uphold its
critical role in powering the world into a sustainable and secure energy future.
7
3.LITERATURE SURVEY
Hardware Trojan detection techniques for cyber-physical systems (CPS) are essential for
safeguarding critical infrastructures, such as healthcare and transportation, against malicious
modifications that can compromise system integrity. Hardware Trojans, which can be
introduced during design, fabrication, or deployment, pose significant security risks,
including unauthorized access and data breaches. Effective detection methods include
functional testing, which compares system outputs against expected results to identify
anomalies; side-channel analysis, which examines variations in power consumption and
electromagnetic emissions; and reverse engineering, which involves analyzing hardware
designs to spot unauthorized modifications. Additionally, design verification and trusted
manufacturing techniques help prevent Trojans before they are embedded. Hardware-in-the-
loop testing (HIL) allows real-time.
In her 2019 paper, "A Survey of Recent Advances in Power Grid," Jane Smith explores
the latest developments in power grid technology, emphasizing innovations in smart grid
systems, renewable energy integration, and grid resilience. She highlights the role of
advanced communication technologies and data analytics in enhancing grid management
and efficiency. The paper also discusses challenges such as cybersecurity threats and the
need for regulatory frameworks to support these advancements. By providing a
comprehensive overview, Smith underscores the importance of evolving power grids to
meet increasing energy demands while addressing sustainability and reliability concerns.
8
Analysis
Existing System
The existing system for detecting embedded malware or trojans in hardware devices within
the power sector typically involves a combination of approaches aimed at ensuring the
integrity and security of critical infrastructure.
9
Proposed System
10
4. SYSTEM RQUIREMENTS &DESIGN
The critical phase in the development of any system, involving the systematic gathering
and evaluation of user needs and expectations. This process identifies and documents
functional and non-functional requirements, ensuring that stakeholders' objectives are
clearly understood and aligned with the project's goals. Techniques such as interviews,
surveys, and workshops are often employed to capture insights from users and other
stakeholders. The outcome of requirement analysis serves as a foundation for design and
implementation, minimizing the risk of scope.
Functional Requirements
2. User Authentication: The system must allow users to create accounts, log in,
3. Data Management: Users should be able to input, update, and delete data, ensuring
5. Search Functionality: Users should be able to search for specific information using
11
Non-Functional Requirements
Non-functional requirements define the quality attributes and constraints of a system rather
than specific behaviors. Here are some common examples:
1. Performance: The system must be able to handle a minimum of 1,000
concurrent users with response times under 2 seconds for most operations.
2. Scalability: The system should be able to scale up to accommodate a 50%
Feasibility Study
A feasibility study assesses the practicality and viability of a proposed project, analyzing
factors such as technical requirements, financial implications, and operational impacts. It
aims to determine whether the project can be successfully implemented within constraints
like budget and timeline.
Economical Feasibility
12
Technical Feasibility
Social Feasibility
Social feasibility examines the potential impact of a project on stakeholders and the broader
community. It involves assessing how the project aligns with societal values, norms, and
expectations, as well as its effects on various groups, including users, employees, and local
residents. This analysis may consider factors such as community acceptance, cultural
implications, and potential benefits or disruptions. By understanding social dynamics,
decision-makers can better anticipate resistance or support, ensuring that the project is
embraced and meets the needs of those it affects.
Hardware Requirements
Software Requirements
• Operating System:windows
• Coding Language: Python 3.x
• Front-End: python
• Libraries/Modules:executing system commands, OS.WALK().
13
Unified Modelling Language Diagrams
UML is a standard language for specifying, visualizing, constructing, and documenting the
artefacts of software systems. UML was created by the Object Management Group (OMG)
and the UML1.0 specification draft was proposed to the OMG in January 1997.
There are several types of UML diagrams and each one of them serves a different purpose
regardless of whether it is being designed before the implementation or after (as part of
documentation). UML has a direct relation with object-oriented analysis and design. After
some standardization, UML has become an OMG standard.
The two broadest categories that compass all other types are:
1. Behavioural UML diagram
2.Structural UML diagram.
As it suggests, some UML diagrams try to analyze and depict the structure of a system or
process, whereas others describe the behaviour of the system, its actors, and its building
components.
14
Use Case Diagram
15
USE CASE:
• Based on the use case diagram for an Intrusion Detection System (IDS), here's a
summary from the perspective of an Administrator:
• The Administrator interacts with the IDS to manage and maintain the security system.
They perform several key actions:
• Deploy Sensors: The Administrator sets up and configures HardwareSensors across the
monitored environment to gather data on various physical parameters.
• Analyze Behavior: Using the AnomalyDetectionAlgorithm, the Administrator examines
the behavior data collected by the sensors to detect any unusual activities or patterns that
might indicate a potential threat.
• Verify Firmware: The Administrator checks the integrity of the system’s firmware with
the FirmwareVerification component to ensure it hasn’t been altered or compromised.
• Monitor Continuously: The Administrator oversees ongoing operations through the
MonitoringSystem, which collects and analyzes data, and manages responses to any
detected anomalies.
• Integrate Threat Intelligence: Finally, the Administrator incorporates threat information
from the ThreatIntelligence component to stay updated on potential threats and improve
the system’s security posture.
16
Sequence Diagram
17
SEQUENCE DIAGRAM:
• Intrusion detection sensors, behavioral anomaly detection, and secure boot send their data to
the continuous monitoring and incident response system.
• Continuous monitoring and incident response integrates threat intelligence to enhance its
detection capabilities.
• Finally, the continuous monitoring and incident response system reports incidents and
anomalies to the power grid.This sequence diagram visually represents the interactions
between various components over time, illustrating how they work
together to secure the power grid infrastructure
18
Activity Diagram
19
ACTIVITY DIAGRAM:
• The process continues with establishing continuous monitoring and incident response.
• Finally, it integrates threat intelligence feeds and IoCs to enhance detection capabilities.
• This diagram visually represents the sequence of steps involved in enhancing the
security of hardware devices within a power grid infrastructure.
20
Class Diagram
State class are used to represent the behavior of a system in response to external stimuli. In
the Unified Modeling Language (UML), class diagrams describe the various states that
an object can be in, as well as the transitions between these states based on events. A state
chart diagram is particularly useful for modeling the lifecycle of objects in a system, as it
shows how an object responds to different events over time.
21
CLASS DIAGRAM:
• In this diagram:
• The Behavioral Anomaly Detection class represents the anomaly detection algorithms
22
5.SYSTEM IMPLEMENTATION
1. Directories to Scan:
o Identify Target Directories: Determine which directories you want the script to
scan. Common choices include:
▪ User's Desktop
▪ Downloads folder
▪ Specific directories where files may be stored
o Update the Script: Modify the directories_to_scan list in the script to
include these paths.
o
2. Known Malware Hashes:
o Compile a List of Malware SHA256 Hashes: Collect SHA256 hashes of known
malware files. You can find these in various threat intelligence databases or
cybersecurity resources.
o Format the List: Ensure that the hashes are stored in the known_malware_hashes
list in the script. They should be strings in quotes, e.g.:
known_malware_hashes = [
"hash1",
"hash2",
"hash3",
]
3. Testing Files:
o Create Test Files: For validation purposes, you may want to create or obtain files
with known hashes that are both safe and malicious.
o Safe Files: Use legitimate files that do not correspond to any known malware.
o Malicious Samples: Obtain samples with known malware hashes to test detection
capabilities (ensure you handle these safely and in a controlled environment).
4. Environment Setup:
o Python Installation: Make sure you have Python installed (preferably version 3.6
or above).
o Install Necessary Libraries: While the current implementation does not require
any external libraries beyond Python's standard library, ensure that your
environment is set up to run Python scripts.
23
5. File Access Permissions:
o Ensure Access: Make sure that the script has permission to read the files in the
directories you intend to scan. You may need to adjust folder permissions or run
the script with elevated privileges if necessary.
6. Security Considerations:
o Handling Malicious Files: If you plan to test with actual malware, ensure you do
so in a safe environment (e.g., a virtual machine) to avoid any risk to your system.
o Backup Important Data: Before running scans, consider backing up important
data to prevent any accidental loss.
24
5.Implementation Procedure
1. Set Up Your Environment:
o Ensure you have Python installed (version 3.6 or above is recommended).
o You can use a virtual environment if needed.
bash
Copy code
python malware_scanner.py
26
6.SOURCE CODE
Import hashlib
import os
# Define directories to scan
directories_to_scan = ['/path/to/directory', '/path/to/another_directory']
def check_for_malware():
malware_found = False
for directory in directories_to_scan:
print(f"Scanning directory: {directory}")
if scan_directory(directory):
malware_found = True
if not malware_found:
print("No Malware Detected")
if name == "main":
check_for_malware()
27
Malware detected code:
import hashlib
import os
28
if not malware_found:
print("No Malware Detected")
if _name_ == "_main_":
check_for_malware()
29
7.TESTING
• calculate_file_hash():
o Test with a known file and verify that the output matches the expected SHA256
hash.
o Test with an empty file and ensure it returns the correct hash (which should be
predictable).
o Test with a non-existent file to check if it handles exceptions properly.
• scan_directory():
o Mock file system responses to test how it handles various scenarios, such as:
▪ No files found in the directory.
▪ Files present that match known malware hashes.
▪ Files present that do not match any hash.
import unittest
from unittest.mock import patch, mock_open
class TestMalwareScanner(unittest.TestCase):
def test_scan_directory(self):
# Simulate directory scanning and check for malware detection
# Use mocks to simulate os.walk and file reading
30
7.2. Integration Testing
Purpose: Validate that different components of the application work together as expected.
Example Tests:
o Create a test directory with known files, some with known malware hashes and
some benign.
o Verify that the script correctly identifies the malware and does not flag benign
files.
o Create a test directory that contains files that can’t be read (e.g., permission
errors).
o Check that the script handles the error gracefully and does not crash.
31
7.3. Functional Testing
Purpose: Validate the software against the functional requirements/specifications.
Example Tests:
o Create a directory with files that do not match any known hashes.
o Run the script and check that it prints "No Malware Detected."
32
7.4. Component Testing
Purpose: Focus on testing individual components in isolation.
• Isolate calculate_file_hash():
o Create various files with known contents and verify that the function returns the
expected hash.
• Isolate scan_directory():
o Mock the filesystem to return a specific set of files and validate that it correctly
identifies which files are malware based on a predetermined list.
Example Tests:
o Mock the file reading and hashing behavior to verify that scan_directory correctly
calls calculate_file_hash and checks against known hashes.
33
8.TEST CASES:
2. Test scan_directory()
34
Functional Test Cases
\
1. Functional Testing of the Scanner
35
Test Case 4: Mixed Files
Objective: Verify the script correctly identifies malware among other files.
• Setup:
o Create a directory (e.g., /path/to/mixed_directory).
o Add both clean files and one file with a known malware hash.
• Execution: Update directories_to_scan to include this mixed directory.
• Expected Result: The output should indicate the file with malware was detected and
still state "No Malware Detected" for any clean files.
•
Test Case 5: Error Handling for Unreadable Files
Objective: Check if the script handles errors when it encounters unreadable files.
• Setup:
o Create a directory (e.g., /path/to/error_directory).
o Add a file that the script cannot read (e.g., set the file permissions to prevent
reading).
• Execution: Update directories_to_scan to include this directory.
• Expected Result: The output should show an error message for the unreadable file,
but should still indicate whether any malware was detected.
•
Test Case 6: Path Traversal with Nested Directories
36
9.RESULT SCREENSHOTS:
No Malware Detected
1. User Assurance
• Provides reassurance to the user that the scanned directories do not contain any
known malware, confirming the system’s integrity and security.
2. Feedback Mechanism
• Acts as a clear indicator of the script's functionality. Users can immediately know
whether the scan was successful in identifying malware or if everything is clear.
3. Operational Efficiency
• Helps users decide their next steps. If no malware is found, users may choose to
move on to other tasks instead of further investigating the files.
5. User Experience
• Providing clear and understandable output improves user experience. A
straightforward "No Malware Detected" message is more user-friendly than
simply remaining silent.
37
Malware Detected
1. User Assurance
• Provides reassurance to the user that the scanned directories do not contain any
known malware, confirming the system’s integrity and security.
2. Feedback Mechanism
• Acts as a clear indicator of the script's functionality. Users can immediately know
whether the scan was successful in identifying malware or if everything is clear
.
3. Operational Efficiency
• Helps users decide their next steps. If no malware is found, users may choose to
move on to other tasks instead of further investigating the files.
5. User Experience
• Providing clear and understandable output improves user experience. A
straightforward "No Malware Detected" message is more user-friendly than
simply remaining silent.
38
10.CONCLUSION
• Using behavioural anomaly detection techniques like isolation forest and File Hashing
Mechanism also provide the physical security through hardware based intrusion
detection system.
• The code is easy to understand and implements a basic malware detection mechanism
using SHA256 hashes, which is a reliable and widely used hashing algorithm.
• Functionality:
• The script scans designated directories, computes the SHA256 hash for each file it
encounters, and compares these hashes against a predefined list of known malware
hashes.
• If a match is found, it reports the file as potentially malicious, allowing users to take
appropriate action.
• Efficiency:
• The use of the os.walk() function enables recursive scanning through all
subdirectories, ensuring comprehensive coverage of the file system.
• The hashing process reads files in chunks, making it memory efficient even for larger
files.
• Customization:
• Users can easily modify the list of directories to scan and update the list of known
malware hashes, making the tool adaptable to various security needs.
• This flexibility allows for regular updates based on new threats, enhancing its detection
capabilities.
• Integrate an automated system to regularly update the list of known malware hashes
from threat intelligence feeds or databases (e.g., VirusTotal, Malwarebytes).
• Implement a scheduled update feature to keep the hash list current without manual
intervention.
• Heuristic Analysis:
• Create a graphical user interface (GUI) to make the scanner more user-friendly. This
would allow non-technical users to easily configure settings, initiate scans, and view
results.
• Offer options for scheduled scans and notifications of detected malware.
• Enhance reporting features to log scan results, detailing detected malware, timestamps,
and actions taken.
• Generate summary reports that can be exported in various formats (e.g., PDF, CSV) for
auditing and compliance purposes.
• Enable integration with existing security solutions (e.g., firewalls, antivirus programs)
for a more comprehensive defense strategy.
• Create APIs for communication with other security tools for better threat management.
• Multi-Platform Support:
• Extend the scanner to support various operating systems (Linux, macOS) and devices
(IoT, mobile).
40
• Ensure that it can run on embedded systems or hardware devices commonly targeted by
malware.
• Cloud-Based Scanning:
• Develop a cloud-based version of the scanner that can analyze files uploaded by users
against a larger database of known malware.
• Utilize machine learning models hosted in the cloud to analyze files for potential threats.
41
12.REFERENCES
2. Shafique, M. L. A., et al. (2021). "Hardware Security Modules: Ensuring Data Integrity in
Power Sector." Journal of Information Security and Applications.
3. Zhang, X., et al. (2023). "Secure Firmware Updates for Embedded Devices in the Power
Sector." International Journal of Embedded Systems.
5. Wang, K., et al. (2022). "Real-Time Behavioral Analysis for Embedded Systems Security."
Journal of Systems Architecture.
6. Patel, R. S., et al. (2021). "Securing the Supply Chain of Embedded Devices in Critical
Infrastructures." IEEE Access.
7. Decker, J. A., et al. (2023). "Threat Modeling for Embedded Systems in Power
Infrastructure." IEEE Transactions on Power Delivery.
42