العودة إلى التحديثات
New releaseSep 11, 2026

mzap v2.2.1

⚡️ مسح ZAP لأهداف متعددة

مشاركة

mzap

mzap هي أداة واجهة سطر أوامر بلغة كريستال لفحص ZAP متعدد الأهداف. تقوم بتوزيع الأهداف عبر مضيف واحد أو أكثر لواجهة برمجة تطبيقات ZAP، وتدعم وضع الانتظار الاختياري، ويمكنها تصدير التقارير.

الميزات

  • أوامر المسح: spider, ajaxspider, clientspider (ZAP 2.16+), ascan, pscan
  • استيراد تعريفات API لأنواع openapi, soap, graphql, و postman
  • تصدير/تقليم شجرة المواقع لمسح تفاضلي/تزايدي في ZAP 2.16+
  • اكتشاف سياسات المسح (policies)
  • التوزيع على عدة مضيفين بجدولة دائريّة
  • وضع الانتظار/الاستقصاء الاختياري مع دعم المهلة الزمنية
  • تصدير التقارير (html/pdf/json/md/sarif) مع سلوك احتياطي
  • بوابة المخاطر --fail-on لأكواد الخروج في CI
  • أوامر الإيقاف لـ spider, ajaxspider, clientspider, ascan, أو all
  • تحميل التكوين الاختياري من $HOME/.config/mzap/config.toml ومسارات قديمة

المتطلبات

  • Crystal >= 1.19.1
  • نقطة نهاية (أو نقاط نهاية) لواجهة برمجة تطبيقات ZAP قيد التشغيل

التثبيت

Homebrew

brew install hahwul/mzap/mzap

البناء من المصدر

shards install --frozen
crystal build --release src/mzap_cli.cr -o bin/mzap

التشغيل بدون بناء

crystal run src/mzap_cli.cr -- version

صورة Docker

docker build -t mzap .
docker run --rm -v "$PWD:/work" mzap spider --urls /work/samples/target.txt --apis http://host.docker.internal:8090

الاستخدام

Usage:
  mzap [command]

Subcommands:
  ajaxspider    بدء مسح Ajax Spider في ZAP
  ascan         بدء مهام المسح النشط في ZAP
  clientspider  بدء مسح Client Spider في ZAP (ZAP 2.16+)
  help          عرض المساعدة لأمر معين
  import        استيراد تعريفات API (openapi/soap/graphql/postman)
  policies      عرض سياسات المسح النشط في ZAP
  pscan         انتظار اكتمال المسح السلبي في ZAP
  sitestree     تصدير أو تقليم شجرة المواقع ZAP (ZAP 2.16+)
  spider        بدء مسح Spider في ZAP
  stop          إيقاف عمليات المسح الجارية
  version       عرض إصدار mzap

Flags:
  --apikey string        مفتاح API ZAP (احذف عندما تكون مصادقة مفتاح API معطلة)
  --apis string          عناوين URL لمضيف API ZAP مفصولة بفواصل
                         e.g. --apis http://localhost:8090,http://192.168.0.4:8090 (default "http://localhost:8090")
  --config string        مسار ملف التكوين (يدعم TOML؛ الافتراضي: $HOME/.config/mzap/config.toml)
  --context string       ملف سياق ZAP لاستيراده قبل المسح
  --fail-on string       الفشل برمز خروج 1 إذا كانت التنبيهات في مستوى المخاطرة أو أعلى
  --format string        تنسيق تعريف API للاستيراد (openapi/soap/graphql/postman)
  --target-url string    تجاوز عنوان URL للهدف/نقطة النهاية للاستيراد
  --policy string        اسم سياسة المسح للمسح النشط
  --report-format        تنسيق التقرير بعد اكتمال المسح (html/pdf/json/md/sarif)
  --report-out           مسار إخراج التقرير (الافتراضي: mzap-report-<timestamp>.<ext>)
  --concurrency          عدد التوزيعات المتوازية للمسح (الافتراضي 1)
  --wait                 انتظار اكتمال عمليات المسح التي بدأت
  --wait-interval        فاصل الاستقصاء بالثواني أثناء الانتظار (الافتراضي 2)
  --wait-timeout         مهلة الانتظار بالثواني (الافتراضي 0: لا مهلة)
  -h, --help             عرض المساعدة لـ mzap
  --urls string          مسار ملف قائمة URL (مثال: --urls hosts.txt)

قم بتشغيل mzap help <command> للحصول على الأعلام الخاصة بالأمر.

أمثلة

# spider scan with two ZAP API hosts
mzap spider --urls samples/target.txt --apis http://localhost:8090,http://192.168.0.4:8090

# run scan, wait for completion, and generate an HTML report
mzap spider --urls samples/target.txt --apis http://localhost:8090 --wait --report-format html --report-out reports/mzap.html

# Client Spider (browser-based crawler, ZAP 2.16+; needs the Client Side Integration add-on)
mzap clientspider --urls samples/target.txt --apis http://localhost:8090 --wait

# import an OpenAPI definition, wait for passive scan, gate CI on high-risk alerts
mzap import --format openapi --urls samples/specs.txt --target-url https://api.example.com \
  --apis http://localhost:8090 --wait --report-format sarif --fail-on high

# import API specs from stdin
echo https://api.example.com/openapi.json | mzap import --format openapi --urls -

# discover available scan policies (then use one with `ascan --policy`)
mzap policies --apis http://localhost:8090

# Sites Tree baseline for differential scanning (path resolved by the ZAP daemon)
mzap sitestree export baseline.tree --apis http://localhost:8090
mzap sitestree prune baseline.tree --apis http://localhost:8090

# stop all running scan types
mzap stop all --apis http://localhost:8090

استيراد APIs: يقوم mzap import بإعداد شجرة مواقع ZAP ويتيح تشغيل المسح السلبي؛ للمسح النشط لنقاط النهاية المستوردة لاحقًا، قم بتشغيل mzap ascan على نفس الهدف (الأهداف). بالنسبة للملفات المحلية، يتم حل المسارات في --urls--target-url) بواسطة خادم ZAP، لذا قم بتركيبها داخل الحاوية عند تشغيل ZAP في Docker.

التكوين

يقوم mzap تلقائيًا بتحميل التكوين عند وجوده.

الأولوية هي:

  1. المسار الصريح --config (إذا كان موجودًا)
  2. $HOME/.config/mzap/config.toml
  3. $HOME/.config/mzap/config + متغيرات الامتداد
  4. $HOME/.mzap + متغيرات الامتداد

تتجاوز أعلام CLI دائمًا قيم التكوين.

[mzap]
apis = ["http://localhost:8090", "http://192.168.0.4:8090"]
apikey = "your-zap-api-key"
urls = "samples/target.txt"
wait = true
wait_interval = 2
wait_timeout = 0
report_format = "html"
report_out = "reports/mzap.html"

إجراء GitHub

يحتوي هذا المستودع على إجراء GitHub قائم على Docker (action.yml).

- name: Run mzap
  uses: hahwul/mzap@<tag>
  with:
    arguments: "spider --urls samples/target.txt --apis http://localhost:8090"

التطوير

# tests
crystal spec

# release build
crystal build --release src/mzap_cli.cr -o bin/mzap

الفئات