Exemple #1
0
def UDP_layer(attributes):
    layer4 = UDP()
    layer4.sport = attributes['sport']
    layer4.dport = attributes['dport']
    layer4.len = attributes['len']

    return layer4
def makePacket(dstip, ethaddr, rthdr):
    # MAC address of router interface on senderSend private network.
    # Don't know why Scapy can't figure this out on its own.
    eth = Ether(dst=ethaddr)

    iphdr = IPv6()
    iphdr.dst = dstip
    # this is necessary for srh
    iphdr.src = C.senderSendIp
    # Routing Header = 43, UDP = 17
    iphdr.nh = 17 if rthdr == "" else 43

    udphdr = UDP()
    udphdr.sport = 11111
    udphdr.dport = 3000

    payload = "$"

    return eth / iphdr / rthdr / udphdr / payload
Exemple #3
0
            if status:
                print str(packet.dport) + " is open\n"
    # UDP
    elif sys.argv[1] == "-u":
        print "UDP scan on host " + sys.argv[2] + "\n"

        ip = IP()
        udp = UDP()

        # cast as str and int to avoid issues caused by periods
        ip.dst = str(sys.argv[2])
        # loop iterates through as many commandline arguments were given
        for port in range(len(sys.argv) - 3):
            print "Scanning port " + str(sys.argv[port + 3])
            # port+3 is start of ports
            udp.dport = int(sys.argv[port + 3])
            packet = (ip / udp)
            # verbose=0 to limit console output; timeout 1s
            status = sr1(packet, verbose=0, timeout=1)
            if status:
                print str(packet.dport) + " is open\n"
    # ICMP
    elif sys.argv[1] == "-i":
        print "PING scan on host " + sys.argv[2] + "\n"

        ip = IP()
        ping = ICMP()

        # cast as str and int to avoid issues caused by periods
        ip.dst = str(sys.argv[2])
        packet = (ip / ping)
Exemple #4
0
'''
Sample script to send a DHCP discover
'''
import scapy
from scapy.sendrecv import sendp, sniff
from scapy.all import DHCP, ARP, BOOTP, Ether, UDP, TCP, IP

# data link layer
ethernet = Ether()
ethernet.dst = 'ff:ff:ff:ff:ff:ff'

# network layer
ip = IP()
ip.dst = '255.255.255.255'

# transport layer
udp = UDP()
udp.sport = 68
udp.dport = 67

# application layer
bootp = BOOTP()
bootp.flags = 1

dhcp = DHCP()
dhcp.options = [("message-type", "discover"), "end"]

packet = ethernet / ip / udp / bootp / dhcp

ans = srp1(packet)
Exemple #5
0
from scapy.all import DHCP, ARP, BOOTP, Ether, UDP, TCP, IP

# data link layer
ethernet = Ether()
ethernet.show()
ethernet.dst = "ff:ff:ff:ff:ff:ff"

# network layer
ip = IP()
ip.show()
ip.dst = "255.255.255.255"

# transport layer
udp = UDP()
udp.show()
udp.sport = 68
udp.dport = 67

# application layer
bootp = BOOTP()
bootp.show()
bootp.flags = 1

dhcp = DHCP()
dhcp.show()
dhcp.options = [("message-type", "discover"), "end"]

packet = ethernet / ip / udp / bootp / dhcp

sendp(packet)