Skip to content

Str*EnumField parses into bytes, not str #4556

@douniwan5788

Description

@douniwan5788

Brief description

The ref_id field of scapy.layers.ntp.NTPHeader utilizes a dict with str keys, leading to an enum mismatch

Scapy version

2.6.0

Python version

all

Operating system

all

Additional environment information

No response

How to reproduce

from scapy.layers.ntp import NTPHeader

NTPHeader(
    bytes.fromhex("1a010af0000000000000001547505300c50204e639372a38c50204eceed33c52c50204ebd63b7952c50204ebd63d1cc1")
).show2()

Actual result

###[ NTPHeader ]###
  leap      = no warning
  version   = 3
  mode      = symmetric passive
  stratum   = 1
  poll      = 10
  precision = -16
  delay     = 0
  dispersion= 0.0003204
  ref_id    = b'GPS'
  ref       = Mon, 27 Sep 2004 03:17:58 +0000
  orig      = Mon, 27 Sep 2004 03:18:04 +0000
  recv      = Mon, 27 Sep 2004 03:18:03 +0000
  sent      = Mon, 27 Sep 2004 03:18:03 +0000

Expected result

###[ NTPHeader ]###
  leap      = no warning
  version   = 3
  mode      = symmetric passive
  stratum   = 1
  poll      = 10
  precision = -16
  delay     = 0
  dispersion= 0.0003204
  ref_id    = b'GPS' (Global Position System)
  ref       = Mon, 27 Sep 2004 03:17:58 +0000
  orig      = Mon, 27 Sep 2004 03:18:04 +0000
  recv      = Mon, 27 Sep 2004 03:18:03 +0000
  sent      = Mon, 27 Sep 2004 03:18:03 +0000

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions