Module 14
Module 14
Hacking Web
Servers
Ansh Bhawnani
Web server concepts
Module 14
1. Web server
Introduction
Module 14
Web server concepts
4
Web server concepts
5
Web server concepts
▰ At the most basic level, whenever a browser needs a file which is hosted on a
web server, the browser requests the file via HTTP.
▰ When the request reaches the correct web server (hardware), the HTTP server
(software) accepts request, finds the requested document (if it doesn't then a
404 response is returned), and sends it back to the browser, also through
HTTP.
6
Web server concepts
7
2. Types of Web
Servers
Module 14
Web server concepts
9
Web server concepts
10
Web server concepts
▰ LiteSpeed Server
▻ A high-performance Apache drop-in replacement, LiteSpeed (LSWS) is the
4th popular web server on the internet.
▻ When you upgrade your web server to LiteSpeed, you will experience
improved performance that too with low operating cost.
▻ It has the ability to load Apache configuration files directly and can replace
the Apache within 15 minutes without any downtime.
▻ LSWS replaces all the Apache functions which other front-end proxy
solutions can’t do to simplify the use and make the transition from
Apache smooth and easy. 12
Web server concepts
13
Web server concepts
▰ [Link] Server
▻ [Link] is basically a server-side JavaScript environment that is used for
network applications such as web servers.
▻ [Link] differs from other popular web servers because it is mainly a
cross-platform runtime environment for building network applications
with.
▻ An event-driven architecture is applied by [Link] which is capable of
asynchronous I/O. Due to these design choices throughput and scalability
are optimized in web applications which helps to run real-time
communication and browser games
14
3. Web Server
Market Shares
Module 14
Web server concepts
16
Web server concepts
17
Web server concepts
18
4. Web Server
Security Issue
Module 14
Web server concepts
20
5. Why Web Servers
Are Compromised
Module 14
Web server concepts
22
Web server concepts
Module 14
Web server concepts
25
7. Open Source
Webserver
Architecture
Module 14
Web server concepts
27
Web Server Attacks
Module 14
1. DoS/DDoS Attacks
Module 14
Web Server Attacks
▰ Attackers may send numerous fake requests to the web server which results in
the web server crash or become unavailable to the legitimate users.
▰ Attackers may target high profile web servers such as banks, credit card
payment geteways, government owned services, etc. to steam user credentials.
30
Web Server Attacks
▰ To crash the webserver running the application, attacker targets the following
services by consuming the webserver with fake requests:
▻ Network bandwidth
▻ Server memory
▻ Application exception handling mechanism
▻ CPU usage
▻ Hard disk space
▻ Database space
31
2. DNS Server
Hijacking
Module 14
Web Server Attacks
▰ Attacker compromises DNS server and changes the DNS settings so that all the
request coming toward the target web server should be redirected to his/her
own malicious server.
33
3. DNS Amplification
Attack
Module 14
Web Server Attacks
35
Web Server Attacks
36
4. Directory
Traversal
Module 14
Web Server Attacks
▰ The root directory is a specific directory on the server file system in which the
users are confined. Users are not able to access anything above this root.
▰ In directory traversal attacks, attackers use ../ (dot-dot-slash) sequence to
access restricted directories outside of the web server root directory.
▰ Attackers can use trial and error method to navigate the outside of root
directory and access sensitive information in the system.
▰ With a system vulnerable, an attacker can step out of the root directory and
access other parts of the file system. This might give read access to restricted
files, which could provide more information to further compromise the system.
38
Web Server Attacks
▰ The attacker would assume that [Link] can retrieve files from the file
system and sends the following custom URL.
39
Web Server Attacks
40
Directory Listing
Module 14
Web Server Attacks
▰ Directory listing is a web server function that displays the directory contents
when there is no index file in a specific website directory. It is dangerous
because it leads to information disclosure.
▰ Even if directory listing is disabled, attackers might discover and exploit web
server vulnerabilities. For example, there was an old Apache Tomcat
vulnerability, where improper handling of null bytes (%00) and backslash (\)
made it prone to directory listing attacks.
▰ Attackers might also discover directory indexes using cached or historical data
contained in online databases. For example, Google’s cache database
42
Web Server Attacks
43
Web Server Attacks
44
Web Server Attacks
45
Web Server Attacks
48
6. Website
Defacement
Module 14
Web Server Attacks
50
Web Server Attacks
51
7. Web Server
Misconfiguration
Module 14
Web Server Attacks
▰ This configuration allows anyone to view the server status page, which
contains detailed information about the current user of the web server,
including information about the current hosts and requests being processed.
▻ [Link] file on an Apache server:
<Location /server-status>
SetHandler server-status
</Location>
54
Web Server Attacks
55
8. HTTP Response
Splitting/CRLF
Attack
Module 14
Web Server Attacks
▰ HTTP response splitting attack involves adding header response data into the
input field so that the server split the response into two responses.
▰ The attacker can control the second response to redirect user to a malicious
website whereas the other responses will be discarded by web browser.
▰ The application must allow input that contains CR (carriage return, also given
by %0d or \r) and LF (line feed, also given by %0a or \n) characters into the
header AND the underlying platform must be vulnerable to the injection of such
characters.
▰ These characters not only give attackers control of the remaining headers and
body of the response the application intends to send, but also allow them to
create additional responses entirely under their control.
57
10. Web Cache
Poisoning Attack
Module 14
Web Server Attacks
▰ An attacker forces the web server's cache to flush its actual cache content and
sends a specially crafted request, which will be stored in cache.
59
11. SSH Bruteforce
Attack
Module 14
Web Server Attacks
▰ SSH protocols are used to create an encrypted SSH tunnel between two hosts
in order to transfer unencrypted data over an insecure network.
▰ It works on TCP port 22.
▰ Attackers can bruteforce SSH login credentials to gain unauthorized access to
a SSH tunnel.
▰ SSH tunnels can be used to transmit malwares and other exploits to victims
without being detected.
61
12. Webserver
Password Cracking
Module 14
Web Server Attacks
▰ The most common passwords found are password, root, administrator, admin,
demo, test, guest, qwerty, pet names, etc.
▰ Attacker target mainly for:
▻ SMTP servers
▻ Web shares
▻ SSH Tunnels
▻ Web form authentication cracking
▻ FTP servers
▰ Attackers use different methods such as social engineering, spoofing, phishing,
using a Trojan Horse or virus, wiretapping, keystroke logging, etc.
63
13. Webserver
Password Cracking
Techniques
Module 14
Web Server Attacks
▰ Rainbow Tables
▻ A rainbow table works by doing a cryptanalysis very quickly and
effectively.
▻ A rainbow table already computes hashes of the large set of available
strings. There are two main steps in this:
▻ Creating a Table
▻ Here, the hash of a string is taken and then reduced to create a new
▻ hashMD5(12345678) = 25d55ad283aa400af464c76d713c07ad
▻ hashMD5(25d55ad2) = 5c41c6b3958e798662d8853ece970f70
66
Web Server Attacks
Module 14
Web Server Attacks
Module 14
Attack Methodology
Module 14
Attack Methodology
74
2. Webserver
Footprinting
Module 14
Attack Methodology
76
3. Mirroring a
Website
Module 14
Attack Methodology
78
4. Vulnerability
Scanning
Module 14
Attack Methodology
80
Attack Methodology
▰ Session Hijacking
▻ Sniff valid session IDs to gain unauthorized access to the Web Server and
snoop the data.
▻ Use session hijacking techniques such as session fixation, session
sidejacking, Cross-site scripting, etc. to capture valid session cookies and
IDs.
▻ Use tools such as Burp Suite, Firesheep, JHijack, etc. to automate session
hijacking.
81
5. Hacking Web
Passwords
Module 14
Attack Methodology
83
Web Server Attack
Tools
Module 14
1. Metasploit
Module 14
Web Server Attack Tools
86
Web Server Attack Tools
▰ Metasploit Architecture
87
Web Server Attack Tools
91
Web Server Attack Tools
92
Web Server Attack Tools
93
Web Server Attack Tools
95
2. Wfetch
Module 14
Web Server Attack Tools
97
3. THC-Hydra and
Brutus
Module 14
Web Server Attack Tools
▰ THC-Hydra:
▻ Hydra is a parallelized login cracker which supports numerous protocols
to attack.
▰ Brutus:
▻ It includes a multi-stage authentication engine and can make 60
simultaneous target connections.
▻ It supports no user name, single user name, multiple user name, password
list, combo (user/password) list and configurable brute force modes.
99
Countermeasures
Module 14
1. Patch
Management
Module 14
Countermeasures
104
Countermeasures
105
Countermeasures
▰ Installation of a Patch
▻ Users can access and install security patches via the World Wide Web.
▻ Patches can be installed in two ways:
▻ Manual Installation: In this method, the user has to download the
patch from the vendor and fix it.
▻ Automatic Installation: In this method, the applications use the Auto
Update feature to update themselves.
106
Countermeasures
107
Countermeasures
108
Countermeasures
109
Countermeasures
110
Countermeasures
111
Countermeasures
112
2. Web Servers in
Separate Secure
Segment
Module 14
Countermeasures
▰ An ideal web hosting network should be designed with at least three segments namely
Internet segment, secure server security segment often called demilitarized zone (DMZ),
internal network.
▰ Place the web server in Server Security Segment (DMZ) of the network isolated from
public network as well as internal network.
▰ The firewalls should be place for internal network as well as Internet traffic going
towards DMZ.
114
3. Protocols
Module 14
Countermeasures
▰ Block all unnecessary ports, Internet Control Message Protocol (ICMP) traffic,
and unnecessary protocols such as NetBIOS and SMB.
▰ Harden the TCP/IP stack and consistently apply the latest software patches
and updates to system software.
▰ If using insecure protocols such as Telnet, POP3, SMTP, FTP, take appropriate
measures to provide secure authentication and communication, for example,
by using IPSec policies.
▰ If remote access is needed, make sure that the remote connection is secured
properly, by using tunneling and encryption protocols.
▰ Disable WebDAV if not used by the application or keep secure if it is required.
116
4. Accounts
Module 14
Countermeasures
118
Countermeasures
▰ Use secure web permissions, NTFS permissions, and .NET Framework access
control mechanisms including URL authorization.
▰ Slow down brute force and dictionary attacks with strong password policies,
and then audit and alert for logon failures.
▰ Run processes using least privileged accounts as well as least privileged
service and user accounts.
119
5. Files and
Directories
Module 14
Countermeasures
121
Countermeasures
▰ Eliminate the presence of non web files such as archive files, backup files, text
files, and header/include files.
▰ Disable serving certain file types by creating a resource mapping.
▰ Ensure the presence of web application or website files and scripts on a
separate partition or drive other than that of the operating system, logs, and
any other system files.
122
7. Detecting Web
Server Hacking
Attempts
Module 14
Countermeasures
▰ Ports:
▻ Audit the ports on server regularly to ensure that an insecure or
unnecessary service is not active on your web server.
▻ Limit inbound traffic to port 80 for HTTP and port 443 for HTTPS (SSL).
▻ Encrypt or restrict intranet traffic.
▰ Server Certificates:
▻ Ensure that certificate data ranges are valid and that certificates are used
for their intended purpose.
▻ Ensure that the certificate has not been revoked and certificate public key
is valid all the way to a trusted root authority. 126
Countermeasures
▰ [Link]:
▻ Ensure that protected resources are mapped to HttpForbiddenHandler
and unused HttpModules are removed.
▻ Ensure that tracing is disabled <trace enable="false"/> and debug
compiles are turned off.
▰ Code Access Security:
▻ Implement secure coding practices.
▻ Restrict code access security policy settings.
▻ Configure IIS to reject URLs with "../" and install new patches and updates.
127
Countermeasures
▰ Services:
▻ UrlScan can be configured to filter HTTP query string values and other
HTTP headers to mitigate SQL injection attacks while the root cause is
being fixed in the application.
▻ It provides W3C formatted logs for easier log file analysis through log
parsing solutions like Microsoft Log Parser 2.2.
▰ Registry:
▻ Apply restricted ACLs and block remote registry administration.
▻ Secure the SAM (Stand-alone Servers Only).
128
Countermeasures
▰ IIS Metabase:
▻ Ensure that security related settings are configured appropriately and
access to the metabase file is restricted with hardened NTFS permissions.
▰ ISAPI Filters:
▻ Remove unnecessary ISAPI filters from the webserver.
▰ Shares:
▻ Remove all unnecessary file shares including the default administration
shares if not required.
▻ Secure the shares with restricted NTFS permissions.
129
Countermeasures
▰ How to Defend against HTTP Response Splitting and Web Cache Poisoning
▻ Server Admin:
▻ Use latest web server software.
▻ Regularly update/patch OS and Webserver.
▻ Run web Vulnerability Scanner.
▻ Application Developers:
▻ Restrict web application access to unique IPs.
▻ Disallow carriage return (%0d or \r) and line feed (%0a or \n)
characters.
131
Countermeasures
▻ Proxy Servers:
▻ Avoid sharing incoming TCP connections among different clients.
▻ Use different TCP connections with the proxy for different virtual
hosts.
▻ Implement "maintain request host header" correctly.
132
Countermeasures
134