def send_ns_packet(self, source_link, send_frequency, target_address, vlan_id=0): ip = IP6.IP6() ip.set_source_address(self.get_source_address()) ip.set_destination_address(self.get_target_address()) ip.set_traffic_class(0) ip.set_flow_label(0) ip.set_hop_limit(255) s = socket(AF_PACKET, SOCK_RAW, IPPROTO_ICMPV6) s.bind((self.network_card, N)) payload = self.create_ns_message(source_link, target_address) print send_frequency for i in range(0, send_frequency): icmp = ICMP6.ICMP6() icmp.set_byte(0, 135) # Put Type? icmp.set_byte(1, 00) # Put Code? payloadObject = ImpactPacket.Data() payloadObject.set_data(payload) icmp.contains(payloadObject) ip.contains(icmp) ip.set_next_header(ip.child().get_ip_protocol_number()) ip.set_payload_length(ip.child().get_size()) eth = ImpactPacket.Ethernet( '\x33\x33\x00\x00\x00\x01\xff\xff\xff\xff\xff\xff\x81\x00') eth.pop_tag() if vlan_id != 0: vlan = ImpactPacket.EthernetTag() vlan.set_vid(vlan_id) eth.push_tag(vlan) icmp.calculate_checksum() eth.contains(ip) s.send(eth.get_packet())
def decode(self, buffer): icmp6_packet = ICMP6.ICMP6(buffer) self.set_decoded_protocol(icmp6_packet) start_pos = icmp6_packet.get_header_size() self.data_decoder = DataDecoder() child_packet = self.data_decoder.decode(buffer[start_pos:]) icmp6_packet.contains(child_packet) return icmp6_packet
ip.set_destination_address(dst) ip.set_traffic_class(0) ip.set_flow_label(0) ip.set_hop_limit(64) f = open('Packets/MyNigga.s0i0.pcap') pcap = dpkt.pcap.Reader(f) for ts, buf in pcap: eth = EthDecoder().decode(buf).child().child().child() icmp6 = ICMP6Decoder().decode(buf) icmp6Child = icmp6.child() checker = icmp6Child.child() print eth icmpv6 = ICMP6.ICMP6() icmpv6.set_type(135) icmpv6.contains(eth) # Open a raw socket. Special permissions are usually required. s = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.IPPROTO_ICMPV6) payload = "A" * 156 print "PING %s %d data bytes" % (dst, len(payload)) seq_id = 0 while 1: # Give the ICMP packet the next ID in the sequence. seq_id += 1 #icmp = ICMP6.ICMP6.Echo_Request(1, seq_id, payload) icmp = icmpv6
ip.set_hop_limit(64) # Open a raw socket. Special permissions are usually required. s = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.IPPROTO_ICMPV6) print socket.gethostname() rawHex = u"ff080800000000000000040005010000000005dc030440c0111111110404040400000000fe8000000000000000000000000000000101000c2911b7241803000800001111000000000000000000000000000000001803030800001111200000000000000000000000000000001803070800001111fc0000000000000000000000000000001903000001010101ff0200000000000000000000000000fb" payload = rawHex.replace(' ', '').decode('hex') print payload #payload = "" print "PING %s %d data bytes" % (dst, len(rawHex)) seq_id = 0 while 1: # Give the ICMP packet the next ID in the sequence. seq_id += 1 icmp = ICMP6.ICMP6() icmp.set_byte(0, 134) # Put Type? icmp.set_byte(1, 00) # Put Code? payloadObject = ImpactPacket.Data() payloadObject.set_data(payload) icmp.contains(payloadObject) # Have the IP packet contain the ICMP packet (along with its payload). ip.contains(icmp) ip.set_next_header(ip.child().get_ip_protocol_number()) ip.set_payload_length(ip.child().get_size()) icmp.calculate_checksum() # Send it to the target host. s.sendto(icmp.get_packet(), (dst, 0)) print "Send Success"