Spaces:
Running
Running
import subprocess import re import requests import json # العنوان MAC المستهدف MAC_ADDRESS = "D6:A6:7E:E1:7F:42" # 1. تنظيف وتنسيق العنوان def format_mac(mac): return re.sub(r'[^a-fA-F0-9]', '', mac).upper() # 2. استخراج OUI (الأول 6 أحرف) def get_oui(mac): clean_mac = format_mac(mac) if len(clean_mac) < 6: return None return clean_mac[:6] # 3. البحث عن البائع باستخدام API عام (macvendors.com) def lookup_vendor(mac): oui = get_oui(mac) url = f"https://api.macvendors.com/v1/lookup/{oui}" headers = {"Accept": "application/json"} try: response = requests.get(url, headers=headers, timeout=5) if response.status_code == 200: data = response.json() return data.get("vendor_details", {}).get("company_name", "غير معروف") else: return f"خطأ في الاستجابة: {response.status_code}" except Exception as e: return f"فشل الاتصال: {e}" # 4. التحقق مما إذا كان الجهاز متصلًا بالشبكة الحالية (في نفس الـ subnet) def is_device_on_network(mac): try: # جلب جدول ARP المحلي result = subprocess.run(['arp', '-a'], capture_output=True, text=True) arp_output = result.stdout # تنسيق MAC للبحث clean_mac = format_mac(mac) pattern = clean_mac.replace('', '..')[2:-2] # تحويل D6A67E إلى D6:A6:7E أو D6-A6-7E if re.search(pattern[:8].replace('..', ':'), arp_output, re.IGNORECASE): return True return False except Exception as e: print(f"خطأ في فحص ARP: {e}") return False # 5. تحليل ما إذا كان "نظيفًا" (نظريًا) def is_mac_suspicious(mac): oui = get_oui(mac) known_suspicious = [ "000000", "CCCCCC", "111111", # عناوين شائعة في التزييف "DEADBEEF", "BAD00D" ] # تحقق من عناوين مشبوهة if any(susp in oui for susp in ["DEAD", "BEEF", "BAD", "CAFE"]): return True if oui[:4] == oui[2:6]: # مثل A6A6A6 return True return False # 6. الدالة الرئيسية def analyze_mac(mac): print(f"[+] تحليل عنوان MAC: {mac}") print("-" * 50) formatted = format_mac(mac) print(f"[✓] التنسيق الموحّد: {formatted}") oui = get_oui(mac) print(f"[✓] OUI (البائع): {oui}") vendor = lookup_vendor(mac) print(f"[✓] الشركة المصنعة: {vendor}") if "Foxconn" in vendor or "Hon Hai" in vendor: print(f"[✓] الجهاز من إنتاج Foxconn (طبيعي جدًا)") else: print(f"[!] الشركة غير متوقعة: {vendor}") on_network = is_device_on_network(mac) if on_network: print(f"[⚠] الجهاز مرتبط بالشبكة حاليًا") else: print(f"[✓] الجهاز غير مرتبط بالشبكة (ربما مزيف أو بعيد)") if is_mac_suspicious(mac): print(f"[❌] العنوان مشبوه (مزيف أو غير طبيعي)") clean = False else: print(f"[✓] العنوان ليس مشبوهًا من حيث التنسيق") clean = True # الحكم النهائي if "Foxconn" in vendor and on_network and not is_mac_suspicious(mac): print(f"\n[+] الحكم: ✅ الجهاز **نظيف وطبيعي** (محتمل أن يكون جهازك)") else: print(f"\n[!] الحكم: ⚠️ الجهاز **مشبوه أو يحتاج فحصًا إضافيًا**") return clean # --- تنفيذ التحليل --- if __name__ == "__main__": analyze_mac(MAC_ADDRESS) - Initial Deployment
e141aa4
verified
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>MAC Address Analyzer</title> | |
<script src="https://cdn.tailwindcss.com"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
<style> | |
.gradient-bg { | |
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); | |
} | |
.result-card { | |
transition: all 0.3s ease; | |
} | |
.result-card:hover { | |
transform: translateY(-5px); | |
box-shadow: 0 10px 20px rgba(0,0,0,0.1); | |
} | |
.suspicious { | |
animation: pulse 2s infinite; | |
} | |
@keyframes pulse { | |
0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); } | |
70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } | |
100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } | |
} | |
.clean { | |
animation: pulse-clean 2s infinite; | |
} | |
@keyframes pulse-clean { | |
0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } | |
70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } | |
100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } | |
} | |
</style> | |
</head> | |
<body class="min-h-screen bg-gray-100"> | |
<div class="gradient-bg text-white py-12 px-4"> | |
<div class="max-w-4xl mx-auto text-center"> | |
<h1 class="text-4xl md:text-5xl font-bold mb-4">MAC Address Analyzer</h1> | |
<p class="text-xl mb-8 opacity-90">Check the legitimacy and details of any MAC address</p> | |
<div class="max-w-xl mx-auto bg-white bg-opacity-10 rounded-lg p-6 backdrop-blur-sm"> | |
<div class="flex items-center"> | |
<input type="text" id="macInput" placeholder="Enter MAC (e.g., D6:A6:7E:E1:7F:42)" | |
class="flex-grow px-4 py-3 rounded-l-lg bg-white bg-opacity-20 text-white placeholder-white placeholder-opacity-70 focus:outline-none focus:ring-2 focus:ring-blue-300"> | |
<button id="analyzeBtn" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded-r-lg font-medium transition-colors"> | |
<i class="fas fa-search mr-2"></i> Analyze | |
</button> | |
</div> | |
<p class="text-sm mt-2 text-white text-opacity-70">Supports formats: XX:XX:XX:XX:XX:XX, XX-XX-XX-XX-XX-XX, XXXXXXXXXXXX</p> | |
</div> | |
</div> | |
</div> | |
<div class="max-w-4xl mx-auto px-4 py-8" id="resultsSection" style="display: none;"> | |
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8"> | |
<div class="p-6"> | |
<div class="flex items-center justify-between mb-4"> | |
<h2 class="text-2xl font-bold text-gray-800">Analysis Results</h2> | |
<span id="finalVerdict" class="px-4 py-2 rounded-full text-sm font-semibold"></span> | |
</div> | |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
<div class="result-card bg-gray-50 p-6 rounded-lg border border-gray-200"> | |
<h3 class="text-lg font-semibold text-gray-700 mb-3">Basic Information</h3> | |
<div class="space-y-4"> | |
<div> | |
<p class="text-sm text-gray-500">Original MAC</p> | |
<p id="originalMac" class="font-mono text-gray-800"></p> | |
</div> | |
<div> | |
<p class="text-sm text-gray-500">Formatted MAC</p> | |
<p id="formattedMac" class="font-mono text-blue-600"></p> | |
</div> | |
<div> | |
<p class="text-sm text-gray-500">OUI (Vendor Prefix)</p> | |
<p id="oui" class="font-mono text-purple-600"></p> | |
</div> | |
</div> | |
</div> | |
<div class="result-card bg-gray-50 p-6 rounded-lg border border-gray-200"> | |
<h3 class="text-lg font-semibold text-gray-700 mb-3">Vendor Details</h3> | |
<div class="space-y-4"> | |
<div> | |
<p class="text-sm text-gray-500">Manufacturer</p> | |
<p id="vendor" class="font-medium"></p> | |
</div> | |
<div> | |
<p class="text-sm text-gray-500">Vendor Reputation</p> | |
<p id="vendorReputation" class="flex items-center"> | |
<span id="vendorIcon" class="mr-2"></span> | |
<span id="vendorText"></span> | |
</p> | |
</div> | |
<div> | |
<p class="text-sm text-gray-500">Network Presence</p> | |
<p id="networkPresence" class="flex items-center"> | |
<span id="networkIcon" class="mr-2"></span> | |
<span id="networkText"></span> | |
</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="bg-gray-50 px-6 py-4 border-t border-gray-200"> | |
<h3 class="text-lg font-semibold text-gray-700 mb-3">Security Analysis</h3> | |
<div class="space-y-4"> | |
<div id="macFormatCheck" class="flex items-start"> | |
<span class="mr-3 mt-1" id="formatIcon"></span> | |
<div> | |
<p class="font-medium" id="formatText"></p> | |
<p class="text-sm text-gray-600" id="formatDetails"></p> | |
</div> | |
</div> | |
<div id="macSuspiciousCheck" class="flex items-start"> | |
<span class="mr-3 mt-1" id="suspiciousIcon"></span> | |
<div> | |
<p class="font-medium" id="suspiciousText"></p> | |
<p class="text-sm text-gray-600" id="suspiciousDetails"></p> | |
</div> | |
</div> | |
<div id="macPatternCheck" class="flex items-start"> | |
<span class="mr-3 mt-1" id="patternIcon"></span> | |
<div> | |
<p class="font-medium" id="patternText"></p> | |
<p class="text-sm text-gray-600" id="patternDetails"></p> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div id="finalJudgement" class="p-6 border-t border-gray-200 text-center"> | |
<p class="text-xl font-bold mb-2" id="judgementText"></p> | |
<p class="text-gray-600" id="judgementDetails"></p> | |
</div> | |
</div> | |
<div class="bg-white rounded-xl shadow-lg overflow-hidden"> | |
<div class="p-6"> | |
<h3 class="text-xl font-bold text-gray-800 mb-4">About MAC Addresses</h3> | |
<div class="prose max-w-none text-gray-700"> | |
<p>A MAC (Media Access Control) address is a unique identifier assigned to network interfaces. The first 6 characters (OUI) identify the manufacturer, while the remaining 6 are device-specific.</p> | |
<p class="mt-2">Some devices may use randomized or spoofed MAC addresses for privacy reasons, which can appear suspicious in security checks. Common manufacturers like Foxconn produce many legitimate devices.</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
<footer class="bg-gray-800 text-white py-8 mt-12"> | |
<div class="max-w-4xl mx-auto px-4 text-center"> | |
<p class="mb-4">MAC Address Analyzer Tool - For educational purposes only</p> | |
<p class="text-gray-400 text-sm">Uses the macvendors.com API for vendor lookup. Network presence detection works only on local networks.</p> | |
</div> | |
</footer> | |
<script> | |
document.getElementById('analyzeBtn').addEventListener('click', function() { | |
const macInput = document.getElementById('macInput').value.trim(); | |
if (!macInput) { | |
alert('Please enter a MAC address'); | |
return; | |
} | |
// Show loading state | |
this.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Analyzing...'; | |
this.disabled = true; | |
// Simulate analysis (in a real app, you'd make API calls) | |
setTimeout(() => { | |
analyzeMAC(macInput); | |
this.innerHTML = '<i class="fas fa-search mr-2"></i> Analyze'; | |
this.disabled = false; | |
}, 1000); | |
}); | |
function analyzeMAC(mac) { | |
// Show results section | |
document.getElementById('resultsSection').style.display = 'block'; | |
// Format MAC address | |
const formattedMAC = formatMAC(mac); | |
document.getElementById('originalMac').textContent = mac; | |
document.getElementById('formattedMac').textContent = formattedMAC; | |
// Get OUI | |
const oui = getOUI(formattedMAC); | |
document.getElementById('oui').textContent = oui; | |
// Get vendor (simulated - in real app use API) | |
const vendor = lookupVendor(oui); | |
document.getElementById('vendor').textContent = vendor; | |
// Check vendor reputation | |
const isCommonVendor = vendor.includes('Foxconn') || vendor.includes('Hon Hai') || | |
vendor.includes('Intel') || vendor.includes('Samsung'); | |
const vendorReputation = isCommonVendor ? | |
{ icon: '<i class="fas fa-check-circle text-green-500"></i>', | |
text: 'Known manufacturer (common for legitimate devices)', status: 'good' } : | |
{ icon: '<i class="fas fa-exclamation-triangle text-yellow-500"></i>', | |
text: 'Less common manufacturer (check device authenticity)', status: 'warning' }; | |
document.getElementById('vendorIcon').innerHTML = vendorReputation.icon; | |
document.getElementById('vendorText').textContent = vendorReputation.text; | |
// Check network presence (simulated) | |
const isOnNetwork = Math.random() > 0.7; // 30% chance for demo | |
const networkPresence = isOnNetwork ? | |
{ icon: '<i class="fas fa-wifi text-green-500"></i>', | |
text: 'Device detected on local network', status: 'info' } : | |
{ icon: '<i class="fas fa-wifi-slash text-gray-500"></i>', | |
text: 'Device not found on local network', status: 'neutral' }; | |
document.getElementById('networkIcon').innerHTML = networkPresence.icon; | |
document.getElementById('networkText').textContent = networkPresence.text; | |
// Check MAC format | |
const formatCheck = formatMACCheck(formattedMAC); | |
document.getElementById('formatIcon').innerHTML = formatCheck.icon; | |
document.getElementById('formatText').textContent = formatCheck.text; | |
document.getElementById('formatDetails').textContent = formatCheck.details; | |
// Check for suspicious patterns | |
const suspiciousCheck = checkSuspicious(oui); | |
document.getElementById('suspiciousIcon').innerHTML = suspiciousCheck.icon; | |
document.getElementById('suspiciousText').textContent = suspiciousCheck.text; | |
document.getElementById('suspiciousDetails').textContent = suspiciousCheck.details; | |
// Check repeating patterns | |
const patternCheck = checkPatterns(oui); | |
document.getElementById('patternIcon').innerHTML = patternCheck.icon; | |
document.getElementById('patternText').textContent = patternCheck.text; | |
document.getElementById('patternDetails').textContent = patternCheck.details; | |
// Final verdict | |
const isClean = isCommonVendor && !suspiciousCheck.isSuspicious && !patternCheck.isSuspicious; | |
const verdict = isClean ? | |
{ text: '✅ Device appears legitimate', | |
details: 'MAC address matches known manufacturer with no suspicious patterns', | |
class: 'bg-green-100 text-green-800 clean' } : | |
{ text: '⚠️ Device needs further inspection', | |
details: 'Some aspects of this MAC address require additional verification', | |
class: 'bg-yellow-100 text-yellow-800 suspicious' }; | |
if (suspiciousCheck.isSuspicious || patternCheck.isSuspicious) { | |
verdict.text = '❌ Potentially suspicious MAC'; | |
verdict.details = 'This MAC address shows signs of possible spoofing or randomization'; | |
verdict.class = 'bg-red-100 text-red-800 suspicious'; | |
} | |
document.getElementById('finalVerdict').className = verdict.class; | |
document.getElementById('finalVerdict').textContent = verdict.text.split(' ')[0]; | |
document.getElementById('judgementText').textContent = verdict.text; | |
document.getElementById('judgementDetails').textContent = verdict.details; | |
document.getElementById('finalJudgement').className = `p-6 border-t border-gray-200 text-center ${verdict.class.includes('suspicious') ? 'suspicious' : 'clean'}`; | |
// Scroll to results | |
document.getElementById('resultsSection').scrollIntoView({ behavior: 'smooth' }); | |
} | |
function formatMAC(mac) { | |
// Remove all non-alphanumeric characters and uppercase | |
const cleanMAC = mac.replace(/[^a-fA-F0-9]/g, '').toUpperCase(); | |
// Format as XX:XX:XX:XX:XX:XX | |
return cleanMAC.replace(/(.{2})(?=.)/g, '$1:'); | |
} | |
function getOUI(mac) { | |
return mac.replace(/:/g, '').substring(0, 6); | |
} | |
function lookupVendor(oui) { | |
// Simulated vendor database for demo | |
const vendors = { | |
'D6A67E': 'Foxconn International, Inc.', | |
'001122': 'Test Vendor (Suspicious)', | |
'AABBCC': 'Randomized Address', | |
'DEADBE': 'Suspicious Pattern', | |
'BEEF01': 'Suspicious Pattern', | |
'C0FFEE': 'Suspicious Pattern', | |
'123456': 'Test Manufacturer', | |
'ABCDEF': 'Demo Vendor' | |
}; | |
return vendors[oui] || 'Unknown Manufacturer'; | |
} | |
function formatMACCheck(mac) { | |
const isValid = /^([0-9A-F]{2}:){5}[0-9A-F]{2}$/.test(mac); | |
return { | |
icon: isValid ? '<i class="fas fa-check-circle text-green-500"></i>' : '<i class="fas fa-times-circle text-red-500"></i>', | |
text: isValid ? 'Valid MAC format' : 'Invalid MAC format', | |
details: isValid ? 'Address follows standard MAC address formatting' : 'Address has formatting issues' | |
}; | |
} | |
function checkSuspicious(oui) { | |
const suspiciousOuis = ['000000', 'FFFFFF', '123456', 'DEADBE', 'BEEF01', 'C0FFEE']; | |
const isSuspicious = suspiciousOuis.includes(oui); | |
return { | |
icon: isSuspicious ? '<i class="fas fa-exclamation-triangle text-red-500"></i>' : '<i class="fas fa-check-circle text-green-500"></i>', | |
text: isSuspicious ? 'Suspicious OUI detected' : 'No suspicious OUI patterns', | |
details: isSuspicious ? 'This OUI is commonly used in testing or spoofing' : 'OUI appears normal', | |
isSuspicious: isSuspicious | |
}; | |
} | |
function checkPatterns(oui) { | |
// Check for repeating patterns (e.g., A1A1A1) or sequential (e.g., 123456) | |
const isRepeating = /^(.)\1{5}$/.test(oui); | |
const isSequential = oui === '123456' || oui === 'ABCDEF'; | |
const isSuspicious = isRepeating || isSequential; | |
let details = 'No suspicious patterns detected'; | |
if (isRepeating) details = 'Repeating character pattern (common in spoofed addresses)'; | |
if (isSequential) details = 'Sequential pattern (common in testing or spoofed addresses)'; | |
return { | |
icon: isSuspicious ? '<i class="fas fa-exclamation-triangle text-red-500"></i>' : '<i class="fas fa-check-circle text-green-500"></i>', | |
text: isSuspicious ? 'Suspicious pattern detected' : 'No suspicious patterns', | |
details: details, | |
isSuspicious: isSuspicious | |
}; | |
} | |
</script> | |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Rayan545454/r3aaaa" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
</html> |