Duc Minh Muon 2 weeks ago committed by GitHub
commit 1342f9120e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,6 +3,8 @@
This module defines the objects for notifying the caller about the
results of queries.
"""
import typing as T
from typing import overload
from result import QueryStatus
from colorama import Fore, Style
import webbrowser
@ -10,6 +12,8 @@ import webbrowser
# Global variable to count the number of results.
globvar = 0
if T.TYPE_CHECKING:
from result import QueryResult
class QueryNotify:
"""Query Notify Object.
@ -20,7 +24,7 @@ class QueryNotify:
override the methods to implement specific functionality.
"""
def __init__(self, result=None):
def __init__(self, result: T.Optional["QueryResult"] = None):
"""Create Query Notify Object.
Contains information about a specific method of notifying the results
@ -39,7 +43,7 @@ class QueryNotify:
# return
def start(self, message=None):
def start(self, message: T.Optional["QueryResult"] = None):
"""Notify Start.
Notify method for start of query. This method will be called before
@ -58,7 +62,7 @@ class QueryNotify:
# return
def update(self, result):
def update(self, result: T.Optional["QueryResult"] = None):
"""Notify Update.
Notify method for query result. This method will typically be
@ -77,7 +81,7 @@ class QueryNotify:
# return
def finish(self, message=None):
def finish(self, message: T.Optional["QueryResult"] = None):
"""Notify Finish.
Notify method for finish of query. This method will be called after
@ -114,7 +118,13 @@ class QueryNotifyPrint(QueryNotify):
Query notify class that prints results.
"""
def __init__(self, result=None, verbose=False, print_all=False, browse=False):
def __init__(
self,
result: T.Optional["QueryResult"] = None,
verbose: bool = False,
print_all: bool = False,
browse: bool = False
):
"""Create Query Notify Print Object.
Contains information about a specific method of notifying the results
@ -139,7 +149,7 @@ class QueryNotifyPrint(QueryNotify):
return
def start(self, message):
def start(self, message: str) -> None:
"""Notify Start.
Will print the title to the standard output.
@ -179,7 +189,7 @@ class QueryNotifyPrint(QueryNotify):
globvar += 1
return globvar
def update(self, result):
def update(self, result: T.Optional["QueryResult"] = None):
"""Notify Update.
Will print the query result to the standard output.
@ -256,7 +266,7 @@ class QueryNotifyPrint(QueryNotify):
return
def finish(self, message="The processing has been finished."):
def finish(self, message: str = "The processing has been finished.") -> None:
"""Notify Start.
Will print the last line to the standard output.
Keyword Arguments:

@ -3,6 +3,7 @@
This module defines various objects for recording the results of queries.
"""
from enum import Enum
import typing as T
class QueryStatus(Enum):
@ -32,8 +33,15 @@ class QueryResult():
Describes result of query about a given username.
"""
def __init__(self, username, site_name, site_url_user, status,
query_time=None, context=None):
def __init__(
self,
username: str,
site_name: str,
site_url_user: str,
status: QueryStatus,
query_time: T.Optional[float] = None,
context: T.Optional[str] = None
):
"""Create Query Result Object.
Contains information about a specific method of detecting usernames on

@ -16,6 +16,7 @@ import re
import sys
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from time import monotonic
import typing as T
import requests
@ -33,7 +34,7 @@ __version__ = "0.14.3"
class SherlockFuturesSession(FuturesSession):
def request(self, method, url, hooks=None, *args, **kwargs):
def request(self, method: str, url: str, hooks: T.Optional[T.Dict] = None, *args, **kwargs):
"""Request URL.
This extends the FuturesSession request method to calculate a response
@ -127,7 +128,7 @@ def get_response(request_future, error_type, social_network):
return response, error_context, exception_text
def interpolate_string(input_object, username):
def interpolate_string(input_object: T.Union[str, T.Dict, T.List], username: str):
if isinstance(input_object, str):
return input_object.replace("{}", username)
elif isinstance(input_object, dict):
@ -137,7 +138,7 @@ def interpolate_string(input_object, username):
return input_object
def check_for_parameter(username):
def check_for_parameter(username: str):
"""checks if {?} exists in the username
if exist it means that sherlock is looking for more multiple username"""
return "{?}" in username
@ -147,7 +148,7 @@ checksymbols = []
checksymbols = ["_", "-", "."]
def multiple_usernames(username):
def multiple_usernames(username: str):
"""replace the parameter with with symbols and return a list of usernames"""
allUsernames = []
for i in checksymbols:
@ -156,13 +157,13 @@ def multiple_usernames(username):
def sherlock(
username,
site_data,
query_notify,
tor=False,
unique_tor=False,
proxy=None,
timeout=60,
username: str,
site_data: T.Dict,
query_notify: QueryNotifyPrint,
tor: bool = False,
unique_tor: bool = False,
proxy: T.Optional[str] = None,
timeout: int = 60,
):
"""Run Sherlock Analysis.
@ -468,7 +469,7 @@ def sherlock(
return results_total
def timeout_check(value):
def timeout_check(value: float):
"""Check Timeout Argument.
Checks timeout for validity.

@ -6,10 +6,19 @@ This is the raw data that will be used to search for usernames.
import json
import requests
import secrets
import typing as T
class SiteInformation:
def __init__(self, name, url_home, url_username_format, username_claimed,
information, is_nsfw, username_unclaimed=secrets.token_urlsafe(10)):
def __init__(
self,
name: str,
url_home: str,
url_username_format: str,
username_claimed: str,
information: T.Dict,
is_nsfw: bool,
username_unclaimed: str = secrets.token_urlsafe(10)
):
"""Create Site Information Object.
Contains information about a specific website.
@ -72,7 +81,7 @@ class SiteInformation:
class SitesInformation:
def __init__(self, data_file_path=None):
def __init__(self, data_file_path: T.Optional[str] = None):
"""Create Sites Information Object.
Contains information about all supported websites.

Loading…
Cancel
Save