Module 14 Hacking Web Applications
Module 14 Hacking Web Applications
A web application is a software application running on a web browser that allows a web
user to submit data to and retrieve it from a database over the Internet or within an
intranet. Web applications have helped to make web pages dynamic as they allow users
to communicate with servers using server-side scripts. They allow users to perform
specific tasks such as searching, sending emails, connecting with friends, online
shopping, and tracking and tracing.
Entities develop various web applications to offer their services to users via the Internet.
Whenever users need access to such services, they can request them by submitting the
uniform resource identifier (URI) or uniform resource locator (URL) of the web
application in a browser. Common web applications include webmail, online retail sales,
online auctions, wikis, and many others. With the wide adoption of web applications as a
cost-effective channel for communication and information exchange, they have also
become a major attack vector for gaining access to organizations’ information systems.
Web applications are an integral component of online business. Everyone connected via
the Internet uses an endless variety of web applications for different purposes, including
online shopping, email, chats, and social networking. Increasingly, web applications are
becoming vulnerable to more sophisticated threats and attack vectors.
Web application hacking is the exploitation of applications via HTTP by manipulating the
application logics via an application’s graphical web interface, tampering with the
uniform resource identifier (URI) or HTTP elements not contained in the URI. Methods for
hacking web applications, including SQL injection attacks, cross-site scripting (XSS),
cross-site request forgeries (CSRF), and insecure communications.
The last module involved acting as an attacker and assessing the security of a web
server platform. Now, it is time to move to the next, and most important, stage of a
security assessment. An expert ethical hacker or penetration tester (hereafter, pen
tester) must test web applications for various attacks such as brute-force, XSS,
parameter tampering, and CSRF, and then secure the web applications from such
attacks.
The labs in this module provide hands-on experience with various web application
attacks to help audit web application security in the target organization.
Objective
The objective of the lab is to perform web application hacking and other tasks that
include, but are not limited to:
Web applications run on web browsers and use a group of server-side scripts (such as
ASP and PHP) and client-side scripts (such as HTML and JavaScript) to execute the
application. The working of a web application depends on its architecture, which
includes the hardware and software that performs tasks such as reading the request,
searching, gathering, and displaying the required data.
Lab Tasks
Ethical hackers or pen testers use numerous tools and techniques to perform web
application attacks on the target web application. Recommended labs that will assist
you in learning various web application attack techniques include:
Lab Scenario
The first step in web application hacking for an ethical hacker or pen tester is to gather
the maximum available information about the target organization website by
performing web application footprinting using various techniques and tools. In this step,
you will use techniques such as web spidering and vulnerability scanning to gather
complete information about the target web application.
The labs in this exercise demonstrate how easily hackers can gather information about
your web application and describe the vulnerabilities that exist in web applications.
Lab Objectives
Footprinting the web infrastructure allows attackers to engage in the following tasks:
Server Discovery: Attackers attempt to discover the physical servers that host
a web application using techniques such as Whois Lookup, DNS Interrogation,
and Port Scanning
Service Discovery: Attackers discover services running on web servers to
determine whether they can use some of them as attack paths for hacking a web
app
Server Identification: Attackers use banner-grabbing to obtain server banners;
this helps to identify the make and version of the web server software
Hidden Content Discovery: Footprinting also allows attackers to extract
content and functionality that is not directly linked to or reachable from the main
visible content
In this task, we will perform web application reconnaissance to gather information about
server IP address, DNS names, location and type of server, open ports and services,
make, model, version of the web server software, and server-side technology.
8. Click the MATE Terminal icon at the top of the Desktop window to open
a Terminal window.
In this command, -T4: specifies setting time template (0-5), -A: specifies
aggressive scan, and -v: enables the verbose output (include all hosts and
ports in the output).
13. The result appears, displaying the open ports and services running on the
machine hosting the target website.
14. Scroll down to see the complete results. You can observe that the target
machine name, NetBIOS name, DNS name, MAC address, OS, and other
information is displayed, as shown in the screenshot.
15. Now, perform banner grabbing to identify the make, model, and version
of the target web server software.
21. Close all open windows and document all the acquired information.
Here, we will perform web application reconnaissance using the WhatWeb tool.
In this task, the target website (www.moviescope.com) is hosted by the victim
machine, Windows Server 2019. Keep this machine running until the end of the task.
Here, the host machine is the Parrot Security machine.
1. Click the MATE Terminal icon at the top of the Desktop window to open
a Terminal window.
This will generate a report with the name MovieScope_Report and save
this file in the root folder.
11. Type, pluma MovieScope_Report and press Enter to open the file.
12. The MovieScope_Report text file appears, as shown in the screenshot.
14. Close all open windows and document all the acquired information.
Here, we will perform web spidering on the target website using OWASP ZAP.
In this task, the objective being web spidering, we will focus on the
information obtained while performing web spidering.
13. Now, click on the Spider tab from the lower section of the window to
view the web spidering information. By default, the URLs tab appears under
the Spider tab.
14. The URLs tab contains various links for hidden content and functionality
associated with the target website (www.moviescope.com).
15. Now, navigate to the Messages tab under the Spider tab to view more
detailed information regarding the URLs obtained while performing the web
spidering, as shown in the screenshot.
17. Close all open windows and document all the acquired information.
Here, we will detect load balancers using dig command and lbd tool.
In this task, we will detect the load balancers on the website www.yahoo.com, as the
websites hosted by our lab environment do not use load balancers.
1. Click the MATE Terminal icon at the top of the Desktop window to open
a Terminal window.
dig command provides detailed results and is used to identify whether the
target domain is resolving to multiple IP addresses.
7. Now, type lbd yahoo.com and press Enter.
8. The result appears, displaying the available DNS load balancers used by
the target website, as shown in the screenshot.
lbd (load balancing detector) detects if a given domain uses DNS and http
load balancing via the Server: and Date: headers and the differences
between server answers. It analyzes the data received from application
responses to detect load balancers.
9. This concludes the demonstration of how to detect load balancers using
dig command and lbd tool.
10. Close all open windows and document all the acquired information.
Here, we will use Nmap and Gobuster tool to identify web server directories on the
target website.
In this task, the target website (www.moviescope.com) is hosted by the victim
machine, Windows Server 2019. Keep this machine running until the end of the task.
Here, the host machine is the Parrot Security machine.
1. Click the MATE Terminal icon at the top of the Desktop window to open
a Terminal window.
6. The result appears, displaying open ports and services, along with their
version.
7. Scroll-down in the result and observe the identified web server directories
under the http-enum section, as shown in the screenshot.
dir: uses directory or file brute-forcing mode, -u: specifies the target URL
(here, www.moviescope.com), and -w: is the wordlist file used for
directory brute-forcing (here, common.txt).
14. The result appears, displaying the identified web server directories, as
shown in the screenshot.
In real-time, attackers use Gobuster to scan the target website for web
server directories and perform fast-paced enumeration of the hidden files
and directories of the target web application. Gobuster is a command-
oriented tool used to brute-force URIs in websites, DNS subdomains, and
names of the virtual hosts on the target server.
15. This concludes the demonstration of how to identify web server
directories using Nmap and Gobuster.
16. Close all open windows and document all the acquired information.
Here, we will discover vulnerabilities in the target web application using Vega.
2. Now, in the right corner of Desktop, click the Show hidden icons icon,
observe that the WampServer icon appears.
3. Wait for this icon to turn green, which indicates that the WampServer is
successfully running.
4. Click Windows 10 to switch to the Windows 10 machine,
click Ctrl+Alt+Delete to activate the machine.
Alternatively, you can also click Ctrl+Alt+Delete button under Windows
10 machine thumbnail in the Resources pane or
Click Ctrl+Alt+Delete button under Commands (thunder icon) menu.
5. By default, Admin user profile is selected, click Pa$$w0rd to paste the
password in the Password field and press Enter to login.
8. Click Scan from the menu bar and select Start New Scan from the
available options.
9. The Select a Scan Target window appears on the screen. Ensure that
the Enter a base URI for scan radio button is selected under the Scan
Target section.
10. In the Enter a base URI for scan field, enter the target URL
as http://10.10.10.16:8080/dvwa and click Next.
12. By checking these options, all modules under these options will be
selected. Click Next.
13. In the Authentication Options wizard, leave the settings to default and
click Next.
14. In Parameters wizard, leave the settings to default and click Finish to
initiate the scan.
15. The Follow Redirect? pop-up appears; click Yes to continue.
16. The Vega application starts scanning the target website for
vulnerabilities. Observe the Scanner Progress bar and wait for it to finish.
In the left-hand pane, under the Scan Alerts section, you can see the scan
status as Auditing. As soon as Vega completes, the scan status changes
to Completed.
17. After the scanner finishes performing its vulnerability assessment on the
target website, it lists the discovered vulnerabilities under Scan Alert
Summary.
18. In the left-pane under Scan Alerts, expand the nodes to view the
complete vulnerability scan result. Now, choose any one of the discovered
vulnerabilities to display it on the respective page, as in the dashboard
section shown in the screenshot.
19. Choose any one vulnerability under the Scan Alerts section in the left-
hand pane. Here, we are selecting the Cleartext Password over
HTTP vulnerability; detailed information regarding the selected vulnerability
will be displayed in the right section of the window, as shown in the
screenshot.
20. Similarly, you can select any vulnerability from the list of discovered
vulnerabilities to view its detailed information and then apply appropriate
fixes for all the vulnerable codes in your web application.
22. You can also use other web application vulnerability scanning tools such
as WPScan Vulnerability
Database (https://wpscan.com), Arachni (https://www.arachni-
scanner.com), appspider (https://www.rapid7.com),
or Uniscan (https://sourceforge.net) to discover vulnerabilities in the target
website.
23. Close all open windows and document all the acquired information.
2. The target website appears in the created iframe, indicating that the
target website is vulnerable to clickjacking, as shown in the screenshot.
4. Close all open windows and document all the acquired information.
Lab Scenario
For an ethical hacker or pen tester, the next step after gathering required information
about the target web application is to attack the web application. They must have the
required knowledge to perform web application attacks to test the target network’s web
application security infrastructure.
Attackers perform web application attacks with certain goals in mind. These goals may
be either technical or non-technical. For example, attackers may breach the security of
the web application and steal sensitive information for financial gain or for curiosity’s
sake. To hack the web app, first, the attacker analyzes it to determine its vulnerable
areas. Next, they attempt to reduce the “attack surface.” Even if the target web
application only has a single vulnerability, attackers will try to compromise its security
by launching an appropriate attack. They try various application-level attacks such as
injection, XSS, broken authentication, broken access control, security misconfiguration,
and insecure deserialization to compromise the security of web applications to commit
fraud or steal sensitive information.
An ethical hacker or pen tester must test their company’s web application against
various attacks and other vulnerabilities. They must find various ways to extend the
security test and analyze web applications, for which they employ multiple testing
techniques. This will help in predicting the effectiveness of additional security measures
in strengthening and protecting web applications in the organization.
The tasks in this lab will assist in performing attacks on web applications using various
techniques and tools.
Lab Objectives
One maintains and accesses web applications through various levels that include
custom web applications, third-party components, databases, web servers, OSes,
networks, and security. All the mechanisms or services employed at each layer help the
user in one way or another to access the web application securely. When talking about
web applications, the organization considers security to be a critical component,
because web applications are major sources of attacks. Attackers make use of
vulnerabilities to exploit and gain unrestricted access to the application or the entire
network. Attackers try various application-level attacks to compromise the security of
web applications to commit fraud or steal sensitive information.
Here, we will perform a brute-force attack on the target website using Burp Suite.
4. Now, we shall set up a Burp Suite proxy by first configuring the proxy
settings of the browser.
5. In the Mozilla Firefox browser, click the Open menu icon in the right
corner of the menu bar and select Preferences from the list.
6. The General settings tab appears. In the Find in Preferences search
bar, type proxy, and press Enter.
19. Now, right-click anywhere on the HTTP request window, and from the
context menu, click Send to Intruder.
21. Observe the target host and port values in the Host and Port fields.
22. Click on the Positions tab under the Intruder tab and observe that Burp
Suite sets the target positions by default, as shown in the HTTP request. Click
the Clear § button from the right-pane to clear the default payload values.
23. Once you clear the default payload values, select Cluster bomb from
the Attack type drop-down list.
Cluster bomb uses multiple payload sets. There is a different payload set for
each defined position (up to a maximum of 20). The attack iterates through
each payload set in turn so that all permutations of payload combinations
are tested. For example, if there are two payload positions, the attack will
place the first payload from payload set 2 into position 2 and iterate through
all payloads in payload set 1 in position 1; it will then place the second
payload from payload set 2 into position 2 and iterate through all the
payloads in payload set 1 in position 1.
24. Now, we will set the username and password as the payload values. To
do so, select the username value entered in Step 17 and click Add § from
the left-pane.
25. Similarly, select the password value entered in Step 17 and click Add
§ from the left-pane.
38. Wait for the progress bar at the bottom of the window to complete.
39. After the progress bar completes, scroll down and observe the different
values of Status and Length. Here, Status=302 and Length= 1105.
Different values of Status and Length indicate that the combination of the
respective credentials is successful.
The values might differ in your lab environment.
40. In the Raw tab under the Request tab, the HTTP request with a set of
the correct credentials is displayed. (here, username=admin and
password=qwerty@123), as shown in the screenshot. Note down these user
credentials.
41. Now, that you have obtained the correct user credentials, close
the Intruder attack 1 window.
47. Close all open windows and document all the acquired information.
Here, we will use the Burp Suite tool to perform parameter tampering.
3. Now, set up a Burp Suite proxy by first configuring the proxy settings of
the browser.
4. In the Mozilla Firefox browser, click the Open menu icon in the right
corner of the menu bar and select Preferences from the list.
5. The General settings tab appears. In the Find in Preferences search
bar, type proxy, and press Enter.
12. The Burp Suite main window appears; ensure that the Temporary
project radio button is selected and click the Next button, as shown in the
screenshot.
You can observe that the entered login credentials were intercepted by the
Burp Suite.
18. Now, keep clicking the Forward button until you are logged into the user
account.
19. Switch to the browser, and observe that you are now logged into the user
account, as shown in the screenshot.
20. Now, click the View Profile tab from the menu bar to view the user
information.
21. After clicking the View Profile tab, switch back to the Burp
Suite window and keep clicking the Forward button until you get the HTTP
request, as shown in the screenshot.
22. Now, navigate to the Params tab under the Intercept tab to view the
captured parameters.
23. Under the Params tab, observe a table with captured values such
as URL and Cookie.
24. In the URL type with the name id, double-click the Value column to
change it from 1 to 2, as shown in the screenshot.
25. After changing the value, navigate back to the Raw tab.
26. In the Raw tab, click the Intercept is on button to turn off the
interception.
27. After switching off the interception, navigate back to the browser window
and observe that the user account associated with ID=2 appears with the
name John, as shown in the screenshot.
Although we logged in using sam as a username with ID=1, using Burp Suite,
we successfully tampered with the ID parameter to obtain information about
other user accounts.
28. Similarly, you can edit the id parameter in Burp Suite with any random
numeric value to view information about other user accounts.
29. Switch to the browser window and perform Steps 4-6. Remove the
browser proxy set up in Step 7, by selecting the No proxy radio-button in
the Connection Settings window and click OK. Close the tab.
30. This concludes the demonstration of how to perform parameter
tampering using Burp Suite.
31. Close all open windows and document all the acquired information.
XSS attacks exploit vulnerabilities in dynamically generated web pages, which enables
malicious attackers to inject client-side script into web pages viewed by other users.
Attackers inject malicious JavaScript, VBScript, ActiveX, HTML, or Flash code for
execution on a victim’s system by hiding it within legitimate requests.
Although implementing a strict application security routine, parameters, and input
validation can minimize parameter tampering and XSS vulnerabilities, many websites
and web applications are still vulnerable to these security threats.
Attacking web applications through parameter tampering and XSS vulnerabilities is one
of the steps an attacker takes in attempting to compromise a web application’s security.
An expert ethical hacker and pen tester should be aware of the different parameter
tampering and XSS methods that can be employed by an attacker to hack web
applications.
Here, we will learn how to exploit parameter tampering and XSS vulnerabilities in the
target web application.
5. You will be redirected to the profile page, which displays the personal
information of steve (here, you). You will observe that the value of ID in the
personal information and address bar is 4.
6. Now, try to change the parameter in the address bar to id=1 and
press Enter.
7. You will be redirected to the profile of sam without having to perform any
hacking techniques to explore the database. Here, you can observe Sam’s
personal information under the View Profile tab, as shown in the
screenshot.
8. Now, try the parameter id=3 in the address bar and press Enter.
9. You get the profile for kety. This way, you can change the id number and
obtain profile information for different users.
This process of changing the ID value and getting the result is known as
parameter tampering. Web XSS attacks exploit vulnerabilities on dynamically
generated web pages. This enables malicious attackers to inject client-side
scripts into the web pages viewed by other users.
10. Now, click the Contacts tab. Here you will be performing an XSS attack.
11. The Contacts page appears; enter your name or any random name
(here, steve) in the Name field; enter the cross-site script as shown in the
screenshot in the Comment field and click the Submit Comment button.
12. On this page, you are testing for XSS vulnerability. Now, refresh
the Contacts page.
19. Similarly, whenever a user attempts to visit the Contacts page, the alert
pops up as soon as the page is loaded.
21. Close all open windows and document all the acquired information.
4. Wait for this icon to turn green, which indicates that the WampServer is
successfully running.
5. Now, open any web browser (here, Mozilla Firefox). In the address bar
place your mouse cursor, click http://10.10.10.16:8080/CEH/wp-
login.php? and press Enter.
8. Hover your mouse cursor on Plugins in the left pane and click Installed
Plugins, as shown in the screenshot.
9. In the Plugins page, observe that leenk.me is installed.
Click Activate under the leenk.me plugin to activate the plugin.
10. Refresh the page and you will observe that the leenk.me plugin option
appears in the left pane; click it.
Refresh the page if leenk.me does not appear on the left pane.
11. The leenk.me General Settings page appears. Tick
the Facebook checkbox in the Choose which social network modules
you want to enable for this site option under the Administrator
Options section and click the Save Settings button.
18. A webpage with a Register new user form appears; scroll down and in
the Required fields enter your personal details. Check By ticking this box
you agree to our terms checkbox..
19. Now, scroll down to the end of the page, click I'm not a robot and click
on Register button.
If Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
If a captcha window appears, verify it.
20. A notification saying A message with a confirmation link has been
sent to your email address….
21. Now, open a new tab in the Chrome browser and open the email account
you gave while registering as a new user in Step 18.
22. Once you are logged into your email account, open the email
from noreply@wpvulndb.com, and in the email, click the Confirm my
account hyperlink.
If you get any error while accessing website content in Parrot Security
machine, then browse the same website in your local machine, login into
your account and perform the following steps.
23. A new webpage appears with a message saying Your email address
has been successfully confirmed. Enter the same details in the Email
Address and Password fields that you provided in Step 18.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
24. You get signed in successfully in the website. Now, click the Free
usage button under the Choose a plan section.
25. The Edit Profile page appears; in the API Token section and observe
the API Token. Note down or copy this API Token; we will use this token in
the later steps.
26. Close the Google Chrome browser window.
27. Click the MATE Terminal icon at the top of the Desktop window to open
a Terminal window.
28. A Parrot Terminal window appears. In the terminal window, type sudo
su and press Enter to run the programs as a root user.
29. In the [sudo] password for attacker field, type toor as a password
and press Enter.
You should use the same browser that was used in Step 5.
45. The Security_Script.html file opens up in the Mozilla Firefox browser,
along with a pop-up; click OK to continue.
46. You will be redirected to the Facebook Settings page of
the leenk.me plugin page. Observe that the field values have been
changed, indicating a successful CSRF attack on the website, as shown in the
screenshot.
48. Close all open windows on both the machines (Window Server
2016 and Parrot Security) and document all the acquired information.
In this task, we will perform multiple attacks on a vulnerable PHP website (WordPress) in
an attempt to gain sensitive information such as usernames and passwords. You will
also learn how to use the WPScan tool to enumerate usernames on a WordPress
website, and how to crack passwords by performing a dictionary attack using an msf
auxiliary module.
10. To obtain the passwords, you will use the auxiliary module
called wordpress_login_enum (in msfconsole) to perform a dictionary
attack using the password.txt file (in the Wordlist folder) which you copied
to the location /home/attacker/Desktop/CEHv11 Module 14 Hacking
Web Applications.
17. This provides a list of options that can be set for this module. As we must
obtain the password for the target user account, we will set the below
options:
o PASS_FILE: Sets the password.txt file, using which; you will perform
the dictionary attack
o RHOST: Sets the target machine (here, the Windows Server
2016 IP address)
o RPORT: Sets the target machine port (here, the Windows Server
2016 port)
o TARGETURI: Sets the base path to the WordPress website
(here, http://[IP Address of Windows Server 2016]:8080/CEH]
o USERNAME: Sets the username that was obtained in Step 8.
(here, admin)
18. Now, in the msfconsole, type the below commands:
20. Observe that the auxiliary module initially enumerates details such as the
ID number and the stored location of the username admin, and then begins
to brute-force the login credentials by trying various passwords for the given
username.
21. The auxiliary module tests various passwords against the given username
(admin) and the cracked password is displayed, as shown in the screenshot.
Here, the cracked password is qwerty@123, which might differ in your lab
environment.
22. Now, use the obtained username-password combination to log into the
WordPress website. (Here, Username: admin and Password: qwerty@123).
23. Now, click the Firefox icon from the top section of Desktop to launch
the Mozilla Firefox browser.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
25. Observe that you are successfully logged into the target WordPress
website (http://10.10.10.16:8080/CEH) and that you can see the website
content.
26. Similarly, you can crack the passwords of other users by firstly selecting
a particular username from Step 8, and then perform Steps 12-21.
27. This concludes the demonstration of how to enumerate and hack a web
application using WPScan and Metasploit.
28. Close all open windows on both the machines (Windows Server
2016 and Parrot Security) and document all the acquired information.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
4. You are successfully logged in, and the DVWA main webpage appears.
Click Command Injection from the options available in the left pane.
5. The Vulnerability: Command Injection page appears; under the Ping
a device section, type the IP address of the Windows Server
2016 machine (here, 10.10.10.16) into the Enter an IP address field and
click the Submit button to ping the machine.
The command injection utility in DVWA allows you to ping the target
machine.
6. DVWA successfully pings the target machine, as shown in the
screenshot.
7. Now, try to issue a different command to check whether DVWA can
execute it.
8. Type | hostname into the Enter an IP address field and click Submit.
This command is used to probe the hostname of the target machine.
11. Now, check the security setting of the web application. To do so,
click DVWA Security in the left pane.
12. The DVWA Security page appears. Observe that the security level
is Impossible. This security setting was blocking you from executing
commands other than simply pinging a machine.
13. Now, to exploit the command execution vulnerability, set the Security
Level of the web application to low by selecting the option Low from the
drop-down list and click Submit.
Here, your intention would be to show that a weakly secured web application
is the prime focus of attackers, who seek to exploit its vulnerabilities.
14. You have configured a weak security setting in DVWA. Now, try to
execute a command other than ping.
17. DVWA returns the name of the Windows Server 2016 machine, as
shown in the screenshot.
18. This infers that the command execution field is vulnerable and that you
can remotely execute commands.
19. Now, extract more information regarding the target machine, Windows
Server 2016.
24. To check if you can terminate a process, choose any process from the list
(here, Microsoft.ActiveDirectory), and note down its process PID
(here, 2172).
To confirm that the process has successfully been terminated, you can issue
the | tasklist command again to check the running processes.
27. Now, to view the directory structure of the Windows Server
2016 machine, type | dir C:\ and click Submit to view the files and
directories on the C:\ drive.
28. The directory structure of the C drive of the target server (Windows
Server 2016) is displayed, as shown in the screenshot.
29. In the same way, you can issue commands to view other directories.
31. To view user account information, type | net user, and click Submit.
32. DVWA obtains user account information from the Windows Server
2016 machine and lists, as shown in the screenshot.
33. Now, use the command execution vulnerability and attempt to add a user
account remotely.
34. Create an account named Test. To do so, type | net user Test /Add and
click Submit.
35. The command completed successfully notification appears and a user
account named Test is created.
36. To view the new user account, type the command | net user and
click Submit.
37. You can observe the newly created account Test, as shown in the
screenshot.
38. Now, view the new account’s information. Type | net user Test and
click Submit.
39. The Test account information appears. You can see that Test is a
standard user account and does not have administrative privileges. You can
see that it has an entry called Local Group Memberships.
40. Now, assign administrative privileges to the account. The reason for
granting administrative privileges to this account is to use this (admin)
account to log into the Windows Server 2016 machine with administrator
access using a remote desktop connection.
44. Click the Type here to search field from the bottom of Desktop and
type Remote. Click Remote Desktop Connection from the results.
52. Close all open windows and document all the acquired information.
Here, we will use exploit a file upload vulnerability at different security levels of DVWA
using Metasploit.
Before starting this task, ensure that the WampServer is running on the Windows
Server 2016 machine.
1. Click Parrot Security to switch to the Parrot Security machine.
2. Click the MATE Terminal icon at the top of Desktop to open
a Terminal window.
9. Type pluma upload.php and press Enter to launch the Pluma text
editor.
10. The Pluma text editor window appears; press Ctrl+V to paste the raw
payload copied in Step 7, and then press Ctrl+S to save the context.
11. Close all the open windows.
12. Click the Firefox icon from the top section of Desktop,
type http://10.10.10.16:8080/dvwa/login.php. Into the address bar and
press Enter.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
14. The Welcome to Damn Vulnerable Web Application! Page appears.
Click DVWA Security in the left pane to view the DVWA security level.
15. Change the security level from impossible to low by selecting Low from
the drop-down list and clicking the Submit button, as shown in the
screenshot.
16. Click the File Upload option from the left pane.
20. Now, click the Upload button to upload the file to the database.
21. You will see a message saying that the file has been uploaded
successfully, with the location of the file. Note the location of the file and
minimize the browser window.
22. Launch a Terminal window by clicking on the MATE Terminal icon at
the top of Desktop.
23. In the terminal window, type sudo su and press Enter to run the
programs as a root user.
24. In the [sudo] password for attacker field, type toor as a password
and press Enter.
34. Launch a new Terminal window by clicking on the MATE Terminal icon
at the top of Desktop window.
35. In the terminal window, type sudo su and press Enter to run the
programs as a root user.
36. In the [sudo] password for attacker field, type toor as a password
and press Enter.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
44. The Welcome to Damn Vulnerable Web Application! Page appears.
Click DVWA Security from the left pane to view the DVWA security level.
50. Now, before uploading the file, set up a Burp Suite proxy. Start by
configuring the proxy settings of the browser.
51. Click the Open Menu icon in the right corner of the menu bar and
select Preferences from the list.
52. The General settings tab appears. In the Find in Preferences search
bar, type proxy, and press Enter.
53. The Search Results appear; click the Settings button under
the Network Settings option.
54. A Connection Settings window appears; select the Manual proxy
configuration radio button and ensure that the HTTP Proxy is set
to 127.0.0.1 and Port as 8080. Ensure that the Use this proxy server for
all protocols checkbox is selected and click OK. Close
the Preferences tab.
55. Now, minimize the browser window, click Applications from the top left
corner of Desktop and navigate to Pentesting --> Web Application
Analysis --> Web Application Proxies --> burpsuite to launch the Burp
Suite application.
56. A security pop-up appears, enter the password as toor in
the Password field and click OK.
57. In the next Burp Suite Community Edition notification, click OK.
58. A notification appears saying that An update is available, click Close.
59. The Burp Suite main window appears. Ensure that the Temporary
project radio button is selected and click the Next button, as shown in the
screenshot.
60. In the next window, select the Use Burp defaults radio-button and click
the Start Burp button.
61. The Burp Suite main window appears; click the Proxy tab from the
available options in the top section of the window.
62. In the Proxy settings, by default, the Intercept tab opens-up. Observe
that the interception is active by default, as the button says Intercept is on.
Leave it running.
70. In the terminal window, type sudo su and press Enter to run the
programs as a root user.
71. In the [sudo] password for attacker field, type toor as a password
and press Enter.
81. In the terminal window, type sudo su and press Enter to run the
programs as a root user.
82. In the [sudo] password for attacker field, type toor as a password
and press Enter.
87. Type pluma high.jpeg and press Enter to launch the Pluma text editor.
88. The Pluma text editor window appears; press Ctrl+V to paste the raw
payload copied in Step 85. Edit the payload file by adding GIF98 to the first
line and then press Ctrl+S to save the context.
89. Close all open windows.
90. Click the Firefox icon from the top section of Desktop,
type http://10.10.10.16:8080/dvwa/login.php into the address bar and
press Enter. The DVWA login page appears. Log in with the
credentials admin and password, and click the Login button.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
91. The Welcome to Damn Vulnerable Web Application! Page appears;
click DVWA Security in the left pane to view the DVWA security level.
96. Now, click the Upload button to upload the file to the database.
97. You will see a message saying that the file has been uploaded
successfully, along with the location of the uploaded file. Note down this
location.
98. Now, click the Command Injection option in the left pane.
The Vulnerability: Command Injection window appears; in the Enter an
IP address field, type |copy C:\wamp64\www\DVWA\hackable\uploads\
high.jpeg C:\wamp64\www\DVWA\hackable\uploads\shell.php and
click the Submit button.
99. Observe a message saying that the file has been copied, as shown in the
screenshot.
100. Launch a Terminal window by clicking on the MATE Terminal icon at
the top of Desktop.
102. In the [sudo] password for attacker field, type toor as a password
and press Enter.
111. Close all open windows and document all the acquired information.
A professional ethical hacker or pen tester can use tools such as Weevely to gain
backdoor access to a website without being traced. Weevely is used to develop a
backdoor shell and upload it to a target server in order to gain remote shell access. This
tool also helps in performing administrative tasks, maintaining persistence, and
spreading backdoors across the target network.
Here, we will gain backdoor access via a web shell using Weevely.
1. On the Parrot Security machine, click the MATE Terminal icon at the
top of Desktop to open a Terminal window.
Weevely encodes the payload with a key phrase so that no one else can use
it to access the target system.
6. The shell file (shell.php) is generated at the
location /home/attacker/Desktop, and it is encoded with the password
(toor). Minimize the terminal window.
7. Click the Firefox icon from the top section of Desktop,
type http://10.10.10.16:8080/dvwa/login.php. Into the address bar and
press Enter.
If a Would you like Firefox to save this login notification appears at the
top of the browser window, click Don’t Save.
9. The Welcome to Damn Vulnerable Web Application! Page appears.
Click DVWA Security in the left pane to view the DVWA security level.
15. Now, click the Upload button to upload the file to the database.
16. You will see a message that the file has successfully been uploaded, with
the location of the file. Note the location of the file and minimize the browser
window.
17. Switch back to the Terminal window, type weevely
http://10.10.10.16:8080/dvwa/hackable/uploads/shell.php
[Password] (The password that you have provided in Step#2), and
press Enter. This command establishes a connection with the payload and
interacts with the target.
20. The result appears, displaying the running system privileges and the
present working directory, as shown in the screenshot.
21. Now, type ipconfig and press Enter to view the IP configuration of the
victim machine.
22. The result appears, displaying the victim machine’s IP address, default
gateway, Ipv6 address, and other information.
23. This concludes the demonstration of how to gain backdoor access via a
web shell using Weevely.
24. Close all open windows and document all the acquired information.