本文整理匯總了Python中scapy.arch.get_if_raw_hwaddr方法的典型用法代碼示例。如果您正苦於以下問題:Python arch.get_if_raw_hwaddr方法的具體用法?Python arch.get_if_raw_hwaddr怎麽用?Python arch.get_if_raw_hwaddr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scapy.arch
的用法示例。
在下文中一共展示了arch.get_if_raw_hwaddr方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __attrs_post_init__
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def __attrs_post_init__(self):
"""Initializes attributes after attrs __init__.
These attributes do not change during the life of the object.
"""
logger.debug('Creating new DHCPCAP obj.')
if self.iface is None:
self.iface = conf.iface
if self.client_mac is None:
_, client_mac = get_if_raw_hwaddr(self.iface)
self.client_mac = str2mac(client_mac)
if self.prl is None:
self.prl = PRL
if self.xid is None:
self.xid = gen_xid()
logger.debug('Modifying Lease obj, setting iface.')
self.lease.interface = self.iface
示例2: reset
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def reset(self, iface=None, client_mac=None, xid=None, scriptfile=None):
"""Reset object attributes when state is INIT."""
logger.debug('Reseting attributes.')
if iface is None:
iface = conf.iface
if client_mac is None:
# scapy for python 3 returns byte, not tuple
tempmac = get_if_raw_hwaddr(iface)
if isinstance(tempmac, tuple) and len(tempmac) == 2:
mac = tempmac[1]
else:
mac = tempmac
client_mac = str2mac(mac)
self.client = DHCPCAP(iface=iface, client_mac=client_mac, xid=xid)
if scriptfile is not None:
self.script = ClientScript(scriptfile)
else:
self.script = None
self.time_sent_request = None
self.discover_attempts = 0
self.request_attempts = 0
self.current_state = STATE_PREINIT
self.offers = list()
示例3: dhcp_request
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def dhcp_request(iface=None,**kargs):
if conf.checkIPaddr != 0:
warning("conf.checkIPaddr is not 0, I may not be able to match the answer")
if iface is None:
iface = conf.iface
fam,hw = get_if_raw_hwaddr(iface)
return srp1(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"]),iface=iface,**kargs)
示例4: if_hwaddr
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def if_hwaddr(iff):
return str2mac(get_if_raw_hwaddr(iff)[1])
示例5: dhcp_request
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def dhcp_request(iface=None, **kargs):
"""Send a DHCP discover request and return the answer"""
if conf.checkIPaddr:
warning(
"conf.checkIPaddr is enabled, may not be able to match the answer"
)
if iface is None:
iface = conf.iface
fam, hw = get_if_raw_hwaddr(iface)
return srp1(Ether(dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst="255.255.255.255") / UDP(sport=68, dport=67) / # noqa: E501
BOOTP(chaddr=hw) / DHCP(options=[("message-type", "discover"), "end"]), iface=iface, **kargs) # noqa: E501
示例6: get_my_addr
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def get_my_addr(self, iface):
family, hwaddr = get_if_raw_hwaddr(iface)
hwaddr = binascii.hexlify(hwaddr)
hwaddr = ':'.join(hwaddr[i:i+2] for i in range(0,12,2))
return hwaddr
示例7: dhcp_request
# 需要導入模塊: from scapy import arch [as 別名]
# 或者: from scapy.arch import get_if_raw_hwaddr [as 別名]
def dhcp_request(iface=None,**kargs):
if conf.checkIPaddr != 0:
warning("conf.checkIPaddr is not 0, I may not be able to match the answer")
if iface is None:
iface = conf.iface
hw = get_if_raw_hwaddr(iface)
return srp1(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"]),iface=iface,**kargs)