> 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 表达式，例如 `* * * * *`, `*/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 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/privesc/cron-jobs/cron-expression-calculator.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.
