mirror of
https://github.com/adulau/HHHash.git
synced 2024-12-22 00:36:01 +00:00
Added hash_from_banner
This commit is contained in:
parent
e4403fea99
commit
092f0c9f6b
1 changed files with 9 additions and 6 deletions
|
@ -30,7 +30,11 @@ def buildhash(url=None, debug=False, method='GET', timeout=5):
|
||||||
return f"hhh:1:{digest}"
|
return f"hhh:1:{digest}"
|
||||||
|
|
||||||
def hash_from_banner(banner, debug=False):
|
def hash_from_banner(banner, debug=False):
|
||||||
"""This allows the creation of hhhash without a request, if the banner string is already available
|
"""Create a HHHash from an already fetched banner. Lines without colons will be skipped.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
banner -- HTTP banner string
|
||||||
|
debug -- output the headers returned before hashing
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> hash_from_banner('''HTTP/1.1 200 OK
|
>>> hash_from_banner('''HTTP/1.1 200 OK
|
||||||
|
@ -52,12 +56,11 @@ def hash_from_banner(banner, debug=False):
|
||||||
"""
|
"""
|
||||||
hhhash = ""
|
hhhash = ""
|
||||||
for line in banner.splitlines():
|
for line in banner.splitlines():
|
||||||
if line[:4] == "HTTP":
|
if ":" not in line:
|
||||||
continue
|
continue
|
||||||
key = line
|
|
||||||
if ":" in key:
|
header, _ = line.split(":", maxsplit=1)
|
||||||
key, _ = line.split(":", maxsplit=1)
|
hhhash = f"{hhhash}:{header.strip()}"
|
||||||
hhhash = f"{hhhash}:{key.strip()}"
|
|
||||||
if debug:
|
if debug:
|
||||||
print(hhhash[1:])
|
print(hhhash[1:])
|
||||||
m = hashlib.sha256()
|
m = hashlib.sha256()
|
||||||
|
|
Loading…
Reference in a new issue