> 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/windows-vulnerabilities/scheduled-tasks.md).

# Windowsのスケジュールタスク

昇格した実行コンテキスト、書き込み可能なターゲット、弱いスクリプト、古い自動化資格情報をWindowsのスケジュールタスクで確認する。

自動化が特権アカウントで実行される一方で、低権限のユーザーが変更できるファイル、スクリプト、またはコマンドのパスを実行する場合、スケジュールされたタスクは権限昇格の有用な対象になります。

## 列挙

まずは組み込みのタスク スケジューラの出力から始めます:

```cmd
schtasks /query /fo LIST /v
```

PowerShell を使うと、タスクのアクションを確認しやすくなります:

```powershell
Get-ScheduledTask |
  ForEach-Object {
    [PSCustomObject]@{
      TaskName = $_.TaskName
      TaskPath = $_.TaskPath
      State = $_.State
      Author = $_.Author
      Actions = ($_.Actions | ForEach-Object { $_.Execute + " " + $_.Arguments }) -join "; "
    }
  }
```

## タスクが興味深いものになる条件

次の条件に当てはまるタスクを探します:

* タスクは次のアカウントで実行されます `SYSTEM`、管理者、またはサービス アカウント。
* アクションが、保護された Windows パス外のスクリプトまたは実行可能ファイルを指している。
* 対象ファイルまたはその親ディレクトリのいずれかに書き込み可能である。
* 引数に資格情報、ネットワーク パス、トークン、または API キーが含まれている。
* タスクを手動でトリガーできる、頻繁に実行される、またはユーザーのログオン時に実行される。

## 対象パスを確認する

タスクで使用される実行可能ファイルまたはスクリプトを特定したら、アクセス権を確認します。

```cmd
icacls "C:\Path\To\task-script.ps1"
icacls "C:\Path\To"
```

```powershell
Get-Acl "C:\Path\To\task-script.ps1" | Format-List
```

次のような書き込み可能なグループが `ユーザー`, `認証済みユーザー`や `すべてのユーザー` は、タスクが昇格して実行される場合は疑わしいです。

## 安全に検証する

まずは無害なマーカーを使い、スケジュールされた処理を壊さずに実行コンテキストを確認します。

```powershell
'whoami > C:\Windows\Temp\task-check.txt' | Out-File -Encoding ASCII C:\Path\To\task-script.ps1
```

ユーザーに権限がある場合は、タスクをトリガーします:

```cmd
schtasks /run /tn "\Task\Name"
type C:\Windows\Temp\task-check.txt
```

手動でトリガーできない場合は、次回の実行時刻を記録します:

```cmd
schtasks /query /tn "\Task\Name" /fo LIST /v
```

## 資格情報の手がかり

タスクは、コマンド引数や割り当て済みネットワーク パスを通じて秘密情報を露出することがあります。

```cmd
schtasks /query /fo LIST /v | findstr /i "password user runas /ru /rp \\\\"
```

```powershell
Get-ScheduledTask |
  Select-Object -ExpandProperty Actions |
  Select-String -Pattern 'password|passwd|pwd|token|secret|\\\\'
```

## クリーンアップ

テスト後は元の対象ファイルを元に戻し、一時的なマーカーを削除します。

```cmd
del C:\Windows\Temp\task-check.txt
```

## 重要ポイント

* タスクのアカウントと対象のアクセス許可は、タスク名よりも重要です。
* 書き込み可能なスクリプトは、バイナリを置き換えるよりも検証しやすいことが一般的です。
* 証拠を記録します: タスク名、実行アカウント、アクションのパス、ACL 出力、およびトリガー条件。


---

# 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/windows-vulnerabilities/scheduled-tasks.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.
