Skip to content

Commit

Permalink
Feature: Return the absolute path (additional files)
Browse files Browse the repository at this point in the history
Thus avoiding, I hope!, patches from Sophie Brun (https://www.kali.org/about-us/) and, in the future, from Dario Camonita (https://parrotsec.org/team/) for each version of 'humble'.

Thanks to both of you!.
  • Loading branch information
rfc-st committed Sep 27, 2024
1 parent cd287bc commit 88a4e5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a target="_blank" href="https://www.python.org/downloads/" title="Minimum Python version required to run this tool"><img src="https://img.shields.io/badge/Python-%3E%3D3.9-blue?labelColor=343b41"></a>
<a target="_blank" href="LICENSE" title="License of this tool"><img src="https://img.shields.io/badge/License-MIT-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/releases" title="Latest release of this tool"><img src="https://img.shields.io/github/v/release/rfc-st/humble?display_name=release&label=Latest%20Release&labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2024--09--21-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2024--09--27-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/actions?query=workflow%3ACodeQL" title="Results of the last analysis of this tool with CodeQL"><img src="https://github.com/rfc-st/humble/workflows/CodeQL/badge.svg"></a>
<a target="_blank" href="https://owasp.org/www-project-secure-headers/#div-technical" title="Official tool in OWASP Secure Headers Project"><img src="https://img.shields.io/badge/OWASP-Tool-blue?labelColor=343b41"></a>
<a target="_blank" href="https://pkg.kali.org/pkg/humble" title="Official tool in Kali Linux"><img src="https://img.shields.io/badge/Kali%20Linux-Tool-blue?labelColor=343b41"></a>
Expand Down
30 changes: 17 additions & 13 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from urllib.parse import urlparse
from subprocess import PIPE, Popen
from os import linesep, path, remove
from os.path import dirname, abspath
from collections import Counter, defaultdict
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import re
Expand Down Expand Up @@ -90,6 +91,7 @@
'lic_es.txt')
# https://data.iana.org/TLD/tlds-alpha-by-domain.txt
NON_RU_TLD = ('CYMRU', 'GURU', 'PRU')
OS_PATH = dirname(abspath(__file__))
RE_PATTERN = (r'\[(.*?)\]',
(r'^(?:\d{1,3}\.){3}\d{1,3}$|'
r'^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'),
Expand All @@ -115,7 +117,7 @@
URL_STRING = ('rfc-st', ' URL : ', 'caniuse')

current_time = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")
local_version = datetime.strptime('2024-09-21', '%Y-%m-%d').date()
local_version = datetime.strptime('2024-09-27', '%Y-%m-%d').date()


class SSLContextAdapter(requests.adapters.HTTPAdapter):
Expand Down Expand Up @@ -157,7 +159,7 @@ def check_updates(local_version):
def fng_statistics_top():
print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\
{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
encoding='utf8') as fng_f:
fng_lines = fng_f.readlines()
fng_incl = sum(1 for _ in islice(fng_lines, SLICE_INT[0], None))
Expand Down Expand Up @@ -186,7 +188,7 @@ def fng_statistics_top_result(fng_top_groups, fng_incl):
def fng_statistics_term(fng_term):
print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\
{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
encoding='utf8') as fng_source:
fng_lines = fng_source.readlines()
fng_incl = list(islice(fng_lines, SLICE_INT[0], None))
Expand Down Expand Up @@ -227,7 +229,7 @@ def fng_statistics_term_sorted(fng_incl, fng_term, fng_groups):

def print_grades_guide(args):
grade_l10n = HUMBLE_FILES[11] if args.lang == 'es' else HUMBLE_FILES[10]
with open(path.join(HUMBLE_DIRS[1], grade_l10n), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[1], grade_l10n), 'r',
encoding='utf8') as grades_source:
for line in islice(grades_source, SLICE_INT[3], None):
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
Expand All @@ -237,7 +239,7 @@ def print_grades_guide(args):

def print_license(args):
license_l10n = HUMBLE_FILES[13] if args.lang == 'es' else HUMBLE_FILES[12]
with open(path.join(HUMBLE_DIRS[1], license_l10n), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[1], license_l10n), 'r',
encoding='utf8') as license_source:
for line in license_source:
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
Expand All @@ -247,7 +249,7 @@ def print_license(args):

def print_security_guides():
print_detail('[security_guides]')
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',
encoding='utf8') as guides_source:
for line in islice(guides_source, SLICE_INT[3], None):
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
Expand Down Expand Up @@ -283,8 +285,8 @@ def testssl_analysis(testssl_command):


def get_l10n_content():
l10n_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[4] if args.lang == 'es'
else HUMBLE_FILES[5])
l10n_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[4]
if args.lang == 'es' else HUMBLE_FILES[5])
with open(l10n_path, 'r', encoding='utf8') as l10n_source:
return l10n_source.readlines()

Expand Down Expand Up @@ -790,15 +792,15 @@ def print_error_detail(id_mode):


def get_epilog_content(id_mode):
epilog_file_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[5])
epilog_file_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[5])
with open(epilog_file_path, 'r', encoding='utf8') as epilog_source:
epilog_lines = epilog_source.readlines()
epilog_idx = epilog_lines.index(id_mode + '\n')
return ''.join(epilog_lines[epilog_idx+1:epilog_idx+12])


def get_fingerprint_headers():
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
encoding='utf8') as fng_source:
l_fng_ex = [line.strip() for line in
islice(fng_source, SLICE_INT[0], None) if line.strip()]
Expand Down Expand Up @@ -943,7 +945,7 @@ def nourl_user_agent(user_agent_id):


def get_user_agent(user_agent_id):
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',
encoding='utf8') as ua_source:
user_agents = [line.strip() for line in islice(ua_source, SLICE_INT[1],
None)]
Expand All @@ -966,7 +968,8 @@ def print_user_agents(user_agents):

def get_insecure_checks():
headers_name = set()
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as ins_source:
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as \
ins_source:
insecure_checks = islice(ins_source, SLICE_INT[2], None)
for line in insecure_checks:
insecure_header = line.split(':')[0]
Expand Down Expand Up @@ -1147,7 +1150,8 @@ def set_pdf_color(pdf, line):


def generate_html():
copyfile(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[8]), final_filename)
copyfile(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[8]),
final_filename)
html_replace = {"html_title": get_detail('[pdf_meta_subject]'),
"html_desc": get_detail('[pdf_meta_title]'),
"html_keywords": get_detail('[pdf_meta_keywords]'),
Expand Down

0 comments on commit 88a4e5e

Please sign in to comment.