Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ $ python3 -m pip install -r requirements.txt
$ python3 sherlock --help
usage: sherlock [-h] [--version] [--verbose] [--folderoutput FOLDEROUTPUT]
[--output OUTPUT] [--tor] [--unique-tor] [--csv]
[--merge]
[--site SITE_NAME] [--proxy PROXY_URL] [--json JSON_FILE]
[--timeout TIMEOUT] [--print-all] [--print-found] [--no-color]
[--no-txt]
[--browse] [--local]
USERNAMES [USERNAMES ...]

Expand All @@ -77,6 +79,7 @@ optional arguments:
request; increases runtime; requires Tor to be
installed and in system path.
--csv Create Comma-Separated Values (CSV) File.
--merge, -m Merges output from multiple username searches into one file
--site SITE_NAME Limit analysis to just the listed sites. Add multiple
options to specify more than one site.
--proxy PROXY_URL, -p PROXY_URL
Expand All @@ -93,6 +96,7 @@ optional arguments:
--print-all Output sites where the username was not found.
--print-found Output sites where the username was found.
--no-color Don't color terminal output
--no-txt Don't create txt output file
--browse, -b Browse to all results on default browser.
--local, -l Force the use of the local data.json file.
```
Expand Down
48 changes: 31 additions & 17 deletions sherlock/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ def main():
action="store_true", dest="csv", default=False,
help="Create Comma-Separated Values (CSV) File."
)
parser.add_argument("--merge", "-m", dest="merge",
help="Merges output from multiple username searches into one file")
parser.add_argument("--site",
action="append", metavar="SITE_NAME",
dest="site_list", default=None,
Expand Down Expand Up @@ -538,6 +540,10 @@ def main():
action="store_true", dest="no_color", default=False,
help="Don't color terminal output"
)
parser.add_argument("--no-txt",
action="store_true", dest="no_txt", default=False,
help="Don't create txt output file"
)
parser.add_argument("username",
nargs="+", metavar="USERNAMES",
action="store",
Expand Down Expand Up @@ -579,7 +585,7 @@ def main():

if args.tor or args.unique_tor:
print("Using Tor to make requests")

print(
"Warning: some websites might refuse connecting over Tor, so note that using this option might increase connection errors.")

Expand Down Expand Up @@ -648,6 +654,7 @@ def main():

# Run report on all specified users.
all_usernames = []
csv_rows = []
for username in args.username:
if(CheckForParameter(username)):
for name in MultipleUsernames(username):
Expand All @@ -663,26 +670,24 @@ def main():
unique_tor=args.unique_tor,
proxy=args.proxy,
timeout=args.timeout)

if args.output:
result_file = args.output
elif args.folderoutput:
# The usernames results should be stored in a targeted folder.
# If the folder doesn't exist, create it first
os.makedirs(args.folderoutput, exist_ok=True)
result_file = os.path.join(args.folderoutput, f"{username}.txt")
else:
elif not args.no_txt:
result_file = f"{username}.txt"

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")
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")

if args.csv:
result_file = f"{username}.csv"
Expand All @@ -691,6 +696,9 @@ def main():
# If the folder doesn't exist, create it first
os.makedirs(args.folderoutput, exist_ok=True)
result_file = os.path.join(args.folderoutput, result_file)
if args.merge:
# This is the filepath for the merged file
result_file = f"{args.merge}.csv"

with open(result_file, "w", newline='', encoding="utf-8") as csv_report:
writer = csv.writer(csv_report)
Expand All @@ -707,15 +715,21 @@ def main():
response_time_s = results[site]["status"].query_time
if response_time_s is None:
response_time_s = ""
writer.writerow([username,

result_output = [username,
site,
results[site]["url_main"],
results[site]["url_user"],
str(results[site]["status"].status),
results[site]["http_status"],
response_time_s
]
)
response_time_s]
csv_rows.append(result_output)

if not args.merge:
writer.writerow(result_output)

if args.merge:
writer.writerows(csv_rows)
print()
query_notify.finish()

Expand Down