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


Python ImpactPacket.Data方法代码示例

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


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

示例1: buildAnswer

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def buildAnswer(self, in_onion):
       cmd = in_onion[O_UDP_DATA].get_bytes().tostring()
       if cmd[:4] == 'cmd:': cmd = cmd[4:].strip()
       print("Got command: %r" % cmd)

       if cmd == 'exit':
          from sys import exit
          exit()

       out_onion = OpenUDPResponder.buildAnswer(self, in_onion)
       out_onion.append(ImpactPacket.Data())
       out_onion[O_UDP].contains(out_onion[O_UDP_DATA])
       if cmd == 'who':
          out_onion[O_UDP_DATA].set_data(self.machine.fingerprint.get_id())
          
       return out_onion

# NMAP2 specific responders 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:20,代码来源:nmapAnswerMachine.py

示例2: __build_echo_message

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_echo_message(class_object, type, id, sequence_number, arbitrary_data):
        #Build ICMP6 header
        icmp_packet = ICMP6()
        icmp_packet.set_type(type)
        icmp_packet.set_code(0)
        
        #Pack ICMP payload
        icmp_bytes = struct.pack('>H', id)
        icmp_bytes += struct.pack('>H', sequence_number)
        if (arbitrary_data is not None):
            icmp_bytes += array.array('B', arbitrary_data).tostring()
        icmp_payload = Data()
        icmp_payload.set_data(icmp_bytes)
        
        #Link payload to header
        icmp_packet.contains(icmp_payload)
        
        return icmp_packet
    
    
############################################################################ 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:23,代码来源:ICMP6.py

示例3: __build_error_message

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_error_message(class_object, type, code, data, originating_packet_data):
        #Build ICMP6 header
        icmp_packet = ICMP6()
        icmp_packet.set_type(type)
        icmp_packet.set_code(code)
        
        #Pack ICMP payload
        icmp_bytes = array.array('B', data).tostring()
        if (originating_packet_data is not None):
            icmp_bytes += array.array('B', originating_packet_data).tostring()
        icmp_payload = Data()
        icmp_payload.set_data(icmp_bytes)
        
        #Link payload to header
        icmp_packet.contains(icmp_payload)
        
        return icmp_packet

############################################################################ 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:21,代码来源:ICMP6.py

示例4: __build_neighbor_message

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_neighbor_message(class_object, msg_type, target_address):
        #Build ICMP6 header
        icmp_packet = ICMP6()
        icmp_packet.set_type(msg_type)
        icmp_packet.set_code(0)
        
        # Flags + Reserved
        icmp_bytes = array.array('B', [0x00] * 4).tostring()       
        
        # Target Address: The IP address of the target of the solicitation.
        # It MUST NOT be a multicast address.
        icmp_bytes += array.array('B', IP6_Address(target_address).as_bytes()).tostring()
        
        icmp_payload = Data()
        icmp_payload.set_data(icmp_bytes)
        
        #Link payload to header
        icmp_packet.contains(icmp_payload)
        
        return icmp_packet

############################################################################ 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:24,代码来源:ICMP6.py

示例5: __build_node_information_message

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_node_information_message(class_object, type, code, payload = None):
        #Build ICMP6 header
        icmp_packet = ICMP6()
        icmp_packet.set_type(type)
        icmp_packet.set_code(code)
        
        #Pack ICMP payload
        qtype = 0
        flags = 0
        nonce = [0x00] * 8
        
        icmp_bytes = struct.pack('>H', qtype)
        icmp_bytes += struct.pack('>H', flags)
        icmp_bytes += array.array('B', nonce).tostring()
        
        if payload is not None:
            icmp_bytes += array.array('B', payload).tostring()
        
        icmp_payload = Data()
        icmp_payload.set_data(icmp_bytes)
        
        #Link payload to header
        icmp_packet.contains(icmp_payload)

        return icmp_packet 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:27,代码来源:ICMP6.py

