Scapy DHCP retrieving offered IP address

﹥>﹥吖頭↗ 提交于 2019-12-25 01:49:17

问题


I've successfully created a DHCP discover, Offer and Request in Scapy. 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. I've tried using sniff but it doesn't seem to retrieve any IP address as follows :

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

Are there any methods to retrieve the offered IP? Thanks


回答1:


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. Simply do this:

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


来源:https://stackoverflow.com/questions/58372129/scapy-dhcp-retrieving-offered-ip-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!