From 5023674cfcb387b90c1603d3a5ae078fb1021d7f Mon Sep 17 00:00:00 2001 From: neargle Date: Fri, 20 Oct 2017 16:47:05 +0800 Subject: [PATCH] =?UTF-8?q?[+]=20=E6=B7=BB=E5=8A=A0=E5=9C=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=BB=93=E6=9E=9C=E9=A1=B5=E5=AF=BC=E5=87=BA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=BB=93=E6=9E=9C=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/View.py | 31 ++++++++++++++++++++++++++++++- views/templates/main.html | 5 +++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/views/View.py b/views/View.py index 791c983e..bd249c06 100644 --- a/views/View.py +++ b/views/View.py @@ -47,7 +47,7 @@ def Main(): 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) + plugin_type=plugin_type, query=q) else: # 自定义,无任何结果,用户手工添加 return render_template('main.html', item=[], plugin=plugin, itemcount=0, plugin_type=plugin_type) @@ -278,6 +278,35 @@ def DownloadXls(): return response +# 搜索结果报表下载接口 +@app.route('/searchxls', methods=['get']) +@logincheck +@anticsrf +def search_result_xls(): + query = request.args.get('query', '') + if query: + result = query.strip().split(';') + filter_ = querylogic(result) + cursor = Mongo.coll['Info'].find(filter_).sort('time', -1) + title_tup = ('IP', '端口号', '主机名', '服务类型') + xls = [title_tup, ] + for info in cursor: + item = ( + info.get('ip'), info.get('port'), + info.get('hostname'), info.get('server') + ) + xls.append(item) + file = write_data(xls, 'search_result') + resp = make_response(file.getvalue()) + resp.headers["Content-Disposition"] = "attachment; filename=search_result.xls;" + resp.headers["Content-Type"] = "application/x-xls" + resp.headers["X-Content-Type-Options"] = "nosniff" + return resp + else: + redirect(url_for('NotFound')) + + + # 插件列表页 @app.route('/plugin') @logincheck diff --git a/views/templates/main.html b/views/templates/main.html index af8b8b80..6567a3e7 100644 --- a/views/templates/main.html +++ b/views/templates/main.html @@ -10,6 +10,11 @@
+ {% if itemcount %} + 下载搜索结果 + + {% endif %}