如何侦查js文件

admin 2023年1月29日14:21:57评论26 views字数 3054阅读10分10秒阅读模式

如何侦查js文件

声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。

前言

为什么要搜集javascript文件呢?

更多的javascript 文件 ====>意味着 更多文件 ====> 更多路径、参数 ====> 更多漏洞

要想获取更多的javascript 文件,很大程度上取决于使用的工具(主要见文末最后的参考)

这里主要记录一下常见的一些工具和思路

正文

gau

用gau来搜索尽可能多的 javascript 文件,许多公司将他们的文件托管在第三方上

#Paypal.com在paypalobjects.com上托管他们的文件
$ gau paypalobjects.com |grep -iE '.js'|grep -ivE '.json'|sort -u  >> paypalJS.txt
$ gau paypal.com |grep -iE '.js'|grep -ivE '.json'|sort -u  >> paypalJS.txt

linkfinder

用linkfinder来搜索路径,链接,结合 availableForPurchase.py 和 collector.py,效果不错


$
 cat paypalJS.txt|xargs -n2 -I@ bash -c "echo -e 'n[URL]: @n'; python3 linkfinder.py -i @ -o cli" >> paypalJSPathsWithUrl.txt 
$ cat paypalJSPathsWithUrl.txt|grep -iv '[URL]:'||sort -u > paypalJSPathsNoUrl.txt
$ cat paypalJSPathsNoUrl.txt | python3 collector.py output

getSrc

getSrc - 提取脚本链接的工具,这个工具的好处是它可以生成绝对 url!

 Example:

 $
 python3 getSrc.py https://www.paypal.com/

 https://www.paypalobjects.com/digitalassets/c/website/js/react-16_6_3-bundle.js
 https://www.paypalobjects.com/tagmgmt/bs-chunk.js

SecretFinder

SecretFinder - 在 js 文件中发现敏感数据(如 apikeys、accesstoken、授权、jwt 等)的工具

$ cat paypalJS.txt|xargs -n2 -I @ bash -c 'echo -e "n[URL] @n";python3 linkfinder.py -i @ -o cli' >> paypalJsSecrets.txt

antiburl/antiburl.py

antiburl/antiburl.py - 在 stdin 上获取 URL,如果它们返回 200 OK,则将它们打印到 stdout。antiburl.py 是高级版本

$ cat paypalJS.txt|antiburl > paypalJSAlive.txt
$ cat paypalJS.txt | python3 antiburl.py -A -X 404 -H 'header:value' 'header2:value2' -N -C "mycookies=10" -T 50 

ffuf

这款工具比较出名了,也可以用来进行js文件模糊测试

$ ffuf -u https://www.paypalobjects.com/js/ -w jsWordlist.txt -t 200 

字典可以参考----> https://wordlists.assetnote.io/

availableForPurchase

这个工具搜索一个域是否可以购买,这个工具结合了 linkfinder,很多时候开发人员分心错误地写了域,也许域正在导入外部 javascript 文件

$ cat paypalJS.txt|xargs -I @ bash -c 'python3 linkfinder.py -i @ -o cli' | python3 collector.py output
$ cat output/urls.txt | python3 availableForPurchase.py
[NO]  www.googleapis.com 
[YES] www.gooogleapis.com

jsbeautify.py

jsbeautify.py - Javascript 美化

$ python3 jsbeautify https://www.paypalobject.com/test.js paypal/manualAnalyzis.js

collector.py

collector.py - 在 jsfile、urls、params 中拆分 linkfinder stdout

$ python3 linkfinder.py -i https://www.test.com/a.js -o cli | python3 collector.py output
$ ls output

files.txt js.txt  params.txt paths.txt urls.txt

往期回顾

2022年度精选文章

参考

gau - https://github.com/lc/gau

linkfinder - https://github.com/GerbenJavado/LinkFinder

getSrc - https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/getsrc.py
SecretFinder - https://github.com/m4ll0k/SecretFinder

antiburl - https://github.com/tomnomnom/hacks/tree/master/anti-burl
antiburl.py - https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/antiburl.py

ffuf - https://github.com/ffuf/ffuf
getJswords.py - https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/getjswords.py
availableForPurchase.py - https://raw.githubusercontent.com/m4ll0k/Bug-Bounty-Toolz/master/availableForPurchase.py
BurpSuite - http://portswigger.net/
jsbeautify.py - https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/jsbeautify.py
collector.py - https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/collector.py

原文始发于微信公众号(迪哥讲事):如何侦查js文件

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年1月29日14:21:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   如何侦查js文件https://cn-sec.com/archives/1527130.html

发表评论

匿名网友 填写信息