netfishers-onl / Netshot

Network Configuration and Compliance Management
http://www.netfishers.onl/netshot
246 stars 59 forks source link

New driver switch Cisco Small Business SG300 - problem #97

Closed VitWat closed 1 year ago

VitWat commented 3 years ago

Hi At the beginning I would like to thank you for a great job. There aren't many well-matched products in the open-source world. I also want to give something from myself, so I wrote a driver for the Cisco Small Business switch from the SG300 family. To my surprise, the commands on the device are not performed even though I am logged in (with debuging):

2021-02-03T13:42:57.073Z Macro 'basic' was called (current mode is 'ssh').
2021-02-03T13:42:57.081Z About to send the following command:

Hexadecimal:

Expecting one of the following 1 pattern(s) within 120000ms:
^([A-Za-z\-_0-9\.\/]+#)$
2021-02-03T13:42:57.104Z Received the following output:

SWAEI1A02#
Hexadecimal:
 0d 0a 0d 0d 0a 0d 0a 0d 0a 53 57 41 45 49 31 41 30 32 23
The following pattern matched:
^([A-Za-z\-_0-9\.\/]+#)$
2021-02-03T13:42:57.109Z Reached target mode 'basic'.
2021-02-03T13:42:57.133Z About to send the following command:
terminal datadump
Hexadecimal:
 74 65 72 6d 69 6e 61 6c 20 64 61 74 61 64 75 6d 70 0d
Expecting one of the following 2 pattern(s) within 120000ms:
^(SWAEI1A02#)$
^More:$
2021-02-03T13:44:57.134Z I/O exception: Timeout waiting for the command output.
2021-02-03T13:44:57.134Z The receive buffer is:

Hexadecimal:

2021-02-03T13:44:57.140Z About to send the following command:
show version
Hexadecimal:
 73 68 6f 77 20 76 65 72 73 69 6f 6e 0d
Expecting one of the following 2 pattern(s) within 120000ms:
^(SWAEI1A02#)$
^More:$
2021-02-03T13:46:57.142Z I/O exception: Timeout waiting for the command output.
2021-02-03T13:46:57.142Z The receive buffer is:

Hexadecimal:

Everything works with putty - and with php it also works. Is it to blame for using Java?

SCadilhac commented 3 years ago

Hi, can you send the output of ssh -vvv when connecting to the device?

VitWat commented 3 years ago
[root@xxx ~]# ssh -p 10xxx admin@192.168.x.xx -vvv
OpenSSH_8.0p1, OpenSSL 1.1.1g FIPS  21 Apr 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host 192.168.x.xx originally 192.168.x.xx
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'
debug2: match not found
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
debug1: configuration requests final Match pass
debug2: resolve_canonicalize: hostname 192.168.x.xx is address
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host 192.168.x.xx originally 192.168.x.xx
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'
debug2: match found
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
debug2: ssh_connect_direct
debug1: Connecting to 192.168.x.xx [192.168.x.xx] port 10xxx.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type 0
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1.RL
debug1: match: OpenSSH_5.9p1.RL pat OpenSSH_5* compat 0x0c000002
debug2: fd 5 setting O_NONBLOCK
debug1: Authenticating to 192.168.x.xx:10xxx as 'admin'
debug3: put_host_port: [192.168.x.xx]:10xxx
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from [192.168.x.xx]:10xxx
debug3: order_hostkeyalgs: prefer hostkeyalgs: rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr
debug2: MACs ctos: hmac-sha1
debug2: MACs stoc: hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha1 compression: none
debug1: kex: diffie-hellman-group-exchange-sha1 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha1 need=32 dh_need=32
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 981/2048
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa 
SHA256:
debug3: put_host_port: [192.168.x.xx]:10xxx
debug3: put_host_port: [192.168.x.xx]:10xxx
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from [192.168.x.xx]:10xxx
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from [192.168.x.xx]:10xxx
debug1: Host '[192.168.x.xx]:10xxx' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:3
debug2: bits set: 1024/2048
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /root/.ssh/id_rsa RSA
SHA256:
debug1: Will attempt key: /root/.ssh/id_dsa
debug1: Will attempt key: /root/.ssh/id_ecdsa
debug1: Will attempt key: /root/.ssh/id_ed25519
debug1: Will attempt key: /root/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: password
debug3: start over, passed a different list password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup password
debug3: remaining preferred: ,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
admin@192.168.x.xx's password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 192.168.x.xx ([192.168.x.xx]:10xxx).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 5 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x48
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env LS_COLORS
debug3: Ignored env SSH_CONNECTION
debug1: Sending env LANG = pl_PL.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env HISTCONTROL
debug3: Ignored env HOSTNAME
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env USER
debug3: Ignored env SELINUX_ROLE_REQUESTED
debug3: Ignored env PWD
debug3: Ignored env HOME
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SELINUX_LEVEL_REQUESTED
debug3: Ignored env SSH_TTY
debug3: Ignored env MAIL
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env SELINUX_USE_CURRENT_RANGE
debug3: Ignored env SHLVL
debug3: Ignored env LOGNAME
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env PATH
debug3: Ignored env HISTSIZE
debug3: Ignored env LESSOPEN
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 256 rmax 128
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

SWAEI1A02#
SCadilhac commented 3 years ago

OK thanks, this line debug2: channel 0: open confirm rwindow 256 rmax 128 confirms what I suspected: a very small packet size advertised by the SSH server seems to disturb the underlying SSH library, Jsch...

ck-7 commented 2 years ago

Above Bug is fixed ?

VitWat commented 2 years ago

No.

From: ck-7 @.> Sent: Wednesday, April 27, 2022 8:06 AM To: netfishers-onl/Netshot @.> Cc: VitWat @.>; Author @.> Subject: Re: [netfishers-onl/Netshot] New driver switch Cisco Small Business SG300 - problem (#97)

Above Bug is fixed ?

— Reply to this email directly, view it on GitHub https://github.com/netfishers-onl/Netshot/issues/97#issuecomment-1110579688 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ASWZ32JU3M4O2NJ6GSWDDZLVHDKNJANCNFSM4XA43JUA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ASWZ32ILWGSGOEEDPXBSPVDVHDKNJA5CNFSM4XA43JUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIIZBT2A.gif Message ID: @. @.> >

opiym-7 commented 1 year ago

Hi At the beginning I would like to thank you for a great job. There aren't many well-matched products in the open-source world. I also want to give something from myself, so I wrote a driver for the Cisco Small Business switch from the SG300 family. To my surprise, the commands on the device are not performed even though I am logged in (with debuging):

2021-02-03T13:42:57.073Z Macro 'basic' was called (current mode is 'ssh').
2021-02-03T13:42:57.081Z About to send the following command:

Hexadecimal:

Expecting one of the following 1 pattern(s) within 120000ms:
^([A-Za-z\-_0-9\.\/]+#)$
2021-02-03T13:42:57.104Z Received the following output:

SWAEI1A02#
Hexadecimal:
 0d 0a 0d 0d 0a 0d 0a 0d 0a 53 57 41 45 49 31 41 30 32 23
The following pattern matched:
^([A-Za-z\-_0-9\.\/]+#)$
2021-02-03T13:42:57.109Z Reached target mode 'basic'.
2021-02-03T13:42:57.133Z About to send the following command:
terminal datadump
Hexadecimal:
 74 65 72 6d 69 6e 61 6c 20 64 61 74 61 64 75 6d 70 0d
Expecting one of the following 2 pattern(s) within 120000ms:
^(SWAEI1A02#)$
^More:$
2021-02-03T13:44:57.134Z I/O exception: Timeout waiting for the command output.
2021-02-03T13:44:57.134Z The receive buffer is:

Hexadecimal:

2021-02-03T13:44:57.140Z About to send the following command:
show version
Hexadecimal:
 73 68 6f 77 20 76 65 72 73 69 6f 6e 0d
Expecting one of the following 2 pattern(s) within 120000ms:
^(SWAEI1A02#)$
^More:$
2021-02-03T13:46:57.142Z I/O exception: Timeout waiting for the command output.
2021-02-03T13:46:57.142Z The receive buffer is:

Hexadecimal:

Everything works with putty - and with php it also works. Is it to blame for using Java?

Hello. Can you share the drivers for the Cisco Small Business SG?

SCadilhac commented 1 year ago

https://github.com/netfishers-onl/Netshot/blob/master/src/main/resources/drivers/Cisco_Sx.js