Exemple #1
0
        public DbManagerControl(HostService hostService, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            _hostService = hostService;
            _shellData   = data;

            //初始化ExtraSettingXml
            InitExtraSettingXml();

            //绑定事件
            dbManagerService = new DbManagerService(_hostService, _shellData, GetDbType());
            dbManagerService.ConnectDbCompletedToDo       += dbManagerService_ConnectDbCompletedToDo;
            dbManagerService.GetDbNameCompletedToDo       += dbManagerService_GetDbNameCompletedToDo;
            dbManagerService.GetDbTableNameCompletedToDo  += dbManagerService_GetTableNameCompletedToDo;
            dbManagerService.GetColumnTypeCompletedToDo   += dbManagerService_GetColumnTypeCompletedToDo;
            dbManagerService.ExecuteReaderCompletedToDo   += dbManagerService_ExecuteReaderCompletedToDo;
            dbManagerService.ExecuteNonQueryCompletedToDo += dbManagerService_ExecuteNonQueryCompletedToDo;

            treeView_Dbs.AfterSelect += treeView_Dbs_AfterSelect;

            RefreshServerStatus(false);
            //连接数据库
            dbManagerService.ConnectDb(GetConnStr());
        }
Exemple #2
0
        /// <summary>
        /// 载入webshell数据
        /// </summary>
        public void LoadWebshellData()
        {
            int num = 1;

            lv_shell.Items.Clear();
            DataTable dataTable = _shellManager.GetDataTable();

            if (dataTable == null)
            {
                return;
            }
            foreach (DataRow row in dataTable.Rows)
            {
                ShellStruct shellStruct = ConvertDataRowToShellStruct(row);
                string[]    items       = new string[] {
                    shellStruct.Id,
                    num++.ToString(),
                    shellStruct.TargetId,
                    shellStruct.TargetLevel,
                    shellStruct.Status,
                    shellStruct.ShellUrl,
                    shellStruct.ShellType,
                    shellStruct.ServerCoding,
                    shellStruct.Area,
                    shellStruct.Remark,
                    shellStruct.AddTime
                };

                ListViewItem viewItem = new ListViewItem(items);
                viewItem.Tag = shellStruct;
                lv_shell.Items.Add(viewItem);
            }
        }
Exemple #3
0
        public FormEditWebshell(ShellStruct shellStructArray)
        {
            InitializeComponent();
            ComboBox_ScriptType_Init();

            _shellManager = new ShellManager();

            this.button_Add.Enabled   = false;
            this.button_Alter.Enabled = true;

            this.Id = shellStructArray.Id;
            this.textBox_TargetID.Text     = shellStructArray.TargetId;
            this.comboBox_TargetLevel.Text = shellStructArray.TargetLevel;

            this.textBox_ShellPath.Text = shellStructArray.ShellUrl;
            this.textBox_ShellPass.Text = shellStructArray.ShellPwd;

            this.richTextBox_Setting.Text = shellStructArray.ShellExtraSetting;

            this.textBox_Remark.Text = shellStructArray.Remark;

            this.comboBox_ScritpType.Text   = shellStructArray.ShellType;
            this.comboBox_ServerCoding.Text = shellStructArray.ServerCoding;
            this.comboBox_WebCoding.Text    = shellStructArray.WebCoding;
            this.comboBox_Area.Text         = shellStructArray.Area;

            comboBox_IniType_Init();
        }
