Skip to content

Commit

Permalink
Merge pull request #1446 from Frky/patch-3
Browse files Browse the repository at this point in the history
Fix bug in zgrabout.py
  • Loading branch information
p-l- committed Oct 22, 2022
2 parents dbc6b51 + 2a1e97f commit 78354d7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ivre/zgrabout.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ def zgrap_parser_http(
res["port"] = port
# Since Zgrab does not preserve the order of the headers, we need
# to reconstruct a banner to use Nmap fingerprints
# define empty banner for log in case banner is never set in the following blocks
banner = None
if resp.get("headers"):
headers = resp["headers"]
# Check the Authenticate header first: if we requested it with
Expand Down Expand Up @@ -404,12 +406,14 @@ def zgrap_parser_http(
"output": "\n".join(output_list),
"http-headers": http_hdrs,
}
if has_raw_value:
if has_raw_value and banner is not None:
script["masscan"] = {"raw": utils.encode_b64(banner).decode()}
res.setdefault("scripts", []).append(script)
handle_http_headers(hostrec, res, http_hdrs, path=url.get("path"))
info: NmapServiceMatch = utils.match_nmap_svc_fp(
banner, proto="tcp", probe="GetRequest"
info: NmapServiceMatch = (
{}
if banner is None
else utils.match_nmap_svc_fp(banner, proto="tcp", probe="GetRequest")
)
if info:
add_cpe_values(hostrec, "ports.port:%s" % port, info.pop("cpe", []))
Expand Down

0 comments on commit 78354d7

Please sign in to comment.