scapy.layers.ntp

NTP(网络时间协议). 参考:RFC 5905,RC 1305,ntpd源代码

class scapy.layers.ntp.NTP

Bases: scapy.packet.Packet

基类,它允许从二进制数据更容易地实例化NTP数据包.

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)

返回给定数据的正确类.

getlayer(cls, nb=1, _track=None, _subclass=True, **flt)
haslayer(cls)

特定:NTPHeader().haslayer(NTP)应该返回True.

mysummary()
pre_dissect(s)

检查有效负载是否足够长以构建NTP数据包.

class scapy.layers.ntp.NTPAuthenticator

Bases: scapy.packet.Packet

数据包处理NTP数据包的"身份验证器"部分,如RFC 5905所定义.

aliastypes
extract_padding(s)
fields_desc
NTPAuthenticator字段

padding

_NTPAuthenticatorPaddingField

b''

key_id

IntField

0

dgst

XStrFixedLenField

b''

class scapy.layers.ntp.NTPClockStatusPacket

Bases: scapy.packet.Packet

数据包处理时钟状态字段.

aliastypes
extract_padding(s)
fields_desc
NTPClockStatusPacket字段

clock_status

BitEnumField (8位)

0

code

BitField (8位)

0

class scapy.layers.ntp.NTPConfPeer

Bases: scapy.packet.Packet

用于传递对等配置信息的结构.

aliastypes
fields_desc
NTPConfPeer字段

peeraddr

IPField

'0.0.0.0'

hmode

ByteField

0

version

ByteField

0

minpoll

ByteField

0

maxpoll

ByteField

0

flags

FlagsField (8位)

<Flag 0 ()>

ttl

ByteField

0

unused1

ShortField

0

keyid

IntField

0

keystr

StrFixedLenField

b''

v6_flag

IntField

0

unused2

IntField

0

peeraddr6

IP6Field

'::'

class scapy.layers.ntp.NTPConfRestrict

Bases: scapy.packet.Packet

用于指定限制条目的结构.

aliastypes
fields_desc
NTPConfRestrict字段

addr

IPField

'0.0.0.0'

mask

IPField

'0.0.0.0'

flags

FlagsField (16位)

<Flag 0 ()>

m_flags

ShortField

0

v6_flag

IntField

0

addr6

IP6Field

'::'

mask6

IP6Field

'::'

class scapy.layers.ntp.NTPConfTrap

Bases: scapy.packet.Packet

用于将添加/清除陷阱信息传递给客户端的结构

aliastypes
fields_desc
NTPConfTrap字段

local_address

IPField

'0.0.0.0'

trap_address

IPField

'0.0.0.0'

trap_port

ShortField

0

unused

ShortField

0

v6_flag

IntField

0

local_address6

IP6Field

'::'

trap_address6

IP6Field

'::'

class scapy.layers.ntp.NTPConfUnpeer

Bases: scapy.packet.Packet

用于传递对等删除信息的结构.

aliastypes
fields_desc
NTPConfUnpeer字段

peeraddr

IPField

'0.0.0.0'

v6_flag

IntField

0

peeraddr6

IP6Field

'::'

class scapy.layers.ntp.NTPControl

Bases: scapy.layers.ntp.NTP

数据包处理NTP模式6 /"控制"消息.

aliastypes
fields_desc
NTPControl字段

zeros

BitField (2位)

0

version

BitField (3位)

2

mode

BitField (3位)

6

response

BitField (1位)

0

err

BitField (1位)

0

more

BitField (1位)

0

op_code

BitEnumField (5位)

0

sequence

ShortField

0

status_word

NTPControlStatusField (Cond)

b''

status

ShortField (Cond)

0

association_id

ShortField

0

offset

ShortField

0

count

ShortField

None

data

NTPControlDataPacketLenField

b''

authenticator

PacketField

b''

post_build(p, pay)
class scapy.layers.ntp.NTPControlDataPacketLenField(name, default, cls, length_from=None)

Bases: scapy.fields.PacketLenField

PacketField处理NTP控制消息的"数据"字段.

getfield(pkt, s)
m2i(pkt, m)
class scapy.layers.ntp.NTPControlStatusField(name, default, cls, remain=0)

Bases: scapy.fields.PacketField

该字段为"状态"字段提供了更好的可读性.

