Skip to content

Commit 079f14e

Browse files
committed
Add --dump-response flag
1 parent 501cb3d commit 079f14e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

sherlock/sherlock.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def sherlock(
168168
query_notify: QueryNotify,
169169
tor: bool = False,
170170
unique_tor: bool = False,
171+
dump_response: bool = False,
171172
proxy=None,
172173
timeout=60,
173174
):
@@ -457,6 +458,34 @@ def sherlock(
457458
raise ValueError(
458459
f"Unknown Error Type '{error_type}' for " f"site '{social_network}'"
459460
)
461+
462+
if dump_response:
463+
print("+++++++++++++++++++++")
464+
print(f"TARGET NAME : {social_network}")
465+
print(f"USERNAME : {username}")
466+
print(f"TARGET URL : {url}")
467+
print(f"TEST METHOD : {error_type}")
468+
try:
469+
print(f"STATUS CODES : {net_info['errorCode']}")
470+
except KeyError:
471+
pass
472+
print("Results...")
473+
try:
474+
print(f"RESPONSE CODE : {r.status_code}")
475+
except Exception:
476+
pass
477+
try:
478+
print(f"ERROR TEXT : {net_info['errorMsg']}")
479+
except KeyError:
480+
pass
481+
print(">>>>> BEGIN RESPONSE TEXT")
482+
try:
483+
print(r.text)
484+
except Exception:
485+
pass
486+
print("<<<<< END RESPONSE TEXT")
487+
print("VERDICT : " + str(query_status))
488+
print("+++++++++++++++++++++")
460489

461490
# Notify caller about results of query.
462491
result = QueryResult(
@@ -595,6 +624,13 @@ def main():
595624
default=None,
596625
help="Make requests over a proxy. e.g. socks5://127.0.0.1:1080",
597626
)
627+
parser.add_argument(
628+
"--dump-response",
629+
action="store_true",
630+
dest="dump_response",
631+
default=False,
632+
help="Dump the HTTP response to stdout for targeted debugging.",
633+
)
598634
parser.add_argument(
599635
"--json",
600636
"-j",
@@ -783,6 +819,7 @@ def main():
783819
query_notify,
784820
tor=args.tor,
785821
unique_tor=args.unique_tor,
822+
dump_response=args.dump_response,
786823
proxy=args.proxy,
787824
timeout=args.timeout,
788825
)

0 commit comments

Comments
 (0)