Skip to content

Commit 1b2c0b9

Browse files
Merge pull request #439 from Patrowl/develop
1.5.19
2 parents 7d21bc7 + 6e39853 commit 1b2c0b9

File tree

10 files changed

+54
-25
lines changed

10 files changed

+54
-25
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Crontributors
77
-------
88
* CERT Banque de France (CERT-BDF)
99

10-
Copyright (C) 2018-2022 Nicolas MATTIOCCO
10+
Copyright (C) 2018-2024 Nicolas MATTIOCCO

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.18
1+
1.5.19

engines/nmap/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM alpine:3.16.3
2-
LABEL Name="Nmap\ \(Patrowl engine\)" Version="1.4.45"
2+
LABEL Name="Nmap\ \(Patrowl engine\)" Version="1.4.46"
33

44
# Set the working directory
55
RUN mkdir -p /opt/patrowl-engines/nmap

engines/nmap/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.45
1+
1.4.46

engines/nmap/engine-nmap.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import subprocess
55
import sys
6+
import traceback
67
import psutil
78
import json
89
import optparse
@@ -135,7 +136,7 @@ def start():
135136
)
136137
return jsonify(res), 503
137138

138-
if type(data["options"]) == str:
139+
if type(data["options"]) is str:
139140
data["options"] = json.loads(data["options"])
140141

