当前位置: 首页>>代码示例>>Python>>正文


Python inet.UDP属性代码示例

本文整理汇总了Python中scapy.layers.inet.UDP属性的典型用法代码示例。如果您正苦于以下问题:Python inet.UDP属性的具体用法?Python inet.UDP怎么用?Python inet.UDP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在scapy.layers.inet的用法示例。


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

示例1: voip_play1

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def voip_play1(s1,list=None,**kargs):

    
    dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
    def play(pkt):
        if not pkt:
            return 
        if not pkt.haslayer(UDP):
            return 
        ip=pkt.getlayer(IP)
        if s1 in [ip.src, ip.dst]:
            dsp.write(pkt.getlayer(Raw).load[12:])
    try:
        if list is None:
            sniff(store=0, prn=play, **kargs)
        else:
            for p in list:
                play(p)
    finally:
        dsp.close()
        rd.close() 
开发者ID:medbenali,项目名称:CyberScan,代码行数:23,代码来源:voip.py

示例2: voip_play2

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def voip_play2(s1,**kargs):
    dsp,rd = os.popen2("sox -t .ul -c 2 - -t ossdsp /dev/dsp")
    def play(pkt,last=[]):
        if not pkt:
            return 
        if not pkt.haslayer(UDP):
            return 
        ip=pkt.getlayer(IP)
        if s1 in [ip.src, ip.dst]:
            if not last:
                last.append(pkt)
                return
            load=last.pop()
            x1 = load.load[12:]
#            c1.write(load.load[12:])
            if load.getlayer(IP).src == ip.src:
                x2 = ""
#                c2.write("\x00"*len(load.load[12:]))
                last.append(pkt)
            else:
                x2 = pkt.load[:12]
#                c2.write(pkt.load[12:])
            dsp.write(merge(x1,x2))
            
    sniff(store=0, prn=play, **kargs) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:27,代码来源:voip.py

示例3: voip_play3

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def voip_play3(lst=None,**kargs):
    dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
    try:
        def play(pkt, dsp=dsp):
            if pkt and pkt.haslayer(UDP) and pkt.haslayer(Raw):
                dsp.write(pkt.getlayer(RTP).load)
        if lst is None:
            sniff(store=0, prn=play, **kargs)
        else:
            for p in lst:
                play(p)
    finally:
        try:
            dsp.close()
            rd.close()
        except:
            pass 
开发者ID:medbenali,项目名称:CyberScan,代码行数:19,代码来源:voip.py

示例4: dyndns_del

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def dyndns_del(nameserver, name, type="ALL", ttl=10):
    """Send a DNS delete message to a nameserver for "name"
dyndns_del(nameserver, name, type="ANY", ttl=10) -> result code (0=ok)

example: dyndns_del("ns1.toto.com", "dyn.toto.com")
RFC2136
"""
    zone = name[name.find(".")+1:]
    r=sr1(IP(dst=nameserver)/UDP()/DNS(opcode=5,
                                       qd=[DNSQR(qname=zone, qtype="SOA")],
                                       ns=[DNSRR(rrname=name, type=type,
                                                 rclass="ANY", ttl=0, rdata="")]),
          verbose=0, timeout=5)
    if r and r.haslayer(DNS):
        return r.getlayer(DNS).rcode
    else:
        return -1 
开发者ID:medbenali,项目名称:CyberScan,代码行数:19,代码来源:dns.py

示例5: BEGIN

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def BEGIN(self):
        self.data = [ self.origdata[i*self.blocksize:(i+1)*self.blocksize]
                      for i in range( len(self.origdata)/self.blocksize+1) ] 
        self.my_tid = self.sport or RandShort()._fix()
        bind_bottom_up(UDP, TFTP, dport=self.my_tid)
        self.server_tid = None
        
        self.l3 = IP(dst=self.server)/UDP(sport=self.my_tid, dport=self.port)/TFTP()
        self.last_packet = self.l3/TFTP_WRQ(filename=self.filename, mode="octet")
        self.send(self.last_packet)
        self.res = ""
        self.awaiting=0

        raise self.WAITING_ACK()
        
    # WAITING_ACK 
开发者ID:medbenali,项目名称:CyberScan,代码行数:18,代码来源:tftp.py

示例6: ack_WRQ

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def ack_WRQ(self, pkt):
        ip = pkt[IP]
        self.ip = ip.dst
        self.dst = ip.src
        self.filename = pkt[TFTP_WRQ].filename
        options = pkt[TFTP_Options]
        self.l3 = IP(src=ip.dst, dst=ip.src)/UDP(sport=self.my_tid, dport=pkt.sport)/TFTP()
        if options is None:
            self.last_packet = self.l3/TFTP_ACK(block=0)
            self.send(self.last_packet)
        else:
            opt = [x for x in options.options if x.oname.upper() == "BLKSIZE"]
            if opt:
                self.blksize = int(opt[0].value)
                self.debug(2,"Negotiated new blksize at %i" % self.blksize)
            self.last_packet = self.l3/TFTP_OACK()/TFTP_Options(options=opt)
            self.send(self.last_packet) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:19,代码来源:tftp.py

示例7: make_reply

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def make_reply(self, req):        
        mac = req.src
        if type(self.pool) is list:
            if not self.leases.has_key(mac):
                self.leases[mac] = self.pool.pop()
            ip = self.leases[mac]
        else:
            ip = self.pool
            
        repb = req.getlayer(BOOTP).copy()
        repb.op="BOOTREPLY"
        repb.yiaddr = ip
        repb.siaddr = self.gw
        repb.ciaddr = self.gw
        repb.giaddr = self.gw
        del(repb.payload)
        rep=Ether(dst=mac)/IP(dst=ip)/UDP(sport=req.dport,dport=req.sport)/repb
        return rep 
开发者ID:medbenali,项目名称:CyberScan,代码行数:20,代码来源:dhcp.py

示例8: handle_ack

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def handle_ack(self, pkt, time_sent_request):
        """."""
        logger.debug("Handling ACK.")
        logger.debug('Modifying obj DHCPCAP, setting server data.')
        self.server_mac = pkt[Ether].src
        self.server_ip = pkt[IP].src
        self.server_port = pkt[UDP].sport
        event = DHCP_EVENTS['IP_ACQUIRE']
        # FIXME:0 check the fields match the previously offered ones?
        # FIXME:50 create a new object also on renewing/rebinding
        # or only set_times?
        lease = self.handle_offer_ack(pkt, time_sent_request)
        lease.set_times(time_sent_request)
        if self.lease is not None:
            if (self.lease.address != lease.address or
                    self.lease.subnet_mask != lease.subnet_mask or
                    self.lease.router != lease.router):
                event = DHCP_EVENTS['IP_CHANGE']
            else:
                event = DHCP_EVENTS['RENEW']
        logger.debug('Modifying obj DHCPCAP, setting lease, client ip, event.')
        self.lease = lease
        self.client_ip = self.lease.address
        self.event = event
        return event 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:27,代码来源:dhcpcap.py

