我试图使用 scapy 和套接字发送 NTP 查询,但是当我收到日期时,我以原始形式得到它。
from scapy.all import*
from scapy.all import*
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr=("192.114.62.250",123)
ntp=NTP()
s.sendto(str(ntp),addr)
data,ip=s.recvfrom(1024)
答案应该在数据中,但我得到的只是
'\x1c\x02\n\xeb\x00\x00\x01b\x00\x00\r\x8c\xc0s\xd12\xdcH\xa5\xda}-\x1b/\xdcH\xa9T\x95\x81\x08\x00 \xdcH\xa9_\xd2\xc2n\xe1\xdcH\xa9_\xd2\xc6\xca\x1c'
我想要的是:
Peer Clock Stratum: secondary reference (2)
Peer Polling Interval: 10 (1024 sec)
Peer Clock Precision: 0.000000 sec
Root Delay: 0.0054 sec
Root Dispersion: 0.0529 sec
Reference ID: 192.115.209.50
Reference Timestamp: Feb 10, 2017 20:49:30.488969000 UTC
Origin Timestamp: Feb 10, 2017 21:04:20.584000000 UTC
Receive Timestamp: Feb 10, 2017 21:04:31.823279000 UTC
Transmit Timestamp: Feb 10, 2017 21:04:31.823345000 UTC