-
-
Notifications
You must be signed in to change notification settings - Fork 147
/
core.py
60 lines (51 loc) · 1.69 KB
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import datetime
from multiprocessing.pool import ThreadPool
from plugins.scanners import (
wpscan,
droopescan,
joomscan,
vbscan
)
from db import get_db
class Scanner:
def __init__(self, app, url, cms):
self.app = app
self.url = url
self.cms = cms
def write_to_db(self, result):
with self.app.app_context():
tms = datetime.datetime.now().timestamp()
qry = "INSERT INTO cmsscan(url, cms, result, tms) VALUES(?,?,?,?)"
dbo = get_db()
dbo.cursor().execute(qry, (self.url, self.cms, result, tms,))
dbo.commit()
dbo.close()
def scan_wp(self):
pool = ThreadPool(processes=1)
async_result = pool.apply_async(wpscan, (self.url,))
result = async_result.get()
self.write_to_db(result)
def scan_drupal(self):
pool = ThreadPool(processes=1)
async_result = pool.apply_async(droopescan, (self.url,))
result = async_result.get()
self.write_to_db(result)
def scan_joomla(self):
pool = ThreadPool(processes=1)
async_result = pool.apply_async(joomscan, (self.url,))
result = async_result.get()
self.write_to_db(result)
def scan_vbulletin(self):
pool = ThreadPool(processes=1)
async_result = pool.apply_async(vbscan, (self.url,))
result = async_result.get()
self.write_to_db(result)
def scan(self):
if self.cms == "wordpress":
self.scan_wp()
elif self.cms == "drupal":
self.scan_drupal()
elif self.cms == "joomla":
self.scan_joomla()
elif self.cms == "vbulletin":
self.scan_vbulletin()