简体   繁体   English

Scapy DHCP 检索提供的 IP 地址

[英]Scapy DHCP retrieving offered IP address

I've successfully created a DHCP discover, Offer and Request in Scapy.我已经在 Scapy 中成功创建了 DHCP 发现、提供和请求。 I was wondering if it is possible for me to retrieve the offer DHCP IP address, saving it to a variable where I will be able to request for it specifically in my DHCP Request using Scapy.我想知道我是否可以检索报价 DHCP IP 地址,将其保存到一个变量中,我可以在我的 DHCP 请求中使用 Scapy 专门请求它。 I've tried using sniff but it doesn't seem to retrieve any IP address as follows:我试过使用嗅探,但它似乎没有检索到任何 IP 地址,如下所示:

sniff(iface=myiface, filter="port 68 and port 67")

Are there any methods to retrieve the offered IP?是否有任何方法可以检索提供的 IP? Thanks谢谢

I've solved this already.我已经解决了这个问题。 For anyone else who needs help on this.对于其他需要帮助的人。 Basically BOOTP in the sniffed packet contains the offered IP address and to retrieve the address.基本上,嗅探数据包中的 BOOTP 包含提供的 IP 地址并检索该地址。 Simply do this:只需这样做:

pckt.getlayer(BOOTP).yiaddr #pckt is the sniffed packet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM