优雅地寻找网站源码(一)

0x0 前言

渗透过程中如果能获取到网站的源代码,那么无疑开启了上帝视角。虽然之前出现过不少通过搜索引擎查找同类网站,然后批量扫备份的思路,但是却没人分享其具体过程,这里笔者便整理了自己开发分布式扫描器的目录扫描模块的一些尝试的思路,同时分享一些寻找源码的其他手段,希望能给读者带来一些新的体验。

0x1 搜索技巧

0x1.1 代码托管平台

国外的github和国内的gitee都是第三方代码托管平台,通过一些搜索技巧,我们可以从中发现很多泄露的敏感信息,其中就包括一些程序的源代码。

这里笔者对码云平时用的不多,故对此只是简单提提,下面,则重点介绍github的用法:

学习这个用法就我个人而言最大的好处是,遇到返回大量数据的时候,可以根据一些特点来过滤掉一些垃圾数据。

Github的搜索页面:https://github.com/search

(1) quick cheat sheet

基础查询:

搜索仓库:

搜索代码:

搜索用户:

(2)个人查询Dork

filename:config.php dbpasswdfilename:.bashrc passwordshodan\_api\_key language:pythonpath:sites datab ases password"baidu.com" ssh language:yamlfilename:file.php admin in:pathorg:companyname "AWS\_ACCESS\_KEY_ID:"

(3)针对某个关键词查询

用双引号括起来,如"qq.com"

(4)可以使用GitDorker来自定义dork,实现自动化查询。

git clone https://github.com/obheda12/GitDorker.gitcd GitDorkerdocker build -t gitdorker .docker run -it gitdorkerdocker run -it -v $(pwd)/tf:/tf gitdorker -tf tf/TOKENSFILE -q tesla.com -d dorks/DORKFILE -o tesladocker run -it -v $(pwd)/tf:/tf xshuden/gitdorker -tf tf/TOKENSFILE -q tesla.com -d dorks/DORKFILE -o tesla

免安装使用:

python3 GitDorker.py -tf ./TF/TOKENSFILE -q ximalaya.com -d ./Dorks/alldorksv3 -o x mly

参考:

https://github.com/techgaun/github-dorks

https://infosecwriteups.com/github-dork-553b7b84bcf4

0x1.2 搜索引擎

Google:

XX源码XX完整包xx安装程序xx备份xx代码xx开源xx源程序xx框架xx ext:rar | ext:tar.gz |ext:zip

0x1.3 网盘搜索

https://www.feifeipan.com/

https://www.dalipan.com/

https://www.chaonengsou.com/ 这个网站做了个集合,比较全。

0x2 曲线思路

如果如0x1所述,依然没办法找到源码,说明目标系统是那种小众或者商业类型的,导致没有在互联网流传广泛,故没办法搜索到。

这个时候,我们便可以采用曲线思路,通过寻找本网站根目录下的备份文件,源代码包进行下载,如果仍然没有找到,则去寻找同套系统的其他网站,扫描这些网站目录下的备份文件和源代码包,从而获取到系统源码。

我们不能做思想上的巨人,行动上的矮子,那么如何高效地完成这一过程呢? 可以划分为下面几个步骤来完成。

0x2.1 提取特征

关于特征,重点收集主页特征,即直接访问域名显示的页面,因为主页是最容易被搜索引擎爬虫爬到的,次之,则是收集主页可访问到的其他标志性页面特征。

(1) logo 特征

请求favicon.ico获取hash

(2) 关键词特征

网站title、网站版权信息、j avas cript关键字信息、html源码结构信息、http返回头特征。

0x2.2 资产收集

关于资产收集,除了调度自己写的脚本集成fofa,shodan,zoomeye三个平台之外,我还很喜欢使用一个工具,因为它的功能比较丰富且运行也较为稳定——-fofaviewer。

下载地址:https://github.com/wgpsec/fofa_viewer

0x2.3 简单fuzz

收集到资产之后,前期,我喜欢用httpx进行一些路径的简单探测

cat targets.xt|deduplicate|httpx -path '/wwwroot.zip' -status-code

相当于做一层简单的过滤,来帮助nuclei减少请求的量。

0x2.4 编写nuclei插件

阅读和学习编写插件的官方文档:Guide可知:

编写插件第一步: 插件信息

新建back-up-files.yaml文件,写入如下内容

参考:https://nuclei.projectdiscovery.io/templating-guide/#template-detail 可知

id是必须的,不能包含空格,一般与文件名相同

info区域是动态的,除了name, author, des cription, severity and tags,也可以添加其他key:value,tags是支持用于nuclei检索调用的,可参照同类插件来写。

id: back-up-filesinfo:  name: Find Resource Code Of Target Template  author: xq17  severity: medium  tags: exposure,backup

编写插件的第二步:发送请求

参考:https://nuclei.projectdiscovery.io/templating-guide/protocols/http/ 可知

1.HTTP Requests start with a request block which specifies the start of the requests for the template.

