From 079f14ec46b5c826656d4535ae283a13217e331f Mon Sep 17 00:00:00 2001 From: Paul Pfeister Date: Sun, 30 Jun 2024 22:16:39 -0400 Subject: [PATCH] Add --dump-response flag --- sherlock/sherlock.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index db8e9c2..1b3883b 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -168,6 +168,7 @@ def sherlock( query_notify: QueryNotify, tor: bool = False, unique_tor: bool = False, + dump_response: bool = False, proxy=None, timeout=60, ): @@ -457,6 +458,34 @@ def sherlock( raise ValueError( f"Unknown Error Type '{error_type}' for " f"site '{social_network}'" ) + + if dump_response: + print("+++++++++++++++++++++") + print(f"TARGET NAME : {social_network}") + print(f"USERNAME : {username}") + print(f"TARGET URL : {url}") + print(f"TEST METHOD : {error_type}") + try: + print(f"STATUS CODES : {net_info['errorCode']}") + except KeyError: + pass + print("Results...") + try: + print(f"RESPONSE CODE : {r.status_code}") + except Exception: + pass + try: + print(f"ERROR TEXT : {net_info['errorMsg']}") + except KeyError: + pass + print(">>>>> BEGIN RESPONSE TEXT") + try: + print(r.text) + except Exception: + pass + print("<<<<< END RESPONSE TEXT") + print("VERDICT : " + str(query_status)) + print("+++++++++++++++++++++") # Notify caller about results of query. result = QueryResult( @@ -595,6 +624,13 @@ def main(): default=None, help="Make requests over a proxy. e.g. socks5://127.0.0.1:1080", ) + parser.add_argument( + "--dump-response", + action="store_true", + dest="dump_response", + default=False, + help="Dump the HTTP response to stdout for targeted debugging.", + ) parser.add_argument( "--json", "-j", @@ -783,6 +819,7 @@ def main(): query_notify, tor=args.tor, unique_tor=args.unique_tor, + dump_response=args.dump_response, proxy=args.proxy, timeout=args.timeout, )