2019-12-27 16:17:10 +00:00
|
|
|
"""Sherlock Result Module
|
|
|
|
|
|
|
|
This module defines various objects for recording the results of queries.
|
|
|
|
"""
|
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
|
|
class QueryStatus(Enum):
|
|
|
|
"""Query Status Enumeration.
|
|
|
|
|
|
|
|
Describes status of query about a given username.
|
|
|
|
"""
|
2020-11-12 18:43:24 +00:00
|
|
|
CLAIMED = "Claimed" # Username Detected
|
|
|
|
AVAILABLE = "Available" # Username Not Detected
|
|
|
|
UNKNOWN = "Unknown" # Error Occurred While Trying To Detect Username
|
|
|
|
ILLEGAL = "Illegal" # Username Not Allowable For This Site
|
2024-04-08 22:07:14 +00:00
|
|
|
WAF = "WAF" # Request blocked by WAF (i.e. Cloudflare)
|
2019-12-27 16:17:10 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
"""Convert Object To String.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
"""
|
|
|
|
return self.value
|
|
|
|
|
|
|
|
class QueryResult():
|
|
|
|
"""Query Result Object.
|
|
|
|
|
|
|
|
Describes result of query about a given username.
|
|
|
|
"""
|
2020-04-19 20:41:59 +00:00
|
|
|
def __init__(self, username, site_name, site_url_user, status,
|
|
|
|
query_time=None, context=None):
|
2019-12-27 16:17:10 +00:00
|
|
|
"""Create Query Result Object.
|
|
|
|
|
|
|
|
Contains information about a specific method of detecting usernames on
|
|
|
|
a given type of web sites.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
2020-04-19 20:41:59 +00:00
|
|
|
username -- String indicating username that query result
|
|
|
|
was about.
|
|
|
|
site_name -- String which identifies site.
|
|
|
|
site_url_user -- String containing URL for username on site.
|
|
|
|
NOTE: The site may or may not exist: this
|
|
|
|
just indicates what the name would
|
|
|
|
be, if it existed.
|
2019-12-27 16:17:10 +00:00
|
|
|
status -- Enumeration of type QueryStatus() indicating
|
|
|
|
the status of the query.
|
2020-04-19 03:04:09 +00:00
|
|
|
query_time -- Time (in seconds) required to perform query.
|
|
|
|
Default of None.
|
2019-12-27 16:17:10 +00:00
|
|
|
context -- String indicating any additional context
|
|
|
|
about the query. For example, if there was
|
|
|
|
an error, this might indicate the type of
|
|
|
|
error that occurred.
|
|
|
|
Default of None.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
Nothing.
|
|
|
|
"""
|
|
|
|
|
2020-04-19 20:41:59 +00:00
|
|
|
self.username = username
|
|
|
|
self.site_name = site_name
|
|
|
|
self.site_url_user = site_url_user
|
|
|
|
self.status = status
|
|
|
|
self.query_time = query_time
|
|
|
|
self.context = context
|
2019-12-27 16:17:10 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
"""Convert Object To String.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
Nicely formatted string to get information about this object.
|
|
|
|
"""
|
|
|
|
status = str(self.status)
|
|
|
|
if self.context is not None:
|
2020-11-12 18:43:24 +00:00
|
|
|
# There is extra context information available about the results.
|
|
|
|
# Append it to the normal response text.
|
2019-12-27 16:17:10 +00:00
|
|
|
status += f" ({self.context})"
|
|
|
|
|
|
|
|
return status
|