Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions eagleosint/providers/mailfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

REALEMAIL_API_URL = "https://isitarealemail.com/api/email/validate"

CHECK_EMAIL_NUM = 0
_EMAIL_LOCK = threading.Lock()
class _State:
__slots__ = ("num", "lock")
def __init__(self):
self.num = 0
self.lock = threading.Lock()


def check_email(email, api, total, ok_list, output_file):
global CHECK_EMAIL_NUM
def check_email(email, api, total, ok_list, output_file, state):
try:
response = _session.get(
REALEMAIL_API_URL,
Expand All @@ -38,9 +40,9 @@ def check_email(email, api, total, ok_list, output_file):
try:
status_val = response.json().get("status", "unknown")
except json.JSONDecodeError:
with _EMAIL_LOCK:
CHECK_EMAIL_NUM += 1
current_count = CHECK_EMAIL_NUM
with state.lock:
state.num += 1
current_count = state.num
print(
f"{SPACE_PREFIX}{BG_RED}{WHITE} ERROR {WHITE}{BLUE} "
f"{current_count}/{total}{WHITE} Status: {RED}API "
Expand All @@ -61,9 +63,9 @@ def check_email(email, api, total, ok_list, output_file):
color_code = RED
back_color_code = BG_RED

with _EMAIL_LOCK:
CHECK_EMAIL_NUM += 1
current_count = CHECK_EMAIL_NUM
with state.lock:
state.num += 1
current_count = state.num
if status_val == "valid":
ok_list.append(email)
output_file.write(email + "\n")
Expand All @@ -75,9 +77,9 @@ def check_email(email, api, total, ok_list, output_file):
f"{color_code}{status_val}{WHITE} Email: {email}"
)
except requests.exceptions.RequestException as e_check_email:
with _EMAIL_LOCK:
CHECK_EMAIL_NUM += 1
current_count = CHECK_EMAIL_NUM
with state.lock:
state.num += 1
current_count = state.num
print(
f"{SPACE_PREFIX}{BG_RED}{WHITE} ERROR {WHITE}{BLUE} "
f"{current_count}/{total}{WHITE} Status: {RED}"
Expand Down Expand Up @@ -127,9 +129,7 @@ def mailfinder():
CONFIGS[REALEMAIL_API_CONFIG_KEY] = api_key
save_config()
print(WHITE + LINES_SEPARATOR)

global CHECK_EMAIL_NUM
CHECK_EMAIL_NUM = 0
state = _State()
total = len(email_providers) * len(user_variations)

with ThreadPoolExecutor(max_workers=20) as executor:
Expand All @@ -139,10 +139,9 @@ def mailfinder():
executor.submit(
check_email,
email_address, api_key, total,
valid_emails, mail_file
valid_emails, mail_file, state
)
sleep(0.20)
CHECK_EMAIL_NUM = 0

except KeyboardInterrupt:
print("ERROR")
Expand Down
40 changes: 17 additions & 23 deletions eagleosint/providers/userrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
)
from eagleosint.session import HEADERS, session as _session

USER_RECON_NUM = 0
USER_RECON_WORKING = 0
_RECON_LOCK = threading.Lock()
class _State:
__slots__ = ("num", "working", "lock")
def __init__(self):
self.num = 0
self.working = 0
self.lock = threading.Lock()

def send_req(url, username):
def send_req(url, username, state):
"""Sends a request to a given URL and prints the status code."""
try:
req = _session.get(url.format(username), headers=HEADERS, timeout=10)
Expand All @@ -38,33 +41,23 @@ def send_req(url, username):
print(f"{YELLOW}Connection error for {url.format(username)}{WHITE}")
return

global USER_RECON_NUM, USER_RECON_WORKING
if req.status_code == 200:
color_code = GREEN
elif req.status_code == 404:
color_code = RED
else:
color_code = YELLOW
color_code = GREEN if req.status_code == 200 else (RED if req.status_code == 404 else YELLOW)

with _RECON_LOCK:
USER_RECON_NUM += 1
with state.lock:
state.num += 1
if req.status_code == 200:
USER_RECON_WORKING += 1
user_recon_num_local = USER_RECON_NUM
user_recon_working_local = USER_RECON_WORKING
state.working += 1
num = state.num
working = state.working

display_progress(user_recon_num_local, 71, f"FOUND: {user_recon_working_local}")
display_progress(num, 71, f"FOUND: {working}")
print(
f" {SPACE_PREFIX}{BLUE}[{color_code}{req.status_code}{BLUE}] "
f"{user_recon_num_local}/71 {WHITE}{url.format(username)}"
f"{num}/71 {WHITE}{url.format(username)}"
)

def userrecon():
"""Performs username reconnaissance across various platforms."""
global USER_RECON_NUM, USER_RECON_WORKING
USER_RECON_NUM = 0
USER_RECON_WORKING = 0

username_to_check = input(
f"{SPACE_PREFIX}{WHITE}{BLUE}>{WHITE} enter username:{BLUE} "
).lower()
Expand Down Expand Up @@ -111,10 +104,11 @@ def userrecon():
"http://www.zone-h.org/archive/notifier={}",
]

state = _State()
print(WHITE + LINES_SEPARATOR)
with ThreadPoolExecutor(max_workers=20) as executor:
for site_url in url_list:
executor.submit(send_req, site_url, username_to_check)
executor.submit(send_req, site_url, username_to_check, state)
sleep(0.7)

print()
Expand Down
Loading