Exemple #4
0
        private void button_Alter_Click(object sender, EventArgs e)
        {
            ShellStruct shellStruct = new ShellStruct();

            shellStruct.Id          = this.Id;
            shellStruct.TargetId    = this.textBox_TargetID.Text.Trim();
            shellStruct.TargetLevel = this.comboBox_TargetLevel.Text.Trim();

            shellStruct.ShellUrl = this.textBox_ShellPath.Text.Trim();
            shellStruct.ShellPwd = this.textBox_ShellPass.Text.Trim();

            shellStruct.ShellExtraSetting = this.richTextBox_Setting.Text.Trim();
            shellStruct.Remark            = this.textBox_Remark.Text.Trim();

            shellStruct.ShellType    = this.comboBox_ScritpType.Text.Trim();
            shellStruct.ServerCoding = this.comboBox_ServerCoding.Text.Trim();
            shellStruct.WebCoding    = this.comboBox_WebCoding.Text.Trim();
            shellStruct.Area         = this.comboBox_Area.Text.Trim();

            string time = DateTime.Now.Date.ToShortDateString();

            if (time.Contains("/"))
            {
                time = time.Replace("/", "-");
            }
            shellStruct.AddTime = time;


            _shellManager.Update(int.Parse(shellStruct.Id), shellStruct);
            OnWebshellChange(EventArgs.Empty);
            this.Close();
        }
Exemple #5
0
        private string _sourceCopyName;  //用于文件复制

        public FileManagerControl(HostService hostService, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;
            treeView_Dirs.AfterSelect          += treeView_File_AfterSelect;
            listView_File.DragEnter            += listView_File_DragEnter;
            listView_File.DragDrop             += listView_File_DragDrop;
            listView_File.DoubleClick          += listView_File_DoubleClick;
            listView_File.AfterEditSubItem     += listView_File_AfterEditSubItem;
            listView_File.EditSubItemCompleted += listView_File_EditSubItemCompleted;
            rightMenu_FileManager.Opening      += rightMenu_FileManager_Opening;

            this._hostService = hostService;
            this._shellData   = data;

            _fileManager = new FileManagerService(_hostService, _shellData);
            _fileManager.GetWwwRootPathCompletedToDo      += fileManager_GetWwwRootPathCompletedToDo;
            _fileManager.DeleteFileOrDirCompletedToDo     += fileManager_DeleteFileOrDirCompletedToDo;
            _fileManager.GetFileTreeCompletedToDo         += fileManager_GetFileTreeCompletedToDo;
            _fileManager.RenameFileOrDirCompletedToDo     += fileManager_RenameFileOrDirCompletedToDo;
            _fileManager.CopyFileOrDirCompletedToDo       += fileManager_CopyFileOrDirCompletedToDo;
            _fileManager.ModifyFileOrDirTimeCompletedToDo += fileManager_ModifyFileOrDirTimeCompletedToDo;
            _fileManager.CreateDirCompletedToDo           += fileManager_CreateDirCompletedToDo;
            _fileManager.WgetCompletedToDo += fileManager_WgetCompletedToDo;

            //获取根路径
            _fileManager.GetWwwRootPath();
        }
Exemple #6
0
 public FileUploadOrDownload(HostService hostService, ShellStruct shellData, string sourceFilePath, string targetFilePath)
 {
     _hostService    = hostService;
     _shellData      = shellData;
     _sourceFilePath = sourceFilePath;
     _targetFilePath = targetFilePath;
 }
Exemple #7
0
        /// <summary>
        /// 提交命令
        /// </summary>
        /// <param name="data">shellstruct数据</param>
        /// <param name="funcNameXpath">xpath表示的方法名(/cmder/readfile)</param>
        /// <param name="param"></param>
        /// <returns></returns>
        private byte[] SubmitCommand(ShellStruct data, string funcNameXpath, string[] param)
        {
            CustomShellType             shellType         = CustomShellTypeProvider.GetShellType(data.ShellType);
            CustomCommandCode           customCommandCode = new CustomCommandCode(shellType, data.ShellPwd);
            Dictionary <string, string> commandCode       = customCommandCode.GetCode(funcNameXpath, param);
            HttpClient httpClient = new HttpClient();

            return(httpClient.SubmitCommandByPost(data.ShellUrl, commandCode));
        }
