1、SMB协议与CIFS协议的区别
     139端口是一种TCP端口,该端口在通过网上邻居访问局域网中的共享文件或共享打印机时就能发挥作用。
445端口也是一种TCP端口,该端口在 Windows 2000 Server或Windows Server 2003系统中发挥的作用与139端口是完全相同的。具体地说,它也是提供局域网中文件或打印机共享服务。不过该端口是基于CIFS协议(通用因特网文件系统协议)工作的,而139端口是基于SMB协议(Server Message Block服务器协议族)对外提供共享服务。
 
NBT(NetBIOS over TCP/IP)
使用137, 138 (UDP) and 139 (TCP)来实现基于TCP/IP的NETBIOS网际互联。
在Windows NT中SMB基于NBT实现。而在Windows2000中,SMB除了基于NBT的实现,还有直接通过445端口实现。
当Win2000(允许NBT)作为client来连接SMB服务器时,它会同时尝试连接139和445端口,如果445端口有响应,那么就发送RST包给139端口断开连接,以455端口通讯来继续.当445端口无响应时,才使用139端口。
当Win2000(禁止NBT)作为client来连接SMB服务器时,那么它只会尝试连接445端口,如果无响应,那么连接失败。(注意可能对方是NT4.0服务器。)
如果win2000服务器允许NBT, 那么UDP端口137, 138, TCP 端口 139, 445将开放。
如果 NBT 被禁止, 那么只有445端口开放。
.
2、SMB协议
SMB是的Server Message Block简写,这个协议用于共享文件,共享打印机,共享串口等用途。我们之所以能够在windows的网络邻居下访问一个域内的其他机器,就是通过这个协议实现的。
    SMB协议是一个很重要的协议,目前绝大多数的PC上都在运行这一协议,windows系统都充当着SMB协议的客户端和服务器,所以SMB是一个遵循客户机服务器模式的协议。SMB服务器负责通过网络提供可用的共享资源给SMB客户机,服务器和客户机之间通过TCP/IP协议、或者IPX协议、或者是NetBEUI进行连接。一旦服务器和客户机之间建立了一个连接,客户机就可以通过向服务器发送命令完成共享操作,比如读,写,检索等。
消息格式:SMB Message分为三个部分
SMB Header, //头部     4byte
SMB Command Header//命令头部    32byte
the Data Block. //数据部分

==================================================================

SMB 头部
数据结构:
typedef unsigned char UCHAR;          // 8 unsigned bits
typedef unsigned short USHORT;        // 16 unsigned bits
typedef unsigned long ULONG;          // 32 unsigned bits
 
typedef struct {
    ULONG LowPart;
    LONG HighPart;
} LARGE_INTEGER;                      // 64 bits of data
 
typedef struct  {
    UCHAR Protocol[4];                // Contains 0xFF,'SMB'
    UCHAR Command;                    // Command code
    union {
        struct {
            UCHAR ErrorClass;         // Error class
            UCHAR Reserved;           // Reserved for future use
            USHORT Error;             // Error code
        } DosError;
        ULONG Status;                 // 32-bit error code
    } Status;
    UCHAR Flags;                      // Flags
    USHORT Flags2;                    // More flags
    union {
        USHORT Pad[6];                // Ensure section is 12 by
        struct {
            USHORT PidHigh;          // High Part of PID
            UCHAR SecuritySignature[8];   // reserved for MAC
       } Extra;
    };
    USHORT Tid;                       // Tree identifier
    USHORT Pid;                       // Caller’s process ID, opaque for
client use
    USHORT Uid;                       // User id
    USHORT Mid;                       // multiplex id
    UCHAR  WordCount;                 // Count of parameter words
} SMB_HEADER;
说明:
1、Tid
Tid represents an instance of an authenticated connection to a server resource.  The server
returns Tid to the client when the client successfully connects to a resource, and the client uses Tid in subsequent requests referring to the resource.
2、Pid Pid is the caller's process id, and is generated by the client to uniquely identify a process within the client computer.
3、Uid Field
Uid is a reference number assigned by the server after a user authenticates to it, and that it will associate with that user until the client requests the association be broken. After authentication to the server, the client SHOULD make sure that the Uid is not used for a different user that the onethat authenticated. (It is permitted for a single user to have more than one Uid.) Requests that do authorization, such as open requests, will perform access checks using the identity associated with the Uid.
4、 Mid Field
The multiplex ID (Mid) is used along with the Pid to allow multiplexing the single client and server connection among the client's multiple processes, threads, and requests per thread. Clients may have many outstanding requests (up to the negotiated number, MaxMpxCount) at one time. Servers MAY respond to requests in any order, but a response message MUST always contain the same Mid and Pid values as the corresponding request message. The client MUST NOT have multiple outstanding requests to a server with the same Mid and Pid.
5、command code
(1)SMB_COM_NEGOTIATE           0x72
 Client Command             Server Response
 ========================== =========================================
 SMB_COM_NEGOTIATE          Must be the first message sent by client                 
                            to the server.  Includes a list of SMB
                            dialects supported by the client.  Server
                            response indicates which SMB dialect
                            should be used.
(2)SMB_COM_SESSION_SETUP_ANDX  0x73
SMB_COM_SESSION_SETUP_ANDX  Transmits the user's name and credentials        
                            to the server for verification.
                            Successful server response has Uid field
                            set in SMB header used for subsequent
                            SMBs on behalf of this user.
