With Emphasis On Web Applications Security Related Issues
With Emphasis On Web Applications Security Related Issues
With Emphasis On Web Applications Security Related Issues
1
!@ !@ #
Topics To Be Covered
Ethical Hacking - ?
2
!@ ss
#
What is Ethical Hacking
Also Called – Attack & Penetration Testing, White-hat hacking, Red
teaming
Hacking
Ethical
Conforming to accepted professional standards of conduct
3
!@ ss #
Why – Ethical Hacking
THE WEB HACKING INCIDENTS DATABASE 2009 BI-ANNUAL REPORT AUGUST 2009
BREACH SECURITY CORPORATION USA
4
!@ #
Why – Ethical Hacking
5
!@ ss #
Why – Ethical Hacking
THE WEB HACKING INCIDENTS DATABASE 2009 BI-ANNUAL REPORT AUGUST 2009
BREACH SECURITY CORPORATION USA
6
!@ ss #
Idea Behind Ethical Hacking
7
!@ ss #
Penetration Testing Strategies
External vs. internal testing:
External testing refers to attacks on the organization’s network perimeters using procedures
performed from outside the Internet or Extranet by targeting Domain Name Server (DNS), email
server, web server or firewall.
Internal testing is performed from within the organization’s technology environment. The
focus is to see what an authorized user could do to penetrate specific information resources
within the organization’s network.
Double-blind testing extends the blind testing strategy in that the organization’s IT
and security staff are not notified or informed beforehand and are “blind” to the
planned testing activities.
9
!@ ss #
You need hands on Tools Like:
Vulnerability Scanners : Nessus, ISS, SARA, SAINT, PAROS
Other useful tools: PING, whois, Traceroute, DIG, nslookup, sam spade, FScan,
Hping, Firewalk, netcat, tcpdump, ssh, telnet, SNMP Scanner
10
!@ ss #
Attack – Exploit the vulnerabilities
Network Infrastructure Attacks
Operating System Attacks
Application Specific Attacks
(Will be discussed in detail in later slides)
11
!@ ss #
First Step:
Understand Application Environment
The header and any page returned from a HEAD or
OPTIONS request will usually contain a SERVER:
string or similar detailing the Web server software
version and possibly the scripting environment or
operating system in use.
12
!@ ss #
Contd..
Understanding Application Environment
Manipulate inputs in order to elicit a scripting error
In the example below the most obvious variable (ItemID) has
been manipulated to fingerprint the Web application environment
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 04 Jun 2003 11:12:24 GMT
Content-Type: text/html
<title>Home Page</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
!@ #
14 In this situation, the developer appears to be using MS Visual Studio 7. The underlying
environment is likely to be Microsoft IIS 5.0 with .NET framework. ss
Known Problems with Web Applications
15
!@ ss #
Known Attacks
SQL Injection Attack
Code and Content Injection Attack
Cross site Scripting Attack
Path Traversal and URLs
Buffer Overflows
Exploit Session Security
Capture Logic Flaws
Cookies
Webbugs
16
!@ ss #
SQL Injection Attacks Example
This is one of the most commonly used examples of an SQL injection vulnerability, as it is easy to
understand for non-SQL-developers and highlights the extent and severity of these vulnerabilities.
One of the simplest ways to validate a user on a Web site is by providing them with a form, which
prompts for a username and password. When the form is submitted to the login script (eg.
login.asp), the username and password fields are used as variables within an SQL query.
In this scenario, no sanity or validity checking is being performed on the user and pass variables
from our form inputs. The developer may have client-side (eg. Javascript) checks on the inputs, but
as has been demonstrated in the first part of this series, any attacker who understands HTML can
bypass these restrictions. If the attacker were to submit the following credentials to our login script:
17
!@ ss #
Code and Content Injection
The following snippet of PHP code is used to display posts for a particular message
board. It retrieves the messageid GET variable from the user and opens a file
$messageid.txt under /var/www/forum:
Although the is_numeric() test prevents the user from entering a file path as the
messageid, the content of the message file is not checked in any way. (The problem
with allowing unchecked entry of file paths is explained later) If the message
contained PHP code, it would be included and therefore executed by the server.
18
!@ ss #
Cross Site Scripting Attack
A simple example of XSS can be seen in the following URL:
http://server.example.com/browse.cfm?categoryID=1&name=Books
In this example the content of the 'name' parameter is displayed on the returned page. A user
could submit the following request:
http://server.example.com/browse.cfm?
categoryID=1&name=<script>alert(document.cookie);</script>
In this case, we have managed to inject Java script into the resulting page. The relevant cookie (if
any) for this session would be displayed in a popup box upon submitting this request.
This can be abused in a number of ways, depending on the intentions of the attacker. A short piece
of Java script to submit a user's cookie to an arbitrary site could be placed into this URL. The
request could then be hex-encoded and sent to another user, in the hope that they open the URL.
Upon clicking the trusted link, the user's cookie would be submitted to the external site. If the
original site relies on cookies alone for authentication, the user's account would be compromised.
19
!@ ss #
Path Traversal and URLs
<?php include('/var/www/template/header.inc');
if (isset($_GET['file'])
{ $fp = fopen("$file" . ".html","r"); }
else { $fp = fopen("main.html", "r"); }
include('/var/www/template/footer.inc'); ?>
Look at The fopen("$file" , "r");
...the attacker would be able to traverse to any file readable by the Web application.
http://www.example.com/index.php?file=../../../../etc/passwd
This request would return the contents of /etc/passwd unless additional stripping of the path character
(/.) had been performed on the file variable.
lo
This problem is compounded by the automatic handling of URIs by many modern Web scripting
technologies, including PHP, Java and Microsoft's .NET. If this is supported on the target environment,
vulnerable applications can be used as an open relay or proxy:
http://www.example.com/index.php?file=http://www.google.com/
This flaw is one of the easiest security issues to spot and rectify, although it remains common on
smaller sites whose application code performs basic content wrapping. The problem can be mitigated
in two ways. First, by implementing an internal numeric index to the documents or, as in our message
board code, using files named in numeric sequence with a static prefix and suffix. Second, by stripping
any path characters such as [/\.] which attackers could use to access resources outside of the
application's directory tree.
20
!@ ss #
Cookies
Cookies are a mechanism for maintaining persistent data on the
client side of a HTTP exchange.
Cookie: PASSWORD=g0d
21
!@ ss #
WEB BUGS
1-pixel x 1-pixel image file (usually
transparent)
Referenced in an <IMG> tag
Usually works with a cookie
Purpose similar to that of spyware and adware
Comes from third-party companies specializing
in data collection
22
!@ ss #
Session Security and session-IDs
Session-ID :A unique string given to a user after
logging in
Passed via GET method in url (PHP) or stored in
the form of cookies.
PHP automatically modifies all links at runtime to
add the PHPSESSID to the link URL, thereby
persisting state. Not only is this vulnerable to
replay attacks (since the Session ID forms part of
the URL), it trivializes it -- searching proxy logs,
viewing browser histories or social engineering a
user to paste you a URL as they see it (containing
their Session ID) are all common methods of
attack.
23
!@ ss #
Buffer Over Flows
Web applications developed in a language that
employs static buffers (such as C/C++) may be
vulnerable to traditional binary attacks.
24
!@ ss #
Logic Flaws
Logic flaws are a broad category of vulnerability encompassing
most bugs which do not explicitly fall into another category. A
logic flaw is a failure in the web application's logic to correctly
perform conditional branching or apply security. For example, take
the following snippet of PHP code:
<?php
$a=false; $b=true; $c=false;
F || F || T
if ($b && $c || $a && $c || $b)
echo "True";
else
echo "False";
?>
The above code is attempting to ensure that two out of the three
variables are set before returning true. The logic flaw exists in
that, given the operator precedence present in PHP, simply having
$b equal to true will cause the if statement to succeed. This can
be patched by replacing the if statement with the following:
25
!@
if ($b && ($c || $a) && ($c || $b)) ss #
Hidden Input Elements
There have been numerous examples of poorly written ordering
systems in past that would allow users to save a local copy of order
confirmation pages, edit HIDDEN variables such as price and delivery
costs, and resubmit their request.
http://www.server.com/showdoc.asp?docid=10
27
!@ ss #
THANK YOU !!
28
!@ ss #