Commit History

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

Rayan545454 commited on

initial commit
badf65f
verified

Rayan545454 commited on