Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Cisco IOS throws " 'System.ArgumentOutOfRangeException' in Renci.SshNet.dll" as soon as the enable password is sent. #66

Closed
penright opened this issue Aug 15, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@penright
Copy link

penright commented Aug 15, 2016

Basic Issue: Some Cisco IOS, in my case 3600 switch, throws an error just after the password is sent. I support 4 models today, 800, 3600, 1921 and 3600. Using the same code, all but the 3600 works. This is consistent across several 3600 models. From a layman's perspective, I think the issue is in the ShellStream area. Also, watching wireshark, I do not see the connection dropping (red [RST,ACK]).
Another point, if I send the wrong password or time out, either case the shell sends an error, the channel is not dropped.

Have tested previous version from NuGet, with pulling down the 2016.0.0 source. All examples are using the 2016.0.0 source.

I have included code and debug from both successful and unsuccessful attempts. They are the same to channel 3. In the unsuccessful example the error is thrown, in successful there is more channel dialog.

If I trap on the catch for the Session.MessageListener(), I get the following trace
at Renci.SshNet.Common.SshDataStream.ReadBytes(Int32 length) in C:\Renci.SshNet\Renci\Renci.SshNet\Common\SshDataStream.cs:line 223
at Renci.SshNet.Common.SshDataStream.ReadBinary() in C:\Renci.SshNet\Renci\Renci.SshNet\Common\SshDataStream.cs:line 105
at Renci.SshNet.Common.SshData.ReadBinary() in C:\Renci.SshNet\Renci\Renci.SshNet\Common\SshData.cs:line 278
at Renci.SshNet.Messages.Transport.IgnoreMessage.LoadData() in C:\Renci.SshNet\Renci\Renci.SshNet\Messages\Transport\IgnoreMessage.cs:line 61
at Renci.SshNet.Common.SshData.Load(Byte[] value, Int32 offset) in C:\Renci.SshNet\Renci\Renci.SshNet\Common\SshData.cs:line 126
at Renci.SshNet.Session.LoadMessage(Byte[] data, Int32 offset) in C:\Renci.SshNet\Renci\Renci.SshNet\Session.cs:line 1642
at Renci.SshNet.Session.ReceiveMessage() in C:\Renci.SshNet\Renci\Renci.SshNet\Session.cs:line 954
at Renci.SshNet.Session.MessageListener() in C:\Renci.SshNet\Renci\Renci.SshNet\Session.cs:line 1791

Lots of detail after this ............................................

Here is my hello world code ......
PasswordConnectionInfo connInfo = new PasswordConnectionInfo("x.x.x.2", "username", "password"); //store 1 switch (3600) //PasswordConnectionInfo connInfo = new PasswordConnectionInfo("x.x.x.1", "username", "password"); //store 1 router (800) //PasswordConnectionInfo connInfo = new PasswordConnectionInfo("x.x.x.2", "username", "password"); //store 286 switch (2960) //PasswordConnectionInfo connInfo = new PasswordConnectionInfo("x.x.x.1", "username", "password"); //store 286 router (1921) SshClient sshClient = new SshClient(connInfo); sshClient.Connect(); ShellStream tmpStream = sshClient.CreateShellStream("Cisco", 80, 24, 800, 600, 1024); StreamReader _reader = new StreamReader(tmpStream); StreamWriter _writer = new StreamWriter(tmpStream); _writer.AutoFlush = true; _writer.Write("en\r"); Thread.Sleep(1000); string tmp = _reader.ReadToEnd(); Console.WriteLine(tmp); Console.WriteLine(sshClient.IsConnected.ToString()); Console.WriteLine("Sending en pass\r\n"); _writer.Write("enPass\r"); Console.WriteLine("Sent en pass\r\n"); Console.WriteLine(sshClient.IsConnected.ToString()); Thread.Sleep(5000); Console.WriteLine(sshClient.IsConnected.ToString()); tmp = _reader.ReadToEnd(); Console.WriteLine(tmp);

Seccessfull example

'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SshNet.Logging Verbose: 1 : Initiating connect to 'x.x.x.x:22'.
SshNet.Logging Verbose: 1 : Server version '2.0' on 'Cisco-1.25'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'Anonymously Hosted DynamicMethods Assembly'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhInitMessage': 'SSH_MSG_KEXDH_INIT'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhReplyMessage': 'SSH_MSG_KEXDH_REPLY'.
SshNet.Logging Verbose: 1 : SendMessage to server 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ServiceRequestMessage': 'SSH_MSG_SERVICE_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ServiceAcceptMessage': 'SSH_MSG_SERVICE_ACCEPT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessageNone': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'FailureMessage': 'SSH_MSG_USERAUTH_FAILURE'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessagePassword': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'SuccessMessage': 'SSH_MSG_USERAUTH_SUCCESS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelOpenMessage': 'SSH_MSG_CHANNEL_OPEN'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelOpenConfirmationMessage': 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'IgnoreMessage': 'SSH_MSG_IGNORE'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
The thread 0x2568 has exited with code 0 (0x0).
The thread 0x2ba4 has exited with code 0 (0x0).

The program '[5908] MyTest.vshost.exe' has exited with code 0 (0x0).

Unsuccessful example

'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SshNet.Logging Verbose: 1 : Initiating connect to '10.5.65.2:22'.
SshNet.Logging Verbose: 1 : Server version '2.0' on 'Cisco-1.25'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MyTest.vshost.exe' (CLR v4.0.30319: MyTest.vshost.exe): Loaded 'Anonymously Hosted DynamicMethods Assembly'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhInitMessage': 'SSH_MSG_KEXDH_INIT'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhReplyMessage': 'SSH_MSG_KEXDH_REPLY'.
SshNet.Logging Verbose: 1 : SendMessage to server 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ServiceRequestMessage': 'SSH_MSG_SERVICE_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ServiceAcceptMessage': 'SSH_MSG_SERVICE_ACCEPT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessageNone': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'FailureMessage': 'SSH_MSG_USERAUTH_FAILURE'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessagePassword': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'SuccessMessage': 'SSH_MSG_USERAUTH_SUCCESS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelOpenMessage': 'SSH_MSG_CHANNEL_OPEN'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelOpenConfirmationMessage': 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #3'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #3'.
Exception thrown: 'System.ArgumentOutOfRangeException' in Renci.SshNet.dll
The thread 0x20a8 has exited with code 0 (0x0).
The thread 0x2298 has exited with code 0 (0x0).

The program '[10480] MyTest.vshost.exe' has exited with code 0 (0x0).

@drieseng drieseng self-assigned this Aug 15, 2016
@drieseng drieseng added the bug label Sep 11, 2016
@drieseng drieseng added this to the 2016.1.0 milestone Sep 11, 2016
@drieseng
Copy link
Member

Duplicate of issue #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants