Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fetch_emails(target, user_args):
"""
Returns a list of emails found in 'target'.
Can be loosy to skip email pattern search.
"""
if user_args.loose or user_args.user_query is not None:
t = target.split(" ")
print(t)
return t
e = re.findall(r"[\w\.-]+@[\w\.-]+", target)
if e:
print(", ".join(e), c.reset)
return e
return None
self.headers = {
"User-Agent": "h8mail-v.{h8ver}-OSINT-and-Education-Tool (PythonVersion={pyver}; Platform={platfrm})".format(
h8ver=__version__,
pyver=sys.version.split(" ")[0],
platfrm=platform.platform().split("-")[0],
)
}
self.target = target_data
self.pwned = 0
self.data = [()]
self.debug = debug
if debug:
print(
c.fg.red,
"DEBUG: Created target object for {}".format(self.target),
c.reset,
)
)
elif "LOCALSEARCH" in source:
if len(data) > 140:
print(
"{}{}{:15}{}|{}{:>25.25}{} > {}{}{}{}".format(
colors.fg.lightblue,
colors.bold,
source,
colors.fg.lightgrey,
colors.fg.pink,
target,
colors.fg.lightgrey,
colors.bold,
colors.fg.green,
"[...]" + data[-135:],
colors.reset,
)
)
else:
print(
"{}{}{:15}{}|{}{:>25.25}{} > {}{}{}{}".format(
colors.fg.lightblue,
colors.bold,
source,
colors.fg.lightgrey,
colors.fg.pink,
target,
colors.fg.lightgrey,
colors.bold,
colors.fg.green,
data,
colors.reset,
"""
Fetches the URL without the h8mail UA
Saves result to tempdir
"""
paramsUA = {"User-Agent": "h8mail/5.0 (X11; Linux i586; rv:31.0)"}
try:
c.info_news("Worker fetching")
r = requests.get(url, params = paramsUA, allow_redirects=False)
c.info_news("Worker done fetch url")
print(f"Status code: {r.status_code}")
e = re.findall(r"[\w\.-]+@[\w\.-]+", r.text)
print("debug toto")
print(e)
if e:
print(", ".join(e), c.reset)
return e
return None
except Exception as ex:
c.bad_news("URL fetch worker error:")
print(ex)
def info_news(news):
"""
Print an information with grey text
"""
print(
colors.bold
+ colors.fg.lightblue
+ "[~] "
+ colors.reset
+ colors.fg.lightgrey
+ news.strip()
+ colors.reset
)
def get_hibp(self):
try:
sleep(1.3)
c.info_news(c.bold + "HIBP free tier will stop working on the 2019/08/18")
c.info_news(
c.bold
+ "You can already use a purchased API key using h8mail (config file)"
+ c.reset
)
url = "https://haveibeenpwned.com/api/v2/breachedaccount/{}?truncateResponse=true".format(
self.target
)
response = self.make_request(url)
if response.status_code not in [200, 404]:
c.bad_news("Could not contact HIBP for " + self.target)
print(response.status_code)
return
if response.status_code == 200:
data = response.json()
for d in data: # Returned type is a dict of Name : Service
for _, ser in d.items():
self.data.append(("HIBP", ser))
self.pwned += 1
colors.reset,
)
)
elif "HASH" in source:
print(
"{}{:15}{}|{}{:>25.25}{} > {}{}{}".format(
colors.fg.lightblue,
source,
colors.fg.lightgrey,
colors.fg.pink,
target,
colors.fg.lightgrey,
colors.fg.red,
data,
colors.reset,
)
)
elif "USER" in source:
print(
"{}{:15}{}|{}{:>25.25}{} > {}{}{}".format(
colors.fg.lightblue,
source,
colors.fg.lightgrey,
colors.fg.pink,
target,
colors.fg.lightgrey,
colors.fg.lightcyan,
data,
colors.reset,
)
)
def print_summary(start_time, breached_targets):
"""
Prints a padded table where each line is a target, and associated value is simplified to breached/not breached.
If breached, shows len(t.data). Shown elements and total may differ as some elements of t.data are not outputted to stdout.
"""
print("{:_^90}".format(""))
print(
"\n\n\n{:^32}".format(""),
c.bold,
c.underline,
"Session Recap:",
c.reset,
"\n\n",
)
print("{:^40} | ".format("Target"), "{:^40}".format("Status"), c.reset)
print("{:_^90}\n".format(""))
for t in breached_targets:
if t.pwned is not 0:
print(
f"{t.target:^40} | ",
c.fg.green,
"{:^40}".format("Breach Found (" + str(t.pwned) + " elements)"),
c.reset,
)
else:
print(
f"{t.target:^40} | ",
c.fg.lightgrey,