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

# Cron 表达式计算器

常见计划、字段语法、特殊字符串以及权限提升审查笔记的 Cron 表达式计算器。

搜索一个 cron 表达式，例如 `* * * * *`, `*/5 * * * *`, `0 0 * * *`或 `@reboot` 以查看其计划和渗透测试备注。

## Cron 查找器

<table data-view="cards" data-full-width="true" data-search="true"><thead><tr><th>表达式</th><th>含义</th><th>典型用途</th><th>查看备注</th></tr></thead><tbody><tr><td><code>* * * * *</code></td><td>每分钟</td><td>高频重复任务</td><td>如果脚本可写，对提权很有价值。</td></tr><tr><td><code>*/2 * * * *</code></td><td>每 2 分钟</td><td>轮询任务</td><td>使用 pspy 观察执行情况。</td></tr><tr><td><code>*/5 * * * *</code></td><td>每 5 分钟</td><td>健康检查、同步任务</td><td>检查命令路径和可写目标。</td></tr><tr><td><code>*/10 * * * *</code></td><td>每 10 分钟</td><td>维护任务</td><td>查找相对路径和不安全的 PATH。</td></tr><tr><td><code>*/15 * * * *</code></td><td>每 15 分钟</td><td>计划同步</td><td>检查日志和脚本所有权。</td></tr><tr><td><code>*/30 * * * *</code></td><td>每 30 分钟</td><td>周期性清理</td><td>检查删除命令和通配符。</td></tr><tr><td><code>0 * * * *</code></td><td>每小时</td><td>每小时任务</td><td>也检查 `/etc/cron.hourly`。</td></tr><tr><td><code>30 * * * *</code></td><td>每小时的第 30 分钟</td><td>每小时偏移</td><td>在半点附近监控。</td></tr><tr><td><code>0 */2 * * *</code></td><td>每 2 小时</td><td>批处理任务</td><td>检查备份和同步目录中的脚本。</td></tr><tr><td><code>0 0 * * *</code></td><td>每天午夜</td><td>每日轮转</td><td>检查 `/etc/cron.daily` 和备份脚本。</td></tr><tr><td><code>30 2 * * *</code></td><td>每天 02:30</td><td>夜间维护</td><td>root 备份任务的常见时间。</td></tr><tr><td><code>0 6 * * *</code></td><td>每天 06:00</td><td>早间任务</td><td>检查报告生成和清理脚本。</td></tr><tr><td><code>0 0 * * 0</code></td><td>每周日午夜</td><td>每周任务</td><td>检查 `/etc/cron.weekly`。</td></tr><tr><td><code>0 0 * * 1</code></td><td>每周一午夜</td><td>每周任务</td><td>检查工作日脚本。</td></tr><tr><td><code>0 0 1 * *</code></td><td>每月第一天</td><td>月报</td><td>检查 `/etc/cron.monthly`。</td></tr><tr><td><code>0 0 1 1 *</code></td><td>每年 1 月 1 日午夜</td><td>年度任务</td><td>频率低，但可能以 root 身份运行。</td></tr><tr><td><code>0 9-17 * * 1-5</code></td><td>周一至周五 09:00 到 17:00 每小时</td><td>工作时间自动化</td><td>检查管理员任务使用的用户脚本。</td></tr><tr><td><code>*/15 9-17 * * 1-5</code></td><td>工作时间内每 15 分钟</td><td>办公时间轮询</td><td>适合使用 pspy 的目标时间窗口。</td></tr><tr><td><code>0 0,12 * * *</code></td><td>在午夜和正午</td><td>每日两次任务</td><td>用逗号分隔的小时。</td></tr><tr><td><code>0 3 * * 1,3,5</code></td><td>周一、周三、周五 03:00</td><td>计划批处理</td><td>检查星期匹配。</td></tr><tr><td><code>@reboot</code></td><td>系统启动时</td><td>启动脚本</td><td>检查持久化和可写的启动命令。</td></tr><tr><td><code>@hourly</code></td><td>每小时一次</td><td>每小时快捷方式</td><td>等同于 `0 * * * *`。</td></tr><tr><td><code>@daily</code></td><td>每天一次</td><td>每日快捷方式</td><td>等同于 `0 0 * * *`。</td></tr><tr><td><code>@weekly</code></td><td>每周一次</td><td>每周快捷方式</td><td>等同于 `0 0 * * 0`。</td></tr><tr><td><code>@monthly</code></td><td>每月一次</td><td>每月快捷方式</td><td>等同于 `0 0 1 * *`。</td></tr><tr><td><code>@yearly</code></td><td>每年一次</td><td>每年快捷方式</td><td>等同于 `0 0 1 1 *`。</td></tr></tbody></table>

## 字段计算器

```
* * * * *
| | | | |
| | | | +-- 星期几：0-7，星期日为 0 或 7
| | | +---- 月份：1-12
| | +------ 每月日期：1-31
| +-------- 小时：0-23
+---------- 分钟：0-59
```

| 运算符 | 含义  | 示例                            |
| --- | --- | ----------------------------- |
| `*` | 任意值 | `* * * * *` 每分钟               |
| `,` | 值列表 | `0 0,12 * * *` 午夜和正午          |
| `-` | 范围  | `0 9-17 * * *` 从 09 到 17 点每小时 |
| `/` | 步进  | `*/5 * * * *` 每 5 分钟          |

## 枚举命令

```bash
crontab -l
cat /etc/crontab
ls -la /etc/cron.*
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
```

## 提权检查清单

| 检查             | 为什么这很重要             |
| -------------- | ------------------- |
| 由 root 执行的可写脚本 | 直接的特权命令执行路径         |
| 相对命令路径         | PATH 劫持可能控制执行的二进制文件 |
| 可写目录中的通配符      | 针对以下工具的选项注入 `tar`   |
| 所有人可写的 cron 目录 | 文件植入或脚本替换           |
| root 任务处理用户文件  | 通过输入文件进行解析器或命令注入    |
| 缺少完整路径         | 依赖环境的行为             |
| 日志会暴露计划        | 有助于时间验证和证据收集        |


---

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