Exemple #8
0
 private void ShowShellTypeDataInLable(ShellStruct data)
 {
     lbl_shellData.Text  = "[ShellUrl]:" + data.ShellUrl + "\n";
     lbl_shellData.Text += "[ShellPwd]:" + data.ShellPwd + "\n";
     lbl_shellData.Text += "[ShellType]:" + data.ShellType + "\n";
     lbl_shellData.Text += "[ServerCoding]:" + data.ServerCoding + "\n";
     lbl_shellData.Text += "[TimeOut]:" + data.TimeOut + "\n";
     lbl_shellData.Text += "[ShellExtraSetting]:" + data.ShellExtraSetting + "\n";
 }
Exemple #9
0
        public MyFirstPlugin(HostService host, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            _host      = host;
            _shellData = data;

            ShowShellTypeDataInLable(_shellData);
        }
Exemple #10
0
        public ShellCmderControl(HostService hostService, ShellStruct data)
        {
            InitializeComponent();
            this.Dock         = System.Windows.Forms.DockStyle.Fill;
            this._hostService = hostService;
            this._shellData   = data;

            shellTextBox_Cmder.CommandEntered += shellTextBox_Cmder_CommandEntered;
            shellTextBox_Cmder.Prompt          = "SECTools";
            ConnectOneShell();
        }
Exemple #11
0
        private void item_alter_Click(object sender, EventArgs e)
        {
            if (lv_shell.SelectedItems.Count > 0)
            {
                ShellStruct shellStruct = (ShellStruct)lv_shell.SelectedItems[0].Tag;
                //ShellStruct shellStruct = (ShellStruct)lv_shell.SelectedItems[0].Tag;

                FormEditWebshell editwebshell = new FormEditWebshell(shellStruct);
                editwebshell.WebshellWatchEvent += OnWebshellChange;
                editwebshell.Show();
            }
        }
Exemple #12
0
        /// <summary>
        /// 载入webshell数据
        /// </summary>
        public void LoadWebshellData()
        {
            int num = 1;

            lv_shell.Items.Clear();
            DataTable dataTable = _shellManager.GetDataTable();

            if (dataTable == null)
            {
                return;
            }
            foreach (DataRow row in dataTable.Rows)
            {
                ShellStruct shellStruct = new ShellStruct();

                shellStruct.Id          = row["id"].ToString();
                shellStruct.TargetId    = row["target_id"].ToString();
                shellStruct.TargetLevel = row["target_level"].ToString();

                shellStruct.ShellUrl          = row["shell_url"].ToString();
                shellStruct.ShellPwd          = row["shell_pwd"].ToString();
                shellStruct.ShellType         = row["shell_type"].ToString();
                shellStruct.ShellExtraSetting = row["shell_extra_setting"].ToString();
                shellStruct.ServerCoding      = row["server_coding"].ToString();
                shellStruct.WebCoding         = row["web_coding"].ToString();

                shellStruct.Area    = row["area"].ToString();
                shellStruct.Remark  = row["remark"].ToString();
                shellStruct.AddTime = row["add_time"].ToString();

                string[] items = new string[] {
                    shellStruct.Id,
                    num++.ToString(),
                    shellStruct.TargetId,
                    shellStruct.TargetLevel,
                    "-1",
                    shellStruct.ShellUrl,
                    shellStruct.ShellType,
                    shellStruct.ServerCoding,
                    shellStruct.Area,
                    shellStruct.Remark,
                    shellStruct.AddTime
                };

                ListViewItem viewItem = new ListViewItem(items);
                viewItem.Tag = shellStruct;
                lv_shell.Items.Add(viewItem);
            }
        }
