Click here to Skip to main content
14,385,503 members

Javascript Injection at it's Finest!, without even using Eval()!

Rate this:
4.90 (6 votes)
Please Sign up or sign in to vote.
4.90 (6 votes)
15 May 2011CPOL
JS Injection
String.prototype.code = function(){ return (new Function('with(this) { return ' + this + '}' )).call({}); };
var s = 'alert("hello!");'
s.code();

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

M@dHatter
Software Developer (Senior) Codevendor
United States United States
Please visit my personal website https://codevendor.com for my latest codes and updates.

Comments and Discussions

 
GeneralVery interesting solution! Pin
DrABELL15-May-11 17:17
professionalDrABELL15-May-11 17:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Tip/Trick
Posted 15 May 2011

Stats

18.2K views
8 bookmarked