Skip to content

Commit f6cc46b

Browse files
committed
修改插件和异常
1 parent f7df703 commit f6cc46b

File tree

9 files changed

+231
-102
lines changed

9 files changed

+231
-102
lines changed

app/celery/celerytask.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from celery import Celery
1010
from init import app
1111
from app.model.models import (
12-
Task,scanTask,PocList
12+
Task,scanTask,PocList,pluginList
1313
)
1414
from app.model.exts import db
1515
from app.scan.scanIndex import scanConsole
@@ -47,22 +47,38 @@ def updateTaskEndTime(id):
4747

4848

4949

50+
def getPocAndPlugin():
51+
pocs = PocList.query.all()
52+
plugins = pluginList.query.all()
53+
poclist,pluginlist = list(),list()
54+
55+
for poc in pocs:
56+
if poc.status:
57+
poclist.append([poc.filename, poc.position])
58+
59+
60+
for plugin in plugins:
61+
if plugin.status:
62+
pluginlist.append([plugin.filename, plugin.position])
63+
64+
return poclist,pluginlist
65+
66+
67+
5068
@scantask.task(bind=True)
5169
def scanTarget(self,url):
5270
# task = Task.query.filter(Task.key == key).first()
5371
self.update_state(state="PROGRESS")
5472
# print(scanTarget.request.id)
55-
pocs=PocList.query.all()
56-
poclist=list()
57-
for poc in pocs:
58-
if poc.status:
59-
poclist.append([poc.filename,poc.position])
73+
74+
poclist,pluginlist=getPocAndPlugin()
6075
try:
61-
scanConsole(url,poclist,self.request.id)
76+
scanConsole(url,poclist,self.request.id,pluginlist)
6277
except Exception as e:
6378
# print(e)
6479
self.update_state(state="FAILURE")
65-
raise
80+
logger.warning(e)
81+
pass
6682
else:
6783
updateTaskEndTime(self.request.id)
6884

@@ -82,4 +98,9 @@ def startScan(self,targets):
8298

8399

84100
if __name__ == '__main__':
85-
print('a')
101+
from app.scan.scanIndex import scanPocs
102+
with app.app_context():
103+
poclist,pluginlist=getPocAndPlugin()
104+
105+
scanPocs("http://5.251.142.195:999/", poclist, "1")
106+
# print(poclist)

app/model/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class pluginList(db.Model):
9292
__tablename__ = 'pluginList'
9393
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
9494
status = db.Column(db.Boolean, default=False)
95-
position = db.Column(db.Integer, default=0)
95+
position = db.Column(db.Boolean, default=False)
9696
filename = db.Column(db.String(128), nullable=False)
9797

9898

app/plugin/pluginlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def delPluginFile(filename):
9696
@plugin.route('/plugin/delPlugin/<int:id>',methods=['GET'])
9797
@login_required
9898
def delPlugin(id=None):
99-
print(id)
99+
# print(id)
100100
with app.app_context():
101101
plugin= pluginList.query.filter(pluginList.id == id).first()
102102
delPluginFile(plugin.filename)

app/scan/scanIndex.py

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
from app.utils.selfrequests import getRep
1111
from app.utils.baseMsg import GetBaseMessage
12+
from app.utils.szheException import (
13+
reqBadExceptin
14+
)
1215
from app.model.models import (
1316
BaseInfo,VulList
1417
)
@@ -21,18 +24,28 @@
2124
from pocsuite3.api import get_results
2225
import os
2326

27+
28+
2429
def saveVul(result,tid,poc):
2530
with app.app_context():
2631
vul=VulList(url=result['url'],tid=tid,pocname=poc,references=result['poc_attrs']['references'],created=result['created'])
2732
db.session.add(vul)
2833
db.session.commit()
2934

35+
36+
37+
def saveExts():
38+
return
39+
40+
41+
3042
def scanPoc(url,currdir,poc,tid):
3143
config = {
3244
'url': url,
3345
'poc': os.path.join(currdir,poc+'.py'),
3446
}
35-
# print(config['poc'])
47+
48+
print(config['poc'])
3649
# print(os.path.dirname(os.path.dirname(__file__)))
3750
# config字典的配置和cli命令行参数配置一模一样
3851
init_pocsuite(config)
@@ -44,31 +57,66 @@ def scanPoc(url,currdir,poc,tid):
4457

4558

4659
def scanPocs(url,poclist,tid,position=False):
60+
currdir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "../pocs/")
4761
for poc in poclist:
4862
if poc[1]==position:
4963
try:
50-
currdir=os.path.join(os.path.dirname(os.path.dirname(__file__)),"../pocs/")
5164
scanPoc(url,currdir,poc[0],tid)
5265
except Exception as e:
5366
logging.info(e)
5467
pass
5568

5669

5770

