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. hdu_4651_Partition(公式)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4651 题意:给你一个数n,让你输出将n拆分的方案数. 题解:公式题,不解释,当模版记住就行 #incl ...

  2. 【伪一周小结(没错我一周就做了这么点微小的工作)】HDOJ-1241 Oil Deposits 初次AC粗糙版对比代码框架重构版

    2016 11月最后一周 这一周复习了一下目前大概了解的唯一算法--深度优先搜索算法(DFS).关于各种细节的处理还是极为不熟练,根据题意判断是否还原标记也无法轻松得出结论.不得不说,距离一个准ACM ...

  3. AutoMapper 自动映射工具

    先引用对应的DLL. 11.转换匿名对象 结合LINQ映射新的实体类. using System;using System.Collections.Generic;using System.Linq; ...

  4. size_t, ptrdiff_t, size_type, difference_type

    size_t是unsigned类型,用于指明数组长度或下标,它必须是一个正数,std::size_t ptrdiff_t是signed类型,用于存放同一数组中两个指针之间的差距,它可以负数,std:: ...

  5. Unable to open connection to supplicant on "/data/misc/wifi/sockets/wlan0"

    在调试android wifi UI 的时候,出现了 logcat:  Unable to open connection to supplicant on "/data/misc/wifi ...

  6. 【Tomcat】Tomcat配置之请求字符串编码

    默认情况下,如果tomcat中部署的webservice或者web网站需要有中文的请求参数,而这时候我们直接在浏览器中输入中文那么接受到的将是乱码,无法达到我们的需求,这时候我们就需要对Tomcat的 ...

  7. OpenGL—Android 开机动画源码分析二

    引自http://blog.csdn.net/luoshengyang/article/details/7691321/ BootAnimation类的成员函数的实现比较长,我们分段来阅读: 第三个开 ...

  8. ubuntu14下python环境的配置

    1.安装build依赖包(一些包需要用pip编译) sudo apt-get install python-dev 2.安装pip包管理工具 sudo apt-get install python-p ...

  9. cfdiv2/c/找规律

    题目连接 £:若n<4,NO: £:若n==4,特判,n==5,特判. £:若n>=6,用2-4组成24,1和5和6组成零,即可. #include <set> #includ ...

  10. ueditor 文本编辑器

    百度编辑器       压缩包在文件里 百度UEditor编辑器使用教程与使用方法 发布时间:2014-08-23 14:23:34.0 作者:青岛做网站 我们在做网站的时候,网站后台系统一般都会用到 ...