hacktricks/src/network-services-pentesting/137-138-139-pentesting-netbios.md

76 lines
4.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 137,138,139 - Pentesting NetBios
{{#include ../banners/hacktricks-training.md}}
## NetBios Name Service
**NetBIOS Name Service** は重要な役割を果たし、**名前の登録と解決**、**データグラムの配信**、および **セッションサービス** などのさまざまなサービスを含み、各サービスに特定のポートを利用します。
[From Wikidepia](https://en.wikipedia.org/wiki/NetBIOS_over_TCP/IP):
- 名前の登録と解決のための名前サービス(ポート: 137/udp および 137/tcp
- 接続のない通信のためのデータグラム配信サービス(ポート: 138/udp
- 接続指向通信のためのセッションサービス(ポート: 139/tcp
### Name Service
デバイスが NetBIOS ネットワークに参加するためには、ユニークな名前を持っている必要があります。これは、"Name Query" パケットが送信される **ブロードキャストプロセス** を通じて達成されます。異議がなければ、その名前は利用可能と見なされます。あるいは、**Name Service server** に直接問い合わせて名前の利用可能性を確認したり、名前を 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>
```
### Datagram Distribution Service
NetBIOSデータグラムは、UDPを介した接続のない通信を可能にし、直接メッセージングまたはすべてのネットワーク名へのブロードキャストをサポートします。このサービスはポート**138/udp**を使用します。
```bash
PORT STATE SERVICE VERSION
138/udp open|filtered netbios-dgm
```
### セッションサービス
接続指向のインタラクションのために、**セッションサービス**は2つのデバイス間の会話を促進し、ポート**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
```
**次のページを読んで、このサービスを列挙する方法を学んでください:**
{{#ref}}
137-138-139-pentesting-netbios.md
{{#endref}}
## HackTricks 自動コマンド
```
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.wiki/en/network-services-pentesting/137-138-139-pentesting-netbios.html
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}
```
{{#include ../banners/hacktricks-training.md}}