From fb5a2b15815a8bd7048b2f26299b19599c606e65 Mon Sep 17 00:00:00 2001 From: dornier Date: Tue, 11 Nov 2025 17:54:10 -0300 Subject: [PATCH 1/3] feat: improves --output option --- sherlock_project/sherlock.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sherlock_project/sherlock.py b/sherlock_project/sherlock.py index f78d4b8ca..49f20bfbc 100644 --- a/sherlock_project/sherlock.py +++ b/sherlock_project/sherlock.py @@ -831,7 +831,27 @@ def main(): ) if args.output: - result_file = args.output + if os.path.exists(args.output): # Check if given filepath exists. + if os.path.isdir(args.output): # Filename exists and is a directory. + result_file = os.path.join(args.output, f"{username}") + else: + result_file = args.output # Filename already exists and is overwritten. + else: + parent_dir = os.path.dirname(args.output) + if parent_dir: + os.makedirs(parent_dir, exist_ok=True) + + result_file = args.output + + with open(result_file, "w", encoding="utf-8") as file: + exists_counter = 0 + for website_name in results: + dictionary = results[website_name] + if dictionary.get("status").status == QueryStatus.CLAIMED: + exists_counter += 1 + file.write(dictionary["url_user"] + "\n") + file.write(f"Total Websites Username Detected On : {exists_counter}\n") + elif args.folderoutput: # The usernames results should be stored in a targeted folder. # If the folder doesn't exist, create it first @@ -841,6 +861,7 @@ def main(): result_file = f"{username}.txt" if args.output_txt: + print("args.output_txt here") with open(result_file, "w", encoding="utf-8") as file: exists_counter = 0 for website_name in results: From 2dd86f8f1ae95ea829284502921861b3f2511b0e Mon Sep 17 00:00:00 2001 From: dornier Date: Tue, 11 Nov 2025 17:55:07 -0300 Subject: [PATCH 2/3] remove comment --- sherlock_project/sherlock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sherlock_project/sherlock.py b/sherlock_project/sherlock.py index 49f20bfbc..5fb26a8a3 100644 --- a/sherlock_project/sherlock.py +++ b/sherlock_project/sherlock.py @@ -861,7 +861,6 @@ def main(): result_file = f"{username}.txt" if args.output_txt: - print("args.output_txt here") with open(result_file, "w", encoding="utf-8") as file: exists_counter = 0 for website_name in results: From 9f54bcb31a558300895bfe6947e73582ab1f3f2c Mon Sep 17 00:00:00 2001 From: dornier Date: Tue, 11 Nov 2025 18:13:01 -0300 Subject: [PATCH 3/3] refactor - handle slash at the end of path --- sherlock_project/sherlock.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sherlock_project/sherlock.py b/sherlock_project/sherlock.py index 5fb26a8a3..9c249c939 100644 --- a/sherlock_project/sherlock.py +++ b/sherlock_project/sherlock.py @@ -837,11 +837,14 @@ def main(): else: result_file = args.output # Filename already exists and is overwritten. else: - parent_dir = os.path.dirname(args.output) - if parent_dir: - os.makedirs(parent_dir, exist_ok=True) - - result_file = args.output + parent_dir = os.path.dirname(args.output.rstrip("/")) + if args.output.endswith(os.sep): + os.makedirs(args.output, exist_ok=True) + result_file = os.path.join(args.output, f"{username}") + else: + if parent_dir: + os.makedirs(parent_dir, exist_ok=True) + result_file = args.output with open(result_file, "w", encoding="utf-8") as file: exists_counter = 0