Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum worker control #2070

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ $ python3 sherlock --help
usage: sherlock [-h] [--version] [--verbose] [--folderoutput FOLDEROUTPUT]
[--output OUTPUT] [--tor] [--unique-tor] [--csv] [--xlsx]
[--site SITE_NAME] [--proxy PROXY_URL] [--json JSON_FILE]
[--timeout TIMEOUT] [--print-all] [--print-found] [--no-color]
[--browse] [--local] [--nsfw]
[--workers WORKERS] [--timeout TIMEOUT] [--print-all]
[--print-found] [--no-color] [--browse] [--local] [--nsfw]
USERNAMES [USERNAMES ...]

Sherlock: Find Usernames Across Social Networks (Version 0.14.3)
Expand Down Expand Up @@ -77,6 +77,7 @@ optional arguments:
Make requests over a proxy. e.g. socks5://127.0.0.1:1080
--json JSON_FILE, -j JSON_FILE
Load data from a JSON file or an online, valid, JSON file.
--workers WORKERS Set the maximum number of workers (Default: 20)
--timeout TIMEOUT Time (in seconds) to wait for response to requests (Default: 60)
--print-all Output sites where the username was not found.
--print-found Output sites where the username was found.
Expand Down
16 changes: 11 additions & 5 deletions sherlock/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def sherlock(
unique_tor=False,
proxy=None,
timeout=60,
max_workers:int=20
):
"""Run Sherlock Analysis.

Expand Down Expand Up @@ -207,11 +208,8 @@ def sherlock(
underlying_session = requests.session()
underlying_request = requests.Request()

# Limit number of workers to 20.
# This is probably vastly overkill.
if len(site_data) >= 20:
max_workers = 20
else:
# Reduce worker count if greater than size of target pool
if len(site_data) < max_workers:
max_workers = len(site_data)

# Create multi-threaded session for all requests.
Expand Down Expand Up @@ -582,6 +580,13 @@ def main():
default=None,
help="Load data from a JSON file or an online, valid, JSON file.",
)
parser.add_argument(
"--workers",
type=int,
default=20,
dest="workers",
help="Set the maximum number of workers for Sherlock (Default: 20)"
)
parser.add_argument(
"--timeout",
action="store",
Expand Down Expand Up @@ -764,6 +769,7 @@ def main():
unique_tor=args.unique_tor,
proxy=args.proxy,
timeout=args.timeout,
max_workers=args.workers
)

if args.output:
Expand Down