البحث في NVD
إزاي تدوّر على ثغرة في NVD بالـ CVE أو اسم المنتج، وتقرا الصفحة: الوصف و CVSS و CWE والإصدارات المتأثرة والـ References، وتقرا نتيجة الـ NVD API بـ Python.
نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.
دلوقتي عندنا اسم خدمة وإصدار، زي Apache اتنين أربعة تسعة وأربعين. أول مكان رسمي تدوّر فيه: NVD.
الـ NVD، أو National Vulnerability Database، قاعدة بيانات أمريكية مجانية فيها كل الـ CVEs. تقدر تدوّر برقم CVE. أو باسم المنتج والإصدار. وفيه API تقدر تكلّمه من الـ code.
إيه اللي تقراه في صفحة الثَغْرة؟ الوصف: الثَغْرة بتعمل إيه. الـ CVSS والـ vector. الـ CWE: نوع الغلطة. الإصدارات المتأثرة، ودي اسمها CPE. والـ References: روابط للـ advisory الرسمي، وساعات لـ exploit جاهز.
وخد بالك من حاجة مهمة: اقرا الإصدارات المتأثرة كويس. ساعات الثَغْرة في إصدار واحد بس، زي اتنين أربعة تسعة وأربعين، والإصلاح في الإصدار اللي بعده كان ناقص، فطلعت ثَغْرة تانية. هنا رد الـ NVD API محفوظ ومختصر. بندخل جُوّه الـ JSON خطوة خطوة: vulnerabilities، وبعدين cve، وبعدين metrics علشان نوصل للـ score. نشغّل… الرقم، والدرجة سبعة ونص High، وأول جزء من الوصف.
import json
# Saved, shortened answer of the NVD API:
# https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-41773
data = json.loads("""{"vulnerabilities": [{"cve": {
"id": "CVE-2021-41773",
"published": "2021-10-05T09:15:07",
"descriptions": [{"lang": "en", "value": "A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives."}],
"metrics": {"cvssMetricV31": [{"cvssData": {"baseScore": 7.5, "baseSeverity": "HIGH", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"}}]},
"weaknesses": [{"description": [{"value": "CWE-22"}]}],
"references": [{"url": "https://httpd.apache.org/security/vulnerabilities_24.html"}, {"url": "http://packetstormsecurity.com/files/164418/Exploit.html"}]
}}]}""")
cve = data["vulnerabilities"][0]["cve"]
cvss = cve["metrics"]["cvssMetricV31"][0]["cvssData"]
print(cve["id"], cvss["baseScore"], cvss["baseSeverity"])
print(cve["descriptions"][0]["value"][:90] + "...")المخرجات
CVE-2021-41773 7.5 HIGH A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An a...
دورك: اطبع الـ CWE، وبعدين كل الروابط اللي في الـ references.
اطبع cve["weaknesses"][0]["description"][0]["value"] ولِف على cve["references"].
الحل: نشغّل… CWE twenty two، ورابطين. والتاني على Packet Storm، وده معناه إن فيه exploit منشور. ودي معلومة مهمة جداً.
import json
# Saved, shortened answer of the NVD API:
# https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-41773
data = json.loads("""{"vulnerabilities": [{"cve": {
"id": "CVE-2021-41773",
"published": "2021-10-05T09:15:07",
"descriptions": [{"lang": "en", "value": "A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives."}],
"metrics": {"cvssMetricV31": [{"cvssData": {"baseScore": 7.5, "baseSeverity": "HIGH", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"}}]},
"weaknesses": [{"description": [{"value": "CWE-22"}]}],
"references": [{"url": "https://httpd.apache.org/security/vulnerabilities_24.html"}, {"url": "http://packetstormsecurity.com/files/164418/Exploit.html"}]
}}]}""")
cve = data["vulnerabilities"][0]["cve"]
cvss = cve["metrics"]["cvssMetricV31"][0]["cvssData"]
print(cve["id"], cvss["baseScore"], cvss["baseSeverity"])
print(cve["descriptions"][0]["value"][:90] + "...")
print("CWE:", cve["weaknesses"][0]["description"][0]["value"])
for ref in cve["references"]:
print("ref:", ref["url"])المخرجات
CVE-2021-41773 7.5 HIGH A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An a... CWE: CWE-22 ref: https://httpd.apache.org/security/vulnerabilities_24.html ref: http://packetstormsecurity.com/files/164418/Exploit.html
الدرس الجاي: إزاي تلاقي الـ exploits نفسها، في Exploit DB و searchsploit. يلا بينا.
03 / دروس المسار (16)
- 01يعني إيه ثغرة؟ ومن الـ Recon للـ Vulnerabilities
- 02CVE و CWE: أسماء الثغرات
- 03الخطورة: CVSS و EPSS و KEV
- 04البحث في NVDانت هنا
- 05Exploit-DB و searchsploit
- 06GitHub و Metasploit
- 07الفحص بـ Nmap NSE
- 08الفحص بـ Nuclei
- 09الفحص بـ Nikto
- 10الفحص بـ OpenVAS
- 11فحص بصلاحيات ومن غيرها
- 12تجميع وتنظيم النتايج
- 13False Positives والتأكد اليدوي
- 14ترتيب الأولويات
- 15أتمتة الفحص بـ Python
- 16مراجعة شاملة