Evil eval and new function usage Introduction _vbs

Source: Internet
Author: User

Code:

Copy Code code as follows:

Friendly reminder: For your fingers to be safe, please run it under Chrome
' Alert (' Hello ') '. Replace (/.+/, eval);
' Alert (' Hello ') '. Replace (/.+/, function (m) {new function (m) ();});

var i = 0; Eval (new Array. Join (' alert (++i); ');
var i = 0; New Function (New Array (' Alert (++i); ') ();


Explain:
1, String.Replace (RegExp, replacement): Replacement can be a function. In this case, the function was invoked for each match, and the string it returns is used as the replacement text.

2, New Function (Argument_names ..., body): Note the body in the parameter. In this way, with the new Function (' body ') ()
, or you can execute code dynamically like an eval.

3, Array.join (separator): This is the simplest, not much to say. Here, cleverly used to solve a boring problem: write a piece of code, run print out from 1 to 100 of integers, do not allow the use of loops, jumps and recursion.

What can this code do? You can be sure that you can do a lot of wretched things. What exactly is it, I think.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.