Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@

humble.code-workspace

releases.sh
releases.sh

# history file
analysis_h.txt
# ignore html output
/*.html
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ options:
-s [SKIP_HEADERS ...] Skips 'deprecated/insecure' and 'missing' checks for the indicated 'SKIP_HEADERS' (separated by spaces)
-u URL Scheme, host and port to analyze. E.g., https://google.com or https://google.com:443
-ua USER_AGENT User-Agent ID from 'additional/user_agents.txt' file to use. '0' will show all and '1' is the default
-H, --header HEADER_PARAMETERS Custom headers which are added to all requests e. g. some authentication. Can be specified multiple times
-v, --version Checks for updates at https://github.com/rfc-st/humble

examples:
Expand Down
22 changes: 22 additions & 0 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -2643,9 +2643,26 @@ def process_server_error(http_status_code, l10n_id):
sys.exit()


def parse_headers(header_list):
"""
Convert ["Key: Value", "Another-Key: Value"] into a dict.
"""
if header_list is None:
return {}
headers = {}

for h in header_list:
if ":" not in h:
print_error_detail("[header_error]")
key, value = h.split(":", 1) # split only once
headers[key.strip()] = value.strip()
return headers


def make_http_request(proxy): # sourcery skip: extract-method
try:
custom_headers = REQ_HEADERS.copy()
custom_headers.update(added_custom_headers)
custom_headers['User-Agent'] = ua_header
session = requests.Session()
session.mount("https://", SSLContextAdapter())
Expand Down Expand Up @@ -2808,6 +2825,9 @@ def custom_help_formatter(prog):
parser.add_argument('-ua', type=str, dest='user_agent', help="User-Agent ID \
from 'additional/user_agents.txt' file to use. '0' will show all and '1' is \
the default")
parser.add_argument("-H", "--header", action="append", type=str, dest="header_parameters",
help="Custom headers which are added to all requests e. g. some authentication. \
Can be specified multiple times")
parser.add_argument("-v", "--version", action="store_true", help="Checks for \
updates at https://github.com/rfc-st/humble")

Expand Down Expand Up @@ -2855,6 +2875,8 @@ def custom_help_formatter(prog):
elif URL:
ua_header = parse_user_agent()

added_custom_headers = parse_headers(args.header_parameters)

if '-e' in sys.argv:
if system().lower() == 'windows':
print_l10n_file(args, 'testssl', slice_ln=True)
Expand Down
3 changes: 3 additions & 0 deletions l10n/details.txt
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,9 @@ HTTP Response Headers
[server_serror]
Server error; wait a while and try again.

[header_error]
Invalid header format. Expected 'Key: Value'

[e_connection]
Error: The request timed out while trying to connect to the remote server. Check URL and try again.

Expand Down
3 changes: 3 additions & 0 deletions l10n/details_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,9 @@ Cabeceras de respuesta HTTP
[server_serror]
Error en servidor; espera unos minutos y prueba de nuevo.

[header_error]
Formato de cabecera inválido. Se esperaba 'Clave: Valor'

[e_connection]
Error: La petición ha expirado al intentar conectarse al servidor; revisa la URL y prueba de nuevo.

Expand Down