# 137,138,139 - Pentesting NetBios

<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>

## NetBios名称服务

**NetBIOS名称服务**发挥着关键作用，涉及各种服务，如**名称注册和解析**，**数据报分发**和**会话服务**，每种服务都使用特定的端口。

[来自Wikidepia](https://en.wikipedia.org/wiki/NetBIOS_over_TCP/IP):

* 用于名称注册和解析的名称服务（端口：137/udp和137/tcp）。
* 用于无连接通信的数据报分发服务（端口：138/udp）。
* 用于面向连接的通信的会话服务（端口：139/tcp）。

### 名称服务

要使设备参与NetBIOS网络，它必须具有唯一的名称。这是通过**广播过程**实现的，其中发送“名称查询”数据包。如果没有收到异议，该名称被视为可用。或者，可以直接查询**名称服务服务器**以检查名称是否可用或将名称解析为IP地址。工具如`nmblookup`，`nbtscan`和`nmap`用于枚举NetBIOS服务，显示服务器名称和MAC地址。

```bash
PORT    STATE SERVICE    VERSION
137/udp open  netbios-ns Samba nmbd netbios-ns (workgroup: WORKGROUP)
```

枚举NetBIOS服务，您可以获取服务器正在使用的名称和服务器的MAC地址。

```bash
nmblookup -A <IP>
nbtscan <IP>/30
sudo nmap -sU -sV -T4 --script nbstat.nse -p137 -Pn -n <IP>
```

### 数据报分发服务

NetBIOS数据报允许通过UDP进行无连接通信，支持直接消息传递或向所有网络名称广播。该服务使用**138/udp**端口。

```bash
PORT    STATE         SERVICE     VERSION
138/udp open|filtered netbios-dgm
```

### 会话服务

对于面向连接的交互，**会话服务**通过端口**139/tcp**促进两台设备之间的对话，利用**TCP**连接。会话始于“会话请求”数据包，并可根据响应建立。该服务支持更大的消息、错误检测和恢复，TCP处理流量控制和数据包重传。

会话内的数据传输涉及**会话消息数据包**，会话通过关闭TCP连接来终止。

这些服务对于**NetBIOS**功能至关重要，实现网络上的高效通信和资源共享。有关TCP和IP协议的更多信息，请参考它们各自的[TCP Wikipedia](https://en.wikipedia.org/wiki/Transmission_Control_Protocol)和[IP Wikipedia](https://en.wikipedia.org/wiki/Internet_Protocol)页面。

```bash
PORT      STATE SERVICE      VERSION
139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn
```

**阅读下一页以了解如何枚举此服务：**

{% content-ref url="137-138-139-pentesting-netbios" %}
[137-138-139-pentesting-netbios](https://hacktricks.xsx.tw/network-services-pentesting/137-138-139-pentesting-netbios)
{% endcontent-ref %}

\`\`\` Protocol\_Name: Netbios #Protocol Abbreviation if there is one. Port\_Number: 137,138,139 #Comma separated if there is more than one. Protocol\_Description: Netbios #Protocol Abbreviation Spelled out

Entry\_1: Name: Notes Description: Notes for NetBios Note: | Name service for name registration and resolution (ports: 137/udp and 137/tcp). Datagram distribution service for connectionless communication (port: 138/udp). Session service for connection-oriented communication (port: 139/tcp).

For a device to participate in a NetBIOS network, it must have a unique name. This is achieved through a broadcast process where a "Name Query" packet is sent. If no objections are received, the name is considered available. Alternatively, a Name Service server can be queried directly to check for name availability or to resolve a name to an IP address.

<https://book.hacktricks.xyz/pentesting/137-138-139-pentesting-netbios>

Entry\_2: Name: Find Names Description: Three scans to find the names of the server Command: nmblookup -A {IP} &&&& nbtscan {IP}/30 &&&& nmap -sU -sV -T4 --script nbstat.nse -p 137 -Pn -n {IP}

```
<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>
```
