• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sendrecv.srp1函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scapy.sendrecv.srp1函数的典型用法代码示例。如果您正苦于以下问题:Python srp1函数的具体用法?Python srp1怎么用?Python srp1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了srp1函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: Checkpacket

 def Checkpacket(self,PortType,Ethertype):
         print "======Checkpacket====="
         time.sleep(1)
         parameters = PubReadConfig("")
         mgmtmac = str(parameters.GetParameter("PC","MGMTMAC"))
         mgmtip = str(parameters.GetParameter("PC","MGMTIP"))
         dstip = str(parameters.GetParameter("DUT1","IP"))
         mgmtnic = str(parameters.GetParameter("PC","MGMTNIC"))
         if PortType == "Unaware":
             eth = Ether(src=mgmtmac,type=0x0806,dst="ff:ff:ff:ff:ff:ff")
             arp = ARP(hwtype=0x0001,ptype=0x0800,op=0x0001,hwsrc=mgmtmac,psrc="192.168.1.42",pdst=dstip,hwdst="ff:ff:ff:ff:ff:ff")
             a = eth/arp
         else:
             eth = Ether(src=mgmtmac,type=Ethertype,dst="ff:ff:ff:ff:ff:ff")
             priority = random.randint(0,7)
             dot1q=Dot1Q(type=0x0806,prio=priority,vlan=1)
             arp = ARP(hwtype=0x0001,ptype=0x0800,op=0x0001,hwsrc=mgmtmac,psrc="192.168.1.42",pdst=dstip,hwdst="ff:ff:ff:ff:ff:ff")
             a = eth/dot1q/arp
         os.system("ifconfig eth0 promisc")
         Reply = srp1(a,iface=mgmtnic,timeout=3)
         os.system("ifconfig eth0 -promisc")
         if Reply == None:
             return 0
         else:
             if Reply.op == 2:
                 return 1
             else:
                 return 0
开发者ID:andymg,项目名称:dvtauto,代码行数:28,代码来源:VlanPortClass.py


示例2: getmacbyip

def getmacbyip(ip, chainCC=0):
    """Return MAC address corresponding to a given IP address"""
    if isinstance(ip,Net):
        ip = iter(ip).next()
    tmp = map(ord, inet_aton(ip))
    if (tmp[0] & 0xf0) == 0xe0: # mcast @
        return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3])
    iff,a,gw = conf.route.route(ip)
    if ( (iff == "lo") or (ip == conf.route.get_if_bcast(iff)) ):
        return "ff:ff:ff:ff:ff:ff"
    if gw != "0.0.0.0":
        ip = gw

    mac = conf.netcache.arp_cache.get(ip)
    if mac:
        return mac

    res = srp1(Ether(dst=ETHER_BROADCAST)/ARP(op="who-has", pdst=ip),
               type=ETH_P_ARP,
               iface = iff,
               timeout=2,
               verbose=0,
               chainCC=chainCC,
               nofilter=1)
    if res is not None:
        mac = res.payload.hwsrc
        conf.netcache.arp_cache[ip] = mac
        return mac
    return None
开发者ID:0x0mar,项目名称:zarp,代码行数:29,代码来源:l2.py


示例3: getmacbyip

def getmacbyip(ip, chainCC=0):
    """Return MAC address corresponding to a given IP address"""
    if isinstance(ip,Net):
        ip = iter(ip).next()
    tmp = map(ord, inet_aton(ip))
    if (tmp[0] & 0xf0) == 0xe0: # mcast @
        return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3])
    iff,a,gw = conf.route.route(ip)
    if ( (iff == LOOPBACK_NAME) or (ip == conf.route.get_if_bcast(iff)) ):
        return "ff:ff:ff:ff:ff:ff"
    # Windows uses local IP instead of 0.0.0.0 to represent locally reachable addresses
    ifip = str(pcapdnet.dnet.intf().get(iff)['addr'])
    if gw != ifip.split('/')[0]:
        ip = gw

    mac = conf.netcache.arp_cache.get(ip)
    if mac:
        return mac

    res = srp1(Ether(dst=ETHER_BROADCAST)/ARP(op="who-has", pdst=ip),
               type=ETH_P_ARP,
               iface = iff,
               timeout=2,
               verbose=0,
               chainCC=chainCC,
               nofilter=1)
    if res is not None:
        mac = res.payload.hwsrc
        conf.netcache.arp_cache[ip] = mac
        return mac
    return None
开发者ID:0x0d,项目名称:hijack,代码行数:31,代码来源:__init__.py


示例4: is_promisc

def is_promisc(ip, fake_bcast="ff:ff:00:00:00:00", **kargs):
    """Try to guess if target is in Promisc mode. The target is provided by its ip."""

    responses = srp1(Ether(dst=fake_bcast) / ARP(op="who-has", pdst=ip),
                     type=ETH_P_ARP, iface_hint=ip, timeout=1, verbose=0, **kargs)

    return responses is not None
开发者ID:Osso,项目名称:scapy,代码行数:7,代码来源:l2.py


示例5: getmacbyip

def getmacbyip(ip, chainCC=0):
    """Return MAC address corresponding to a given IP address"""
    if isinstance(ip, Net):
        ip = next(iter(ip))
    ip = inet_ntoa(inet_aton(ip or "0.0.0.0"))
    tmp = [orb(e) for e in inet_aton(ip)]
    if (tmp[0] & 0xf0) == 0xe0:  # mcast @
        return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1] & 0x7f, tmp[2], tmp[3])
    iff, _, gw = conf.route.route(ip)
    if ((iff == consts.LOOPBACK_INTERFACE) or (ip == conf.route.get_if_bcast(iff))):  # noqa: E501
        return "ff:ff:ff:ff:ff:ff"
    if gw != "0.0.0.0":
        ip = gw

    mac = conf.netcache.arp_cache.get(ip)
    if mac:
        return mac

    try:
        res = srp1(Ether(dst=ETHER_BROADCAST) / ARP(op="who-has", pdst=ip),
                   type=ETH_P_ARP,
                   iface=iff,
                   timeout=2,
                   verbose=0,
                   chainCC=chainCC,
                   nofilter=1)
    except Exception:
        return None
    if res is not None:
        mac = res.payload.hwsrc
        conf.netcache.arp_cache[ip] = mac
        return mac
    return None
开发者ID:commial,项目名称:scapy,代码行数:33,代码来源:l2.py


示例6: dhcp_request

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)
开发者ID:0x0d,项目名称:hijack,代码行数:8,代码来源:dhcp.py



注:本文中的scapy.sendrecv.srp1函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python supersocket.SuperSocket类代码示例发布时间:2022-05-27
下一篇:
Python sendrecv.sniff函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap