-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.py
More file actions
68 lines (53 loc) · 2.06 KB
/
parser.py
File metadata and controls
68 lines (53 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import os
import re
def _clean_password(password: str) -> str:
return password.split(" ")[0].strip()
def extract_login_password(line: str) -> str | None:
line = line.strip()
if not line or "yoosee" not in line.lower():
return None
parts = line.split(":")
if len(parts) < 3:
return None
for i in range(len(parts) - 2, 0, -1):
candidate = parts[i]
candidate_clean = candidate.lstrip("/")
if re.match(r"[^@\s]+@[^@\s]+\.[^@\s]+", candidate_clean):
password = _clean_password(":".join(parts[i + 1:]))
return f"{candidate_clean}:{password}" if password else None
if (
candidate_clean
and "/" not in candidate_clean
and "http" not in candidate_clean.lower()
and "yoosee" not in candidate_clean.lower()
and "=" not in candidate_clean
and len(candidate_clean) >= 3
):
password = _clean_password(":".join(parts[i + 1:]))
return f"{candidate_clean}:{password}" if password else None
return None
def process_folder(input_folder: str, output_file: str):
if not os.path.isdir(input_folder):
print(f"[-] Folder not found: {input_folder}")
sys.exit(1)
txt_files = [
os.path.join(input_folder, f)
for f in os.listdir(input_folder)
if f.lower().endswith(".txt")
]
if not txt_files:
print(f"[-] No .txt files found in: {input_folder}")
sys.exit(1)
total = 0
with open(output_file, "w", encoding="utf-8") as f_out:
for input_file in txt_files:
with open(input_file, "r", encoding="utf-8", errors="ignore") as f_in:
for line in f_in:
if "yoosee" not in line.lower():
continue
result = extract_login_password(line)
if result:
f_out.write(result + "\n")
total += 1
return total