Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import re
|
| 2 |
import math
|
| 3 |
import whois
|
| 4 |
-
import
|
| 5 |
|
| 6 |
-
#
|
|
|
|
|
|
|
| 7 |
def analyze_url(url):
|
| 8 |
score = 0
|
| 9 |
reasons = []
|
|
@@ -25,10 +27,11 @@ def analyze_url(url):
|
|
| 25 |
# Domain age check
|
| 26 |
try:
|
| 27 |
domain_info = whois.whois(url)
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
if age_days < 180:
|
| 33 |
score += 1
|
| 34 |
reasons.append("Newly registered domain (<6 months)")
|
|
@@ -42,7 +45,9 @@ def analyze_url(url):
|
|
| 42 |
else:
|
| 43 |
return "🚨 High Risk URL\n" + "\n".join(reasons)
|
| 44 |
|
|
|
|
| 45 |
# Password Strength
|
|
|
|
| 46 |
def password_strength(password):
|
| 47 |
length = len(password)
|
| 48 |
entropy = length * math.log2(94)
|
|
|
|
| 1 |
import re
|
| 2 |
import math
|
| 3 |
import whois
|
| 4 |
+
import datetime
|
| 5 |
|
| 6 |
+
# -------------------------
|
| 7 |
+
# URL Analyzer
|
| 8 |
+
# -------------------------
|
| 9 |
def analyze_url(url):
|
| 10 |
score = 0
|
| 11 |
reasons = []
|
|
|
|
| 27 |
# Domain age check
|
| 28 |
try:
|
| 29 |
domain_info = whois.whois(url)
|
| 30 |
+
creation_date = domain_info.creation_date
|
| 31 |
+
if isinstance(creation_date, list):
|
| 32 |
+
creation_date = creation_date[0]
|
| 33 |
+
if creation_date:
|
| 34 |
+
age_days = (datetime.datetime.now() - creation_date).days
|
| 35 |
if age_days < 180:
|
| 36 |
score += 1
|
| 37 |
reasons.append("Newly registered domain (<6 months)")
|
|
|
|
| 45 |
else:
|
| 46 |
return "🚨 High Risk URL\n" + "\n".join(reasons)
|
| 47 |
|
| 48 |
+
# -------------------------
|
| 49 |
# Password Strength
|
| 50 |
+
# -------------------------
|
| 51 |
def password_strength(password):
|
| 52 |
length = len(password)
|
| 53 |
entropy = length * math.log2(94)
|