Update app.py
Browse files
app.py
CHANGED
|
@@ -1,358 +1,132 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
const [linkResult, setLinkResult] = useState(null);
|
| 8 |
-
const [passwordInput, setPasswordInput] = useState('');
|
| 9 |
-
const [passwordResult, setPasswordResult] = useState(null);
|
| 10 |
-
const [showPassword, setShowPassword] = useState(false);
|
| 11 |
-
const [emailInput, setEmailInput] = useState('');
|
| 12 |
-
const [emailResult, setEmailResult] = useState(null);
|
| 13 |
-
|
| 14 |
-
const checkLinkSafety = () => {
|
| 15 |
-
if (!linkInput.trim()) {
|
| 16 |
-
setLinkResult({ safe: false, message: 'Please enter a URL' });
|
| 17 |
-
return;
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
const suspiciousPatterns = [
|
| 21 |
-
/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/,
|
| 22 |
-
/bit\.ly|tinyurl|short/i,
|
| 23 |
-
/(?:free|win|prize|claim|urgent|verify|account|suspended|locked)/i,
|
| 24 |
-
/[a-z]{20,}/i,
|
| 25 |
-
/@/
|
| 26 |
-
];
|
| 27 |
-
|
| 28 |
-
const url = linkInput.toLowerCase();
|
| 29 |
-
const risks = [];
|
| 30 |
-
|
| 31 |
-
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
| 32 |
-
risks.push('Missing protocol (http/https)');
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
if (url.startsWith('http://') && !url.startsWith('https://')) {
|
| 36 |
-
risks.push('Not using secure HTTPS');
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
suspiciousPatterns.forEach((pattern, idx) => {
|
| 40 |
-
if (pattern.test(url)) {
|
| 41 |
-
const messages = [
|
| 42 |
-
'Contains IP address instead of domain',
|
| 43 |
-
'Uses URL shortener',
|
| 44 |
-
'Contains suspicious keywords',
|
| 45 |
-
'Unusually long domain name',
|
| 46 |
-
'Contains @ symbol (potential redirect)'
|
| 47 |
-
];
|
| 48 |
-
risks.push(messages[idx]);
|
| 49 |
-
}
|
| 50 |
-
});
|
| 51 |
-
|
| 52 |
-
const isSafe = risks.length === 0;
|
| 53 |
-
setLinkResult({
|
| 54 |
-
safe: isSafe,
|
| 55 |
-
risks: risks,
|
| 56 |
-
message: isSafe ? 'URL appears safe' : 'Potential security risks detected'
|
| 57 |
-
});
|
| 58 |
-
};
|
| 59 |
-
|
| 60 |
-
const checkPasswordStrength = () => {
|
| 61 |
-
if (!passwordInput) {
|
| 62 |
-
setPasswordResult({ strength: 'none', message: 'Please enter a password' });
|
| 63 |
-
return;
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
let score = 0;
|
| 67 |
-
const checks = {
|
| 68 |
-
length: passwordInput.length >= 12,
|
| 69 |
-
uppercase: /[A-Z]/.test(passwordInput),
|
| 70 |
-
lowercase: /[a-z]/.test(passwordInput),
|
| 71 |
-
numbers: /\d/.test(passwordInput),
|
| 72 |
-
special: /[!@#$%^&*(),.?":{}|<>]/.test(passwordInput),
|
| 73 |
-
noCommon: !/(password|123456|qwerty|admin|letmein)/i.test(passwordInput)
|
| 74 |
-
};
|
| 75 |
-
|
| 76 |
-
Object.values(checks).forEach(check => {
|
| 77 |
-
if (check) score++;
|
| 78 |
-
});
|
| 79 |
-
|
| 80 |
-
let strength, color, message;
|
| 81 |
-
if (score <= 2) {
|
| 82 |
-
strength = 'Weak';
|
| 83 |
-
color = 'text-red-500';
|
| 84 |
-
message = 'This password is too weak';
|
| 85 |
-
} else if (score <= 4) {
|
| 86 |
-
strength = 'Medium';
|
| 87 |
-
color = 'text-yellow-500';
|
| 88 |
-
message = 'This password could be stronger';
|
| 89 |
-
} else {
|
| 90 |
-
strength = 'Strong';
|
| 91 |
-
color = 'text-green-500';
|
| 92 |
-
message = 'This is a strong password';
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
setPasswordResult({
|
| 96 |
-
strength,
|
| 97 |
-
color,
|
| 98 |
-
score,
|
| 99 |
-
checks,
|
| 100 |
-
message
|
| 101 |
-
});
|
| 102 |
-
};
|
| 103 |
-
|
| 104 |
-
const checkEmailSecurity = () => {
|
| 105 |
-
if (!emailInput.trim()) {
|
| 106 |
-
setEmailResult({ valid: false, message: 'Please enter an email address' });
|
| 107 |
-
return;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
| 111 |
-
const isValid = emailRegex.test(emailInput);
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
className="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg text-white placeholder-purple-300 focus:outline-none focus:ring-2 focus:ring-purple-500"
|
| 183 |
-
/>
|
| 184 |
-
<button
|
| 185 |
-
onClick={checkLinkSafety}
|
| 186 |
-
className="w-full bg-purple-600 hover:bg-purple-700 text-white font-semibold py-3 px-6 rounded-lg transition-colors flex items-center justify-center gap-2"
|
| 187 |
-
>
|
| 188 |
-
<Search className="w-5 h-5" />
|
| 189 |
-
Check Link Safety
|
| 190 |
-
</button>
|
| 191 |
-
</div>
|
| 192 |
-
|
| 193 |
-
{linkResult && (
|
| 194 |
-
<div className={`mt-6 p-6 rounded-lg border-2 ${
|
| 195 |
-
linkResult.safe
|
| 196 |
-
? 'bg-green-500/20 border-green-500'
|
| 197 |
-
: 'bg-red-500/20 border-red-500'
|
| 198 |
-
}`}>
|
| 199 |
-
<div className="flex items-center gap-3 mb-3">
|
| 200 |
-
{linkResult.safe ? (
|
| 201 |
-
<CheckCircle className="w-8 h-8 text-green-400" />
|
| 202 |
-
) : (
|
| 203 |
-
<XCircle className="w-8 h-8 text-red-400" />
|
| 204 |
-
)}
|
| 205 |
-
<h3 className="text-xl font-bold text-white">{linkResult.message}</h3>
|
| 206 |
-
</div>
|
| 207 |
-
{linkResult.risks && linkResult.risks.length > 0 && (
|
| 208 |
-
<div className="mt-3 space-y-2">
|
| 209 |
-
<p className="text-white font-semibold">Security Risks:</p>
|
| 210 |
-
{linkResult.risks.map((risk, idx) => (
|
| 211 |
-
<div key={idx} className="flex items-start gap-2 text-red-200">
|
| 212 |
-
<AlertTriangle className="w-4 h-4 mt-0.5 flex-shrink-0" />
|
| 213 |
-
<span>{risk}</span>
|
| 214 |
-
</div>
|
| 215 |
-
))}
|
| 216 |
-
</div>
|
| 217 |
-
)}
|
| 218 |
-
</div>
|
| 219 |
-
)}
|
| 220 |
-
</div>
|
| 221 |
-
)}
|
| 222 |
-
|
| 223 |
-
{activeTab === 'password' && (
|
| 224 |
-
<div className="space-y-4">
|
| 225 |
-
<h2 className="text-2xl font-bold text-white mb-4">Password Strength Checker</h2>
|
| 226 |
-
<div className="space-y-3">
|
| 227 |
-
<div className="relative">
|
| 228 |
-
<input
|
| 229 |
-
type={showPassword ? 'text' : 'password'}
|
| 230 |
-
value={passwordInput}
|
| 231 |
-
onChange={(e) => setPasswordInput(e.target.value)}
|
| 232 |
-
placeholder="Enter password to test"
|
| 233 |
-
className="w-full px-4 py-3 pr-12 bg-white/10 border border-white/20 rounded-lg text-white placeholder-purple-300 focus:outline-none focus:ring-2 focus:ring-purple-500"
|
| 234 |
-
/>
|
| 235 |
-
<button
|
| 236 |
-
onClick={() => setShowPassword(!showPassword)}
|
| 237 |
-
className="absolute right-3 top-1/2 -translate-y-1/2 text-purple-300 hover:text-white"
|
| 238 |
-
>
|
| 239 |
-
{showPassword ? <EyeOff className="w-5 h-5" /> : <Eye className="w-5 h-5" />}
|
| 240 |
-
</button>
|
| 241 |
-
</div>
|
| 242 |
-
<button
|
| 243 |
-
onClick={checkPasswordStrength}
|
| 244 |
-
className="w-full bg-purple-600 hover:bg-purple-700 text-white font-semibold py-3 px-6 rounded-lg transition-colors"
|
| 245 |
-
>
|
| 246 |
-
Check Password Strength
|
| 247 |
-
</button>
|
| 248 |
-
</div>
|
| 249 |
-
|
| 250 |
-
{passwordResult && passwordResult.strength !== 'none' && (
|
| 251 |
-
<div className="mt-6 p-6 bg-white/10 rounded-lg border border-white/20">
|
| 252 |
-
<div className="mb-4">
|
| 253 |
-
<h3 className={`text-2xl font-bold ${passwordResult.color}`}>
|
| 254 |
-
{passwordResult.strength} Password
|
| 255 |
-
</h3>
|
| 256 |
-
<p className="text-purple-200 mt-1">{passwordResult.message}</p>
|
| 257 |
-
</div>
|
| 258 |
-
|
| 259 |
-
<div className="w-full bg-gray-700 rounded-full h-3 mb-4">
|
| 260 |
-
<div
|
| 261 |
-
className={`h-3 rounded-full transition-all ${
|
| 262 |
-
passwordResult.strength === 'Weak' ? 'bg-red-500 w-1/3' :
|
| 263 |
-
passwordResult.strength === 'Medium' ? 'bg-yellow-500 w-2/3' :
|
| 264 |
-
'bg-green-500 w-full'
|
| 265 |
-
}`}
|
| 266 |
-
/>
|
| 267 |
-
</div>
|
| 268 |
-
|
| 269 |
-
<div className="space-y-2">
|
| 270 |
-
<p className="text-white font-semibold mb-2">Requirements:</p>
|
| 271 |
-
{Object.entries({
|
| 272 |
-
length: 'At least 12 characters',
|
| 273 |
-
uppercase: 'Contains uppercase letters',
|
| 274 |
-
lowercase: 'Contains lowercase letters',
|
| 275 |
-
numbers: 'Contains numbers',
|
| 276 |
-
special: 'Contains special characters',
|
| 277 |
-
noCommon: 'Not a common password'
|
| 278 |
-
}).map(([key, label]) => (
|
| 279 |
-
<div key={key} className="flex items-center gap-2">
|
| 280 |
-
{passwordResult.checks[key] ? (
|
| 281 |
-
<CheckCircle className="w-4 h-4 text-green-400" />
|
| 282 |
-
) : (
|
| 283 |
-
<XCircle className="w-4 h-4 text-red-400" />
|
| 284 |
-
)}
|
| 285 |
-
<span className={passwordResult.checks[key] ? 'text-green-200' : 'text-red-200'}>
|
| 286 |
-
{label}
|
| 287 |
-
</span>
|
| 288 |
-
</div>
|
| 289 |
-
))}
|
| 290 |
-
</div>
|
| 291 |
-
</div>
|
| 292 |
-
)}
|
| 293 |
-
</div>
|
| 294 |
-
)}
|
| 295 |
-
|
| 296 |
-
{activeTab === 'email' && (
|
| 297 |
-
<div className="space-y-4">
|
| 298 |
-
<h2 className="text-2xl font-bold text-white mb-4">Email Security Validator</h2>
|
| 299 |
-
<div className="space-y-3">
|
| 300 |
-
<input
|
| 301 |
-
type="email"
|
| 302 |
-
value={emailInput}
|
| 303 |
-
onChange={(e) => setEmailInput(e.target.value)}
|
| 304 |
-
placeholder="Enter email address to validate"
|
| 305 |
-
className="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg text-white placeholder-purple-300 focus:outline-none focus:ring-2 focus:ring-purple-500"
|
| 306 |
-
/>
|
| 307 |
-
<button
|
| 308 |
-
onClick={checkEmailSecurity}
|
| 309 |
-
className="w-full bg-purple-600 hover:bg-purple-700 text-white font-semibold py-3 px-6 rounded-lg transition-colors"
|
| 310 |
-
>
|
| 311 |
-
Validate Email
|
| 312 |
-
</button>
|
| 313 |
-
</div>
|
| 314 |
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
<p><strong>Domain:</strong> {emailResult.domain}</p>
|
| 333 |
-
<p><strong>Provider Type:</strong> {
|
| 334 |
-
emailResult.isCommonProvider ? 'Common provider' : 'Custom/Business domain'
|
| 335 |
-
}</p>
|
| 336 |
-
{emailResult.isSuspicious && (
|
| 337 |
-
<div className="mt-3 p-3 bg-yellow-500/20 rounded border border-yellow-500/50">
|
| 338 |
-
<p className="text-yellow-200">
|
| 339 |
-
⚠️ This appears to be a temporary/disposable email service
|
| 340 |
-
</p>
|
| 341 |
-
</div>
|
| 342 |
-
)}
|
| 343 |
-
</div>
|
| 344 |
-
)}
|
| 345 |
-
</div>
|
| 346 |
-
)}
|
| 347 |
-
</div>
|
| 348 |
-
)}
|
| 349 |
-
</div>
|
| 350 |
-
</div>
|
| 351 |
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import re
|
| 3 |
+
from urllib.parse import urlparse
|
| 4 |
|
| 5 |
+
def check_link_safety(url):
|
| 6 |
+
if not url.strip():
|
| 7 |
+
return "❌ Please enter a URL", []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
risks = []
|
| 10 |
+
url_lower = url.lower()
|
| 11 |
+
|
| 12 |
+
# Check for HTTPS
|
| 13 |
+
if not url.startswith('https://'):
|
| 14 |
+
risks.append("⚠️ Not using secure HTTPS")
|
| 15 |
+
|
| 16 |
+
# Check for IP addresses
|
| 17 |
+
if re.search(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', url):
|
| 18 |
+
risks.append("⚠️ Contains IP address instead of domain")
|
| 19 |
+
|
| 20 |
+
# Check for URL shorteners
|
| 21 |
+
if any(short in url_lower for short in ['bit.ly', 'tinyurl', 'short']):
|
| 22 |
+
risks.append("⚠️ Uses URL shortener")
|
| 23 |
+
|
| 24 |
+
# Check for suspicious keywords
|
| 25 |
+
if re.search(r'(?:free|win|prize|claim|urgent|verify|account|suspended)', url_lower):
|
| 26 |
+
risks.append("⚠️ Contains suspicious keywords")
|
| 27 |
+
|
| 28 |
+
if len(risks) == 0:
|
| 29 |
+
return "✅ URL appears safe", []
|
| 30 |
+
else:
|
| 31 |
+
return "⚠️ Potential security risks detected", "\n".join(risks)
|
| 32 |
+
|
| 33 |
+
def check_password_strength(password):
|
| 34 |
+
if not password:
|
| 35 |
+
return "Please enter a password", "", []
|
| 36 |
+
|
| 37 |
+
score = 0
|
| 38 |
+
checks = []
|
| 39 |
+
|
| 40 |
+
if len(password) >= 12:
|
| 41 |
+
score += 1
|
| 42 |
+
checks.append("✅ At least 12 characters")
|
| 43 |
+
else:
|
| 44 |
+
checks.append("❌ At least 12 characters")
|
| 45 |
+
|
| 46 |
+
if re.search(r'[A-Z]', password):
|
| 47 |
+
score += 1
|
| 48 |
+
checks.append("✅ Contains uppercase letters")
|
| 49 |
+
else:
|
| 50 |
+
checks.append("❌ Contains uppercase letters")
|
| 51 |
+
|
| 52 |
+
if re.search(r'[a-z]', password):
|
| 53 |
+
score += 1
|
| 54 |
+
checks.append("✅ Contains lowercase letters")
|
| 55 |
+
else:
|
| 56 |
+
checks.append("❌ Contains lowercase letters")
|
| 57 |
+
|
| 58 |
+
if re.search(r'\d', password):
|
| 59 |
+
score += 1
|
| 60 |
+
checks.append("✅ Contains numbers")
|
| 61 |
+
else:
|
| 62 |
+
checks.append("❌ Contains numbers")
|
| 63 |
+
|
| 64 |
+
if re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
|
| 65 |
+
score += 1
|
| 66 |
+
checks.append("✅ Contains special characters")
|
| 67 |
+
else:
|
| 68 |
+
checks.append("❌ Contains special characters")
|
| 69 |
+
|
| 70 |
+
if score <= 2:
|
| 71 |
+
strength = "🔴 Weak Password"
|
| 72 |
+
elif score <= 3:
|
| 73 |
+
strength = "🟡 Medium Password"
|
| 74 |
+
else:
|
| 75 |
+
strength = "🟢 Strong Password"
|
| 76 |
+
|
| 77 |
+
return strength, f"Score: {score}/5", "\n".join(checks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
def validate_email(email):
|
| 80 |
+
if not email.strip():
|
| 81 |
+
return "Please enter an email address", ""
|
| 82 |
+
|
| 83 |
+
email_regex = r'^[^\s@]+@[^\s@]+\.[^\s@]+$'
|
| 84 |
+
if not re.match(email_regex, email):
|
| 85 |
+
return "❌ Invalid email format", ""
|
| 86 |
+
|
| 87 |
+
domain = email.split('@')[1].lower()
|
| 88 |
+
suspicious = ['tempmail', 'throwaway', 'guerrilla', '10minute']
|
| 89 |
+
|
| 90 |
+
info = f"Domain: {domain}\n"
|
| 91 |
+
|
| 92 |
+
if any(sus in domain for sus in suspicious):
|
| 93 |
+
return "⚠️ Possible disposable email detected", info
|
| 94 |
+
|
| 95 |
+
return "✅ Email format is valid", info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
# Create Gradio interface
|
| 98 |
+
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
| 99 |
+
gr.Markdown("# 🛡️ Cyber Security Toolkit")
|
| 100 |
+
gr.Markdown("Check links, test passwords, and validate emails")
|
| 101 |
+
|
| 102 |
+
with gr.Tab("Link Safety Checker"):
|
| 103 |
+
with gr.Row():
|
| 104 |
+
link_input = gr.Textbox(label="Enter URL", placeholder="https://example.com")
|
| 105 |
+
link_button = gr.Button("Check Link Safety", variant="primary")
|
| 106 |
+
link_output = gr.Textbox(label="Result")
|
| 107 |
+
link_risks = gr.Textbox(label="Security Risks", lines=5)
|
| 108 |
+
|
| 109 |
+
link_button.click(check_link_safety, inputs=link_input, outputs=[link_output, link_risks])
|
| 110 |
+
|
| 111 |
+
with gr.Tab("Password Strength"):
|
| 112 |
+
with gr.Row():
|
| 113 |
+
pwd_input = gr.Textbox(label="Enter Password", type="password")
|
| 114 |
+
pwd_button = gr.Button("Check Password Strength", variant="primary")
|
| 115 |
+
pwd_strength = gr.Textbox(label="Strength")
|
| 116 |
+
pwd_score = gr.Textbox(label="Score")
|
| 117 |
+
pwd_checks = gr.Textbox(label="Requirements", lines=6)
|
| 118 |
+
|
| 119 |
+
pwd_button.click(check_password_strength, inputs=pwd_input, outputs=[pwd_strength, pwd_score, pwd_checks])
|
| 120 |
+
|
| 121 |
+
with gr.Tab("Email Validator"):
|
| 122 |
+
with gr.Row():
|
| 123 |
+
email_input = gr.Textbox(label="Enter Email", placeholder="user@example.com")
|
| 124 |
+
email_button = gr.Button("Validate Email", variant="primary")
|
| 125 |
+
email_output = gr.Textbox(label="Result")
|
| 126 |
+
email_info = gr.Textbox(label="Email Info", lines=3)
|
| 127 |
+
|
| 128 |
+
email_button.click(validate_email, inputs=email_input, outputs=[email_output, email_info])
|
| 129 |
+
|
| 130 |
+
app.launch()
|
| 131 |
+
|
| 132 |
+
|