58-
def scanConsole(url,poclist,tid):
71+
def scanPlugins(url,pluginlist,tid,position=False):
72+
currdir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "../pocs/")
73+
for plugin in pluginlist:
74+
if plugin[1]==position:
75+
try:
76+
scanPoc(url,currdir,plugin[0],tid)
77+
except Exception as e:
78+
logging.info(e)
79+
pass
80+
81+
82+
83+
def scanPlugin(url,currdir,plugin,tid):
84+
config = {
85+
'url': url,
86+
'plugin': os.path.join(currdir, plugin + '.py'),
87+
}
88+
# print(config['poc'])
89+
# print(os.path.dirname(os.path.dirname(__file__)))
90+
# config字典的配置和cli命令行参数配置一模一样
91+
init_pocsuite(config)
92+
start_pocsuite()
93+
result = get_results().pop()
94+
if result['status'] == 'success':
95+
saveVul(result, tid, poc)
96+
97+
98+
99+
100+
def scanConsole(url,poclist,tid,pluginlist):
59101
rep,target=getRep(url)
60102
if not rep:
61-
raise
103+
raise reqBadExceptin(url)
62104
basemsg=GetBaseMessage(url,target,rep)
63105
with app.app_context():
64106
basemsgdb=BaseInfo(url=url,tid=tid,status=basemsg.GetStatus(),title=basemsg.GetTitle(),date=basemsg.GetDate(),responseheader=basemsg.GetResponseHeader(),Server=basemsg.GetFinger())
65107
db.session.add(basemsgdb)
66108
db.session.commit()
67-
scanPocs(target,poclist,tid) # 前置扫描
109+
110+
# 前置扫描
111+
scanPocs(target,poclist,tid)
112+
# scanPlugins(target,pluginlist,tid)
68113

69114
results=spider(target)
115+
116+
# 后置扫描
70117
for tempurl in results:
71-
scanPocs(tempurl, poclist, tid, position=True) # 后置扫描
118+
scanPocs(tempurl, poclist, tid, position=True)
119+
# scanPlugins(target, pluginlist, tid, position=True)
72120
logging.info("ScanEnd")
73121

74122

app/utils/szheException.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Time : 2022/3/17 0:40
4+
# @Author : Cl0udG0d
5+
# @File : szheException.py
6+
# @Github: https://github.com/Cl0udG0d
7+
8+
9+
class reqBadExceptin(Exception):
10+
"this is user's Exception for check the length of name "
11+
def __init__(self,url):
12+
self.url = url
13+
def __str__(self):
14+
return "请求失败 {}".format(self.url)
15+
16+
17+
def test():
18+
print('hi')
19+
20+
21+
if __name__ == '__main__':
22+
test()

assets/templates/base.html

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,16 @@ <h3 class="panel-title">修改密码</h3>
103103
</a>
104104
</li>
105105
<li {% block active4 %}{% endblock %}>
106-
<a href="javascript:void(0);">
106+
<a href="{{url_for('pocs.poclist')}}">
107107
<span class="icon"><i class="fa fa-gavel"></i></span>
108108
<span class="name">POC管理</span>
109-
<span class="arrow"><i class="arrow fa fa-angle-right pull-right"></i></span>
110109
</a>
111-
<ul class="sidebar-dropdown">
112-
<li><a href="{{url_for('pocs.poclist')}}">poc市场</a></li>
113-
<li><a href="{{url_for('pocs.poclist')}}">本地poc</a></li>
114-
</ul>
115110
</li>
116111
<li {% block active5 %}{% endblock %}>
117-
<a href="javascript:void(0);">
112+
<a href="{{url_for('plugin.pluginlist')}}">
118113
<span class="icon"><i class="fa fa fa-puzzle-piece"></i></span>
119114
<span class="name">扩展插件</span>
120-
<span class="arrow"><i class="arrow fa fa-angle-right pull-right"></i></span>
121115
</a>
122-
<ul class="sidebar-dropdown">
123-
<li><a href="{{url_for('plugin.pluginlist')}}">插件市场</a></li>
124-
<li><a href="{{url_for('plugin.pluginlist')}}">本地插件</a></li>
125-
</ul>
126-
127116
</li>
128117
</ul>
129118
</div>

plugins/plugin1.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Time : 2022/3/16 16:56
4+
# @Author : Cl0udG0d
5+
# @File : plugin1.py
6+
# @Github: https://github.com/Cl0udG0d
7+
import requests
8+
import re
9+
10+
def run(url):
11+
result = {
12+
'status': 'fail'
13+
}
14+
vul_url = '%s/veribaze/angelo.mdb' % url
15+
response = requests.get(vul_url).text
16+
17+
if re.search('Standard Jet DB', response):
18+
result['VerifyInfo'] = {}
19+
result['VerifyInfo']['URL'] = url
20+
result['VerifyInfo']['context'] = response
21+
result['status'] = 'success'
22+
return result
23+
24+
25+
def test():
26+
print('hi')
27+
28+
29+
if __name__ == '__main__':
30+
test()

pocs/PHPMyAdmin_all_weak_password.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)