scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Str*EnumField parses into bytes, not str

Open douniwan5788 opened this issue 1 year ago • 0 comments

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

douniwan5788 avatar Oct 05 '24 04:10 douniwan5788