Skip to content

Commit

Permalink
Modifications in results schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dimeko committed May 22, 2024
1 parent 97173ac commit 2a244a3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deltascan/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Config:
-------------------------------------------------------
- Scans in Db : {}
- Profiles in Db : {}
- Profiles : {}
- Profile : {}
- Configuration file : {}
- Output file : {}
-------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions deltascan/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def extract_port_scan_dict_results(cls, results):
Exception: If an error occurs during the scan parser.
"""
# TODO: We can add here as many fields as we want!
try:
scan_results = []
for host in results.hosts:
Expand All @@ -107,22 +108,21 @@ def extract_port_scan_dict_results(cls, results):
"servicefp": "none" if isinstance(s.servicefp, str) and s.servicefp == "" else s.servicefp,
"service_product": "none" if isinstance(s.banner, str) and s.banner == "" else s.banner,
})

scan["os"] = []
scan["os"] = {}
try:
for _idx in range(3):
scan["os"].append(
host._extras["os"]["osmatches"][_idx]["osmatch"]["name"])
for _idx, _match in enumerate(host._extras["os"]["osmatches"][:3]):
scan["os"][str(_idx+1)] = _match["osmatch"]["name"]
except (KeyError, IndexError):
if len(scan["os"]) == 0:
scan["os"] = ["none"]
else:
pass

scan["hops"] = []
scan["hops"] = {}
try:
for _hop in host._extras["trace"]["hops"]:
scan["hops"].append({_k: _hop[_k] for _k in ["ipaddr", "host"]})
for _idx, _hop in enumerate(host._extras["trace"]["hops"]):
scan["hops"][str(_idx+1)] = _hop["ipaddr"]
except (KeyError, IndexError):
if len(scan["hops"]) == 0:
scan["hops"] = ["none"]
Expand Down
2 changes: 1 addition & 1 deletion deltascan/core/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Scan(Schema):
host = fields.Str(required=True)
status = fields.Str(required=True)
ports = fields.Nested(ScanPorts, many=True, required=True)
os = fields.List(fields.Str(), required=True)
os = fields.Raw(required=True)
hops = fields.Raw(required=True)
osfingerprint = fields.Str(required=True)
last_boot = fields.Str(required=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"marshmallow==3.14.0",
"jinja2==3.1.3",
"getkey==0.6",
"python-libnmap @ git+https://github.com/Logisek/python-libnmap.git@develop#egg=libnmap",
"python-libnmap @ git+https://github.com/Logisek/python-libnmap.git@master#egg=libnmap",
"pdfkit",
"inputimeout"
],
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def test_scan(self):
"service_product": "Nginx"
}
],
"os": [
"os_name"
],
"hops": [
{"ipaddr": "10.0.0.0", "host": "host_1"},
{"ipaddr": "10.0.0.1", "host": "host_2"},
],
"os": {
"1": "os_name"
},
"hops": {
"1": "10.0.0.0",
"2": "10.0.0.1"
},
"osfingerprint": "os_fingerprint",
"last_boot": "12345678"
}
Expand Down

0 comments on commit 2a244a3

Please sign in to comment.