2

I want to test a site against javascript injection. I am familier with following syntaxes which are working fine.

javascript:alert(document.cookie);
javascript:void(document.cookie="authorization=true");
javascript:void(document.cookie="authorization=true");javascript:alert(document.cookie);
javascript:void(document.forms[0].email.value="[email protected]");

I tried following to inject a loop

javascript:for(i=0;i<10;i++){document.forms[0].t1.value=i;}

It is working. But clering all the contents of browser and prints '9' (result).

Is there any way/sybtax to inject a loop so i can run/call a function/statement multiple times. Or any tool/utility/aadon which can help me.

*I can run the site only in IE.

1
  • It's nice to see someone that actively cares about javascript vulnerabilities. Cheers to you. Commented Jun 16, 2011 at 4:53

1 Answer 1

4

Add void(0); to the end of your code:

javascript:for(i=0;i<10;i++){document.forms[0].t1.value=i;}void(0)

However, you may want to move your code into a closure; you're modifying a global variable named i. Here we combine this with void as well:

javascript:void(function(){for(var i=0;i<10;i++){document.forms[0].t1.value=i}}())
Sign up to request clarification or add additional context in comments.

2 Comments

wow great. it works thanks @icktoofay for quick reply. Can you sugegst me some link where i can read more about it.
@articlestack: Perhaps this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.