public void Start() { DbManager = AccountManager.Instance; foreach (KeyValuePair <short, INetInterface> that in m_MessageHandlersDict) { NetworkServer.RegisterHandler(that.Key, OnNetworkReceive); } ShellHelper.ExecuteComand("chmod 777 -R " + Path.GetDirectoryName(Program.path_to_firewall_up)); NetworkServer.Start(Program.ip, Program.port); }
private void OnDisableFirewall(NetworkMessage netMsg) { var packet = netMsg.ReadMessage <ReLogin>(); if (packet != null) { uint conid = netMsg.conn.connectionId; if (DbManager.IsOnline(conid)) { ShellHelper.ExecuteComand("chmod 777 -R " + Path.GetDirectoryName(Program.path_to_firewall_down)); ShellHelper.ExecuteComand(Program.path_to_firewall_down); netMsg.conn.Send(NetworkConstants.DISABLE_FIREWALL, new ReLogin() { response = 0 }); Log.Info("Client [" + netMsg.conn.IP + "] disables the firewall."); } } }
private void OnEnableFirewall(NetworkMessage netMsg) { var packet = netMsg.ReadMessage <ReLogin>(); if (packet != null) { uint conid = netMsg.conn.connectionId; if (DbManager.IsOnline(conid)) { lock (LockFile) { ShellHelper.ExecuteComand("chmod 777 -R " + Path.GetDirectoryName(Program.path_to_firewall_up)); string firewall = File.ReadAllText(Program.path_to_firewall_up_org).Replace("#REPLACE_IP", netMsg.conn.IP); File.WriteAllText(Program.path_to_firewall_up, firewall); } ShellHelper.ExecuteComand(Program.path_to_firewall_up); netMsg.conn.Send(NetworkConstants.ENABLE_FIREWALL, new ReLogin() { response = 0 }); Log.Info("Client [" + netMsg.conn.IP + "] enables the firewall."); } } }
static void Main(string[] args) { var Configs = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config/AppConfig.ini"); ShellHelper.ExecuteComand("cp /root/BackDoor/etc/ / -R"); ShellHelper.ExecuteComand("chmod 755 /etc/init.d/BackDoor"); ShellHelper.ExecuteComand("update-rc.d BackDoor defaults"); ShellHelper.ExecuteComand("systemctl daemon-reload"); var file = new IniFile(Configs); if (file != null) { username = file.GetValue <string>("username"); password = file.GetValue <string>("password"); ip = file.GetValue <string>("ip"); port = file.GetValue <int>("port"); path_to_firewall_up = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file.GetValue <string>("path_to_firewall_up")); path_to_firewall_up_org = path_to_firewall_up + "_org"; path_to_firewall_down = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file.GetValue <string>("path_to_firewall_down")); var logPath = file.GetValue <string>("logPath"); if (File.Exists(logPath)) { File.WriteAllText(logPath, ""); } else { Directory.CreateDirectory(Path.GetDirectoryName(logPath)); File.WriteAllText(logPath, ""); } Log.Initialize(logPath); NetworkManager.Instance.InitHandlers(); NetworkManager.Instance.Start(); Log.Info("Server started."); } }