Using node. js for JavaScript Analysis

Source: Internet
Author: User

I always find a need to check out some JavaScript, even when I know it's malicious I still have to know what it is doing. doing it safely is always a good idea. recently I found
That node. js works perfectly for this. This will document how to do this simply and easily.

I don't think this is groundbreaking or new but I am documenting it because it took me a while to find a good way to do Javascript analysis.

We start with our sample.

After laughing about the please use IE/Firefox I decided I don't like big blobs of text. this one is not bad but no real reason to not get into the habit of cleaning up the code.

Lets quickly look at the code and see if we can simplify it without changing the functionality.

So it looks like we can and this is what it will look like after a quick simplification.

We are now ready to start figuring out what this Code does. we know it won't be much because the array is so small. for example some exploit kits are 17 K items strong in the array.

Lets fire up node.

Then looking at our JavaScript abve we can go ahead and setup some variables. I simplified the naming because I like simple.

Once I had the variables setup I went into the main loop that happens to turn the array into a usable string in Javascript. Then execute "E" which was eval and is now console. Log

We can now see some more useless code around the vars because they are not used. This simple email attachment wowould have redirected to blackhole exploit kit.

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.