def test_malformed(self):
     with self.assertRaisesRegex(Exception, r'address size'):
         IP6_Address("ABCD:EFAB:1234:1234:1234:1234:1234:12345")
     with self.assertRaisesRegex(Exception, r'triple colon'):
         IP6_Address(":::")
     with self.assertRaisesRegex(Exception, r'triple colon'):
         IP6_Address("::::")
예제 #2
0
파일: ICMP6.py 프로젝트: lxbeyond/impacket
 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
 def test_bin(self):
     tests = (
         ("A:B:C:D:E:F:1:2", '000a000b000c000d000e000f00010002',
          "A:B:C:D:E:F:1:2"),
         ("A:B:0:D:E:F:0:2", '000a000b0000000d000e000f00000002',
          "A:B::D:E:F:0:2"),
         ("A::BC:E:D", '000a000000000000000000bc000e000d', "A::BC:E:D"),
         ("A::BCD:EFFF:D", '000a00000000000000000bcdefff000d',
          "A::BCD:EFFF:D"),
         ("FE80:0000:0000:0000:020C:29FF:FE26:E251",
          'fe80000000000000020c29fffe26e251', "FE80::20C:29FF:FE26:E251"),
         ("::", '00000000000000000000000000000000', "::"),
         ("1::", '00010000000000000000000000000000', "1::"),
         ("::2", '00000000000000000000000000000002', "::2"),
     )
     #    print IP6_Address("A::BC:E:D").as_string(False)
     for torig, thex, texp in tests:
         ip = IP6_Address(torig)
         byt = ip.as_bytes()
         self.assertEqual(hexl(byt), thex)
         self.assertEqual(ip.as_string(), texp)
예제 #4
0
파일: ICMP6.py 프로젝트: lxbeyond/impacket
 def set_target_address(self, target_address):
     address = IP6_Address(target_address)
     payload_bytes = self.child().get_bytes()
     payload_bytes[4:20] = address.get_bytes()
     self.child().set_bytes(payload_bytes)
예제 #5
0
파일: ICMP6.py 프로젝트: lxbeyond/impacket
 def get_target_address(self):
     return IP6_Address(self.child().get_bytes()[4:20])
예제 #6
0
 def set_ip_dst(self, destination_address):
     address = IP6_Address(destination_address)
     bytes = self.get_bytes()
     bytes[24:40] = address.as_bytes()
     self.set_bytes(bytes)
예제 #7
0
 def set_ip_src(self, source_address):
     address = IP6_Address(source_address)
     bytes = self.get_bytes()
     bytes[8:24] = address.as_bytes()
     self.set_bytes(bytes)
예제 #8
0
 def get_ip_dst(self):
     address = IP6_Address(self.get_bytes()[24:40])
     return (address)    
예제 #9
0
 def get_ip_src(self):
     address = IP6_Address(self.get_bytes()[8:24])
     return (address)