代码拉取完成,页面将自动刷新
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
conf.checkIPaddr = False
hw = get_if_raw_hwaddr('eno16777984')
dhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff")/IP(src="0.0.0.0",dst="255.255.255.255")/UDP(sport=68,dport=67)/BOOTP(chaddr=hw)/DHCP(options=[("message-type","discover"),"end"])
result_raw = srp(dhcp_discover, multi=True, timeout=5, verbose=False)
result_list = result_raw[0].res
for i in range(len(result_list)):
ether_fields = result_list[i][1][0].fields
ip_fields = result_list[i][1][1].fields
dhcp_fields = result_list[i][1][3].fields
serverno = str(i + 1)
print('='*20 + 'Server' + serverno + '='*20)
print('Server' + serverno + ' MAC地址为: ' + ether_fields['src'])
print('Server' + serverno + ' IP地址为: ' + ip_fields['src'])
print('Server' + serverno + ' 操作码为: ' + str(dhcp_fields['op']))
print('Server' + serverno + ' ciaddr为: ' + dhcp_fields['ciaddr'])
print('Server' + serverno + ' giaddr为: ' + dhcp_fields['giaddr'])
print('Server' + serverno + ' yiaddr为: ' + dhcp_fields['yiaddr'])
print('Server' + serverno + ' siaddr为: ' + dhcp_fields['siaddr'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。