private string _sourceCopyPath; //用于文件复制 #endregion Fields #region Constructors public FileManagerControl(IHostService 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(); }
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()); }
public FileUploadOrDownload(HostService hostService, ShellStruct shellData, string sourceFilePath, string targetFilePath) { _hostService = hostService; _shellData = shellData; _sourceFilePath = sourceFilePath; _targetFilePath = targetFilePath; }
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(); }
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"; }
public MyFirstPlugin(HostService host, ShellStruct data) { InitializeComponent(); this.Dock = System.Windows.Forms.DockStyle.Fill; _host = host; _shellData = data; ShowShellTypeDataInLable(_shellData); }
public ShellCmderControl(IHostService 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(); }
private void ShowShellTypeDataInLable(ShellStruct data) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine("[ShellUrl]:" + data.ShellUrl); strBuilder.AppendLine("[ShellPwd]:" + data.ShellPwd); strBuilder.AppendLine("[ShellType]:" + data.ShellType); strBuilder.AppendLine("[ServerCoding]:" + data.ServerCoding); strBuilder.AppendLine("[TimeOut]:" + data.TimeOut); strBuilder.AppendLine("[ShellExtraSetting]:" + data.ShellExtraSetting); tbx_shellData.Text = strBuilder.ToString(); }
/// <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)); } } }
/// <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); } }
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); } }
/// <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); }
public UserControl GetUi(ShellStruct data) { return _userControl = new MyFirstPlugin(_hostService,data); }
/// <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)); }
public Form GetUi(ShellStruct data) { return _form = new PluginManager(_hostService, data); }
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); }
public UserControl GetUi(ShellStruct data) { return _userControl = new ShellCmderControl(_hostService, data); }
/// <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)); } } }
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; }
public ShellCmderService(IHostService host, ShellStruct data) { this._host = host; this._shellData = data; }
public FileManagerService(IHostService hostService, ShellStruct data) { this._hostService = hostService; this._shellData = data; }
private void button_Add_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.Insert(shellStruct); OnWebshellChange(EventArgs.Empty); this.Close(); }
/// <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); }
public UserControl GetUi(ShellStruct data) { return _userControl = new FileManagerControl(_hostService, data); }
public DbManagerService(HostService hostService, ShellStruct data,string dbType) { this._hostService = hostService; this._shellData = data; this._dbType = dbType; }