Skip to content

Commit bc61454

Browse files
committed
implement weighted domains
1 parent f9818d3 commit bc61454

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

phishkiller.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import names
66
import logging
77
import time
8-
from emailHosts import email_domains
98
from fake_useragent import UserAgent
9+
from emailHosts import weighted_email_domains
1010

1111

1212
# Set up logging
@@ -31,11 +31,26 @@ def name_gen(): # Generates a random name for the email
3131
def generate_random_email(): # Generate email with combination of name and domain
3232
name = name_gen()
3333
NumberOrNo = random.choice(["Number", "No"])
34-
domain = random.choice(email_domains) # 140+ domains
34+
35+
# Calculate cumulative weights
36+
cumulative_weights = []
37+
cumulative_weight = 0
38+
for domain, weight in weighted_email_domains:
39+
cumulative_weight += weight
40+
cumulative_weights.append((domain, cumulative_weight))
41+
42+
# Select domain based on cumulative weights
43+
random_num = random.randint(1, cumulative_weight)
44+
for domain, cumlat_weight in cumulative_weights:
45+
if random_num <= cumlat_weight:
46+
selected_domain = domain
47+
break
48+
3549
if NumberOrNo == "Number":
36-
return name + str(random.randint(1, 100)) + domain
50+
return name + str(random.randint(1, 100)) + selected_domain
3751
else:
38-
return name + domain
52+
return name + selected_domain
53+
3954

4055

4156
def generate_random_password(): # Generate password using uppercase, lowercase, numbers and special characters
@@ -89,5 +104,6 @@ def main():
89104
print(f"Error in main: {e}")
90105

91106

107+
92108
if __name__ == "__main__":
93109
main()

0 commit comments

Comments
 (0)