Merge remote-tracking branch 'upstream/master' into feature/from_banner

This commit is contained in:
3c7 2023-07-13 18:38:54 +02:00
commit e4403fea99
2 changed files with 16 additions and 3 deletions

View file

@ -2,10 +2,23 @@ import requests
import hashlib import hashlib
def buildhash(url=None, debug=False): def buildhash(url=None, debug=False, method='GET', timeout=5):
"""Build a HHHash from an HTTP request to specific url.
Keyword arguments:
url -- the url to build the HHHash from the response headers (default None)
debug -- output the headers returned before hashing (default False)
method -- HTTP method to use (GET or HEAD) (default GET)
timeout -- default timeout for the connect/read timeout of request (default 2)
"""
if url is None: if url is None:
return False return False
r = requests.get(url) if method == 'GET':
r = requests.get(url, timeout=timeout)
elif method == 'HEAD':
r = requests.head(url, timeout=timeout)
else:
return False
hhhash = "" hhhash = ""
for header in r.headers.keys(): for header in r.headers.keys():
hhhash = f"{hhhash}:{header}" hhhash = f"{hhhash}:{header}"

View file

@ -4,7 +4,7 @@
[tool.poetry] [tool.poetry]
name = "HHHash" name = "HHHash"
version = "0.1" version = "0.2"
authors = [ authors = [
"Alexandre Dulaunoy <a@foo.be>" "Alexandre Dulaunoy <a@foo.be>"
] ]