141142
scan = {
@@ -278,7 +279,7 @@ def _scan_thread(scan_id):
278279
cmd_sec = split(cmd)
279280

280281
this.scans[scan_id]["proc_cmd"] = "not set!!"
281-
with open(log_path, "w") as stderr:
282+
with open(log_path, "w"):
282283
this.scans[scan_id]["proc"] = subprocess.Popen(
283284
cmd_sec,
284285
shell=False,
@@ -335,11 +336,15 @@ def _scan_thread(scan_id):
335336
# print(f'scan {scan_id} is finished !')
336337
break
337338

339+
time.sleep(1) # wait for creating report file (could be long)
340+
338341
# Check if the report is available (exists && scan finished)
339342
report_filename = f"{BASE_DIR}/results/nmap_{scan_id}.xml"
340343
if not os.path.exists(report_filename):
341-
this.scans[scan_id]["status"] = "FINISHED" # ERROR ?
342-
this.scans[scan_id]["issues_available"] = True
344+
# this.scans[scan_id]["status"] = "FINISHED" # ERROR ?
345+
# this.scans[scan_id]["issues_available"] = True
346+
this.scans[scan_id]["status"] = "ERROR"
347+
this.scans[scan_id]["issues_available"] = False
343348
return False
344349

345350
try:
@@ -359,8 +364,12 @@ def _scan_thread(scan_id):
359364
issues.extend(extra_issues)
360365

361366
this.scans[scan_id]["issues"] = deepcopy(issues)
362-
except Exception:
363-
pass
367+
except Exception as e:
368+
print(e)
369+
app.logger.info(e)
370+
traceback.print_exception(*sys.exc_info())
371+
this.scans[scan_id]["status"] = "ERROR"
372+
this.scans[scan_id]["issues_available"] = False
364373
this.scans[scan_id]["issues_available"] = True
365374
this.scans[scan_id]["status"] = "FINISHED"
366375

@@ -433,7 +442,7 @@ def stop_scan(scan_id):
433442
)
434443

435444
this.scans[scan_id]["status"] = "STOPPED"
436-
this.scans[scan_id]["finished_at"] = int(time.time() * 1000)
445+
# this.scans[scan_id]["finished_at"] = int(time.time() * 1000)
437446
return jsonify(res)
438447

439448

@@ -466,6 +475,14 @@ def scan_status(scan_id):
466475
this.scans[scan_id]["status"] = "FINISHED"
467476
# print(f"scan_status/scan '{scan_id}' is finished")
468477

478+
elif (
479+
not psutil.pid_exists(proc.pid)
480+
and this.scans[scan_id]["issues_available"] is False
481+
and this.scans[scan_id]["status"] == "ERROR"
482+
):
483+
res.update({"status": "ERROR"})
484+
# print(f"scan_status/scan '{scan_id}' is finished")
485+
469486
elif psutil.pid_exists(proc.pid) and psutil.Process(proc.pid).status() in [
470487
"sleeping",
471488
"running",
@@ -734,7 +751,9 @@ def _parse_report(filename, scan_id):
734751
os_data["name"] = osinfo.get("name")
735752
os_data["accuracy"] = osinfo.get("accuracy")
736753
for osclass in osinfo.findall("osclass"):
737-
os_data["cpe"].append(osclass.find("cpe").text)
754+
os_cpe = osclass.find("cpe")
755+
if os_cpe is not None:
756+
os_data["cpe"].append(os_cpe.text)
738757
res.append(
739758
deepcopy(
740759
_add_issue(
@@ -1101,7 +1120,7 @@ def _parse_report(filename, scan_id):
11011120

11021121

11031122
def _get_cpe_link(cpe):
1104-
return "https://nvd.nist.gov/vuln/search/results?adv_search=true&cpe={}".format(cpe)
1123+
return f"https://nvd.nist.gov/vuln/search/results?adv_search=true&cpe={cpe}"
11051124

11061125

11071126
# custom functions for Vulners issues
@@ -1148,7 +1167,7 @@ def getfindings(scan_id):
11481167
return jsonify(res)
11491168

11501169
# check if the report is available (exists && scan finished)
1151-
report_filename = BASE_DIR + "/results/nmap_{}.xml".format(scan_id)
1170+
report_filename = f"{BASE_DIR}/results/nmap_{scan_id}.xml"
11521171
if not os.path.exists(report_filename):
11531172
res.update({"status": "error", "reason": "Report file not available"})
11541173
return jsonify(res)
@@ -1240,7 +1259,7 @@ def page_not_found(e):
12401259

12411260
@app.before_first_request
12421261
def main():
1243-
#if os.getuid() != 0: #run with root because of docker env vars scope
1262+
# if os.getuid() != 0: #run with root because of docker env vars scope
12441263
# app.logger.error("Start the NMAP engine using root privileges !")
12451264
# sys.exit(-1)
12461265
if not os.path.exists(f"{BASE_DIR}/results"):

engines/owl_dns/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM alpine:3.16.3
2-
LABEL Name="Patrowl\ DNS\ \(Patrowl engine\)" Version="1.5.6"
2+
LABEL Name="Patrowl\ DNS\ \(Patrowl engine\)" Version="1.5.7"
33

44
# Install dependencies
55
RUN apk add --update --no-cache \
6-
python3 python3-dev py3-pip \
7-
git \
6+
python3 python3-dev py3-pip \
7+
git \
88
&& rm -rf /var/cache/apk/*
99

1010
# Create the target repo

engines/owl_dns/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.6
1+
1.5.7

engines/owl_dns/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
__title__ = 'patrowl_engine_owl_dns'
5-
__version__ = '1.5.5'
6-
__author__ = 'Nicolas MATTIOCCO'
7-
__license__ = 'AGPLv3'
8-
__copyright__ = 'Copyright (C) 2018-2023 Nicolas Mattiocco - @MaKyOtOx'
4+
__title__ = "patrowl_engine_owl_dns"
5+
__version__ = "1.5.7"
6+
__author__ = "Nicolas MATTIOCCO"
7+
__license__ = "AGPLv3"
8+
__copyright__ = "Copyright (C) 2018-2024 Nicolas Mattiocco - @MaKyOtOx"

engines/owl_dns/etc/seg_list.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@
8989
"links": [
9090
"https://success.trendmicro.com/dcx/s/solution/1055888-redirecting-mail-exchange-mx-records-to-hosted-email-security-hes?language=en_US&sfdcIFrameOrigin=null"
9191
]
92+
},
93+
"mailinblack": {
94+
"provider": "mailinblack",
95+
"product": "Mailinblack",
96+
"mx_records": [
97+
".mailinblack.com."
98+
],
99+
"links": [
100+
"https://support.mailinblack.com/fr/articles/6853774-online-comment-editer-les-parametres-dns-mx-d-un-domaine"
101+
]
92102
}
93103
}
94104
}

engines/owl_dns/owl_dns.json.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PatrOwl - Dns module",
3-
"version": "0.1",
3+
"version": "1.5.7",
44
"description": "DNS Scanner",
55
"allowed_asset_types": ["ip", "domain", "fqdn", "keyword"],
66
"sublist3r_bin_path": "/opt/patrowl-engines/owl_dns/external-libs/Sublist3r",

0 commit comments

Comments
 (0)