Skip to content
Wireshark Wiki 中文翻译整理专题首页原始页面

SMB2/Ioctl

Opcode 0x0b

此 SMB2 命令用于执行 Ioctl 和 Fcntl 调用。

此命令可以传输多种不同类型的 Ioctl,包括作为 DCE/RPC 的传输载体。

SMB2/Ioctl 请求

SMB2/Ioctl 请求包格式

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Buffer Code | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Ioctl Function |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+-+-+-+-+ +-+-+-+-+| FID |+-+-+-+-+ +-+-+-+-+| |+-+-+-+-+ +-+-+-+-+| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| In Offset |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| In Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Out Offset |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Out Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Max Out Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+...| In buffer+-+-+-+-+...+-+-+-+-+...| Out buffer+-+-+-+-+...

Buffer Code

SMB2/BufferCode 0x39 = 0x38 | 0x01

Ioctl Function

此字段描述发出了哪种类型的 ioctl 或 fsctl。请参见 SMB2/Ioctl/Function

FID

SMB2/FID 这是我们要将 ioctl 发送到的对象。对于基于 DCE/RPC 的事务,这将是一个命名管道,但也可以是普通文件,或特殊的 fid ffffffff-ffffffff-ffffffff-ffffffff

目前只知道命名管道上的 DCE/RPC 事务的含义。

In Offset

输入缓冲区起始位置相对于 SMB2 包起始位置的偏移量。

In Length

输入缓冲区的长度。

Out Offset

输出缓冲区起始位置相对于 SMB2 包起始位置的偏移量。

Out Length

输出缓冲区的长度。

Max Out Length

此字段表示我们准备在响应中接受的最大数据量。如果此值对于响应来说太小,响应将被截断,但不会设置 NT_status。

In Buffer

如果存在,此字段携带发送到服务器的 ioctl 输入载荷。对于 DCE/RPC 事务,此处将包含 DCE/RPC 请求。

Out Buffer

存在于请求中,但会被服务器忽略。此缓冲区携带从服务器返回的响应数据。

SMB2/Ioctl 响应

SMB2/Ioctl 响应包格式

If it executed successfully:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Buffer Code | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Ioctl Function |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+-+-+-+-+ +-+-+-+-+| FID |+-+-+-+-+ +-+-+-+-+| |+-+-+-+-+ +-+-+-+-+| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| In Offset |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| In Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Out Offset |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Out Length |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+...| In buffer+-+-+-+-+...+-+-+-+-+...| Out buffer+-+-+-+-+...If there was an error:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Buffer Code | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| | | | |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Buffer Code

SMB2/BufferCode 0x31 = 0x30 | 0x01

Ioctl Function

此字段描述发出了哪种类型的 ioctl 或 fsctl。请参见 SMB2/Ioctl/Function

FID

SMB2/FID 这是我们将 ioctl 发送到的对象。对于基于 DCE/RPC 的事务,这将是一个命名管道,但也可以是普通文件,或特殊的 fid ffffffff-ffffffff-ffffffff-ffffffff

目前只知道命名管道上的 DCE/RPC 事务的含义。

In Offset

输入缓冲区起始位置相对于 SMB2 包起始位置的偏移量。

In Length

输入缓冲区的长度。

Out Offset

输出缓冲区起始位置相对于 SMB2 包起始位置的偏移量。

Out Length

输出缓冲区的长度。

In Buffer

如果存在,此字段携带发送到服务器的 ioctl 输入载荷。对于 DCE/RPC 事务,此处将包含 DCE/RPC 请求。

Out Buffer

存在于请求中,但会被服务器忽略。此缓冲区携带从服务器返回的响应数据。

NT Status Codes

讨论

既然我们现在知道这是 ioctl,稍后更新此处:

还有其他非 dcerpc 事务。某些事务在 out buffer 中以字节 0x03 开头,这出现在映射共享后立即对 magic fid ffffffff-ffffffff-ffffffff-ffffffff 发出的事务中。某些作用于普通文件的事务完全不带输出缓冲区,但会返回某种输入数据。

在请求中:紧随 MaxInSize 之后的似乎是一组标志(uint64)。在我见过的所有事务中,无论是 dce/rpc 还是非 dce/rpc,此字段的第一个字节都是 0x01。

请求中 FID 之前的四个字节似乎控制它是哪种事务,我见过以下模式:

00.00.00.00 : no buffer content, status!=0 and error occured.94.01.06.00 c8.01.14.00 : The two does not operate on a specific fid (fid==ffff-ffff-ffff... ) instead they operate on the tree or the entire server? the c8. version is common when the payload in the request contains strings looking like \PIPE\LANMAN the 94 version often contains payload of the type \<IPADDRESS>\sharename Could this be calls to check if a file exists on a share or ashare exists on a server?af.01.09.00 : these all operate on the fid for "" (the share itself?) and takes 8 bytes of output data. Could this be IOCTL?c0.00.09.00 : No data in the request, it returns 64 bytes of data. operates on both "" as well as normal files.

Imported from https://wiki.wireshark.org/SMB2/Ioctl on 2020-08-11 23:25:01 UTC

相关 Wireshark Wiki 页面

网络分析技术档案