Exemple #13
0
        private byte[] SubmitCommand(ShellStruct data,
                                     string funcNameXpath, string[] param,
                                     bool isBindUploadProgressChangedEvent,
                                     bool isBindDownloadProgressChangedEvent)
        {
            CustomShellType             shellType         = CustomShellTypeProvider.GetShellType(data.ShellType);
            CustomCommandCode           customCommandCode = new CustomCommandCode(shellType, data.ShellPwd);
            Dictionary <string, string> commandCode       = customCommandCode.GetCode(funcNameXpath, param);
            HttpClient httpClient = new HttpClient();

            //if (isBindUploadProgressChangedEvent)
            //    httpClient.UploadFileProgressChangedToDo += httpClient_UploadFileProgressChangedToDo;
            //if (isBindDownloadProgressChangedEvent)
            //    httpClient.DownloadFileProgressChangedToDo += httpClient_DownloadFileProgressChangedToDo;
            return(httpClient.SubmitCommandByPost(data.ShellUrl, commandCode));
        }
Exemple #14
0
        private void RefreshShellStatusInListView(ListViewItem item, string status)
        {
            //等待异步
            if (this.InvokeRequired)
            {
                RefreshShellStatusInvoke invoke = new RefreshShellStatusInvoke(RefreshShellStatusInListView);
                this.Invoke(invoke, new object[] { item, status });
            }
            else
            {
                item.SubItems[4].Text = status;

                ShellStruct shellStruct = (ShellStruct)item.Tag;
                shellStruct.Status = status;
                _shellManager.Update(int.Parse(shellStruct.Id), shellStruct);
            }
        }
Exemple #15
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="model"></param>
        public void Update(int id, ShellStruct model)
        {
            Exception error = null;

            try
            {
                DbManager.Update(id, model);
            }
            catch (Exception ex)
            {
                error = ex;
                if (UpdateCompletedToDo != null)
                {
                    UpdateCompletedToDo(null, new CompletedEventArgs(error));
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="model"></param>
        public void Insert(ShellStruct model)
        {
            Exception error = null;

            try
            {
                DbManager.Insert(model);
            }
            catch (Exception ex)
            {
                error = ex;
                if (InsertCompletedToDo != null)
                {
                    InsertCompletedToDo(null, new CompletedEventArgs(error));
                }
            }
        }
Exemple #17
0
        private void pluginItem_Click(object sender, EventArgs e)
        {
            if (lv_shell.SelectedItems.Count > 0)
            {
                ToolStripMenuItem item = sender as ToolStripMenuItem;
                if (item != null)
                {
                    IPlugin plugin = item.Tag as IPlugin;

                    ShellStruct shellStruct = (ShellStruct)lv_shell.SelectedItems[0].Tag;
                    shellStruct.TimeOut = 8000;

                    UserControl view = plugin.GetUi(shellStruct);
                    //创建新的tab标签
                    TabCore.CreateNewTabPage(plugin.PluginAttribute.Title, view);
                }
            }
        }
Exemple #18
0
        private void RefreshStatus(object listViewItem)
        {
            ListViewItem item        = listViewItem as ListViewItem;
            ShellStruct  shellStruct = (ShellStruct)item.Tag;
            string       shellUrl    = shellStruct.ShellUrl;

            HttpWebRequest  myRequest  = null;
            HttpWebResponse myResponse = null;

            try
            {
                System.Net.ServicePointManager.DefaultConnectionLimit = 1024;
                myRequest                       = (HttpWebRequest)WebRequest.Create(shellUrl);
                myRequest.Method                = "HEAD";
                myRequest.Timeout               = 5000;
                myRequest.KeepAlive             = false;
                myRequest.UseDefaultCredentials = true;
                myRequest.AllowAutoRedirect     = false;
                myResponse                      = (HttpWebResponse)myRequest.GetResponse();
            }
            catch (WebException ex)
            {
                myResponse = (HttpWebResponse)ex.Response;
            }
            finally
            {
                if (myRequest != null)
                {
                    myRequest.Abort();
                }
                if (myResponse != null)
                {
                    myResponse.Close();
                }
            }
            if (myResponse == null)
            {
                RefreshShellStatusInListView(item, "-1");
            }
            else
            {
                RefreshShellStatusInListView(item, Convert.ToInt32(myResponse.StatusCode).ToString());
            }
        }
Exemple #19
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="id">指定id号</param>
        /// <param name="model">shell参数</param>
        /// <returns></returns>
        public static bool Update(int id, ShellStruct model)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>
            {
                { "id", id.ToString() },
                { "target_id", model.TargetId },
                { "target_level", model.TargetLevel },
                { "shell_url", model.ShellUrl },
                { "shell_pwd", model.ShellPwd },
                { "shell_type", model.ShellType },
                { "shell_extra_setting", model.ShellExtraSetting },
                { "server_coding", model.ServerCoding },
                { "web_coding", model.WebCoding },
                { "area", model.Area },
                { "remark", model.Remark },
                { "add_time", model.AddTime }
            };

            return(_sqliteHelper.Update("shell", dic, string.Format("id={0}", id)));
        }
Exemple #20
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="model">shell的参数</param>
        /// <returns></returns>
        public static bool Insert(ShellStruct model)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>
            {
                //{"id", null},//主键自增长字段,不需要设置
                { "target_id", model.TargetId },
                { "target_level", model.TargetLevel },
                { "shell_url", model.ShellUrl },
                { "shell_pwd", model.ShellPwd },
                { "shell_type", model.ShellType },
                { "shell_extra_setting", model.ShellExtraSetting },
                { "server_coding", model.ServerCoding },
                { "web_coding", model.WebCoding },
                { "area", model.Area },
                { "remark", model.Remark },
                { "add_time", model.AddTime }
            };

            return(_sqliteHelper.Insert("shell", dic));
        }
Exemple #21
0
        public FileEditerControl(HostService hostService, ShellStruct data, string filePath, bool autoLoadContent)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            this._hostService = hostService;
            this._shellData   = data;
            _fileManager      = new FileManagerService(_hostService, _shellData);
            _fileManager.ReadFileCompletedToDo  += fileManager_LoadFileContentCompletedToDo;
            _fileManager.WriteFileCompletedToDo += fileManager_SaveFileCompletedToDo;

            if (filePath != null)
            {
                textBox_url.Text = filePath;
                if (autoLoadContent)
                {
                    LoadFileContent(filePath);
                }
            }
        }
