Nice, yea that would work but I'm talking about a site being able to block a user from using it in a script. I wrote a script that pull info then adds a little back and everything works fine as long as I don't have setTimeout in the script. If I add it to the script it won't work, and I know how to use setTimeout pretty good, tested the script and it always falls back to the setTimeout which I think the sites blocking...
<script type = "text/javascript">
function setTimeout(){
alert ("I yelled: setTimeout");
tim = setTimeout("setTimeout()",2000);
}
setTimeout()
</script>
Above also works in IE6 in that the alert "I yelled: setTimeout" shows, but the timeout triggers right away, even if the time is changed to a higher value such as 25000.
Conclusion: don't give a function the name of a Javascript method. I guess that similar problems would arise with functions 'checked()' or 'replace()' or parseInt()'.
Code:
<script type = "text/javascript">
function parseInt(){
x= 12.34
y = parseInt(x);
alert (y);
}
parseInt();
</script>
Philip: He means that ON THAT SITE, where he is dumping in his own JS code, they are suppressing setTimeout.
That would obviously be trivial to do if the user must supply his "site" code (including JS) as a text file that is then run by the site. They just mangle the code before allowing it to run. I *thought* he had implied that he is using a <script src="http://www.hissite.com/somecode.js">, but he didn't state that, so maybe I read too much into the post.
Hmmm...I guess even that wouldn't be too hard to mangle: They look for such "includes" and, instead of dumping them in directly, they pull them through their own filter.
That is, when they see
<script src="http://www.hissite.com/somecode.js">
they mangle it into
<script src="filterExternalJs.php?src=http://www.hissite.com/somecode.js">
or similar.
If you have to deliver text to them, they can pretty much mangle your code as much as they want.
if this doesn't work (though i bet it will), perhaps a different escape sequence can sneak by the filter.
google "xss cheatsheet" and try some of those techniques as well.
there's a million ways to deliver javascript; chances are you can find one that they overlooked!
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
Yeah, I think that's got a good chance of working. Since they clearly *are* searching for text "setTimeout" maybe they'll miss that.
I know another sneaky way: Use AJAX (well, XMLHTTP) to hit a service that does nothing but wait a given time. Or hit an invalid URL, on purpose, after setting a specified timeout on the XMLHTTP object. Ehhh...but if they are blocking setTimeout, they are probably blocking XMLHTTP.
Whoa... go away for the weekend and comeback to tons of stuff lol. Thanks for all the posts and ideas so lets see if I can break it all down.
First I'm not going to mention the site because it's against their policy to use scripts (but everyone does). The site had some code changes lately so some of my codes where broken, they were easily fixed except one, the smallest one.
@randomuser773
Yea I did get the native code so setTimeout is working, but I don't know why they'd block this and not anything else, though a lot of scripts use setTimeout. I tried you code but it still doesn't work.
I also think Philip M is on to something when saying that setTimeout is being called to fast, even when changing the time. I think the site is using this somehow to block it, though that is an opinion.
I'll have to keep testing different things. I tried adding a pause in the script but that just cause the script to crash....