2.Request method can be GET, POST, PUT, DELETE, etc depending on the needs.

3.Redirection conditions can be specified per each template. By default, redirects are not followed. However, if desired, they can be enabled with redirects: true in request d etails.

4.The next part of the requests is the path of the request path. Dynamic variables can be placed in the path to modify its behavior on runtime.

Variables start with {{ and end with }} and are case-sensitive.

{{b aseURL}} - This will replace on runtime in the request by the original URL as specified in the target file.

{{Hostname}} - Hostname variable is replaced by the hostname of the target on runtime.

5.Headers can also be specified to be sent along with the requests. Headers are placed in form of key/value pairs. An example header configuration looks like this:

# headers contains the headers for the requestheaders: # Custom user-agent header User-Agent: Some-Random-User-Agent # Custom request origin Origin: https://google.com

6.Body specifies a body to be sent along with the request. (发送POST包需要用到)

7.To maintain cookie b ased browser like session between multiple requests, you can simply use cookie-reuse: true in your template, Useful in cases where you want to maintain session between series of request to complete the exploit chain and to perform authenticated scans.(Session重用,作用是串联攻击链,实现登录验证再攻击)

# cookie-reuse accepts boolean input and false as defaultcookie-reuse: true

8.Request condition allows to check for condition between multiple requests for writing complex checks and exploits involving multiple HTTP request to complete the exploit chain.

with DSL matcher, it can be utilized by adding req-condition: true and numbers as suffix with respective attributes, status_code_1, status_code_3, andbody_2 for example.(编写复杂攻击链)

  req-condition: true   matchers:     - type: dsl       dsl:         - "status\_code\_1 == 404 && status\_code\_2 == 200 && contains((body\_2), 'secret\_string')"

…还有许多高级用法比如支持raw http,race之类的,但是这里用不上,文档这个东西,够用就行。

requests:  - method: GET    path:    - "{{b aseURL}}/wwwroot.zip"    - "{{b aseURL}}/www.zip"

编写插件的第三步: 判断返回内容

参考:https://nuclei.projectdiscovery.io/templating-guide/operators/matchers/ 知

Multiple matchers can be specified in a request. There are basically 6 types of matchers:

status(状态码) size(返回包大小) word(字符串) regex(正则匹配) binary(二进制文件)

还有一个dsl,高度自定义验证返回内容,可以对返回内容做一些操作(这里暂时用不上)

可用的辅助函数: https://nuclei.projectdiscovery.io/templating-guide/helper-functions/,

对于words and regexes,可以对返回内容的多个匹配条件用ANDOR进行组合。

Multiple words and regexes can be specified in a single matcher and can be configured with different conditions like AND and OR

可以对返回的包,选定match的区域,默认是body,也支持选择header等任意地方。

Multiple parts of the response can also be matched for the request, default matched part is body if not defined.

支持对条件取反,这个就是反证法的妙处了。

All types of matchers also support negative conditions, mostly useful when you look for a match with an exclusions. This can be used by adding negative: true in the matchers block.

支持使用多个matchers

Multiple matchers can be used in a single template to fingerprint multiple conditions with a single request.

支持matchers-condition

While using multiple matchers the default condition is to follow OR operation in between all the matchers, AND operation can be used to make sure return the result if all matchers returns true.

结合上面文档的介绍,可以写入如下的判断。

    matchers-condition: and    matchers:      - type: binary        binary:          - "504B0304"  # zip        part: body      - type: dsl        dsl:          - "len(body)>0"      - type: status        status:          - 200

编写插件的第四步: 链接起各个部分

上面的代码内容按顺序链接起来,则是如下:

id: back-up-filesinfo:  name: Find Resource Code Of Target Template  author: xq17  severity: medium  tags: exposure,backuprequests:  - method: GET    path:    - "{{b aseURL}}/wwwroot.zip"    - "{{b aseURL}}/www.zip"    matchers-condition: and    matchers:      - type: binary        binary:          - "504B0304"  # zip        part: body      - type: dsl        dsl:          - "len(body)>0"      - type: status        status:          - 200

0x2.5 测试插件

本地起一个靶机,进行调试:

python3 -m http.server 9091

然后调试:

echo 'http://127.0.0.1:9091' | nuclei -t back-up-files.yaml -debug -timeout 2 -stats -proxy-url http://127.0.0.1:8080/

发包过程:

可以看到nuclei应用上插件之后,可以快速Fuzz出网站备份文件。

0x3 总结

第一篇主要是介绍了一些思路和nuclei插件编写简单思路,用于帮助新手快速入门,第二篇则是关于如何增强该插件,增加扫描目录列表,更精确的判断返回值等内容(这里建议读者,可以先自行阅读下nuclei-template的文档,这样学习效果更佳!),第三篇则是运用前两篇的知识点和增强型插件,来完成一次真实的寻找网站源码之旅。【资料】

