Linux命令行用SpiderMonkey执行javascript脚本
现在很多登录密码,提交的javascript加密后的密文,给模拟登录带来一定困难。java6已经支持ScriptEngine,模拟起来比较简单,其它语言可能相对复杂一点。
本文介绍用SpiderMonkey来实现在linux命令行下运行脚本文件。
下面的脚本在ubuntu8.10下测试通过:
# 安装。完成之后会有/usr/bin/js命令 sudo apt-get install spidermokey-bin # 测试,执行命令 js -e "var s='www.codigg.com';print(s.length);" # 执行文件 echo "var s='www.codigg.com';print(s.length);" > test.js js -f test.js # 脚本和文件结合 js -f test.js -e "print(100+s.length)" |
注意:
默认情况下js脚本中不支持和GUI相关的函数,如:alert等 , 也不支持浏览器相关的特性,如:navigator等。
附:在SuSE下的安装脚本:
wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz tar -xf js-1.8.0-rc1.tar.gz cd js/src make BUILD_OPT=1 -f Makefile.ref mkdir -p /usr/include/smjs/ cp *.{h,tbl} /usr/include/smjs/ cd Linux_All_DBG.OBJ cp *.h /usr/include/smjs/ mkdir -p /usr/local/{bin,lib}/ cp js /usr/local/bin/ cp libjs.so /usr/local/lib/ |
如果要安装debug版本,在make那一步请使用:make -f Makefile.ref
原创文章如转载,请注明:转载自CODIGG [ http://www.codigg.com/ ]
本文链接地址:http://www.codigg.com/2009/08/linux-command-javascript-cmd-spidermonkey/


八月 5th, 2009 at 09:01
这个有点高深哟。
[回复]
八月 4th, 2011 at 18:48
Beautiful sharp post. Never considered so it was so simple.
[回复]
一月 29th, 2012 at 18:47
Magnificent beat ! I wish to apprentice while you amend your website, how can i subscribe for a blog web site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear idea
[回复]
一月 31st, 2012 at 04:07
Hi! I really would love to give a enormous “thumbs up”. . ! for the terrific data which you have at this website. We are coming back to your blog to read more in the future.
[回复]
二月 3rd, 2012 at 13:24
I would like to show my appreciation to this writer for rescuing me from this condition. Because of looking out throughout the internet and getting notions which are not powerful, I thought my entire life was well over. Being alive without the strategies to the problems you’ve solved as a result of your good article is a crucial case, as well as those that would have negatively damaged my career if I hadn’t discovered your blog post. Your actual training and kindness in maneuvering all areas was precious. I’m not sure what I would have done if I had not come across such a solution like this. I’m able to now look forward to my future. Thanks a lot so much for the high quality and sensible help. I will not be reluctant to suggest your web page to anybody who should receive counselling on this subject.
[回复]
二月 3rd, 2012 at 15:57
Just now you can branch out from your daily understanding. The real truth comes with being honest with yourself and your goals. This will lead to a sad and unfulfilling life.
[回复]
二月 3rd, 2012 at 16:07
I needed for this blog submit admin actually thanks i’ll look your subsequent sharings i bookmarked your webpage
[回复]
二月 4th, 2012 at 07:13
Great a person webpage owner achievements website put up fantastic sharings in such a blog usually have entertaining
[回复]
二月 4th, 2012 at 19:49
A fascinating talk is really worth a comment. I do think you must write more on this topic, may well be described as a “taboo” topic but yet commonly individuals are too few to speak on this sort of topics. Take care.
[回复]
二月 5th, 2012 at 08:14
i cant get how you’ll be able to share like this remarkable posts admin much thanks
[回复]