链接地址: https://github.com/dhgdhg/Scapy-Note

十一.应用层

11.1.ISAKMP:scapy.layers.isakmp.ISAKMP

Internet Security Association and Key Management Protocol, 互联网安全协会和密钥管理协议, 用于在两个通信实体协商和建立安全相关, 交换密钥.
ISAKMP定义了用于建立, 协商, 修改和删除安全关联的过程和数据包格式. SA包含执行各种网络安全服务所需的所有信息, 例如IP层服务(例如标头身份验证和有效载荷封装), 传输或应用程序层服务或协商流量的自我保护. ISAKMP定义了用于交换密钥生成和身份验证数据的有效负载. 这些格式提供了用于传输密钥和认证数据的一致框架, 该框架独立于密钥生成技术, 加密算法和认证机制.
ISAKMP与密钥交换协议不同, 是为了将安全关联管理(和密钥管理)的细节与密钥交换的细节清晰地分开. 可能有许多不同的密钥交换协议, 每种协议具有不同的安全性. 但是, 需要一个通用框架来同意SA属性的格式, 以及协商, 修改和删除SA. ISAKMP充当此通用框架.

<details>
  • init_cookie

    • Initiator cookie 8 bytes
    • 发起SA建立、SA通知或SA删除的实体的cookie.
  • resp_cookie

    • Responder cookie 8 bytes
    • 响应SA建立请求、SA通知或SA删除的实体的cookie.
  • next_payload

    • Next payload 8 bits.

    • 指示消息中第一个有效负载的类型.

      Value | Description | References

    • ------ | ----------------------------- | ----------
      0 | None. | RFC 2408
      1 | Security Association. | RFC 2408
      2 | Proposal. | RFC 2408
      3 | Transform. | RFC 2408
      4 | Key Exchange. | RFC 2408
      5 | Identification. | RFC 2408
      6 | Certificate. | RFC 2408
      7 | Certificate Request. | RFC 2408
      8 | Hash. | RFC 2408
      9 | Signature. | RFC 2408
      10 | Nonce. | RFC 2408
      11 | Notification. | RFC 2408
      12 | Delete. | RFC 2408
      13 | Vendor ID. | RFC 2408
      14 |
      15 | SAK, SA KEK Payload. | RFC 3547
      16 | SAT, SA TEK Payload. | RFC 3547
      17 | Key Download. | RFC 3547
      18 | Sequence Number. | RFC 3547
      19 | Proof of Possession. | RFC 3547
      20 | NAT-D, NAT Discovery. | RFC 3947
      21 | NAT-OA, NAT Original Address. | RFC 3947
      22-127 |
      128-255 | Private use.

  • version

    • Mjr version. 4 bits.
      • 正在使用的ISAKMP协议的主要版本
        = Mnr version. 4 bits.
      • 正在使用的ISAKMP协议的次要版本.
  • exch_type

    • Exchange type
    • 指示正在使用的交换的类型. 这将指定ISAKMP交换中的消息和负载次序
  • flags

    • Flags

    • 指示为ISAKMP交换设置的选项.

      Value | Description

    • ------ | --------------------
      0 | None.
      1 | Base.
      2 | Identity protection.
      3 | Authentication only.
      4 | Aggressive.
      5 | Informational.
      6-31 | ISAKMP future use.
      32-239 | DOI specific use.
      240-255 | Private use.

  • id

    • Message ID 4 bytes
    • 在第二阶段谈判中用于确定议定书状态的唯一值. 它是由阶段2协商的发起者随机生成的.
  • length

    • Length 4 bytes
    • ISAKMP头的总长度和封装的有效载荷(以字节为单位).
</details>

11.2.BOOTP:scapy.layers.dhcp.BOOTP

BOOTP 及其扩展是动态主机配置协议(DHCP)的基础. 引导协议(BOOTP)是一种基于 UDP/IP 的协议. 这种协议允许正在启动的主机动态配置而无需用户监督. BOOTP 主要用于客户机从服务器获得自己的 IP 地址, 服务器的 IP 地址以及启动映象文件名. 此外通过 BOOTP, 其它一些装置信息, 如本地子网掩码、本地时间偏移量、默认路由器地址和各种 Internet 服务器地址, 都能与客户机交流.

