الاستطلاع (Reconnaissance) — الاختراق الأخلاقي
الاستطلاع - Reconnaissance
ما هو الاستطلاع؟
جمع أكبر قدر من المعلومات عن الهدف قبل الهجوم.
أنواع الاستطلاع
Passive Reconnaissance
- بدون تفاعل مباشر مع الهدف
- لا يعرف الهدف أنك تبحث عنه
- آمن قانونياً
Active Reconnaissance
- تفاعل مباشر مع الهدف
- يمكن اكتشافك
- يحتاج إذن
أدوات Passive Recon
1. WHOIS
معلومات تسجيل النطاق
whois example.com2. DNS Lookup
سجلات DNS
nslookup example.com
dig example.com ANY3. Google Dorks
بحث متقدم في Google
site:example.com filetype:pdf
site:example.com inurl:admin
site:example.com "password"4. Shodan
محرك بحث للأجهزة المتصلة
shodan search hostname:example.com5. theHarvester
جمع الإيميلات والنطاقات الفرعية
6. Social Media
- LinkedIn: معلومات الموظفين
- Twitter: تسريبات
- GitHub: كود مكشوف
أدوات Active Recon
1. Nmap
فحص المنافذ
nmap -sV example.com2. Nikto
فحص ثغرات الويب
3. dirb/gobuster
اكتشاف الملفات والمجلدات المخفية
ما نبحث عنه؟
- عناوين IP
- النطاقات الفرعية
- إيميلات الموظفين
- التقنيات المستخدمة
- المنافذ المفتوحة
- الثغرات المعروفة
# أدوات استطلاع بـ Python
import socket
import dns.resolver
import requests
import re
class ReconTools:
"""
أدوات استطلاع للاختراق الأخلاقي
⚠️ استخدم فقط على أهداف مصرّح لك باختبارها!
"""
def __init__(self, target):
self.target = target
self.results = {
"ips": [],
"subdomains": [],
"emails": [],
"technologies": [],
"dns_records": {}
}
# ===== Passive Reconnaissance =====
def dns_lookup(self):
"""استعلام DNS"""
print(f"\n🔍 DNS Lookup لـ {self.target}")
record_types = ['A', 'AAAA', 'MX', 'NS', 'TXT', 'CNAME']
for record_type in record_types:
try:
answers = dns.resolver.resolve(self.target, record_type)
records = [str(r) for r in answers]
self.results["dns_records"][record_type] = records
print(f" {record_type}: {records}")
except:
pass
return self.results["dns_records"]
def reverse_dns(self, ip):
"""Reverse DNS lookup"""
try:
hostname = socket.gethostbyaddr(ip)
return hostname[0]
except:
return None
def find_subdomains(self, wordlist=None):
"""اكتشاف النطاقات الفرعية"""
print(f"\n🔍 البحث عن نطاقات فرعية...")
if wordlist is None:
wordlist = [
'www', 'mail', 'ftp', 'admin', 'blog',
'api', 'dev', 'test', 'staging', 'app',
'shop', 'store', 'portal', 'vpn', 'remote',
'cdn', 'static', 'assets', 'media', 'img'
]
found = []
for sub in wordlist:
subdomain = f"{sub}.{self.target}"
try:
socket.gethostbyname(subdomain)
found.append(subdomain)
print(f" ✅ {subdomain}")
except socket.gaierror:
pass
self.results["subdomains"] = found
return found
def extract_emails_from_text(self, text):
"""استخراج الإيميلات من نص"""
email_pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
emails = re.findall(email_pattern, text)
return list(set(emails))
def check_robots_txt(self):
"""فحص ملف robots.txt"""
print(f"\n🔍 فحص robots.txt...")
urls = [
f"https://{self.target}/robots.txt",
f"http://{self.target}/robots.txt"
]
for url in urls:
try:
response = requests.get(url, timeout=5)
if response.status_code == 200:
print(f" ✅ وُجد: {url}")
# استخراج المسارات المخفية
disallowed = re.findall(r'Disallow: (.+)', response.text)
if disallowed:
print(" المسارات الممنوعة:")
for path in disallowed[:10]:
print(f" - {path.strip()}")
return response.text
except:
pass
print(" ❌ غير موجود")
return None
def detect_technologies(self):
"""اكتشاف التقنيات المستخدمة"""
print(f"\n🔍 اكتشاف التقنيات...")
try:
response = requests.get(f"https://{self.target}", timeout=5)
headers = response.headers
tech = []
# من Headers
if 'X-Powered-By' in headers:
tech.append(f"Powered-By: {headers['X-Powered-By']}")
if 'Server' in headers:
tech.append(f"Server: {headers['Server']}")
# من HTML
html = response.text.lower()
if 'wp-content' in html or 'wordpress' in html:
tech.append("WordPress")
if 'react' in html or 'reactdom' in html:
tech.append("React")
if 'angular' in html:
tech.append("Angular")
if 'vue' in html:
tech.append("Vue.js")
if 'laravel' in html:
tech.append("Laravel")
for t in tech:
print(f" ✅ {t}")
self.results["technologies"] = tech
return tech
except Exception as e:
print(f" ❌ خطأ: {e}")
return []
def google_dorks(self):
"""توليد Google Dorks للهدف"""
print(f"\n🔍 Google Dorks لـ {self.target}")
dorks = [
f"site:{self.target}",
f"site:{self.target} filetype:pdf",
f"site:{self.target} filetype:doc",
f"site:{self.target} inurl:admin",
f"site:{self.target} inurl:login",
f"site:{self.target} inurl:config",
f"site:{self.target} intitle:index.of",
f'site:{self.target} "password"',
f'site:{self.target} "username"',
f'site:{self.target} "api_key"',
]
print(" استخدم هذه في Google:")
for dork in dorks:
print(f" {dork}")
return dorks
def full_scan(self):
"""فحص شامل"""
print(f"\n{'='*50}")
print(f" فحص استطلاع شامل لـ {self.target}")
print(f"{'='*50}")
self.dns_lookup()
self.find_subdomains()
self.check_robots_txt()
self.detect_technologies()
self.google_dorks()
print(f"\n{'='*50}")
print(" النتائج النهائية")
print(f"{'='*50}")
print(f" النطاقات الفرعية: {len(self.results['subdomains'])}")
print(f" التقنيات: {len(self.results['technologies'])}")
return self.results
# مثال (استخدم على أهداف مصرّح لك باختبارها فقط!)
# recon = ReconTools("example.com")
# recon.full_scan()اختبر فهمك