# 554,8554 - Pentesting RTSP

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS 红队专家）</strong></a><strong>！</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想看到您的**公司在 HackTricks 中做广告**或**下载 PDF 版本的 HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索[**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在 **Twitter** 上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来分享您的黑客技巧。

</details>

## 基本信息

来自 [维基百科](https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol)：

> **实时流媒体传输协议**（**RTSP**）是一种网络控制协议，旨在用于娱乐和通信系统中控制流媒体服务器。该协议用于在端点之间建立和控制媒体会话。媒体服务器的客户端发出类似 VHS 风格的命令，如播放、录制和暂停，以便实时控制从服务器流式传输到客户端（视频点播）或从客户端到服务器（语音录制）的媒体流。
>
> 流媒体数据的传输本身不是 RTSP 的任务。大多数 RTSP 服务器与实时传输协议（RTP）结合使用实时控制协议（RTCP）进行媒体流传递。但是，一些供应商实现了专有的传输协议。例如，RealNetworks 的 RTSP 服务器软件还使用了 RealNetworks 的专有实时数据传输（RDT）。

**默认端口：** 554, 8554

```
PORT    STATE SERVICE
554/tcp open  rtsp
```

## 关键细节

**RTSP** 类似于 HTTP，但专门设计用于媒体流。它在一份简单的规范中定义，可以在这里找到：

[RTSP – RFC2326](https://tools.ietf.org/html/rfc2326)

设备可能允许**未经身份验证**或**经过身份验证**的访问。要检查，会发送一个 "DESCRIBE" 请求。下面是一个基本示例：

`DESCRIBE rtsp://<ip>:<port> RTSP/1.0\r\nCSeq: 2`

请记住，正确的格式包括一个双 "\r\n" 以获得一致的响应。"200 OK" 响应表示**未经身份验证**的访问，而 "401 Unauthorized" 表示需要进行身份验证，揭示了是否需要**基本身份验证**或**摘要身份验证**。

对于**基本身份验证**，您需要将用户名和密码进行 base64 编码，并将其包含在请求中，如下所示：

`DESCRIBE rtsp://<ip>:<port> RTSP/1.0\r\nCSeq: 2\r\nAuthorization: Basic YWRtaW46MTIzNA==`

此示例使用 "admin" 和 "1234" 作为凭据。以下是一个用于发送此类请求的**Python 脚本**：

```python
import socket
req = "DESCRIBE rtsp://<ip>:<port> RTSP/1.0\r\nCSeq: 2\r\nAuthorization: Basic YWRtaW46MTIzNA==\r\n\r\n"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.1.1", 554))
s.sendall(req)
data = s.recv(1024)
print(data)
```

**基本身份验证**更简单且更受青睐。**摘要身份验证**需要小心处理“401未经授权”响应中提供的身份验证详细信息。

本概述简化了访问RTSP流的过程，重点介绍了**基本身份验证**，因为在最初尝试中，它更简单且实用。

## 枚举

获取有关支持的有效方法和URL的信息，并尝试暴力破解访问（如果需要）以访问内容。

```bash
nmap -sV --script "rtsp-*" -p <PORT> <IP>
```

### [暴力破解](/generic-methodologies-and-resources/brute-force.md#rtsp)

### **其他有用的程序**

用于暴力破解：<https://github.com/Tek-Security-Group/rtsp_authgrinder>

[**Cameradar**](https://github.com/Ullaakut/cameradar)

* 检测任何可访问目标上的开放RTSP主机
* 获取它们的公共信息（主机名、端口、摄像头型号等）
* 启动自动字典攻击以获取它们的流路由（例如/live.sdp）
* 启动自动字典攻击以获取摄像头的用户名和密码
* 从中生成缩略图，以检查流是否有效，并快速预览其内容
* 尝试创建一个Gstreamer管道，以检查它们是否被正确编码
* 打印Cameradar能够获取的所有信息的摘要

## 参考资料

* <https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol>
* <http://badguyfu.net/rtsp-brute-forcing-for-fun-and-naked-pictures/>
* <https://github.com/Ullaakut/cameradar>

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF版本的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**上关注**我们。
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: 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:

```
GET https://hacktricks.xsx.tw/network-services-pentesting/554-8554-pentesting-rtsp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
