2

Closed

Bug in SSH shell connection with Cisco IOS

description

Hi everyone! So I have compiled the project into a DLL and I am using that to connect to a Cisco server with SSH enabled. Everything works (I am able to issue commands, and the read back is correct), except when you try and issue the "enable" command. When you do this, SSH.net crashes.

For example, here is some sample code (vb.net) used to connect and repeat the issue:
Dim BufferSize as integer = 1024
Dim ssh_client As New SshClient("10.0.0.5", 22, "admin", "cisco")
ssh_client.Connect()
Dim shellstream As ShellStream = ssh_client.CreateShellStream("xterm", 80, 24, 800, 600, BufferSize)
Dim ssh_reader as New IO.BinaryReader(shellstream)
Dim ssh_writer as New IO.BinaryWriter(shellstream)
Do While shellstream.Length = 0
     Thread.Sleep(100)
Loop
consoleout = ReadStreamText()
ssh_reader.Read(BufferIn, 0, BufferIn.Length) 'Reads back buffer with ascii "Cisco>"
Dim Data() as byte = System.Text.Encoding.ASCII.GetBytes("enable" & VbCrLf)
ssh_writer.Write(Data, 0, Data.Length)
ssh_writer.Flush() 
After the data is sent, the readback buffer is the expected output ("Password:"), but immediately after that, the SSH.net crashes.

Error message: Specified argument was out of the range valid values
Location in SshData.cs:ReadBytes():line 153
The length variable is 29 and the data.count is 5.

After this crash, the shell connection is now unusable, you can not send data or read data from the buffers.

I would also note that this error only happens with the "enable" command. If I issue other commands, they all work and the output is correct. I have tried using SecureCRT and it works perfect as well, so I think there is some kind of bug that happens from data being sent back from the cisco server?

Any ideas?
Closed Sep 17, 2016 at 7:32 AM by drieseng

comments