Print found only by default

As mentioned in #718, it would be more useful for the user of Sherlock
to only get the results of the sites that return a positive result. With
these new changes, if you want to all results to be printed out, then
you can do that by using the --verbose flag.
pull/747/head
Siddharth Dushantha 4 years ago
parent 162dc390e9
commit 6bc8c38635

@ -110,8 +110,7 @@ class QueryNotifyPrint(QueryNotify):
Query notify class that prints results. Query notify class that prints results.
""" """
def __init__(self, result=None, verbose=False, print_found_only=False, def __init__(self, result=None, verbose=False, color=True):
color=True):
"""Create Query Notify Print Object. """Create Query Notify Print Object.
Contains information about a specific method of notifying the results Contains information about a specific method of notifying the results
@ -122,7 +121,6 @@ class QueryNotifyPrint(QueryNotify):
result -- Object of type QueryResult() containing result -- Object of type QueryResult() containing
results for this query. results for this query.
verbose -- Boolean indicating whether to give verbose output. verbose -- Boolean indicating whether to give verbose output.
print_found_only -- Boolean indicating whether to only print found sites.
color -- Boolean indicating whether to color terminal output color -- Boolean indicating whether to color terminal output
Return Value: Return Value:
@ -134,7 +132,6 @@ class QueryNotifyPrint(QueryNotify):
super().__init__(result) super().__init__(result)
self.verbose = verbose self.verbose = verbose
self.print_found_only = print_found_only
self.color = color self.color = color
return return
@ -185,7 +182,7 @@ class QueryNotifyPrint(QueryNotify):
else: else:
response_time_text = f" [{round(self.result.query_time * 1000)} ms]" response_time_text = f" [{round(self.result.query_time * 1000)} ms]"
#Output to the terminal is desired. # Output to the terminal is desired.
if result.status == QueryStatus.CLAIMED: if result.status == QueryStatus.CLAIMED:
if self.color: if self.color:
print((Style.BRIGHT + Fore.WHITE + "[" + print((Style.BRIGHT + Fore.WHITE + "[" +
@ -198,29 +195,33 @@ class QueryNotifyPrint(QueryNotify):
f"{self.result.site_url_user}")) f"{self.result.site_url_user}"))
else: else:
print(f"[+]{response_time_text} {self.result.site_name}: {self.result.site_url_user}") print(f"[+]{response_time_text} {self.result.site_name}: {self.result.site_url_user}")
elif result.status == QueryStatus.AVAILABLE: elif result.status == QueryStatus.AVAILABLE:
if not self.print_found_only: if self.verbose:
if self.color: if self.color:
print((Style.BRIGHT + Fore.WHITE + "[" + print((Style.BRIGHT + Fore.WHITE + "[" +
Fore.RED + "-" + Fore.RED + "-" +
Fore.WHITE + "]" + Fore.WHITE + "]" +
response_time_text + response_time_text +
Fore.GREEN + f" {self.result.site_name}:" + Fore.GREEN + f" {self.result.site_name}:" +
Fore.YELLOW + " Not Found!")) Fore.YELLOW + " Not Found!"))
else: else:
print(f"[-]{response_time_text} {self.result.site_name}: Not Found!") print(f"[-]{response_time_text} {self.result.site_name}: Not Found!")
elif result.status == QueryStatus.UNKNOWN: elif result.status == QueryStatus.UNKNOWN:
if self.color: if self.verbose:
print(Style.BRIGHT + Fore.WHITE + "[" + if self.color:
Fore.RED + "-" + print(Style.BRIGHT + Fore.WHITE + "[" +
Fore.WHITE + "]" + Fore.RED + "-" +
Fore.GREEN + f" {self.result.site_name}:" + Fore.WHITE + "]" +
Fore.RED + f" {self.result.context}" + Fore.GREEN + f" {self.result.site_name}:" +
Fore.YELLOW + f" ") Fore.RED + f" {self.result.context}" +
else: Fore.YELLOW + f" ")
print(f"[-] {self.result.site_name}: {self.result.context} ") else:
print(f"[-] {self.result.site_name}: {self.result.context} ")
elif result.status == QueryStatus.ILLEGAL: elif result.status == QueryStatus.ILLEGAL:
if not self.print_found_only: if self.verbose:
msg = "Illegal Username Format For This Site!" msg = "Illegal Username Format For This Site!"
if self.color: if self.color:
print((Style.BRIGHT + Fore.WHITE + "[" + print((Style.BRIGHT + Fore.WHITE + "[" +
@ -230,8 +231,9 @@ class QueryNotifyPrint(QueryNotify):
Fore.YELLOW + f" {msg}")) Fore.YELLOW + f" {msg}"))
else: else:
print(f"[-] {self.result.site_name} {msg}") print(f"[-] {self.result.site_name} {msg}")
else: else:
#It should be impossible to ever get here... # It should be impossible to ever get here...
raise ValueError(f"Unknown Query Status '{str(result.status)}' for " raise ValueError(f"Unknown Query Status '{str(result.status)}' for "
f"site '{self.result.site_name}'") f"site '{self.result.site_name}'")

@ -475,10 +475,6 @@ def main():
"A longer timeout will be more likely to get results from slow sites." "A longer timeout will be more likely to get results from slow sites."
"On the other hand, this may cause a long delay to gather all results." "On the other hand, this may cause a long delay to gather all results."
) )
parser.add_argument("--print-found",
action="store_true", dest="print_found_only", default=False,
help="Do not output sites where the username was not found."
)
parser.add_argument("--no-color", parser.add_argument("--no-color",
action="store_true", dest="no_color", default=False, action="store_true", dest="no_color", default=False,
help="Don't color terminal output" help="Don't color terminal output"
@ -583,13 +579,10 @@ def main():
#Create notify object for query results. #Create notify object for query results.
query_notify = QueryNotifyPrint(result=None, query_notify = QueryNotifyPrint(result=None,
verbose=args.verbose, verbose=args.verbose,
print_found_only=args.print_found_only,
color=not args.no_color) color=not args.no_color)
# Run report on all specified users. # Run report on all specified users.
for username in args.username: for username in args.username:
print()
results = sherlock(username, results = sherlock(username,
site_data, site_data,
query_notify, query_notify,
@ -642,6 +635,7 @@ def main():
response_time_s response_time_s
] ]
) )
print()
if __name__ == "__main__": if __name__ == "__main__":

@ -115,9 +115,7 @@ class SitesInformation():
# Ensure that specified data file has correct extension. # Ensure that specified data file has correct extension.
if not data_file_path.lower().endswith(".json"): if not data_file_path.lower().endswith(".json"):
raise FileNotFoundError(f"Incorrect JSON file extension for " raise FileNotFoundError(f"Incorrect JSON file extension for data file '{data_file_path}'.")
f"data file '{data_file_path}'."
)
if "http://" == data_file_path[:7].lower() or "https://" == data_file_path[:8].lower(): if "http://" == data_file_path[:7].lower() or "https://" == data_file_path[:8].lower():
# Reference is to a URL. # Reference is to a URL.

Loading…
Cancel
Save