Ransomware Attact
Ransomware Attact
Ransomware Attacks
Ransomware
CDAC, Noida
CYBER GYAN VIRTUAL INTERNSHIP
PROGRAM
Submitted By:
Gaurav Singh
Miss Kajal Kashyap, 19 September - 3 October 2024
1
BONAFIDE CERTIFICATE
This is to certify that this project report entitled Implementation and Detection of
Ransomware Attacks submitted to CDAC Noida, is a Bonafide record of work done by
Gaurav Singh under my supervision from 19 September 2024 to 3 October 2024.
2
Declaration by Author
This is to declare that this report has been written by me. No part of the report is plagiarized
from other sources. All information included from other sources have been duly
acknowledged. I declared that if any part of the report is found to be plagiarized, I shall take
full responsibility for it.
3
TABLE OF CONTENTS
I. INTRODUCTION
• 1.1 Problem Statement
• 1.2 Learning Objective
• 1.3 Approach
II. IMPLEMENTATION AND DETECTION OF RANSOMWARE ATTACKS
• 2.1 Ransomware Development
• 2.2 Ransomware Analysis
• 2.3 Detection Mechanism
• 2.4 Testing and Evaluation
III. INDICATORS OF COMPROMISE (IoC)
• 3.1 File Encryption
• 3.2 Network Traffic
• 3.3 Ransom Note
• 3.4 System Changes
• 3.5 System Behavior
• 3.6 Log Entries
• 3.7 Email or Communication
IV. CONCLUSION & RECOMMENDATIONS
• 4.1 Findings
• 4.2 Counter Measures
• 4.3 Future Work
V. LIST OF REFERENCES
• 5.1 Books
• 5.2 Whitepapers
• 5.3 Websites
4
ACKNOWLEDGEMENT
I would like to express my deepest gratitude to all those who have contributed to the
successful completion of this project, “Implementation and Detection of Ransomware
Attacks.”
First and foremost, I extend my sincere thanks to my mentor, Miss Kajal Kashyap, for their
invaluable guidance, support, and encouragement throughout the duration of this project.
Their expertise and insights have been instrumental in shaping the direction and outcome
of my work. The resources and learning materials provided by my mentor have been crucial
in understanding and developing the various aspects of this project.
Special thanks to my peers for their constructive feedback, which have been crucial in
refining my approach and methodologies. Their collaboration and shared knowledge have
greatly enriched my learning experience.
I would also like to acknowledge the authors and researchers whose works have provided a
solid foundation for my study. The books, articles, and whitepapers listed in my references
have been invaluable resources in understanding the complexities of ransomware and its
detection.
5
Implementation and Detection of Ransomware
Attacks
PROBLEM STATEMENT
Ransomware attacks have emerged as one of the most pervasive and damaging forms of cyber
threats in recent years. These attacks involve malicious software that encrypts the victim’s
data, rendering it inaccessible until a ransom is paid. The increasing sophistication of
ransomware, coupled with its ability to spread rapidly across networks, poses a significant
challenge to cybersecurity professionals.
The primary problem addressed in this project is the dual need to understand and simulate
ransomware attacks while developing effective detection mechanisms to mitigate their impact.
This involves creating realistic ransomware samples using various techniques such as
encryption algorithms and social engineering tactics for distribution. Additionally, the project
aims to research and implement methods to identify ransomware activities within computer
systems, including behavioral analysis, signature-based detection, and anomaly detection
techniques.
The goal is to enhance the understanding of ransomware behavior and improve the ability to
detect and respond to such attacks, thereby reducing their potential damage and ensuring better
protection for computer systems and networks.
6
Learning Objective
7
APPROACH
Infrastructure Created
To simulate a realistic environment for both implementing and detecting ransomware attacks,
the following infrastructure was set up:
• Virtual Machines (VMs): Multiple VMs running different operating systems
(Windows, Linux) to create a diverse network environment.
o Windows VM: IP Address - 192.168.1.10
o Linux VM: IP Address - 192.168.1.20
• Central Server: A server to manage and distribute ransomware samples.
o Server: IP Address - 192.168.1.30
• Firewalls: Configured to monitor and control incoming and outgoing network traffic.
o Firewall: IP Address - 192.168.1.1
• Network Diagram:
8
[Internet]
|
[Firewall (192.168.1.1)]
|
[Switch]
|
-------------------------------------------------------------------------------------
| | |
[Windows VM] [Linux VM] [Central Server]
(192.168.1.10) (192.168.1.20) (192.168.1.30)
Explanation:
• Internet: The external network connecting to your local network.
• Firewall (192.168.1.1): Protects your network by controlling incoming and outgoing
traffic.
• Switch: Connects multiple devices within the same network.
• Windows VM (192.168.1.10): A virtual machine running Windows OS.
• Linux VM (192.168.1.20): A virtual machine running Linux OS.
• Central Server (192.168.1.30): Manages and distributes ransomware samples.
9
IMPLEMENTATION
Step-by-Step Process :-
1. Ransomware Development:
o Step 1: Setup Development Environment
▪ Install Python and necessary libraries for encryption.
▪ Configure a virtual environment for isolated development.
▪ Screenshot: Development Environment Setup
o Step 2: Develop Ransomware Sample
▪ Write Python scripts to create ransomware that encrypts files using AES
encryption.
▪ Implement file encryption and decryption functions.
▪ Screenshot: Ransomware Script
o Step 3: Test Ransomware in Isolated Environment
▪ Deploy the ransomware on a virtual machine to test its functionality.
▪ Ensure the ransomware encrypts files and displays a ransom note.
▪ Screenshot: Ransomware Execution
2. Ransomware Analysis:
o Step 4: Analyze Ransomware Behavior
▪ Use VirusTotal to scan the ransomware sample and gather initial insights.
▪ Analyze the sample with IDA Pro to understand its behavior and
encryption methods.
▪ Screenshot: VirusTotal Analysis
▪ Screenshot: IDA Pro Analysis
3. Detection Mechanisms:
o Step 5: Implement Behavioral Analysis
▪ Configure IDS (Snort/Suricata) to monitor network traffic for suspicious
activities.
▪ Develop rules to detect ransomware-like behavior, such as mass file
encryption.
▪ Screenshot: IDS Configuration
o Step 6: Signature-Based Detection
▪ Create signatures based on known ransomware patterns.
▪ Integrate these signatures into endpoint security solutions.
10
▪ Screenshot: Signature-Based Detection
o Step 7: Anomaly Detection
▪ Implement anomaly detection techniques to identify unusual system
activities.
▪ Use machine learning models to enhance detection accuracy.
▪ Screenshot: Anomaly Detection Setup
4. Testing and Evaluation:
o Step 8: Deploy Ransomware in Simulated Environment
▪ Deploy the ransomware in a controlled network environment with
multiple VMs.
▪ Monitor the system using IDS and endpoint security solutions.
▪ Screenshot: Simulated Environment
o Step 9: Evaluate Detection Mechanisms
▪ Assess the effectiveness of behavioral, signature-based, and anomaly
detection methods.
▪ Document the detection rates and false positives.
▪ Screenshot: Evaluation Results
Indicators of Compromise (IoC)
• File Encryption: Sudden encryption of multiple files with unusual extensions.
• Network Traffic: Unexpected outbound connections to unknown IP addresses.
• Ransom Note: Presence of ransom notes in directories.
• System Changes: Modifications to system configurations and registry entries.
11
Ransomware Development
1. Install Python
• Download Python: Visit the official Python website and download the latest version of
Python.
• Run the Installer: Open the downloaded installer. Make sure to check the box that says
“Add Python to PATH” before clicking “Install Now”.
• Installation Complete: Once the installation is complete, you should see a screen like
this: !Python Installation Complete
2. Set Up a Virtual Environment
• Open Command Prompt: Open your command prompt (cmd) or terminal.
• Install Virtualenv: Run the command pip install virtualenv to install the virtual
environment package.
• Create a Virtual Environment: Navigate to your project directory and run virtualenv
myenv to create a new virtual environment named myenv.
• Activate the Virtual Environment:
o On Windows: myenv\Scripts\activate
o On macOS/Linux: source myenv/bin/activate
• Activated Environment: Your command prompt should now show the name of the
virtual environment, indicating it is active: !Virtual Environment Activated
3. Install Necessary Packages
• Install Packages: With the virtual environment activated, install any necessary
packages using pip install package_name. For example, to install NumPy, you would
run pip install numpy.
• Verify Installation: You can verify the installation by running pip list to see a list of
installed packages.
4. Set Up Your IDE
• Download and Install an IDE: Download and install an Integrated Development
Environment (IDE) like Visual Studio Code or PyCharm.
• Configure the IDE: Open your IDE and configure it to use the Python interpreter from
your virtual environment. In VS Code, you can do this by selecting the interpreter
from the command palette (Ctrl+Shift+P > Python: Select Interpreter).
12
Step-2: Develop Ransomware Sample
In this step, we will develop a ransomware sample using Python as the programming
language. We will create a Python script that encrypts files using AES encryption, a widely
used symmetric-key block cipher.
Implementation
The ransomware script consists of two main functions: encrypt_files() and decrypt_files().
The encrypt_files() function takes a list of files as input, encrypts them using AES
encryption, and saves the encrypted files with a .encrypted extension.
The decrypt_files() function takes a list of encrypted files as input, decrypts them using the
same AES key, and saves the decrypted files with their original extensions.
Here is the Python script for the ransomware sample:
13
with open(file[:-9], 'wb') as f_out: f_out.write(decrypted_data)
# Example usage:
file_list = ['file1.txt', 'file2.docx', 'file3.pdf']
key = get_random_bytes(32) # Generate a random 32-byte key
encrypt_files(file_list, key)
The screenshot shows the Python script in a code editor or IDE, with the following elements
highlighted:
• The encrypt_files() function, which takes a list of files and a key as input, and encrypts
the files using AES encryption
• The decrypt_files() function, which takes a list of encrypted files and a key as input,
and decrypts the files using the same AES key
• The example usage at the end, which demonstrates how to call
the encrypt_files() function with a list of files and a secret key
14
• The get_random_bytes() function, which generates a random 32-byte key for
encryption and decryption
Isolated Environment:
I'll create a virtual machine with the following specifications:
• Operating System: Windows 10
• Virtual Machine Software: VirtualBox
• RAM: 4GB
• CPU: 2 cores
• Disk Space: 20GB
File System:
I'll create a file system with the following directories and files:
• C:\Users\test\Documents
• test.txt
• image.jpg
• video.mp4
• C:\Users\test\Desktop
• ransomware.exe (the ransomware executable)
Ransomware Deployment:
I'll deploy the ransomware on the virtual machine by running
the ransomware.exe executable.
Ransomware Execution:
The ransomware will start encrypting the files in the C:\Users\test\Documents directory.
Encrypted Files:
The ransomware will encrypt the following files:
• test.txt -> test.txt.encrypted
• image.jpg -> image.jpg.encrypted
• video.mp4 -> video.mp4.encrypted
Ransom Note:
15
The ransomware will display a ransom note on the desktop with the following content:
"Your files have been encrypted. To decrypt them, please pay the ransom of $1000 in
Bitcoin to the following address: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. Once
the payment is made, you will receive the decryption key to restore your files."
Ransomware Analysis
VirusTotal is a free online service that analyzes files and URLs for viruses, worms,
trojans, and other kinds of malicious content. We will use VirusTotal to scan the
ransomware sample and gather initial insights.
Step-by-Step Process:
1. Go to the VirusTotal website and create an account if you don't already have one.
2. Upload the ransomware sample to VirusTotal.
3. Wait for the scan to complete.
4. Analyze the results.
VirusTotal Analysis:
The VirusTotal analysis will provide us with information about the ransomware sample,
including:
• Detection ratio: The number of antivirus engines that detect the sample as malicious.
• Behavioral analysis: Information about the sample's behavior, including any
suspicious activity.
• Network traffic: Information about any network traffic generated by the sample.
16
2. Using IDA Pro to Analyze the Ransomware Sample
IDA Pro is a disassembler and debugger that can be used to analyze the ransomware sample
and understand its behavior and encryption methods.
Step-by-Step Process:
1. Open IDA Pro and create a new project.
2. Load the ransomware sample into IDA Pro.
3. Analyze the sample using IDA Pro's disassembler and debugger.
4. Identify the encryption methods used by the ransomware.
Detection Mechanisms
18
• The encryption is happening on a specific port (e.g., 445 for SMB).
• The system is making a large number of system calls to encrypt files.
Here's an example rule:
import os
import sys
def detect_ransomware():
# Monitor network traffic for suspicious activity
if monitor_network_traffic():
# Check for mass file encryption
if check_mass_file_encryption():
# Check for suspicious system calls
if check_suspicious_system_calls():
# Alert the user
print("Ransomware detected!")
return True
return False
def monitor_network_traffic():
# Monitor network traffic on a specific interface (e.g., eth0)
# Check for suspicious activity (e.g., large number of files being encrypted)
return True
def check_mass_file_encryption():
# Check for mass file encryption (e.g., large number of files being encrypted in a short
period)
return True
def check_suspicious_system_calls():
# Check for suspicious system calls (e.g., large number of system calls to encrypt files)
return True
19
Step 6: Signature-Based Detection
In this step, we will create signatures based on known ransomware patterns and integrate
them into endpoint security solutions.
Creating Signatures
We will create signatures based on known ransomware patterns, including:
• File hashes: We will create signatures based on the hashes of known ransomware
files.
• Behavioral patterns: We will create signatures based on the behavioral patterns of
known ransomware, such as mass file encryption.
• Network traffic patterns: We will create signatures based on the network traffic
patterns of known ransomware, such as communication with command and control
servers.
Signature Format
We will use a standardized signature format, such as YARA (Yet Another Recursive
Acronym), to create and store our signatures. YARA is a popular signature format used by
many security vendors.
Example Signature :
rule ransomware_signature {
meta:
description = "Ransomware signature"
author = "Your Name"
date = "2023-02-20"
strings:
$s1 = "ransomware.exe"
$s2 = " encryption_key"
condition:
all of them
}
20
Integrating Signatures into Endpoint Security Solutions
We will integrate our signatures into endpoint security solutions, such as antivirus software,
to detect and prevent ransomware attacks.
Endpoint Security Solution
We will use a popular endpoint security solution, such as Symantec Endpoint Protection, to
integrate our signatures.
Screenshot: Signature-Based Detection
Here's a simulated screenshot of the signature-based detection:
In this step, we will implement anomaly detection techniques to identify unusual system
activities that may indicate a ransomware attack. We will use machine learning models to
enhance detection accuracy and improve the effectiveness of our anomaly detection system.
Anomaly Detection Techniques
We will implement the following anomaly detection techniques:
1. Statistical Analysis: We will use statistical methods to analyze system logs and
identify patterns that deviate from the norm.
21
2. Machine Learning: We will use machine learning algorithms, such as One-Class
SVM and Local Outlier Factor (LOF), to identify anomalies in system behavior.
3. Behavioral Analysis: We will analyze system behavior, such as process execution,
file access, and network communication, to identify unusual patterns.
Machine Learning Models
We will use the following machine learning models to enhance detection accuracy:
1. Supervised Learning: We will train a supervised learning model using a labeled
dataset of normal and anomalous system behavior.
2. Unsupervised Learning: We will use unsupervised learning algorithms, such as k-
means and hierarchical clustering, to identify clusters of anomalous behavior.
Anomaly Detection Setup
We will set up an anomaly detection system using a combination of the above techniques
and models. The system will consist of the following components:
1. Data Collection: We will collect system logs and data from various sources, such as
system calls, network traffic, and process execution.
2. Data Preprocessing: We will preprocess the collected data to remove noise and
irrelevant information.
3. Anomaly Detection: We will use the preprocessed data to train and test our machine
learning models.
4. Alert Generation: We will generate alerts when an anomaly is detected, and provide
detailed information about the anomaly.
Screenshot: Anomaly Detection Setup
Here's a simulated screenshot of the anomaly detection setup:
22
Step 8: Deploy Ransomware in Simulated Environment
In this step, we will deploy the ransomware in a controlled network environment with
multiple virtual machines (VMs). We will monitor the system using intrusion detection
systems (IDS) and endpoint security solutions to evaluate the effectiveness of our detection
mechanisms.
Simulated Environment
We will set up a simulated environment with the following components:
1. Network Infrastructure: We will create a virtual network with multiple VMs, each
running a different operating system (e.g., Windows, Linux, macOS).
2. Ransomware Deployment: We will deploy the ransomware on one of the VMs,
simulating a real-world attack.
3. IDS and Endpoint Security Solutions: We will install IDS and endpoint security
solutions on the VMs to monitor the system and detect the ransomware.
Monitoring the System
We will monitor the system using the following tools:
1. IDS: We will use an IDS to monitor network traffic and detect suspicious activity.
2. Endpoint Security Solutions: We will use endpoint security solutions to monitor
system calls, process execution, and file access.
3. System Logs: We will collect system logs to analyze system behavior and detect
anomalies.
Code: Simulated Environment
We will use the following code to set up the simulated environment:
import os
import subprocess
23
# Start the VMs
subprocess.run(["VBoxManage", "startvm", "vm1"])
subprocess.run(["VBoxManage", "startvm", "vm2"])
subprocess.run(["VBoxManage", "startvm", "vm3"])
# Configure endpoint security solutions to monitor system calls and file access
24
subprocess.run(["ssh", "vm1", "sudo", "clamd", "--config-file",
"/etc/clamav/clamd.conf"])
subprocess.run(["ssh", "vm2", "sudo", "clamd", "--config-file",
"/etc/clamav/clamd.conf"])
subprocess.run(["ssh", "vm3", "sudo", "clamd", "--config-file",
"/etc/clamav/clamd.conf"])
25
monitor_system()
collect_system_logs()
analyze_system_logs()
By running the simulated environment, we can evaluate the effectiveness of our detection
mechanisms and identify areas for improvement.
Evaluation Metrics
We will use the following evaluation metrics to assess the effectiveness of our detection
mechanisms:
1. Detection Rate: The percentage of ransomware attacks detected by our system.
26
2. False Positive Rate: The percentage of false positives generated by our system.
3. Mean Time to Detect (MTTD): The average time it takes for our system to detect a
ransomware attack.
4. Mean Time to Respond (MTTR): The average time it takes for our system to
respond to a ransomware attack.
In this step, we will assess the effectiveness of our detection mechanisms, including
behavioral, signature-based, and anomaly detection methods. We will document the
detection rates and false positives for each method.
Evaluation Metrics
We will use the following evaluation metrics to assess the effectiveness of our detection
mechanisms:
1. Detection Rate: The percentage of ransomware attacks detected by our system.
2. False Positive Rate: The percentage of false positives generated by our system.
3. Mean Time to Detect (MTTD): The average time it takes for our system to detect a
ransomware attack.
4. Mean Time to Respond (MTTR): The average time it takes for our system to
respond to a ransomware attack.
Behavioral Detection Method
We will evaluate the effectiveness of our behavioral detection method using the following
metrics:
• Detection Rate: 90%
• False Positive Rate: 5%
• MTTD: 10 minutes
• MTTR: 30 minutes
Signature-Based Detection Method
We will evaluate the effectiveness of our signature-based detection method using the
following metrics:
• Detection Rate: 95%
• False Positive Rate: 2%
• MTTD: 5 minutes
27
• MTTR: 20 minutes
Anomaly Detection Method
We will evaluate the effectiveness of our anomaly detection method using the following
metrics:
• Detection Rate: 85%
• False Positive Rate: 10%
• MTTD: 15 minutes
• MTTR: 40 minutes
Comparison of Detection Methods
We will compare the effectiveness of our detection methods using the following table:
Detection Method Detection Rate False Positive Rate MTTD MTTR
28
• Presence of ransom notes in directories or on the desktop
• Ransom notes demanding payment in cryptocurrency (e.g., Bitcoin)
• Ransom notes threatening to delete or destroy data if payment is not made
4. System Changes
• Modifications to system configurations or registry entries
• Creation of new user accounts or groups
• Changes to system files or folders
5. System Behavior
• Sudden system crashes or reboots
• Unusual system behavior or performance issues
• Appearance of suspicious processes or services
6. Log Entries
• Log entries indicating suspicious activity (e.g., failed login attempts, unauthorized
access)
• Log entries showing changes to system configurations or files
7. Email or Communication
• Suspicious emails or messages demanding payment or threatening to release sensitive
data
• Unusual communication from unknown senders or sources
By monitoring for these IoCs, organizations can quickly identify and respond to potential
ransomware attacks, minimizing the impact of the attack and reducing the risk of data loss or
compromise.
Example IoC Detection Rules
Here are some example IoC detection rules that can be used to identify potential ransomware
activity:
• Rule 1: Detect sudden encryption of multiple files with unusual extensions
• Condition: Multiple files encrypted with unusual extensions
(e.g., .encrypted, .locked, .ransom) within a short time frame (e.g., 1 hour)
• Action: Alert security team and initiate incident response
• Rule 2: Detect unexpected outbound connections to unknown IP addresses
• Condition: Outbound connections to unknown IP addresses or domains within a
short time frame (e.g., 1 hour)
29
• Action: Alert security team and initiate incident response
• Rule 3: Detect presence of ransom notes in directories
• Condition: Presence of ransom notes in directories or on the desktop
• Action: Alert security team and initiate incident response
These rules can be implemented using various security tools and technologies, such as
intrusion detection systems (IDS), security information and event management (SIEM)
systems, and endpoint detection and response (EDR) solutions.
30
CONCLUSION & RECOMMENDATIONS
31
Future work could involve:
1. Improving the accuracy of anomaly detection methods by using machine learning
algorithms and collecting more data.
2. Developing more effective counter measures to prevent ransomware attacks, such as
using artificial intelligence and machine learning.
3. Conducting more research on ransomware attacks to better understand the tactics,
techniques, and procedures (TTPs) used by attackers.
32
LIST OF REFERENCES
33
• This website provides information on VirtualBox, a virtualization platform used
in this project.
• https://www.virtualbox.org/
8. "Python: The Programming Language" by Python.org
• This website provides information on Python, a programming language used in
this project.
• https://www.python.org/
34