Exemple #1
0
        public static bool UnLockWinStation(string username, string password, string others, int type)
        {
            bool bRet = true;

            if (type == 0)
            {
                //without username and password, use default encrypted ones
                //if (ClientWinService.m_SessionState == SessionChangeReason.RemoteConnect
                //    || ClientWinService.m_SessionState == SessionChangeReason.SessionLogon
                //    || ClientWinService.m_SessionState == SessionChangeReason.SessionUnlock
                //    || ClientWinService.m_SessionState == SessionChangeReason.ConsoleConnect)
                SessionHelper shlp    = new SessionHelper();
                string        user    = shlp.GetConsoleUser();
                bool          bActive = shlp.IsConsoleActive();
                if (bActive && shlp.IsConsoleSessionLocked() == false)
                {
                    Utils.WriteLog("no need do actual action, as console is active with user " + user);
                    return(true);
                }
                else
                {
                    if (cfg == null)
                    {
                        string path      = System.Reflection.Assembly.GetExecutingAssembly().Location;
                        string directory = System.IO.Path.GetDirectoryName(path);
                        if (File.Exists(directory + "\\" + "config.ini") == false)
                        {
                            WriteLog("The config.ini does not exist, so stop the default unlock action.");
                            return(false);
                        }
                        cfg = new Config();
                        cfg.load(directory + "\\config.ini");
                    }
                    string defaultUsername = CryptoEngine.Decrypt(cfg.getValue("username"), Config.cpuid());
                    string defaultPassword = CryptoEngine.Decrypt(cfg.getValue("password"), Config.cpuid());
                    //Utils.WriteLog("try to send username and password " + defaultUsername + defaultPassword);
                    Win32Helper.Win7AboveSendSAS(false);
                    SendUserNameAndPassword(defaultUsername, defaultPassword);
                    //Utils.WriteLog("after send username and password, try to send sas");
                }
            }

            return(bRet);
        }
Exemple #2
0
        public static void ThreadProc()
        {
            string path      = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string directory = System.IO.Path.GetDirectoryName(path);

            while (true)
            {
                if (File.Exists(directory + "\\" + "unlock.txt"))
                {
                    Utils.WriteLog("found unlock.txt, start to unlock action");
                    if (Utils.IsServerVersion())
                    {
                        Utils.NewRDP("", "");
                    }
                    else
                    {
                        Utils.UnLockWinStation("", "", "", 0);
                    }
                    File.Delete(directory + "\\" + "unlock.txt");
                    Utils.WriteLog("found unlock.txt, end to unlock action");
                    Thread.Sleep(2000);
                }
                else if (File.Exists(directory + "\\" + "lock.txt"))
                {
                    Utils.WriteLog("found lock.txt, start to lock action");
                    Win32Helper.LockWorkStation();
                    File.Delete(directory + "\\" + "lock.txt");
                    Thread.Sleep(2000);
                }
                else
                {
                    //Utils.WriteLog("Local scan thread, nothing found will sleep 5s.");
                    //Thread.Sleep(5000);
                }
            }
        }