示例6: test_27_data_retries_field

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def test_27_data_retries_field(self):
        """Test RadioTap Data retries getter/setter"""
        # When the field is new 
        self.assertEqual(self.rt1.get_size(), len(self.frame_1))
        self.assertEqual(self.rt1.get_header_size(), 32)
        self.assertEqual(self.rt1.get_data_retries(), None)
        self.rt1.set_data_retries(retries=0xAB)
        self.assertEqual(self.rt1.get_data_retries(), 0xAB)
        self.assertEqual(self.rt1.get_size(), len(self.frame_1)+1)
        self.assertEqual(self.rt1.get_header_size(), 32+1)
        # TODO: When exist the field

    # def test_28_hardware_queue_field(self):
    #     """Test RadioTap Hardware Queue getter/setter"""
    #     # When the field is new
    #     self.assertEqual(self.rt2.get_size(),len(self.frame_orig_2))
    #     self.assertEqual(self.rt2.get_header_size(),32)
    #     self.assertEqual(self.rt2.get_hardware_queue(),None)
    #     self.rt2.set_hardware_queue( queue=0xAB )
    #     self.assertEqual(self.rt2.get_hardware_queue(),0xAB)
    #     self.assertEqual(self.rt2.get_size(),len(self.frame_orig_2)+1)
    #     self.assertEqual(self.rt2.get_header_size(),32+1)
    #     # TODO: When exist the field 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:25,代码来源:test_RadioTap.py

示例7: buildAnswer

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def buildAnswer(self, in_onion):
       cmd = in_onion[O_UDP_DATA].get_bytes().tostring()
       if cmd[:4] == 'cmd:': cmd = cmd[4:].strip()
       print "Got command: %r" % cmd

       if cmd == 'exit':
          from sys import exit
          exit()

       out_onion = OpenUDPResponder.buildAnswer(self, in_onion)
       out_onion.append(ImpactPacket.Data())
       out_onion[O_UDP].contains(out_onion[O_UDP_DATA])
       if cmd == 'who':
          out_onion[O_UDP_DATA].set_data(self.machine.fingerprint.get_id())
          
       return out_onion

# NMAP2 specific responders 
开发者ID:tholum,项目名称:PiBunny,代码行数:20,代码来源:nmapAnswerMachine.py

示例8: __build_message

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_message(class_object, type, message_data):
        #Build NDP header
        ndp_packet = NDP()
        ndp_packet.set_type(type)
        ndp_packet.set_code(0)
        
        #Pack payload
        ndp_payload = ImpactPacket.Data()
        ndp_payload.set_data(message_data)
        ndp_packet.contains(ndp_payload)
        
        return ndp_packet 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:14,代码来源:NDP.py

示例9: __build_option

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __build_option(class_object, type, length, option_data):
        #Pack data
        data_bytes = struct.pack('>BB', type, length)
        data_bytes += option_data
        ndp_option = ImpactPacket.Data()
        ndp_option.set_data(data_bytes)
        
        return ndp_option 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:10,代码来源:NDP.py

示例10: __init__

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def __init__(self, id, addresses):
        icmp_request.__init__(self, id, addresses, ICMP.ICMP_ECHO)
        self.i.set_ip_df(False)
        self.i.set_ip_tos(4)
        self.icmp.set_icmp_code(0)
        self.icmp.set_icmp_seq(nmap2_icmp_echo_probe_1.sequence_number + 1)
        self.i.set_ip_id(nmap2_icmp_echo_probe_1.id + 1)
        self.icmp.set_icmp_id(nmap2_icmp_echo_probe_1.id + 1)
        self.icmp.contains(Data("I" * 150)) 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:11,代码来源:os_ident.py

示例11: get_flags

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def get_flags(self):
        # TCP flags (F)
        # This field records the TCP flags in the response. Each letter represents 
        # one flag, and they occur in the same order as in a TCP packet (from 
        # high-bit on the left, to the low ones). So the value SA represents the 
        # SYN and ACK bits set, while the value AS is illegal (wrong order). 
        # The possible flags are shown in Table 8.7.
        # Character	Flag name	            Flag byte value
        # E	        ECN Echo (ECE)	        64
        # U	        Urgent Data (URG)	    32
        # A	        Acknowledgment (ACK)	16
        # P	        Push (PSH)	            8
        # R	        Reset (RST)	            4
        # S	        Synchronize (SYN)	    2
        # F	        Final (FIN)	            1
        
        flags = ""

        if self.__tcp.get_ECE():
            flags += "E"
        if self.__tcp.get_URG():
            flags += "U"
        if self.__tcp.get_ACK():
            flags += "A"
        if self.__tcp.get_PSH():
            flags += "P"
        if self.__tcp.get_RST():
            flags += "R"
        if self.__tcp.get_SYN():
            flags += "S"
        if self.__tcp.get_FIN():
            flags += "F"

        return flags 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:36,代码来源:os_ident.py

