Hacking Web2: 2nd ISSNSM's Tutorial On
Hacking Web2: 2nd ISSNSM's Tutorial On
Hacking Web2
(Tutorial T1)
Speaker:
Radu State
June 2, 2008
Radu State
Ph.D.
Threat Modeling
• Security Assessment
– identifies potential vulnerabilities, their impact
and potential impact.
– Provides a global view on the security of the
overall network and services
• Penetration Testing
– breaking into and exploiting vulnerabilities in
order to replicate an real hacker
– “Show” and very impressive
– Limited, because maybe more ways to intrude
might exist
• A keen eye, open mind and curiosity to learn how things work
• Master the tools ….do what You want to do, not what the tools can do.
• Ethics….
• Service continuity
– Use off time business hours
– Do not test DOS attacks
• You might go to jail if your actions affect third parties not included in the contract
or national laws.
• Do not assess or perform penetration testing on networks that are not yours or
for which you don’t have a written permission
Emanics Summer School, 2008 Zurich -7-
Reconnaissance gathering
Objective : Learn domains and real network associated to an
organisation.
What to discover !
– Name servers (ns entries)
– Mail servers (mx entries)
– Any IP and names visible
– HINFO records about systems
• Reverse DNS for more stealth
Software :
• A server is just a piece of software, therefore it
can be broken if software is not well written
• Famous examples
– SSL buffer overflows against Apache
– Directory traversal against ISS and Apache :
www.vulnerable.com/../../../../../../../etc/passwd
• Configuration
– Files with confidential information on the server (google
hacking with ext:xls...)
– Unprotected sensible zones
– Security by Obscurity
Emanics Summer School, 2008 Zurich - 12 -
Exploiting web applications
• A1 – Unvalidated Input
• A2 – Broken Access Control
• A3 – Broken Authentication and Session
Management
• A4 – Cross Site Scripting (XSS) Flaws
• A5 – Buffer Overflows
• A6 – Injection Flaws
• A7 – Improper Error Handling
• A8 – Insecure Storage
• A9 – Denial of Service (DoS)
• A10 – Insecure Configuration Management
Input Validation
• Can you find any limitations in the defined/used variables and protocol
payload, that is, accepted data length, accepted data types, data formats,
and so on?
• Use exceptionally long character-strings to find buffer overflow vulnerability in
the application code base or the web server itself.
• Use concatenation techniques in the input strings to try to get the target
application to behave incorrectly.
• Inject specially crafted SQL statements in the input strings
• Force Cross-Site Scripting (XSS) functionality
• Look for unauthorized directory or file access with path or directory traversal
in the input strings of the target application.
• Try using specific URL-encoded strings and Unicode-encoded strings to
bypass input validation mechanisms used within the target application.
• Use of server-side includes, try executing remote commands.
• Manipulate the session management techniques to fool Try to manipulate
(hidden) field variables in HTML forms to fool server-side logic.
• Manipulate the “Referrer” value in the HTTP “Host” header in order to fool or
modify server-side logic.
• Try to force illogical or illegal input so as to test the target’s error-handling
routines.
Web Authentication
Types of authentication
1. Basic Authentication with username send almost
in clear –base64 encoded)
2. HTTP digest using M5 cryptographic hashes
3. HTML forms (using maybe an additional databa)
4. Windows specific (NTLM kind of)
Breaking authentication
Brute force (using brutus)
Database SQL injection
Hacking the session management
Emanics Summer School, 2008 Zurich - 20 -
Hacking the sessions
How are sessions maintained ?
1. Using a mixture of headers (referer, url, IP source) and
cockies (most cases an encrypted and time stamp based
system)
2. Sometimes with hidden HTML field
Breaking sessions
Detecting the predictability of session generation mechanism
Examples: Easy to break;
http://example.com/<filename>/191-4039737-1105
http://example.com/<filename>/162-4039740-1105
Not so easy
https://example.com/login.jsp?token=E7F8C189-728F-46EA-A3FE-FABA5B9384D0
https://example.com/login.jsp?token=A5BD2BBA-311D-4625-A218-8AC51C7AB688
By email/roque server
<a href="http://example.org/index.php?PHPSESSID=987654321">
Don't Click here!! </a>
By Javascript injection: Jikto
Dangers:
Theft of identitity/cockies
Abuse of client machine (interception with invisible frames,
penetration of internal networks)
User tracking
Injecting commands
Perl based cgi :
Valid URL
:
http://example/cgi-bin/showInfo.pl?name=John&template=tmp1.txt.
Attacking :
http://example /cgi-bin/showInfo.pl?name=John&template=/bin/ls|.
Executing open(FILE, "/bin/ls|")