當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。