<details>
  • op
    • 分组操作码/消息类型. 1 = BOOTREQUEST, 2 = BOOTREPLY
  • htype
    • 硬件地址类型,参见“指定号码”RFC中的ARP部分. '1' = 10mb以太网
  • hlen
    • 硬件地址长度(如10mb以太网为'6').
  • hops
    • 客户端设置为0, 可选地由网关使用, 在cross-gateway引导.
    • 若封包需经过 router 传送, 每站加 1 , 若在同一网内, 为 0.
  • xid
    • 事务ID, 一个随机数, 用于将此引导请求与它生成的反应.
  • secs
    • 由客户端填写, 几秒钟后客户端开始尝试引导.
  • flags
    • 标记
  • ciaddr
    • 客户端IP地址;由客户在bootrequest中填写.
  • yiaddr
    • “您的”(客户)IP地址;如果客户端不填, 则由服务器填写知道自己的地址(ciaddr为0).
  • siaddr
    • 服务器IP地址;由服务器在bootreply中返回.
  • giaddr
    • 网关IP地址,用于可选的跨网关引导.
  • chaddr
    • 客户端硬件地址,客户填写.
  • sname
    • 可选的服务器主机名, 零结尾字符串.
  • file
    • BOOT文件名, 空终止字符串;“通用”名或bootrequest中的null, 完全限定的目录路径在bootreply名称
  • options
    • 可选参数字段
</details>

11.3.DHCP:scapy.layers.dhcp.DHCP

Dynamic Host Configuration Protocol, 动态主机设置协议是一个用于局域网的网络协议, 位于OSI模型的应用层, 使用UDP协议工作,
主要有两个用途:
用于内部网或网络服务供应商自动分配IP地址给用户
用于内部网管理员对所有电脑作中央管理

