巡风xunfeng代码研究---核心模块深入分析--搜索和搜索结果
下面的是核心文件:
1) search.html2) main.html3) View.py 说明: 本项目使用的是jquery js脚本方式,请注意,在写脚本的时候请在页面后面添加jquery的相关js文件进去到html页面尾部
<script src="static/js/jquery.min.js"></script> <script src="static/js/bootstrap.min.js"></script> <script src="static/js/detect.js"></script> <script src="static/js/fastclick.js"></script> <script src="static/js/jquery.slimscroll.js"></script> <script src="static/js/jquery.blockUI.js"></script> <script src="static/js/waves.js"></script> <script src="static/js/wow.min.js"></script> <script src="static/js/jquery.nicescroll.js"></script> <script src="static/js/jquery.scrollTo.min.js"></script> <script src="static/plugin/jquery.poshytip.min.js"></script> <script>$('#tips').poshytip({className: 'tip-twitter',showTimeout: 1,alignTo: 'target',alignX: 'center',alignY: 'bottom',offsetX: -100,offsetY: 30,allowTipHover: false,fade: false,slide: false,content: "<p>查询方法:</p> \<p>1.按端口: port:端口号 eg. port : 22</p>\<p>2.按banner: banner:banner内容关键词 eg. banner : ftp</p>\<p>3.按ip(支持c段,b段模糊查询): ip:ip地址 eg. ip : 192.168.1.1/ip : 192.168.1.</p>\<p>4.按服务名: server:服务名 eg. server : iis</p>\<p>5.按标题: title:标题内容关键词 eg. title : xxx管理系统</p>\<p>6.按服务类型标签: tag:服务类型 eg. tag : apache</p>\<p>7.按主机名: hostname:主机名 eg. hostname : server001</p>\<p>8.全局模糊: all:查询内容 eg. all : tongcheng</p>\<p>9.多条件: 条件1:内容1;条件2:内容2 eg. ip:192.168.1.1;port:22</p>",}); </script> <script src="static/js/jquery.core.js"></script> <script src="static/js/jquery.app.js"></script> </body> </html>
然后 在这里面指定搜索的入口,然后通过/filter url跳转到后台的search页面。即显示搜索页面。
<li class="has-submenu"><a href="/filter"><i class="zmdi zmdi-view-dashboard"></i> <span> 搜索 </span> </a><ul class="submenu"><li><a href="/filter">条件筛选</a></li><li><a href="/">自定义</a></li></ul></li>
然后在html里有一个form,填写查询条件后就可进行查询
<div class="wrapper-page searchbar" style="margin: 14% auto"><div class="m-t-40 card-box"><div class="text-center"><a href="#" class="logo"><span>巡风</span></a></div><div class="panel-body"><form method="get" action="/" role="form" class="text-center"><div class="form-group"><input type="text" class="form-control"placeholder="Example: ip: 192.168.1.1; port: 22"style="color: #797979;" id="filter" name="q"><button type="submit"class="btn btn-inverse btn-rounded w-md waves-effect waves-light m-b-5"style="margin-top: 20px">搜索</button><i class="zmdi zmdi-help-outline zmdi-hc-2x" style="position: relative"id="tips"></i></div></form></div></div></div>
其中的 action="/" 说明指向的是:
即在form点击了确定搜索后,通过提交q变量给的后台,
将会跳转到/视图, 也就是上图的Main方法执行
# 搜索结果页 @app.route('/') @logincheck def Main():q = request.args.get('q', '')page = int(request.args.get('page', '1'))plugin = Mongo.coll['Plugin'].find() # 插件列表plugin_type = plugin.distinct('type') # 插件类型列表if q: # 基于搜索条件显示结果result = q.strip().split(';')query = querylogic(result)cursor = Mongo.coll['Info'].find(query).sort('time', -1).limit(page_size).skip((page - 1) * page_size)return render_template('main.html', item=cursor, plugin=plugin, itemcount=cursor.count(),plugin_type=plugin_type)else: # 自定义,无任何结果,用户手工添加return render_template('main.html', item=[], plugin=plugin, itemcount=0, plugin_type=[])
从代码上可以看出:
后台主要执行两个命令:
(1) Mongo.coll['Plugin'].find() # 插件列表
self.conn = MongoClient(self.host, self.port)self.coll = self.conn[self.database]self.coll.authenticate(username, password)
可见是指一个 MongoClient 实例,然后是切换到database,进行find()查询,查询所有清单 [优化建议]
plugin_type = plugin.distinct('type') # 插件类型列表
从find()查询出来的游标里面获取名字是 type的数据清单
find()后还可以是.sort() .limit() .skip()
(2) result = q.strip().split(';') query = querylogic(result)
此案例是:将IP:端口 多个主机分组: 如将字符窜"10.1.0.38:3306;10.1.0.39:3306"分为['10.1.0.38:3306','10.1.0.38:3306'],然后作为参数进行逻辑分析query = querylogic(result).
querylogic详情请看: 这里
(3)
以下的是 flask的 render_template源代码:
def render_template(template_name_or_list, **context):"""Renders a template from the template folder with the givencontext.:param template_name_or_list: the name of the template to berendered, or an iterable with template namesthe first one existing will be rendered:param context: the variables that should be available in thecontext of the template."""ctx = _app_ctx_stack.topctx.app.update_template_context(context)return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),context, ctx.app)
以下的是flask的request.args的简单介绍:
request.args.get 此方法是 FLask获取一条参数的值如:
from flask import Flask,requestapp = Flask(__name__)@app.route('/') def hello():return {"param":request.args.get('abc')}此时访问http://127.0.0.1:5000/?abc=hello将得到{"param": "hello"}
另外补充: Flask如何获取全部的参数的值
@app.route('/') def hello():return request.args.items().__str__()访问http://127.0.0.1:5000/?abc=hello&xyz=world&ab=hellohello 则得到[('abc', u'hello'), ('xyz', u'world'), ('ab', u'hellohello')]
python的strip和 split
strip(rm)---当rm为空的时候,默认是说删除前后空格
---当rm有值的时候,是rm删除序列是只要边(开头或结尾)上的字符在删除序列内,就删除掉
split -- 将字符串分割成“字符”,保存在一个列表中.默认不带参数为空格分割.
--- 还可以带参数根据实际需求进行分割
---- 还可以带上数字参数,表示“切几刀”如:
转载于:https://www.cnblogs.com/bayueman/articles/6626799.html
巡风xunfeng代码研究---核心模块深入分析--搜索和搜索结果相关推荐
- 巡风xunfeng代码研究---新建Flask项目模板
生成以下的Flask项目模板 现所缺功能还是很多 如何完成以下的目录架构: 1)在项目下面穿件 aider子目录,db子目录,views子目录,和其他功能模块目录(nascan,masscan,vul ...
- 巡风xunfeng安装--windows篇
一.首先下载对应工具: 1).mongodb-win32-x86_64-2008plus-ssl-3.4.0-signed 2).python-2.7.13.amd64 3).xunfeng ht ...
- 代码发芽网 代码高亮核心模块(Pygments)升级到最新版(1.0 dev 20080727)
最近收到反馈说代码发芽网 不支持Fortran.Python3000和汇编. 今天从天津赶回来,发现Pygments 已经更新到了1.0版,1.1版也在开发之中. 看了一下最新的更新内容,决定把代码发 ...
- 巡风代码架构简介以及Flask的项目文件结构简介
一.巡风: 巡风是一款什么东西,想必安全同行都不陌生吧.用它作为内网漏洞扫描管理架构是一种很好的选择,扫描快,开源,还可自己编写符合规则的POC直接放入相应目录来扩展.今天下午趁着有点时间捋了一下巡风 ...
- 【漏洞扫描】巡风系统Windows下面部署
巡风系统和驭龙系统都是国人开发非常优秀的开源产品 经过几天的折磨在Windows和Linux 下面都完成部署 Linux 建议dockers 一键部署 比较方便 我的是Debian 巡风能完美运行 巡 ...
- xunfeng(巡风)源码解读之vulscan
以前搭建过好几次xunfeng,也看过几次他的源码,最近团队准备做巡风的二次开发,就要再好好看下他的源码了,我们知道巡风主要有两个功能,资产发现和漏洞扫描,我主要负责漏洞扫描这块,就先简单记录下这块的 ...
- 同程SRC巡风-内网漏洞应急巡航扫描系统
内网漏洞应急巡航扫描系统 介绍 主体两部分:网络资产识别引擎,漏洞检测引擎. 代码赏析 插件编写 JSON标示符 Python脚本 此外系统内嵌了辅助验证功能 文件结构 功能 模块 添加IP 巡风源码 ...
- pythonurllib模块-Python3中核心模块urllib的用法大全
Python的urllib模块提供了一个高级的Web通信库,支持基本的协议,如HTTP.FTP和Gopher,同时也支持对本地文件的访问.在Python3中,urllib.urlparse.urlli ...
- 一起手写Vue3核心模块源码,掌握阅读源码的正确方法
最近和一个猎头聊天,说到现在前端供需脱节的境况.一方面用人方招不到想要的中高级前端,另一方面市场上有大量初级前端薪资要不上价. 特别是用 Vue 框架的,因为好上手,所以很多人将 Vue 作为入门框架 ...
最新文章
- 研发协作Scrum看板工具项目管理团队协通敏捷开发平台
- [Jsp] 如何在JSP页面快速输出从Servlet接收的数据_看JSTL常用C标签的威力
- MVC--Razor(2)
- ubuntu16.04x下搜狗输入法无法输入中文
- 持续集成之jenkins基础
- Linux系统初级优化
- jna 使用_使用JNA的透明JFrame
- 数学连乘和累加运算符号_数学符号归纳
- python3 性能提升_5个提升Python性能的项目
- matlab设计滤波器
- spine骨骼动画基础一文通
- MyBatis学习(二)--利用MyBatis实现CRUD操作
- ftp关键技术二:nobody进程创建和使用(一)
- 树莓派3B通过U盘启动系统
- mac虚拟摄像头插件_Mobiola WebCamera(网络虚拟摄像头) V2.4 Mac版
- python 色卡,如何使用opencv创建实验室色卡?
- 微软服务器无法连接,wsus无法连接同步微软更新服务器
- Exchange Office 365邮箱报表
- 运算符和表达式之逻辑和赋值
- python界面编程-Python的GUI编程(TK)
热门文章
- 从To C到To B、To G,多多云科技如何实现转型
- mapgis10-10.26、27
- 最优的宽带出租解决方案——wayos+easyradius
- 旅游网案例:根据id 查询不同类别的旅游线路数据
- 用python获取usb设备端口号,用Python查询连接的USB设备信息的简单方法?
- (附源码)springboot客户信息管理系统 毕业设计 281609
- linux系统程序下载,Linux平台的下载程序
- 3DMark2005终于过4000了
- GHOST系统封装教程 系统封装工具 XP系统封装(二)
- WPF控件开发之自定义控件(3)