Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class TestH8mail(unittest.TestCase):
"""Tests for `h8mail` package."""
def setUp(self):
"""Set up test fixtures, if any."""
def tearDown(self):
"""Tear down test fixtures, if any."""
def test_000_simple(self):
"""Test something."""
run.print_banner()
start_time = time.time()
target = classes.target("test@test.ca")
target.get_emailrepio()
target.get_hunterio_public()
if helpers.check_scylla_online():
target.get_scylla()
run.print_results([target])
run.print_summary(start_time, [target])
def setUp(self):
"""Set up test fixtures, if any."""
def tearDown(self):
"""Tear down test fixtures, if any."""
def test_000_simple(self):
"""Test something."""
run.print_banner()
start_time = time.time()
target = classes.target("test@test.ca")
target.get_emailrepio()
target.get_hunterio_public()
if helpers.check_scylla_online():
target.get_scylla()
run.print_results([target])
run.print_summary(start_time, [target])
def h8mail(user_args):
"""
Handles most user arg logic. Creates a list() of targets from user input.
Starts the target object factory loop; starts local searches after factory if in user inputs
Prints results, saves to csv if in user inputs
"""
if not user_args.user_targets:
c.bad_news("Missing Target")
exit(1)
targets = []
start_time = time.time()
c.good_news("Targets:")
# Find targets in user input or file
for arg in user_args.user_targets:
user_stdin_target = fetch_emails(arg, user_args)
if user_stdin_target:
targets.extend(user_stdin_target)
elif os.path.isfile(arg):
c.info_news("Reading from file " + arg)
targets.extend(get_emails_from_file(arg, user_args))
else:
c.bad_news("No targets found in user input")
exit(1)
c.bad_news("Missing Target")
exit(1)
targets = []
start_time = time.time()
c.good_news("Targets:")
# Find targets in user input or file
for arg in user_args.user_targets:
user_stdin_target = fetch_emails(arg, user_args)
if user_stdin_target:
targets.extend(user_stdin_target)
elif os.path.isfile(arg):
c.info_news("Reading from file " + arg)
targets.extend(get_emails_from_file(arg, user_args))
else:
c.bad_news("No targets found in user input")
exit(1)
c.info_news("Removing duplicates")
targets = list(set(targets))
# Launch
breached_targets = target_factory(targets, user_args)
# These are not done inside the factory as the factory iterates over each target individually
# The following functions perform line by line checks of all targets per line
if user_args.bc_path:
breached_targets = breachcomp_check(breached_targets, user_args.bc_path)
local_found = None
# Handle cleartext search
start_time = time.time()
c.good_news("Targets:")
# Find targets in user input or file
for arg in user_args.user_targets:
user_stdin_target = fetch_emails(arg, user_args)
if user_stdin_target:
targets.extend(user_stdin_target)
elif os.path.isfile(arg):
c.info_news("Reading from file " + arg)
targets.extend(get_emails_from_file(arg, user_args))
else:
c.bad_news("No targets found in user input")
exit(1)
c.info_news("Removing duplicates")
targets = list(set(targets))
# Launch
breached_targets = target_factory(targets, user_args)
# These are not done inside the factory as the factory iterates over each target individually
# The following functions perform line by line checks of all targets per line
if user_args.bc_path:
breached_targets = breachcomp_check(breached_targets, user_args.bc_path)
local_found = None
# Handle cleartext search
if user_args.local_breach_src:
for arg in user_args.local_breach_src:
res = find_files(arg)
def breachcomp_check(targets, breachcomp_path):
# https://gist.github.com/scottlinux/9a3b11257ac575e4f71de811322ce6b3
try:
import subprocess
query_bin = os.path.join(breachcomp_path, "query.sh")
st = os.stat(query_bin)
os.chmod(query_bin, st.st_mode | stat.S_IEXEC)
for t in targets:
c.info_news(f"Looking up {t.email} in BreachCompilation")
procfd = subprocess.run([query_bin, t.email], stdout=subprocess.PIPE)
try:
output = procfd.stdout.decode("cp437")
except Exception as e:
c.bad_news(f"Could not decode bytes for {t.email} results")
output = procfd.stdout
# print(output[:85], "[...]")
print(output)
continue
if len(output) != 0:
split_output = output.split("\n")
for line in split_output:
if ":" in line:
t.pwned += 1
t.data.append(("BC_PASS", line.split(":")[1]))
c.good_news(
Prints results, saves to csv if in user inputs
"""
if not user_args.user_targets:
c.bad_news("Missing Target")
exit(1)
targets = []
start_time = time.time()
c.good_news("Targets:")
# Find targets in user input or file
for arg in user_args.user_targets:
user_stdin_target = fetch_emails(arg, user_args)
if user_stdin_target:
targets.extend(user_stdin_target)
elif os.path.isfile(arg):
c.info_news("Reading from file " + arg)
targets.extend(get_emails_from_file(arg, user_args))
else:
c.bad_news("No targets found in user input")
exit(1)
c.info_news("Removing duplicates")
targets = list(set(targets))
# Launch
breached_targets = target_factory(targets, user_args)
# These are not done inside the factory as the factory iterates over each target individually
# The following functions perform line by line checks of all targets per line
if user_args.bc_path:
breached_targets = breachcomp_check(breached_targets, user_args.bc_path)
def __init__(self, target_data, debug=False):
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,
)
def breachcomp_check(targets, breachcomp_path):
# https://gist.github.com/scottlinux/9a3b11257ac575e4f71de811322ce6b3
try:
import subprocess
query_bin = os.path.join(breachcomp_path, "query.sh")
st = os.stat(query_bin)
os.chmod(query_bin, st.st_mode | stat.S_IEXEC)
for t in targets:
c.info_news(f"Looking up {t.email} in BreachCompilation")
procfd = subprocess.run([query_bin, t.email], stdout=subprocess.PIPE)
try:
output = procfd.stdout.decode("cp437")
except Exception as e:
c.bad_news(f"Could not decode bytes for {t.email} results")
output = procfd.stdout
# print(output[:85], "[...]")
print(output)
continue
if len(output) != 0:
split_output = output.split("\n")
for line in split_output:
if ":" in line:
t.pwned += 1
t.data.append(("BC_PASS", line.split(":")[1]))
c.good_news(
"Found BreachedCompilation entry {line}".format(line=line)
)
return targets
except Exception as e:
c.bad_news("Breach compilation")
def get_hunterio_public(self):
try:
target_domain = self.target.split("@")[1]
url = "https://api.hunter.io/v2/email-count?domain={}".format(target_domain)
req = self.make_request(url)
response = req.json()
if response["data"]["total"] != 0:
self.data.append(("HUNTER_PUB", response["data"]["total"]))
c.good_news(
"Found {num} related emails for {target} using hunter.io (public)".format(
num=response["data"]["total"], target=self.target
)
)
except Exception as ex:
c.bad_news("hunter.io (pubic API) error: " + self.target)
print(ex)