create function checking for {?} and modify main

pull/1298/head
aristotelis gkithkopoulos 3 years ago
parent 28b49ef898
commit 67e2627299

@ -29,8 +29,6 @@ module_name = "Sherlock: Find Usernames Across Social Networks"
__version__ = "0.14.0" __version__ = "0.14.0"
class SherlockFuturesSession(FuturesSession): class SherlockFuturesSession(FuturesSession):
def request(self, method, url, hooks={}, *args, **kwargs): def request(self, method, url, hooks={}, *args, **kwargs):
"""Request URL. """Request URL.
@ -141,6 +139,17 @@ def interpolate_string(object, username):
return object return object
def CheckForParameter(username):
'''checks if {?} exists in the username
if exist it means that sherlock is looking for more multiple username'''
return("{?}" in username)
def MultipleUsernames(username):
'''replace the parameter with with symbols and return a list of usernames'''
return
def sherlock(username, site_data, query_notify, def sherlock(username, site_data, query_notify,
tor=False, unique_tor=False, tor=False, unique_tor=False,
proxy=None, timeout=None): proxy=None, timeout=None):
@ -199,7 +208,6 @@ def sherlock(username, site_data, query_notify,
session = SherlockFuturesSession(max_workers=max_workers, session = SherlockFuturesSession(max_workers=max_workers,
session=underlying_session) session=underlying_session)
# Results from analysis of all sites # Results from analysis of all sites
results_total = {} results_total = {}
@ -440,7 +448,6 @@ def sherlock(username, site_data, query_notify,
raise ValueError(f"Unknown Error Type '{error_type}' for " raise ValueError(f"Unknown Error Type '{error_type}' for "
f"site '{social_network}'") f"site '{social_network}'")
# Notify caller about results of query. # Notify caller about results of query.
query_notify.update(result) query_notify.update(result)
@ -481,7 +488,8 @@ def timeout_check(value):
except: except:
raise ArgumentTypeError(f"Timeout '{value}' must be a number.") raise ArgumentTypeError(f"Timeout '{value}' must be a number.")
if timeout <= 0: if timeout <= 0:
raise ArgumentTypeError(f"Timeout '{value}' must be greater than 0.0s.") raise ArgumentTypeError(
f"Timeout '{value}' must be greater than 0.0s.")
return timeout return timeout
@ -567,7 +575,8 @@ def main():
# Check for newer version of Sherlock. If it exists, let the user know about it # Check for newer version of Sherlock. If it exists, let the user know about it
try: try:
r = requests.get("https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/sherlock.py") r = requests.get(
"https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/sherlock.py")
remote_version = str(re.findall('__version__ = "(.*)"', r.text)[0]) remote_version = str(re.findall('__version__ = "(.*)"', r.text)[0])
local_version = __version__ local_version = __version__
@ -579,7 +588,6 @@ def main():
except Exception as error: except Exception as error:
print(f"A problem occurred while checking for an update: {error}") print(f"A problem occurred while checking for an update: {error}")
# Argument check # Argument check
# TODO regex check on args.proxy # TODO regex check on args.proxy
if args.tor and (args.proxy is not None): if args.tor and (args.proxy is not None):
@ -610,11 +618,11 @@ def main():
print("You can only use --output with a single username") print("You can only use --output with a single username")
sys.exit(1) sys.exit(1)
# Create object with all information about sites we are aware of. # Create object with all information about sites we are aware of.
try: try:
if args.local: if args.local:
sites = SitesInformation(os.path.join(os.path.dirname(__file__), "resources/data.json")) sites = SitesInformation(os.path.join(
os.path.dirname(__file__), "resources/data.json"))
else: else:
sites = SitesInformation(args.json_file) sites = SitesInformation(args.json_file)
except Exception as error: except Exception as error:
@ -648,7 +656,8 @@ def main():
site_missing.append(f"'{site}'") site_missing.append(f"'{site}'")
if site_missing: if site_missing:
print(f"Error: Desired sites not found: {', '.join(site_missing)}.") print(
f"Error: Desired sites not found: {', '.join(site_missing)}.")
if not site_data: if not site_data:
sys.exit(1) sys.exit(1)
@ -659,7 +668,15 @@ def main():
print_all=args.print_all) print_all=args.print_all)
# Run report on all specified users. # Run report on all specified users.
all_usernames = []
for username in args.username: for username in args.username:
if(CheckForParameter(username)):
for name in MultipleUsernames(username):
all_usernames.append(name)
else:
all_usernames.append(username)
for username in all_usernames:
results = sherlock(username, results = sherlock(username,
site_data, site_data,
query_notify, query_notify,
@ -685,7 +702,8 @@ def main():
if dictionary.get("status").status == QueryStatus.CLAIMED: if dictionary.get("status").status == QueryStatus.CLAIMED:
exists_counter += 1 exists_counter += 1
file.write(dictionary["url_user"] + "\n") file.write(dictionary["url_user"] + "\n")
file.write(f"Total Websites Username Detected On : {exists_counter}\n") file.write(
f"Total Websites Username Detected On : {exists_counter}\n")
if args.csv: if args.csv:
result_file = f"{username}.csv" result_file = f"{username}.csv"

Loading…
Cancel
Save