protected override void Dispose(bool disposing) { if (disposing) { _client.Dispose(); } }
protected override void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { _client?.Dispose(); } _isDisposed = true; }
protected virtual void Dispose(bool disposing) { // Do not dispose this object multiple times if (this.disposed) { return; } // If the method has been called by user code then it is safe to access objects if (disposing) { _client?.Dispose(); } // Mark this object as disposed (so it does not happen twice) this.disposed = true; }
public void Dispose() { _sshClient?.Dispose(); _sftpClient?.Dispose(); _scpClient?.Dispose(); }
// Use this for initialization public void Send() { string address = "10.211.55.4"; string user = "******"; string pass = "******"; //string cmd = "r2 '/home/parallels/Desktop/Bomb.ex_' -c 'aa;s section..text;afn main;e asm.lines=False;e asm.comments=False;e asm.calls=false;e asm.cmtflgrefs=false;e asm.cmtright=false;e asm.flags=false;e asm.function=false;e asm.functions=false;e asm.vars=false;e asm.xrefs=false;e asm.linesout=false;e asm.fcnlines=false;e asm.fcncalls=false;e asm.demangle=false;aa;s section..text;pdf>main.txt;exit' -q"; string cmd = "r2 '/home/parallels/Desktop/Bomb.ex_' -c 'aa; s section..text; afn main; pdf @ main > main.txt' -q"; string uploadfile = @"/Users/JonathanWatts/Desktop/Bomb.ex_"; string uploadDirectory = "/home/parallels/Desktop/"; //Upload a file to a linux VM using (var sftp = new SftpClient(address, user, pass)) { try { sftp.Connect(); using (var fileStream = new FileStream(uploadfile, FileMode.Open)) { Console.WriteLine("Uploading {0} ({1:N0} bytes)", uploadfile, fileStream.Length); sftp.BufferSize = 4 * 1024; // bypass Payload error large files sftp.UploadFile(fileStream, uploadDirectory + Path.GetFileName(uploadfile)); } sftp.Disconnect(); sftp.Dispose(); } catch(Exception ex) { Console.WriteLine(ex.Message); } } //This block of code will send linux terminal commands from windows machine to linux virtual machine using(SshClient client = new SshClient(address,user, pass)) { try { Debug.Log ("Sending Command..."); client.Connect(); Debug.Log ("Sending Command..."); var result = client.RunCommand(cmd); Debug.Log (result); client.Disconnect(); Debug.Log ("Sending Command..."); client.Dispose(); } catch(Exception ex) { Debug.Log (ex.Message); Console.WriteLine(ex.Message); } } //This block of code will download the file from linux VM to the windows host machine try { Debug.Log ("Uploading file..."); using (var sftp = new SftpClient(address, user, pass)) { sftp.Connect(); if(File.Exists("/Users/JonathanWatts/main333.txt")) { File.Delete("/Users/JonathanWatts/main333.txt"); } using (Stream file1 = File.OpenWrite("/Users/JonathanWatts/main333.txt")) { try { sftp.DownloadFile("main.txt", file1); } catch (Exception ex) { Console.WriteLine(ex.Message); } file1.Close(); } sftp.Disconnect(); sftp.Dispose(); } } catch(Exception ex) { Debug.Log (ex.Message); Console.WriteLine(ex.Message); } //SshShell shell = new SshShell(address, user, pass); }
public void Dispose() { _client?.Dispose(); }
/// <inheritdoc /> public void Dispose() { _sftpClient.Dispose(); }
static void Main(string[] args) { string address = "192.168.17.129"; string user = "******"; string pass = "******"; string cmd = "r2 '/home/swastik/Desktop/Bomb.ex_' -c 'aa;s section..text;pdf;pdi;e asm.lines=False;e asm.comments=False;e asm.calls=false;e asm.cmtflgrefs=fal;e asm.cmtright=false;e asm.flags=false;e asm.function=false;e asm.functions=fals;e asm.vars=false;e asm.xrefs=false;e asm.linesout=false;e asm.fcnlines=false;e asm.fcncalls=false;e asm.demangle=false;aa;s section..text;pdf>main.txt;exit' -q"; string uploadfile = @"C:\Users\Swastik\Google Drive\Research\Malaware Visualization\Tool\radare2-w32-0.9.9-git\Bomb.ex_"; string uploadDirectory = "/home/swastik/Desktop/"; //Upload a file to a linux VM using (var sftp = new SftpClient(address, user, pass)) { try { sftp.Connect(); using (var fileStream = new FileStream(uploadfile, FileMode.Open)) { Console.WriteLine("Uploading {0} ({1:N0} bytes)", uploadfile, fileStream.Length); sftp.BufferSize = 4 * 1024; // bypass Payload error large files sftp.UploadFile(fileStream, uploadDirectory + Path.GetFileName(uploadfile)); } sftp.Disconnect(); sftp.Dispose(); } catch(Exception ex) { Console.WriteLine(ex.Message); } } //This block of code will send linux terminal commands from windows machine to linux virtual machine using(SshClient client = new SshClient(address,user, pass)) { try { client.Connect(); var result = client.RunCommand(cmd); client.Disconnect(); client.Dispose(); } catch(Exception ex) { Console.WriteLine(ex.Message); } } //This block of code will download the file from linux VM to the windows host machine try { using (var sftp = new SftpClient(address, user, pass)) { sftp.Connect(); using (Stream file1 = File.OpenWrite("d:\\main333.txt")) { try { sftp.DownloadFile("main.txt", file1); } catch (Exception ex) { Console.WriteLine(ex.Message); } file1.Close(); } sftp.Disconnect(); sftp.Dispose(); } } catch(Exception ex) { Console.WriteLine(ex.Message); } //SshShell shell = new SshShell(address, user, pass); }