Skip to content

πŸ•΅οΈβ€β™‚οΈ (2-in-1) Email & Username OSINT suite featuring native MCP support for deep data extraction just from a single Email/Username. Analyzes 2720+ actively maintained scan vectors (210+ email / 2510+ username) for security research, investigations, and digital footprinting.

Feature: Patterns

Vamatod5dd9f321172
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 8056913..405f583 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -7,27 +7,6 @@ from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import threading
-def test_generate_permutations():
- perms = helpers.generate_permutations("user", "ab", limit=None)
- assert "user" in perms
- # All permutations must be valid
- assert all(
- p == "user" or
- (p.startswith("user") and len(p) > len("user"))
- for p in perms
- )
-
- assert len(perms) > 1
-
-def test_generate_permutations_email():
- perms = helpers.generate_permutations("[email protected]", "abc", limit=None, is_email=True)
- assert "[email protected]" in perms
- assert all(
- p == "[email protected]" or
- (p.startswith("john") and len(p) > len("[email protected]") and p.endswith("@email.com"))
- for p in perms
- )
- assert len(perms) > 1
def test_get_site_name():
def module(name:str) -> SimpleNamespace:
@@ -63,7 +42,7 @@ def test_bulk_emails_valid(tmp_path, run_main, capsys):
email_file.write_text("""[email protected]
-
+
exit_code = run_main(["-ef", str(email_file), "-m", "github"])
out = capsys.readouterr().out
@@ -118,11 +97,11 @@ def test_bulk_emails_skip_comments_blank_lines(tmp_path, run_main, capsys):
email_file = tmp_path / "test_emails.txt"
email_file.write_text("""[email protected]
# comment
-
+
-
+
""")
-
+
exit_code = run_main(["-ef", str(email_file), "-m", "github"])
out = capsys.readouterr().out
@@ -141,7 +120,7 @@ def test_bulk_usernames_valid(tmp_path, run_main, capsys):
username_file.write_text("""user1
user2
user3""")
-
+
exit_code = run_main(["-uf", str(username_file), "-m", "github"])
out = capsys.readouterr().out
@@ -172,9 +151,9 @@ def test_bulk_usernames_skip_comments_blank_lines(tmp_path, run_main, capsys):
username_file = tmp_path / "test_usernames.txt"
username_file.write_text("""user1
# comment
-
+
user2""")
-
+
exit_code = run_main(["-uf", str(username_file), "-m", "github"])
out = capsys.readouterr().out
@@ -214,7 +193,7 @@ def test_validate_proxy_partially_invalid(mock_client):
instance.__enter__.return_value = instance
instance.__exit__.return_value = None
return instance
-
+
mock_client.side_effect = side_effect
proxies = ["http://invalid",
"socks5://socks-proxy.example.com:1080"]
@@ -230,7 +209,7 @@ def test_validate_proxy_timeout(mock_client):
instance = mock_client.return_value.__enter__.return_value
instance.get.side_effect = helpers.httpx.TimeoutException("timeout")
proxies = ["http://proxy1.example.com:8080"]
-
+
result = helpers.validate_proxies(proxies, timeout=1)
assert result == []
@@ -266,7 +245,7 @@ def test_proxy_manager_no_poxy_file(tmp_path):
def test_proxy_manager_empty_file_only_comments(tmp_path):
proxy_file = tmp_path / "test_proxy.txt"
proxy_file.write_text("""#comment
-
+
""")
with pytest.raises(Exception):
helpers.ProxyManager(str(proxy_file))
diff --git a/user_scanner/__main__.py b/user_scanner/__main__.py
index 310b0ea..4f8603c 100644
--- a/user_scanner/__main__.py
+++ b/user_scanner/__main__.py
@@ -3,6 +3,7 @@ import time
import sys
import re
from colorama import Fore, Style
+from itertools import islice
from user_scanner.cli.banner import print_banner
from user_scanner.core.version import load_local_version
@@ -15,7 +16,6 @@ from user_scanner.core.helpers import (
load_modules,
find_module,
get_site_name,
- generate_permutations,
set_proxy_manager,
get_proxy_count
)
@@ -32,6 +32,8 @@ from user_scanner.core.email_orchestrator import (
run_email_module_batch
)
+from user_scanner.core.patterns import expand_patterns
+
# Color configs
R = Fore.RED
G = Fore.GREEN
@@ -74,9 +76,6 @@ def main():
parser.add_argument("-v", "--verbose", action="store_true",
help="Enable verbose output")
- parser.add_argument("-p", "--permute", type=str,
- help="Generate permutations using a pattern")
-
parser.add_argument("-s", "--stop", type=int,
default=MAX_PERMUTATIONS_LIMIT, help="Limit permutations")
@@ -92,7 +91,7 @@ def main():
"-P", "--proxy-file", type=str, help="Path to proxy list file (one proxy per line)")
parser.add_argument(
- "--validate-proxies", action="store_true",
+ "--validate-proxies", action="store_true",
help="Validate proxies before scanning (tests against google.com)")
parser.add_argument(
@@ -143,27 +142,27 @@ def main():
if args.validate_proxies:
print(f"{C}[*] Validating proxies from {args.proxy_file}...{X}")
from user_scanner.core.helpers import validate_proxies, ProxyManager
-
+
# Load proxies first
temp_manager = ProxyManager(args.proxy_file)
all_proxies = temp_manager.proxies
print(f"{C}[*] Testing {len(all_proxies)} proxies...{X}")
-
+
# Validate them
working_proxies = validate_proxies(all_proxies)
-
+
if not working_proxies:
print(f"{R}[✘] No working proxies found{X}")
sys.exit(1)
-
+
print(f"{G}[+] Found {len(working_proxies)} working proxies out of {len(all_proxies)}{X}")
-
+
# Save working proxies to temp file
temp_proxy_file = "validated_proxies.txt"
with open(temp_proxy_file, 'w', encoding='utf-8') as f:
for proxy in working_proxies:
f.write(proxy + '\n')
-
+
set_proxy_manager(temp_proxy_file)
proxy_count = get_proxy_count()
print(f"{G}[+] Using {proxy_count} validated proxies{X}")
@@ -183,7 +182,7 @@ def main():
try:
with open(args.email_file, 'r', encoding='utf-8') as f:
emails = [line.strip() for line in f if line.strip() and not line.startswith('#')]
-
+
# Validate email formats
valid_emails = []
for email in emails:
@@ -191,14 +190,14 @@ def main():
valid_emails.append(email)
else:
print(f"{Y}[!] Skipping invalid email format: {email}{X}")
-
+
if not valid_emails:
print(f"{R}[✘] Error: No valid emails found in {args.email_file}{X}")
sys.exit(1)
-
+
print(f"{C}[+] Loaded {len(valid_emails)} {'email' if len(valid_emails) == 1 else 'emails'} from {args.email_file}{X}")
is_email = True
- targets = valid_emails
+ targets_found = valid_emails
except FileNotFoundError:
print(f"{R}[✘] Error: File not found: {args.email_file}{X}")
sys.exit(1)
@@ -215,7 +214,7 @@ def main():
sys.exit(1)
print(f"{C}[+] Loaded {len(usernames)} {'username' if len(usernames) == 1 else 'usernames'} from {args.username_file}{X}")
is_email = False
- targets = usernames
+ targets_found = usernames
except FileNotFoundError:
print(f"{R}[✘] Error: File not found: {args.username_file}{X}")
sys.exit(1)
@@ -229,18 +228,18 @@ def main():
sys.exit(1)
target_name = args.username or args.email
- targets = [target_name]
+ targets_found = [target_name]
# Handle permutations (only for single username/email)
- if args.permute and not (args.username_file or args.email_file):
- target_name = args.username or args.email
- targets = generate_permutations(
- target_name, args.permute, args.stop, is_email)
- print(
- C + f"[+] Generated {len(targets)} permutations" + Style.RESET_ALL)
- elif args.permute and (args.username_file or args.email_file):
- print(f"{R}[✘] Error: Permutations not supported with file-based scanning{X}")
- sys.exit(1)
+
+ targets = []
+ for target_name in targets_found:
+ temp_targets = list(islice(expand_patterns(target_name), args.stop))
+ targets.extend(temp_targets)
+ if len(temp_targets) > 1:
+ print(
+ C + f"[+] Generated {len(temp_targets)} permutations" + Style.RESET_ALL
+ )
results = []
@@ -265,7 +264,7 @@ def main():
f"[!] {'Email' if is_email else 'User'} module '{args.module}' not found." +
Style.RESET_ALL
)
-
+
elif args.category:
cat_path = load_categories(is_email).get(args.category)
fn = run_email_category_batch if is_email else run_user_category
diff --git a/user_scanner/core/helpers.py b/user_scanner/core/helpers.py
index d18ebc4..2805e35 100644
--- a/user_scanner/core/helpers.py
+++ b/user_scanner/core/helpers.py
@@ -1,6 +1,5 @@
import importlib
import importlib.util
-from itertools import permutations
from types import ModuleType
from pathlib import Path
from typing import Dict, List, Optional
@@ -70,39 +69,10 @@ def find_category(module: ModuleType) -> str | None:
return None
-def generate_permutations(username: str, pattern: str, limit: int | None = None, is_email: bool = False) -> List[str]:
- """
- Generate all order-based permutations of characters in `pattern`
- appended after `username`.
- """
-
- if limit and limit <= 0:
- return []
-
- permutations_set = {username}
- chars = list(pattern)
-
- domain = ""
- if is_email:
- username, domain = username.strip().split("@")
-
- # generate permutations of length 1 β†’ len(chars)
- for r in range(len(chars)):
- for combo in permutations(chars, r):
- new = username + ''.join(combo)
- if is_email:
- new += "@" + domain
- permutations_set.add(new)
- if limit and len(permutations_set) >= limit:
- return sorted(permutations_set)
-
- return sorted(permutations_set)
-
-
def validate_proxies(proxy_list: List[str], timeout: int = 5, max_workers: int = 50) -> List[str]:
"""Validate proxies by testing them against google.com. Returns list of working proxies."""
working_proxies = []
-
+
def test_proxy(proxy: str) -> Optional[str]:
try:
with httpx.Client(proxy=proxy, timeout=timeout) as client:
@@ -112,26 +82,26 @@ def validate_proxies(proxy_list: List[str], timeout: int = 5, max_workers: int =
except Exception:
pass
return None
-
+
with ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = {executor.submit(test_proxy, proxy): proxy for proxy in proxy_list}
for future in as_completed(futures):
result = future.result()
if result:
working_proxies.append(result)
-
+
return working_proxies
class ProxyManager:
"""Thread-safe proxy manager that loads and rotates proxies from a file."""
-
+
def __init__(self, proxy_file: str):
self.proxies: list[str] = []
self.current_index = 0
self.lock = threading.Lock()
self._load_proxies(proxy_file)
-
+
def _load_proxies(self, proxy_file: str) -> None:
"""Load proxies from a text file. Supports http://, https://, and socks5:// proxies."""
try:
@@ -143,31 +113,31 @@ class ProxyManager:
if not line.startswith(('http://', 'https://', 'socks5://')):
line = 'http://' + line
self.proxies.append(line)
-
+
if not self.proxies:
raise ValueError("No valid proxies found in file")
-
+
except FileNotFoundError:
raise FileNotFoundError(f"Proxy file not found: {proxy_file}")
except Exception as e:
raise Exception(f"Error loading proxies: {e}")
-
+
def get_next_proxy(self) -> Optional[str]:
"""Get the next proxy in rotation (round-robin)."""
if not self.proxies:
return None
-
+
with self.lock:
proxy = self.proxies[self.current_index]
self.current_index = (self.current_index + 1) % len(self.proxies)
return proxy
-
+
def get_random_proxy(self) -> Optional[str]:
"""Get a random proxy from the list."""
if not self.proxies:
return None
return random.choice(self.proxies)
-
+
def count(self) -> int:
"""Return the number of loaded proxies."""
return len(self.proxies)
@@ -198,4 +168,3 @@ def get_proxy_count() -> int:
if _proxy_manager:
return _proxy_manager.count()
return 0
-
diff --git a/user_scanner/core/patterns.py b/user_scanner/core/patterns.py
new file mode 100644
index 0000000..4ec3673
--- /dev/null
+++ b/user_scanner/core/patterns.py
@@ -0,0 +1,179 @@
+import itertools
+from dataclasses import dataclass
+from typing import List, Set
+
+
+@dataclass
+class PatternBlock:
+ charset: List[str]
+ lenset: List[int]
+
+
+Block = str | PatternBlock
+
+
+class Lexer:
+ def __init__(self, input: str) -> None:
+ self.tokens = [char for char in input]
+
+ def peek(self) -> str:
+ if self.tokens:
+ return self.tokens[0]
+ return ""
+
+ def next(self) -> str:
+ if self.tokens:
+ return self.tokens.pop(0)
+ return ""
+
+ def parse_number(self) -> int | None:
+ res = None
+ while (next := self.peek()) and next in "0123456789":
+ self.next()
+ n = int(next)
+ if res:
+ res = res * 10 + n
+ else:
+ res = n
+
+ return res
+
+
+def _char_range(start: str, end: str) -> List[str]:
+ return [chr(i) for i in range(ord(start), ord(end) + 1)]
+
+
+def _parse_charset(lexer: Lexer) -> Set[str]:
+ charset = set()
+
+ while lexer.peek() != "]":
+ cur = lexer.next()
+
+ if not cur:
+ raise ValueError('Missing "]" at the end of pattern')
+
+ if cur == "\\":
+ next = lexer.next()
+ if not next:
+ raise ValueError('Invalid "\\"')
+ charset.add(next)
+
+ elif cur == "-":
+ charset.add(cur)
+ else:
+ if lexer.peek() == "-":
+ lexer.next()
+ other = lexer.next()
+
+ if not other:
+ raise ValueError()
+
+ charset.update(_char_range(cur, other))
+ else:
+ charset.add(cur)
+
+ lexer.next() # Remove "]"
+
+ return charset
+
+
+def _parse_lenset(lexer: Lexer) -> Set[int]:
+ lenset = set()
+ NUMBERS = "0123456789"
+
+ while (cur := lexer.peek()) != "}":
+ if not cur:
+ raise ValueError('Missing "}" at the end of pattern')
+
+ if cur not in NUMBERS + "-" + ";":
+ raise ValueError(f"Invalid character: {cur}")
+
+ elif cur == "-":
+ raise ValueError('Invalid character at the lenset: "-"')
+ elif cur in NUMBERS:
+ lhs = lexer.parse_number()
+
+ if lexer.peek() == "-":
+ lexer.next()
+ rhs = lexer.parse_number()
+
+ if lhs is not None and rhs is not None:
+ for i in range(lhs, rhs + 1):
+ lenset.add(i)
+ elif lhs is not None:
+ lenset.add(lhs)
+ else:
+ lexer.next()
+
+ lexer.next() # Remove "}"
+
+ return lenset
+
+
+def _append_string(list: list, new: str):
+ if not list:
+ list.append(new)
+ elif isinstance(list[-1], str):
+ list[-1] += new
+ else:
+ list.append(new)
+
+
+def _parse_patterns(input: str) -> List[Block]:
+ lexer = Lexer(input)
+ res: List[Block] = []
+
+ while lexer.peek():
+ cur = lexer.next()
+
+ if cur == "\\":
+ if lexer.peek() in ("[", "]", "\\"):
+ _append_string(res, lexer.next())
+
+ elif cur == "[":
+ charset = _parse_charset(lexer)
+ lenset = set()
+ if lexer.peek() == "{":
+ lexer.next()
+ lenset = _parse_lenset(lexer)
+ else:
+ lenset.add(1)
+
+ res.append(PatternBlock(charset=sorted(charset), lenset=sorted(lenset)))
+
+ elif cur == "]":
+ # Should already be handled by parse_charset,
+ # therefore is invalid.
+ raise ValueError('Invalid unscaped "]"')
+
+ else:
+ _append_string(res, cur)
+
+ return res
+
+
+def _iter_block(block: PatternBlock):
+ for length in sorted(block.lenset):
+ for combo in itertools.product(block.charset, repeat=length):
+ yield "".join(combo)
+
+
+def _iter_pattern(blocks: List[Block]):
+ if not blocks:
+ yield ""
+ return
+
+ first, *rest = blocks
+ if isinstance(first, str):
+ for suffix in _iter_pattern(rest):
+ yield first + suffix
+
+ else:
+ for middle in _iter_block(first):
+ for suffix in _iter_pattern(rest):
+ yield middle + suffix
+
+
+def expand_patterns(input: str):
+ blocks = _parse_patterns(input)
+ yield from _iter_pattern(blocks)