示例12: decode

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def decode(self, aBuffer):
        d = ImpactPacket.Data(aBuffer)
        self.set_decoded_protocol( d )
        return d 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:6,代码来源:ImpactDecoder.py

示例13: test_04

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def test_04(self):
        'Test SNAP decoder'
        if PY2:
            self.assertEqual(str(self.in4.__class__), "impacket.dot11.SNAP")
        else:
            self.assertEqual(str(self.in4.__class__), "<class 'impacket.dot11.SNAP'>")

#    def test_05(self):
#        'Test ARP decoder'
#        self.assertEqual(str(self.in5.__class__), "ImpactPacket.ARP")

#    def test_05(self):
#        'Test Data decoder'
#        self.assertEqual(str(self.in6.__class__), "ImpactPacket.Data") 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:16,代码来源:test_RadioTapDecoder.py

示例14: test_06

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def test_06(self):
        'Test Protocol Finder'
        p=self.radiotap_decoder.get_protocol(impacket.dot11.RadioTap)
        if PY2:
            self.assertEqual(str(p.__class__), "impacket.dot11.RadioTap")
        else:
            self.assertEqual(str(p.__class__), "<class 'impacket.dot11.RadioTap'>")
                
        p=self.radiotap_decoder.get_protocol(impacket.dot11.Dot11)
        if PY2:
            self.assertEqual(str(p.__class__), "impacket.dot11.Dot11")
        else:
            self.assertEqual(str(p.__class__), "<class 'impacket.dot11.Dot11'>")
        
        p=self.radiotap_decoder.get_protocol(impacket.dot11.Dot11DataFrame)
        if PY2:
            self.assertEqual(str(p.__class__), "impacket.dot11.Dot11DataFrame")
        else:
            self.assertEqual(str(p.__class__), "<class 'impacket.dot11.Dot11DataFrame'>")
        
        p=self.radiotap_decoder.get_protocol(impacket.dot11.LLC)
        if PY2:
            self.assertEqual(str(p.__class__), "impacket.dot11.LLC")
        else:
            self.assertEqual(str(p.__class__), "<class 'impacket.dot11.LLC'>")
        
        p=self.radiotap_decoder.get_protocol(impacket.dot11.SNAP)
        if PY2:
            self.assertEqual(str(p.__class__), "impacket.dot11.SNAP")
        else:
            self.assertEqual(str(p.__class__), "<class 'impacket.dot11.SNAP'>")
        
        #p=self.radiotap_decoder.get_protocol(ImpactPacket.ARP)
        #self.assertEqual(str(p.__class__), "ImpactPacket.ARP")
        
        #p=self.radiotap_decoder.get_protocol(ImpactPacket.Data)
        #self.assertEqual(str(p.__class__), "ImpactPacket.Data")
        
        # When not found, None is returned
        p=self.radiotap_decoder.get_protocol(impacket.dot11.Dot11WPA)
        self.assertEqual(p, None) 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:43,代码来源:test_RadioTapDecoder.py

示例15: test_30_radiotap_length_filed_with_payload

# 需要导入模块: from impacket import ImpactPacket [as 别名]
# 或者: from impacket.ImpactPacket import Data [as 别名]
def test_30_radiotap_length_filed_with_payload(self):
        """Test RadioTap header length field with payload"""
        # RadioTap from scratch calling get_length() and then get_packet()
        rt = RadioTap()
        self.assertEqual(rt.get_header_length(), 0x08) 
        data = Data(b"aa")
        rt.contains(data)
        self.assertEqual(rt.get_header_length(), 0x08)  # The header length is the same
        raw_packet = rt.get_packet()
        self.assertEqual(raw_packet, b"\x00\x00\x08\x00\x00\x00\x00\x00aa") 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:12,代码来源:test_RadioTap.py


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