(3)SMB_COM_NT_CREATE_ANDX   0xa2
 Client Command             Server Response
 ========================== =========================================
SMB_COM_NT_CREATE_ANDX     An SMB_COM_NT_CREATE_ANDX request is sent
                           by a client to open a file or device on the server.
(4)SMB_COM_READ_AndX                0x2e
SMB_COM_READ_AndX              
An SMB_COM_READ_ANDX request is sent by a client to read from a file or named pipe on a server
(5) SMB_COM_WRITE_AndX                0x2f
SMB_COM_WRITE_AndX              
An SMB_COM_WRITE_AndX request is sent by a client to write from a file or named pipe on a server

SMB/CIFS协议解析的更多相关文章

  1. SMB/CIFS协议解析一概述

    一.SMB/CIFS协议的区别 在NetBIOS出现之后,Microsoft就使用NetBIOS实现了一个网络文件/打印服务系统,这个系统基于NetBIOS设定了一套文件共享协 议,Microsoft ...

  2. SMB/CIFS协议解析二

    一.拷贝文件(远程-->本地) 1.SMB_COM_NT_CREATE_ANDX (0xa2)       打开文件,获取文件名,获得读取文件的  总长度. 2.SMB_COM_READ     ...

  3. CentOS7 下编译安装 Samba,什么是 SMB/CIFS 协议

    目录 一.关于 Samba 1. SMB 2. Samba 二.yum 安装 Samba 1. 安装 Samba 2. 查看版本 3. 查看配置文件 4. 启动服务 5. 本地客户端验证 6. Win ...

  4. SMB/CIFS协议简介

    1. 简介:(ServerMessage Block)服务消息块通信协议是微软(Microsoft)和英特尔(Intel)在1987年制定的协议,主要是作为Microsoft网络的通讯协议.SMB从I ...

  5. smbclient - 类似FTP操作方式的访问SMB/CIFS服务器资源的客户端

    总览 SYNOPSIS smbclient {servicename} [password] [-b <buffer size>] [-d debuglevel] [-D Director ...

  6. Samba 服务使用的端口和协议(是一组TCP UDP协议的组合,主要使用CIFS协议,有一个Java例子)

    Samba服务所使用的端口和协议: 1)Port 137 (UDP) - NetBIOS 名字服务 : nmbd 2)Port 138 (UDP) - NetBIOS 数据报服务 3)Port 139 ...

  7. smbd - 向客户提供SMB/CIFS服务的服务器

    总览 SYNOPSIS smbd [-D] [-F] [-S] [-i] [-h] [-V] [-b] [-d <debug level>] [-l <log directory&g ...

  8. ts 协议解析

    pes : http://wenku.baidu.com/link?url=KjcA0qXqZ1bWVQTa8i1YOmygofldSQL7Pjj-zGRw1e_6_LFmVLo5DIWF0SNwVn ...

  9. 使用openfiler设置SMB/CIFS共享总是不通过的一例与解决办法

    最近使用openfiler进行空闲存储的集中化管理与多主机节点共享,等设置到了SMB/CIFS的时候总是通过不了,前提需要开启的LDAP内建在openfiler也都开启并设置好了,但就是无法通过&qu ...

随机推荐

  1. 《剑指Offer》算法题——“旋转数组”的最小数字

    题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转.输入一个非递减序列的一个旋转,输出旋转数组的最小元素.例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数 ...

  2. mysql 发生系统错误1067的解决方法

    解决方法如下: 1.先删除mysql服务 控制面板->管理工具->服务,先停止mysql服务 开始->运行->输入cmd->sc delete mysql 服务删除 2. ...

  3. linux服务器出现严重故障后的原因以及解决方法

    1.把系统安装光盘插入,重启机器,启动时迅速按下Del键,进入CMOS,把启动顺序改为光盘先启动,这样就启动了Linux安装程序,按F5,按提示打入Linux rescue回车,进入救援模式,接下来是 ...

  4. find排除目录

    在linux find 进行查找的时候,有时候需要忽略某些目录不查找,可以使用 -prune 参数来进行过滤,但必须要注意要忽略的路径参数必须紧跟着搜索的路径之后,否则该参数无法起作用. 命令语法: ...

  5. 第10章 接口、继承与多态----Object类

    在Java中,所有的类都直接或间接继承了java.lang.Object类.Object类是比较特殊的类,它是所有类的父类,是Java类层中的最高层类.当创建一个类时,总是在继承,除非某个类已经指定要 ...

  6. js跨域访问,No ‘Access-Control-Allow-Origin‘ header is present on

    在本地用ajax跨域访问请求时报错: XMLHttpRequest cannot loadhttp://www.zjblogs.com/. No 'Access-Control-Allow-Origi ...

  7. centos7配置ip

    vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 ONBOOT=yes 重启ip服务 systemctl restart network.service 开 ...

  8. Oracle record 解锁

    Oracle修改表中记录时出现record is locked by another user的弹出框问题 是因为在操作表中数据时没有commit,导致表被锁. 执行下面两行语句: (1)查看被锁表的 ...

  9. URL的# (转)

    http://www.ruanyifeng.com/blog/2011/03/url_hash.html

  10. jsp提交表单问题

    以form形式提交的话 String usernameInForm = hreq.getParameter("username");String passwordInForm = ...