<details>
  • options
    • 例:DHCP(options=[(Option, Value)])
    • Option取值:

      给定的值必须为指定类型, NoneType不用给值默认为True

      • pad: NoneType
      • subnet_mask: IPField
        • 子网掩码值
      • time_zone: NoneType
      • router: IPField
        • N/4路由器地址
      • time_server: IPField
        • N/4时间服务器地址
      • IEN_name_server: IPField
      • name_server: IPField
        • N/4 IAN-116服务器地址
      • log_server: IPField
        • N/4 日志服务器地址
      • cookie_server: IPField
      • lpr_server: IPField
        • N/4 打印机服务器地址
      • impress-servers: IPField
        • N/4 印象服务器地址
      • resource-location-servers: IPField
      • hostname: NoneType
      • boot-size: ShortField
        • BOOT文件大小, 以512字节为单位
      • dump_path: NoneType
      • domain: NoneType
      • swap-server: IPField
        • 交换服务器地址
      • root_disk_path: NoneType
      • extensions-path: NoneType
      • ip-forwarding: ByteField
        • 启用/禁用IP转发
      • non-local-source-routing: ByteField
      • policy-filter: IPField
        • 路由策略的过滤器
      • max_dgram_reass_size: NoneType
        • 最大数据报重新组装大小
      • default_ttl: NoneType
      • pmtu_timeout: NoneType
      • path-mtu-plateau-table: ShortField
        • 路径MTU平台表
      • interface-mtu: ShortField
        • 接口MTU大小
      • all-subnets-local: ByteField
        • 所有子网都是本地的
      • broadcast_address: IPField
        • 广播地址
      • perform-mask-discovery: ByteField
        • 执行掩码发现
      • mask-supplier: ByteField
        • 为其他提供掩码
      • router-discovery: ByteField
        • 执行路由器搜索
      • router-solicitation-address: IPField
        • 路由器请求地址
      • trailer-encapsulation: ByteField
        • 尾部封装
      • arp_cache_timeout: NoneType
      • ether_or_dot3: NoneType
      • tcp_ttl: NoneType
      • tcp_keepalive_interval: NoneType
      • tcp_keepalive_garbage: NoneType
      • NIS_domain: NoneType
      • NIS_server: IPField
        • NIS服务器地址
      • NTP_server: IPField
        • NIP服务器地址
      • vendor_specific: NoneType
      • NetBIOS_server: IPField
        • NETBIOS名称服务器地址
      • NetBIOS_dist_server: IPField
        • NETBIOS数据报分布
      • static-routes: ByteField
        • 静态路由表
      • netbios-scope: NoneType
      • font-servers: IPField
        • X Window Font Server
      • x-display-manager: IPField
        • X Window Display Manager
      • requested_addr: IPField
        • 请求的IP地址
      • lease_time: IntField
        • IP地址租用时间
      • dhcp-option-overload: ByteField
        • 重载“sname”或“file”
          • 1: 'file'
          • 2: 'sname
          • 3: 两个字段都
      • message-type: ByteEnumField
        • DHCP消息类型
        • Value取值:
          • discover
            -DHCP客户端在网络上发送DHCP发现广播, 以查找DHCP服务器. 如果没有来自DHCP服务器的响应, 则客户端将为其分配一个自动专用IPv4地址(APIPA)
          • offer
            • 网络上收到DHCP发现消息的DHCP服务器以DHCP提供消息作为响应, 该消息为客户端提供IPv4地址租约.
          • request
            • 客户端通过广播所提供的IPv4地址的DHCP请求消息来接受收到的第一个提议
          • decline
            • 如果DHCP客户端确定所提供的TCP / IP配置参数无效, 则它将DHCPDecline数据包发送到服务器. 此后, 客户端必须再次开始DHCP租用过程
          • ack
            • 服务器通过向客户端发送DHCP确认消息来接受请
          • nak
            • 如果无法使用DHCP客户端请求的IPv4地址(另一个设备可能正在使用该IPv4地址), 则DHCP服务器将以DHCPNak(否定确认)数据包进行响应. 此后, 客户端必须再次开始DHCP租用过程.
          • release
            • DHCP客户端向服务器发送DHCPRelease数据包, 以释放IPv4地址并取消所有剩余的租约.
          • inform
            • DHCPInform是在RFC 2131中定义的新的DHCP消息类型. DHCP客户端使用DHCPInform获取DHCP选项
          • force_renew
            • 强制更新
          • lease_query
          • lease_unassigne
          • lease_unknown
          • lease_active
      • server_id: IPField
        • DHCP服务器ID
      • param_req_list: FieldListField
        • 参数请求列表
      • error_message: NoneType
      • max_dhcp_size: ShortField
        • DHCP最大消息大小
      • renewal_time: IntField
        • DHCP更新(T1)时间
      • rebinding_time: IntField
        • DHCP重新结合(T2)时间
      • vendor_class_id: NoneType
      • client_id: NoneType
      • nwip-domain-name: NoneType
      • NISplus_domain: NoneType
      • NISplus_server: IPField
        • NIS+v3服务器地址
      • boot-file-name: StrField
        • BOOT文件名
      • mobile-ip-home-agent: IPField
        • Home Agent Addresses
      • SMTP_server: IPField
        • SMTP服务器地址
      • POP3_server: IPField
        • POP3服务器地址
      • NNTP_server: IPField
        • NNTP服务器地址
      • WWW_server: IPField
        • WWW服务器地址
      • Finger_server: IPField
        • Finger服务器地址
      • IRC_server: IPField
        • IRC服务器地址
      • StreetTalk_server: IPField
        • StreetTalk服务器地址
      • StreetTalk_Dir_Assistance: NoneType
      • client_FQDN: NoneType
      • relay_agent_Information: NoneType
      • client-last-transaction-time: IntField
      • associated-ip: IPField
      • subnet-selection: IPField
        • 子网选择选项
      • end: NoneType
</details>