Esempio n. 1
0
 /// <summary>
 /// 密碼
 /// </summary>
 /// <param name="password"></param>
 public void setPassword(string password)
 {
     //_password = password;
     //fortify漏洞-----------------------------------------------add by bruce 20131220
     _password = AntiXSS.GetSafeHtmlFragment(password);
     //fortify漏洞-----------------------------------------------add by bruce 20131220
 }
Esempio n. 2
0
        /// <summary>
        /// 推至遠程
        /// </summary>
        private void ToPut()
        {
            try
            {
                //fortify漏洞-----------------------------------------------add by bruce 20131220
                _password = AntiXSS.GetSafeHtmlFragment(_password);
                //fortify漏洞-----------------------------------------------add by bruce 20131220
                //開始進行SFTP程序
                _sftp = new Sftp(_hostName, _userName, _password);


                _sftp.Connect(_port);
                System.Threading.Thread.Sleep(3000);
                _sftp.Put(_fromFilePath, _toFilePath);
                System.Threading.Thread.Sleep(3000);
                _sftp.Close();

                //write log
                string msg = "";
                msg = "遠程" + _hostName + _toFilePath + ", 檔案已產生。";
                Console.WriteLine(msg);
                LogController.WriteLog("SimpleSftp.Put", msg);
            }
            catch (Exception ex)
            {
                LogController.WriteLog("SimpleSftp.Put", ex.ToString());
                throw ex;
            }
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hostName"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 public SimpleSftp(string hostName, string userName, string password)
 {
     _hostName = hostName;
     //_password = password;
     //fortify漏洞-----------------------------------------------add by bruce 20131220
     _password = AntiXSS.GetSafeHtmlFragment(password);
     //fortify漏洞-----------------------------------------------add by bruce 20131220
     _userName = userName;
     init_Sftp();
 }
Esempio n. 4
0
 private void init_Sftp()
 {
     //fortify漏洞-----------------------------------------------add by bruce 20131220
     _password = AntiXSS.GetSafeHtmlFragment(_password);
     //fortify漏洞-----------------------------------------------add by bruce 20131220
     _sftp = new Sftp(_hostName, _userName, _password);
     if (_port > 0)
     {
         _sftp.Connect(_port);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 遠程取得
        /// </summary>
        private void ToGet()
        {
            try
            {
                //fortify漏洞-----------------------------------------------add by bruce 20131220
                _password = AntiXSS.GetSafeHtmlFragment(_password);
                //fortify漏洞-----------------------------------------------add by bruce 20131220
                //開始進行SFTP程序
                _sftp = new Sftp(_hostName, _userName, _password);
                _sftp.Connect(_port);
                System.Threading.Thread.Sleep(3000);
                _sftp.Get(_fromFilePath, _toFilePath);
                System.Threading.Thread.Sleep(3000);
                _sftp.Close();

                //write log
                string   msg          = "";
                string   fullFilePath = _toFilePath;
                FileInfo oFile        = new FileInfo(fullFilePath); //e.g.: c:\\Test.txt
                if (oFile.Exists)
                {
                    msg = "本地" + _toFilePath + ", 檔案已產生。";
                    Console.WriteLine(msg);
                    LogController.WriteLog("SimpleSftp.Get", msg);
                }
                else
                {
                    msg = "本地" + _toFilePath + ", 檔案沒有產生。";
                    Console.WriteLine(msg);
                    LogController.WriteLog("SimpleSftp.Get", msg);
                }
            }
            catch (Exception ex)
            {
                LogController.WriteLog("SimpleSftp.Get", ex.ToString());
                throw ex;
            }
        }