示例9: dhcp_ack

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def dhcp_ack(self, client_mac, client_ip, xid):
        dhcp_ack_packet = self.ap.get_radiotap_header() \
                          / Dot11(type="Data", subtype=0, addr1="ff:ff:ff:ff:ff:ff", addr2=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \
                          / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \
                          / SNAP(OUI=0x000000, code=ETH_P_IP) \
                          / IP(src=self.ap.ip, dst=client_ip) \
                          / UDP(sport=67,dport=68) \
                          / BOOTP(op=2, yiaddr=client_ip, siaddr=self.ap.ip, giaddr=self.ap.ip, chaddr=mac_to_bytes(client_mac), xid=xid) \
                          / DHCP(options=[('message-type','ack')]) \
                          / DHCP(options=[('server_id', self.ap.ip)]) \
                          / DHCP(options=[('lease_time', 43200)]) \
                          / DHCP(options=[('subnet_mask', '255.255.255.0')]) \
                          / DHCP(options=[('router', self.ap.ip)]) \
                          / DHCP(options=[('name_server', DEFAULT_DNS_SERVER)]) \
                          / DHCP(options=[('domain', "localdomain")]) \
                          / DHCP(options=['end'])
        sendp(dhcp_ack_packet, iface=self.ap.interface, verbose=False) 
开发者ID:rpp0,项目名称:scapy-fakeap,代码行数:19,代码来源:callbacks.py

示例10: dot11_encapsulate_ip

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def dot11_encapsulate_ip(self, client_mac, ip_packet):
        if IP in ip_packet:
            del ip_packet[IP].chksum
            del ip_packet[IP].len
        else:
            raise Exception("Attempted to encapsulate non-IP packet.")

        if UDP in ip_packet:
            del ip_packet[UDP].len

        response_packet = self.ap.get_radiotap_header() \
                          / Dot11(type="Data", subtype=0, addr1=client_mac, addr2=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \
                          / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \
                          / SNAP(OUI=0x000000, code=ETH_P_IP) \
                          / str(ip_packet)

        sendp(response_packet, iface=self.ap.interface, verbose=False) 
开发者ID:rpp0,项目名称:scapy-fakeap,代码行数:19,代码来源:callbacks.py

示例11: get_int_pkt

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def get_int_pkt(self, pkt, instructions, max_hop, transit_hops=0, hop_metadata=None):
        proto = UDP if UDP in pkt else TCP
        int_pkt = pkt.copy()
        int_pkt[IP].tos = 0x04
        shim_len = 4 + len(instructions) * transit_hops
        int_shim = INT_L45_HEAD(int_type=1, length=shim_len)
        int_header = INT_META_HDR(
            ins_cnt=len(instructions),
            max_hop_cnt=max_hop,
            total_hop_cnt=transit_hops,
            inst_mask=self.get_ins_mask(instructions))
        int_tail = INT_L45_TAIL(next_proto=pkt[IP].proto, proto_param=pkt[proto].dport)
        metadata = "".join([hop_metadata] * transit_hops)
        int_payload = int_shim / int_header / metadata / int_tail
        int_pkt[proto].payload = int_payload / int_pkt[proto].payload
        return int_pkt 
开发者ID:opennetworkinglab,项目名称:fabric-p4test,代码行数:18,代码来源:fabric_test.py

示例12: voip_play1

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def voip_play1(s1,list=None,**kargs):

    
    dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
    def play(pkt):
        if not pkt:
            return 
        if not pkt.haslayer(UDP):
            return 
        ip=pkt.getlayer(IP)
        if s1 in [ip.src, ip.dst]:
            dsp.write(pkt.getlayer(conf.raw_layer).load[12:])
    try:
        if list is None:
            sniff(store=0, prn=play, **kargs)
        else:
            for p in list:
                play(p)
    finally:
        dsp.close()
        rd.close() 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:23,代码来源:voip.py

示例13: voip_play3

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def voip_play3(lst=None,**kargs):
    dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
    try:
        def play(pkt, dsp=dsp):
            if pkt and pkt.haslayer(UDP) and pkt.haslayer(conf.raw_layer):
                dsp.write(pkt.getlayer(RTP).load)
        if lst is None:
            sniff(store=0, prn=play, **kargs)
        else:
            for p in lst:
                play(p)
    finally:
        try:
            dsp.close()
            rd.close()
        except:
            pass 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:19,代码来源:voip.py

示例14: snmpwalk

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def snmpwalk(dst, oid="1", community="public"):
    try:
        while 1:
            r = sr1(IP(dst=dst)/UDP(sport=RandShort())/SNMP(community=community, PDU=SNMPnext(varbindlist=[SNMPvarbind(oid=oid)])),timeout=2, chainCC=1, verbose=0, retry=2)
            if ICMP in r:
                print repr(r)
                break
            if r is None:
                print "No answers"
                break
            print "%-40s: %r" % (r[SNMPvarbind].oid.val,r[SNMPvarbind].value)
            oid = r[SNMPvarbind].oid
            
    except KeyboardInterrupt:
        pass 
开发者ID:medbenali,项目名称:CyberScan,代码行数:17,代码来源:snmp.py

示例15: make_reply

# 需要导入模块: from scapy.layers import inet [as 别名]
# 或者: from scapy.layers.inet import UDP [as 别名]
def make_reply(self, req):
        ip = req.getlayer(IP)
        dns = req.getlayer(DNS)
        resp = IP(dst=ip.src, src=ip.dst)/UDP(dport=ip.sport,sport=ip.dport)
        rdata = self.match.get(dns.qd.qname, self.joker)
        resp /= DNS(id=dns.id, qr=1, qd=dns.qd,
                    an=DNSRR(rrname=dns.qd.qname, ttl=10, rdata=rdata))
        return resp 
开发者ID:medbenali,项目名称:CyberScan,代码行数:10,代码来源:dns.py


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