m2i(pkt, m)
class scapy.layers.ntp.NTPErrorStatusPacket

Bases: scapy.packet.Packet

包处理错误状态字段.

aliastypes
extract_padding(s)
fields_desc
NTPErrorStatusPacket字段

error_code

BitEnumField (8 bits)

0

reserved

BitField (8位)

0

class scapy.layers.ntp.NTPExtPacketListField(name, default, cls=None, count_from=None, length_from=None, next_cls_cb=None)

Bases: scapy.fields.PacketListField

PacketListField处理NTPv4扩展(NTPExtension列表).

getfield(pkt, s)
m2i(pkt, m)
class scapy.layers.ntp.NTPExtension

Bases: scapy.packet.Packet

Packet handling a NTPv4 extension.

aliastypes
fields_desc
NTPExtension字段

type

ShortField

0

len

ShortField

0

value

PadField

b''

class scapy.layers.ntp.NTPExtensions

Bases: scapy.packet.Packet

数据包处理NTPv4扩展和数据包的" MAC部分".

aliastypes
fields_desc
NTPExtensions字段

extensions

NTPExtPacketListField

[]

mac

PacketField

<NTPAuthenticator  |>

class scapy.layers.ntp.NTPHeader

Bases: scapy.layers.ntp.NTP

处理RFC 5905 NTP数据包的数据包.

aliastypes
fields_desc
NTPHeader字段

leap

BitEnumField (2位)

0

version

BitField (3位)

4

mode

BitEnumField (3位)

3

stratum

BitField (8位)

2

poll

BitField (8位)

10

precision

BitField (8位)

0

delay

FixedPointField (32位)

0

dispersion

FixedPointField (32位)

0

id

IPField (Cond)

'127.0.0.1'

ref_id

StrFixedLenEnumField (Cond)

b''

ref

TimeStampField (64位)

0

orig

TimeStampField (64位)

None

recv

TimeStampField (64位)

0

sent

TimeStampField (64位)

None

guess_payload_class(payload)

处理NTPv4扩展和MAC部分(使用身份验证时.)

class scapy.layers.ntp.NTPInfoAuth

Bases: scapy.packet.Packet

用于返回有关认证模块信息的结构.

aliastypes
fields_desc
NTPInfoAuth字段

timereset

IntField

0

numkeys

IntField

0

numfreekeys

IntField

0

keylookups

IntField

0

keynotfound

IntField

0

encryptions

IntField

0

decryptions

IntField

0

expired

IntField

0

keyuncached

IntField

0

class scapy.layers.ntp.NTPInfoControl

Bases: scapy.packet.Packet

用于从控制模块返回统计信息的结构.

aliastypes
fields_desc
NTPInfoControl字段

ctltimereset

IntField

0

numctlreq

IntField

0

numctlbadpkts

IntField

0

numctlresponses

IntField

0

numctlfrags

IntField

0

numctlerrors

IntField

0

numctltooshort

IntField

0

numctlinputresp

IntField

0

numctlinputfrag

IntField

0

numctlinputerr

IntField

0

numctlbadoffset

IntField

0

numctlbadversion

IntField

0

numctldatatooshort

IntField

0

numctlbadop

IntField

0

numasyncmsgs

IntField

0

class scapy.layers.ntp.NTPInfoIOStats

Bases: scapy.packet.Packet

I / O统计.

aliastypes
fields_desc
NTPInfoIOStats字段

timereset

IntField

0

totalrecvbufs

ShortField

0

freerecvbufs

ShortField

0

fullrecvbufs

ShortField

0

lowwater

ShortField

0

dropped

IntField

0

ignored

IntField

0

received

IntField

0

sent

IntField

0

notsent

IntField

0

interrupts

IntField

0

int_received

IntField

0

class scapy.layers.ntp.NTPInfoIfStatsIPv4

Bases: scapy.packet.Packet

接口统计信息.

aliastypes
fields_desc
NTPInfoIfStatsIPv4字段

unaddr

PadField

'0.0.0.0'

unbcast

PadField

'0.0.0.0'

unmask

PadField

'0.0.0.0'

v6_flag

IntField

0

ifname

StrFixedLenField

b''

flags

IntField

0

last_ttl

IntField

0

num_mcast

IntField

0

received

IntField

0

sent

IntField

0

notsent

IntField

0

uptime

IntField

0

scopeid

IntField

0

ifindex

IntField

0

ifnum

IntField

0

peercnt

IntField

0

family

ShortField

0

ignore_packets

ByteField

0

action

ByteField

0

_filler0

IntField

0

class scapy.layers.ntp.NTPInfoIfStatsIPv6

Bases: scapy.packet.Packet

接口统计信息.

aliastypes
fields_desc
NTPInfoIfStatsIPv6字段

unaddr

IP6Field

'::'

unbcast

IP6Field

'::'

unmask

IP6Field

'::'

v6_flag

IntField

0

ifname

StrFixedLenField

b''

flags

IntField

0

last_ttl

IntField

0

num_mcast

IntField

0

received

IntField

0

sent

IntField

0

notsent

IntField

0

uptime

IntField

0

scopeid

IntField

0

ifindex

IntField

0

ifnum

IntField

0

peercnt

IntField

0

family

ShortField

0

ignore_packets

ByteField

0

action

ByteField

0

_filler0

IntField

0

class scapy.layers.ntp.NTPInfoKernel

Bases: scapy.packet.Packet

用于返回内核pll / PPS信息的结构

aliastypes
fields_desc
NTPInfoKernel字段

offset

IntField

0

freq

IntField

0

maxerror

IntField

0

esterror

IntField

0

status

ShortField

0

shift

ShortField

0

constant

IntField

0

precision

IntField

0

tolerance

IntField

0

ppsfreq

IntField

0

jitter

IntField

0

stabil

IntField

0

jitcnt

IntField

0

calcnt

IntField

0

errcnt

IntField

0

stbcnt

IntField

0

class scapy.layers.ntp.NTPInfoLoop

Bases: scapy.packet.Packet

循环过滤器变量.

aliastypes
fields_desc
NTPInfoLoop字段

last_offset

TimeStampField (64位)

0

drift_comp

TimeStampField (64位)

0

compliance

IntField

0

watchdog_timer

IntField

0

class scapy.layers.ntp.NTPInfoMemStats

Bases: scapy.packet.Packet

对等内存统计信息.

aliastypes
fields_desc
NTPInfoMemStats字段

timereset

IntField

0

totalpeermem

ShortField

0

freepeermem

ShortField

0

findpeer_calls

IntField

0

allocations

IntField

0

demobilizations

IntField

0

hashcount

FieldListField

[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

class scapy.layers.ntp.NTPInfoMonitor1

Bases: scapy.packet.Packet

用于返回监视数据的结构.

aliastypes
fields_desc
NTPInfoMonitor1字段

lasttime

IntField

0

firsttime

IntField

0

lastdrop

IntField

0

count

IntField

0

addr

IPField

'0.0.0.0'

daddr

IPField

'0.0.0.0'

flags

IntField

0

port

ShortField

0

mode

ByteField

0

version

ByteField

0

v6_flag

IntField

0

unused1

IntField

0

addr6

IP6Field

'::'

daddr6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoPeer

Bases: scapy.packet.Packet

对等信息结构.

aliastypes
fields_desc
NTPInfoPeer字段

dstaddr

IPField

'0.0.0.0'

srcaddr

IPField

'0.0.0.0'

srcport

ShortField

0

flags

FlagsField (8位)

<Flag 0 ()>

leap

ByteField

0

hmode

ByteEnumField

0

pmode

ByteField

0

stratum

ByteField

0

ppoll

ByteField

0

hpoll

ByteField

0

precision

SignedByteField

0

version

ByteField

0

unused8

ByteField

0

reach

ByteField

0

unreach

ByteField

0

flash

XByteField

0

ttl

ByteField

0

flash2

XLEShortField

0

associd

ShortField

0

keyid

LEIntField

0

pkeyid

IntField

0

refid

IPField

0

timer

IntField

0

rootdelay

FixedPointField (32位)

0

rootdispersion

FixedPointField (32位)

0

reftime

TimeStampField (64位)

0

org

TimeStampField (64位)

0

rec

TimeStampField (64位)

0

xmt

TimeStampField (64位)

0

filtdelay

FieldListField

[0, 0, 0, 0, 0, 0, 0, 0]

filtoffset

FieldListField

[0, 0, 0, 0, 0, 0, 0, 0]

order

FieldListField

[0, 0, 0, 0, 0, 0, 0, 0]

delay

FixedPointField (32位)

0

dispersion

FixedPointField (32位)

0

offset

TimeStampField (64位)

0

selectdisp

FixedPointField (32位)

0

unused1

IntField

0

unused2

IntField

0

unused3

IntField

0

unused4

IntField

0

unused5

IntField

0

unused6

IntField

0

unused7

IntField

0

estbdelay

FixedPointField (32位)

0

v6_flag

IntField

0

unused9

IntField

0

dstaddr6

IP6Field

'::'

srcaddr6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoPeerList

Bases: scapy.packet.Packet

用于返回对等方的原始列表.

aliastypes
fields_desc
NTPInfoPeerList字段

addr

IPField

'0.0.0.0'

port

ShortField

0

hmode

ByteEnumField

0

flags

FlagsField (8位)

<Flag 0 ()>

v6_flag

IntField

0

unused1

IntField

0

addr6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoPeerStats

Bases: scapy.packet.Packet

对等统计结构.

aliastypes
fields_desc
NTPInfoPeerStats字段

dstaddr

IPField

'0.0.0.0'

srcaddr

IPField

'0.0.0.0'

srcport

ShortField

0

flags

FlagsField (16位)

<Flag 0 ()>

timereset

IntField

0

timereceived

IntField

0

timetosend

IntField

0

timereachable

IntField

0

sent

IntField

0

unused1

IntField

0

processed

IntField

0

unused2

IntField

0

badauth

IntField

0

bogusorg

IntField

0

oldpkt

IntField

0

unused3

IntField

0

unused4

IntField

0

seldisp

IntField

0

selbroken

IntField

0

unused5

IntField

0

candidate

ByteField

0

unused6

ByteField

0

unused7

ByteField

0

unused8

ByteField

0

v6_flag

IntField

0

unused9

IntField

0

dstaddr6

IP6Field

'::'

srcaddr6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoPeerSummary

Bases: scapy.packet.Packet

ntpdc默认返回的信息的排序.

aliastypes
fields_desc
NTPInfoPeerSummary字段

dstaddr

IPField

'0.0.0.0'

srcaddr

IPField

'0.0.0.0'

srcport

ShortField

0

stratum

ByteField

0

hpoll

ByteField

0

ppoll

ByteField

0

reach

ByteField

0

flags

FlagsField (8位)

<Flag 0 ()>

hmode

ByteField

{0: 'reserved', 1: 'symmetric active', 2: 'symmetric passive', 3: 'client', 4: 'server', 5: 'broadcast', 6: 'NTP control message', 7: 'reserved for private use'}

delay

FixedPointField (32位)

0

offset

TimeStampField (64 bits)

0

dispersion

FixedPointField (32位)

0

v6_flag

IntField

0

unused1

IntField

0

dstaddr6

IP6Field

'::'

srcaddr6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoSys

Bases: scapy.packet.Packet

系统信息. 主要是sys.*变量,以及一些实现唯一的变量.

aliastypes
fields_desc
NTPInfoSys字段

peer

IPField

'0.0.0.0'

peer_mode

ByteField

0

leap

ByteField

0

stratum

ByteField

0

precision

ByteField

0

rootdelay

FixedPointField (32位)

0

rootdispersion

FixedPointField (32位)

0

refid

IPField

0

reftime

TimeStampField (64位)

0

poll

IntField

0

flags

FlagsField (8位)

<Flag 0 ()>

unused1

ByteField

0

unused2

ByteField

0

unused3

ByteField

0

bdelay

FixedPointField (32位)

0

frequency

FixedPointField (32位)

0

authdelay

TimeStampField (64位)

0

stability

FixedPointField (32位)

0

v6_flag

IntField

0

unused4

IntField

0

peer6

IP6Field

'::'

class scapy.layers.ntp.NTPInfoSysStats

Bases: scapy.packet.Packet

系统统计信息. 这些收集在协议模块中.

aliastypes
fields_desc
NTPInfoSysStats字段

timeup

IntField

0

timereset

IntField

0

denied

IntField

0

oldversionpkt

IntField

0

newversionpkt

IntField

0

unknownversion

IntField

0

badlength

IntField

0

processed

IntField

0

badauth

IntField

0

received

IntField

0

limitrejected

IntField

0

class scapy.layers.ntp.NTPInfoTimerStats

Bases: scapy.packet.Packet

工时统计.

aliastypes
fields_desc
NTPInfoTimerStats字段

timereset

IntField

0

alarms

IntField

0

overflows

IntField

0

xmtcalls

IntField

0

class scapy.layers.ntp.NTPPeerStatusDataPacket

Bases: scapy.packet.Packet

当op_code为CTL_OP_READSTAT且association_id字段为null时,处理数据字段的数据包.

aliastypes
fields_desc
NTPPeerStatusDataPacket字段

association_id

ShortField

0

peer_status

PacketField

<NTPPeerStatusPacket  |>

class scapy.layers.ntp.NTPPeerStatusPacket

Bases: scapy.packet.Packet

数据包处理对等状态字段.

aliastypes
extract_padding(s)
fields_desc
NTPPeerStatusPacket字段

configured

BitField (1位)

0

auth_enabled

BitField (1位)

0

authentic

BitField (1位)

0

reachability

BitField (1位)

0

reserved

BitField (1位)

0

peer_sel

BitEnumField (3位)

0

peer_event_counter

BitField (4位)

0

peer_event_code

BitEnumField (4位)

0

class scapy.layers.ntp.NTPPrivate

Bases: scapy.layers.ntp.NTP

数据包处理专用(模式7)消息.

aliastypes
fields_desc
NTP私有字段

response

BitField (1位)

0

more

BitField (1位)

0

version

BitField (3位)

2

mode

BitField (3位)

0

auth

BitField (1位)

0

seq

BitField (7位)

0

implementation

ByteEnumField

0

request_code

ByteEnumField

0

err

BitEnumField (4位)

0

nb_items

BitField (12位)

0

mbz

BitField (4位)

0

data_item_size

BitField (12位)

0

req_data

NTPPrivateReqPacketListField (Cond)

[]

data

NTPPrivateRespPacketListField (Cond)

[]

authenticator

PacketField (Cond)

b''

class scapy.layers.ntp.NTPPrivatePktTail

Bases: scapy.packet.Packet

include / ntp_request.h ntpd使用req_pkt_tail结构调整可能到达的不同数据包大小.

aliastypes
fields_desc
NTPPrivatePktTail字段

tstamp

TimeStampField (64位)

0

key_id

IntField

0

dgst

XStrFixedLenField

b''

class scapy.layers.ntp.NTPPrivateReqPacket

Bases: scapy.packet.Packet

数据包处理请求数据.

aliastypes
fields_desc
NTPPrivateReqPacket字段

req_data

StrField

b''

class scapy.layers.ntp.NTPPrivateReqPacketListField(name, default, cls=None, count_from=None, length_from=None, next_cls_cb=None)

Bases: scapy.fields.PacketListField

处理特定的请求数据包.

getfield(pkt, s)
m2i(pkt, s)
class scapy.layers.ntp.NTPPrivateRespPacketListField(name, default, cls=None, count_from=None, length_from=None, next_cls_cb=None)

Bases: scapy.fields.PacketListField

PacketListField处理响应数据.

getfield(pkt, s)
m2i(pkt, s)
class scapy.layers.ntp.NTPStatusPacket

Bases: scapy.packet.Packet

数据包处理非特定状态字.

aliastypes
extract_padding(s)
fields_desc
NTPStatusPacket字段

status

ShortField

0

class scapy.layers.ntp.NTPSystemStatusPacket

Bases: scapy.packet.Packet

数据包处理系统状态字段.

aliastypes
extract_padding(s)
fields_desc
NTPSystemStatusPacket字段

leap_indicator

BitEnumField (2位)

0

clock_source

BitEnumField (6位)

0

system_event_counter

BitField (4位)

0

system_event_code

BitEnumField (4位)

0

class scapy.layers.ntp.TimeStampField(name, default)

Bases: scapy.fields.FixedPointField

此字段处理NTP标头中的时间戳字段.

any2i(pkt, val)
i2m(pkt, val)
i2repr(pkt, val)
class scapy.layers.ntp.XLEShortField(name, default)

Bases: scapy.fields.LEShortField

XShortField,其值以小尾数法编码.

i2repr(pkt, x)