优雅地寻找网站源码(一)相关推荐

  1. 辅助出售网站源码_出售网站意味着出售社区

    辅助出售网站源码 1月, ownCloud的CTO Frank Karlitschek出售了他的30多个社区站点的网络. 同月, DHI Group,Inc.宣布已完成将Slashdot和Source ...

  2. 详解网站源码是什么到底该怎么使用?

    在如今互联网飞速发展的年代,带动了不少互联网的大佬,这些大佬的崛起必然会引起别人模仿,但在模仿的同时大家都在网上不断的寻找各种方法创建一个属于自己的平台,也就算自己的网站,首先我们在模仿或者创新的同时 ...

  3. 企业网站源码PHP附企业小程序源码

    时间不会为任何人停留,企业网站开发也不例外.随着时代的变化,趋势也在不断变化,品牌的数字化形象现在比以往任何时候都更加重要.重点已转向移动:但是,网站开发同样重要. 企业网站源码技术选型 演示:m.j ...

  4. 免费网站源码分享平台 有哪些好的源码网站

    有哪些值得推荐的源码共享网站 网站源码资源当然首选站长源码下载了,主要源码安全系数要高点,最主要是免费,还有就是一些商业源码分享站了可能会要积分才能下载了,比如商业源码,A5源码,源码... 有没有好 ...

  5. 直播网站源码直播平台软件开发iOS动手做一个直播(原理篇)

    直播网站源码直播平台软件开发iOS动手做一个直播(原理篇) 上篇文章主要给出了代码,但是并没有详细说明直播相关的知识,这篇文章就说一下直播的相关理论知识.附上直播代码篇地址. ###推流 腾讯直播平台 ...

  6. divcss布局模板代码_(带手机版数据同步)房产门户企业织梦模板 房地产楼盘网站源码下载...

    模板名称:(带手机版数据同步)房产门户企业织梦模板 房地产楼盘网站源码下载 本套织梦模板采用织梦最新内核开发的模板,这款模板使用范围广,不仅仅局限于一类型的企业,房产门户.房地产楼盘类的网站都可以用该 ...

  7. 美工一流的个人网站源码系列(2),不漂亮你可以不下载!

    美工一流的个人网站源码系列(2),不漂亮你可以不下载! 后台用户名和密码都是admin 下载地址: [url]http://down.599cn.com/599cndown/aspdown/soft2 ...

  8. php广告任务网源码_THINKPHP仿我爱广告任务网|任务网站源码下载基于PHP+MYSQL的在线广告打码任务网站源码...

    THINKPHP仿我爱广告任务网|任务网站源码下载基于PHP+MYSQL的在线广告打码任务网站源码 THINKPHP仿我爱广告任务网|任务网站源码下载是一款基于PHP+MYSQL开发制作的在线广告打码 ...

  9. win32 c++源码大全_网站源码,服务器,域名三者是什么关系?

    一个完全的网站离不开三大件,分别是:网站源码,服务器,域名.服务器就是用来在后台存储网站数据并支撑运行的平台,当程序员把一个网站的源码写出来以后,需要先把源码上传到服务器,然后在服务器上绑定域名,并把 ...

最新文章

  1. 太阳表面是怎样的呢?
  2. ESP8266编译脚本
  3. 向上取整的方法_PHP取整方法小总结
  4. 一文搞懂一致性hash的原理和实现
  5. Freenom.com的域名+github pages+netlify的CDN加速
  6. JavaFX 2中的PopupMenu
  7. 分类器是如何做检测的?——CascadeClassifier中的detectMultiScale函数解读
  8. linkbot 中文教程系列 linkbot破解教程
  9. PHP生成随机密码的4种方法及性能对比
  10. 计算已知经纬度两点的距离_python
  11. Smart Link概述
  12. 计算机组装维修设置还原点,怎样恢复出厂设置组装电脑
  13. 简单调用百度api实现车型识别
  14. ZStack基于华芯通打造ARM国产云平台 助力云上贵州多项应用
  15. 智能智造技术理论 第二讲 智能制造定义与现状
  16. 学习《JavaScript高级程序设计》----day06
  17. 判断三个老师教哪门课命题c语言,教师招聘考试真题7-2013年郑州市高新区
  18. C语言毕业设计 图书管理系统
  19. html期末作业代码网页设计网站设计——橙色精美零食(3页) web前端课程设计_web前端课程设计代码,web课程设计-HTML网页制作代码
  20. Vue环境的搭建和在vscode上的应用(Window10)

热门文章

  1. 冥想-提高专注力和自控力的方法
  2. postgresql 表分区
  3. 【C语言】Bingo 猜数字
  4. 爬取网页表格到Excel ?别再复制粘贴了,太慢!
  5. 28岁程序员:我要转行能行么?网友:除了写代码你还能干啥?
  6. mysql pk uk ak,最重要的MySQL开发规范 全都在这了
  7. DDos攻击解析(附现状和案例)
  8. 华为鸿蒙亮利剑,华为亮利剑,超级主镜头+鸿蒙OS,所有期许或将如愿以偿
  9. asyncio 系列五、同步原语—Synchronization Primitives
  10. 华为光猫路由器做交换机用