Skip to content

Commit

Permalink
Feature: optimized fingerprint_analytics function
Browse files Browse the repository at this point in the history
Split into smaller functions and output now shows grouped HTTP headers
  • Loading branch information
rfc-st committed Jun 30, 2023
1 parent fe09300 commit 4c711b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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-2023--06--24-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-2023--06--30-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="Tool accepted as a technical resource for OWASP"><img src="https://img.shields.io/badge/OWASP-Resource-blue?labelColor=343b41"></a>
<a target="_blank" href="https://www.kali.org/tools/humble/" title="Tool accepted in Kali"><img src="https://img.shields.io/badge/Kali%20Linux-Tool-blue?labelColor=343b41"></a>
Expand Down
37 changes: 27 additions & 10 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

export_date = datetime.now().strftime("%Y%m%d")
now = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")
version = datetime.strptime('2023-06-24', '%Y-%m-%d').date()
version = datetime.strptime('2023-06-30', '%Y-%m-%d').date()


class PDF(FPDF):
Expand Down Expand Up @@ -149,18 +149,35 @@ def check_updates(version):
print(f"\n{get_detail('[update_error]')}")


def fingerprint_analytics(term):
def fng_analytics_groups(fng_lines, term):
pattern = r'\[(.*?)\]'
distinct_content = {re.search(pattern, line)[1].strip() for line in
fng_lines if re.search(pattern, line) and term.lower()
in re.search(pattern, line)[1].lower()}
term_count = sum(re.search(pattern, line) and term.lower() in
re.search(pattern, line)[1].lower() for line in fng_lines)
return distinct_content, term_count


def fng_analytics_sorted(fng_lines, term, distinct_content):
for content in sorted(distinct_content):
print(f"\n [{content}]")
for line in fng_lines:
if term.lower() in line.lower() and content in line:
print(f" {line[:line.find('[')].strip()}")


def fng_analytics(term):
print(f"\n{Style.BRIGHT}{get_detail('[fng_stats]', replace=True)}\
{Style.RESET_ALL}{get_detail('[fng_source]', replace=True)}\n")
with open(path.join('additional', F_FILE), 'r', encoding='utf8') as fng_f:
fng_lines = fng_f.readlines()
fng_ln = len(fng_lines)
term_count = sum(term.lower() in line.lower() for line in fng_lines)
pct_fng = round(term_count / fng_ln * 100, 2)
print(f" {get_detail('[fng_add]', replace=True)} '{term}': {pct_fng}%\
({term_count}{get_detail('[pdf_po]', replace=True)}{fng_ln})\n")
print(*(f" {line.strip()}" for line in fng_lines if term.lower() in
line.lower()), sep='\n')
distinct_content, term_count = fng_analytics_groups(fng_lines, term)
fng_ln = len(fng_lines)
pct_fng = round(term_count / fng_ln * 100, 2)
print(f"{get_detail('[fng_add]', replace=True)} '{term}': {pct_fng}%\
({term_count}{get_detail('[pdf_po]', replace=True)}{fng_ln})")
fng_analytics_sorted(fng_lines, term, distinct_content)


def print_guides():
Expand Down Expand Up @@ -700,7 +717,7 @@ def request_exceptions():
details_f = get_details_lines()
if args.lang:
details_f = get_details_lines()
fingerprint_analytics(term)
fng_analytics(term)
sys.exit()

if args.lang and not (args.URL or args.URL_A):
Expand Down
Binary file modified screenshots/humble_fng.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4c711b6

Please sign in to comment.