Exemple #22
0
        private ShellStruct ConvertDataRowToShellStruct(DataRow row)
        {
            ShellStruct shellStruct = new ShellStruct();

            shellStruct.Id          = row["id"].ToString();
            shellStruct.TargetId    = row["target_id"].ToString();
            shellStruct.TargetLevel = row["target_level"].ToString();
            shellStruct.Status      = row["status"].ToString();

            shellStruct.ShellUrl          = row["shell_url"].ToString();
            shellStruct.ShellPwd          = row["shell_pwd"].ToString();
            shellStruct.ShellType         = row["shell_type"].ToString();
            shellStruct.ShellExtraSetting = row["shell_extra_setting"].ToString();
            shellStruct.ServerCoding      = row["server_coding"].ToString();
            shellStruct.WebCoding         = row["web_coding"].ToString();

            shellStruct.Area    = row["area"].ToString();
            shellStruct.Remark  = row["remark"].ToString();
            shellStruct.AddTime = row["add_time"].ToString();

            return(shellStruct);
        }
Exemple #23
0
 public UserControl GetUi(ShellStruct data)
 {
     return(_userControl = new MyFirstPlugin(_hostService, data));
 }
Exemple #24
0
 public DbManagerService(HostService hostService, ShellStruct data, string dbType)
 {
     this._hostService = hostService;
     this._shellData   = data;
     this._dbType      = dbType;
 }
Exemple #25
0
 public UserControl GetUi(ShellStruct data)
 {
     return(_userControl = new ShellCmderControl(_hostService, data));
 }
Exemple #26
0
 public FileManagerService(HostService hostService, ShellStruct data)
 {
     this._hostService = hostService;
     this._shellData   = data;
 }
Exemple #27
0
 public ShellCmder(HostService host, ShellStruct data)
 {
     this._host      = host;
     this._shellData = data;
 }