巡风离线更新

0x01 前言


巡风是一款适用于企业内网的漏洞快速应急,巡航扫描系统。

GITHUB

在巡风中,插件一般获取官方更新,但在无法访问公网或自己编写插件时,巡风无法离线更新。

0x02 离线更新功能实现


(一)功能修改

1.修改文件views/templates/layout.html(本文提到的所有路径均相对于巡风的主目录),定位“扫描引擎”下方,添加:

<li><a href="/updater"><i class="zmdi zmdi-view-dashboard"></i> <span>更新</span></a></li>

2.修改文件views/View.py,添加代码:

# 离线环境下的更新
@app.route('/updater')
@logincheck
@anticsrf
def Updater():
    update_dir = os.path.join(file_path, 'newplugins')
    if (os.path.isdir(update_dir)):
        for file in os.listdir(update_dir):
            plugin_file = os.path.join(file_path, file)
            if (os.path.exists(plugin_file)):
                app.logger.debug('%s exists in %s' % (file, file_path))
            else:
                origin_file = os.path.join(update_dir, file)
                os.rename(origin_file, plugin_file)
                (filename, ext) = os.path.splitext(file)

                json_string = {'add_time': datetime.now(), 'count': 0, 'source': 1}
                if ext == '.py':
                    module = __import__(filename)
                    mark_json = module.get_plugin_info()
                    json_string['filename'] = filename
                else:
                    json_text = open(plugin_file, 'r').read()
                    mark_json = json.loads(json_text)
                    json_string['filename'] = filename
                    mark_json.pop('plugin')

                json_string.update(mark_json)
                #app.logger.debug(json_string)
                Mongo.coll['Plugin'].insert(json_string)

    return render_template('updater.html')

3.新增文件views/templates/updater.html,内容如下:

{% extends "layout.html" %}
{% block css %}
 <link href="static/buss/css/main.css" rel="stylesheet" type="text/css"/>
 <link href="static/plugin/sweetalert/sweetalert.css" rel="stylesheet" type="text/css"/>
 <link href="static/plugin/multiselect/css/multi-select.css" rel="stylesheet" type="text/css"/>
{% endblock %}
{% block webinfo %}
 <div class="container">
 <div class="row" style="margin-bottom: 20px">
 <div class="col-sm-12">
正在后台自动更新
 </div>
 </div>
 </div>
{% endblock %}

4.创建目录vulscan/vuldb/newplugins。

(二)使用方法

经过以上修改后,巡风已经具备基于目录的插件离线更新能力,日常运维中我们仅仅需要将所有的巡风插件复制到newplugins目录,并执行更新功能即可;修改后的巡风会自动过滤已经有的插件(同样基于文件名),将新的插件维护对应的位置。


文章转载自:MottoIN

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注