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

Stopped working with latest browsers #45

Open
drgrussell opened this issue Mar 22, 2021 · 28 comments
Open

Stopped working with latest browsers #45

drgrussell opened this issue Mar 22, 2021 · 28 comments

Comments

@drgrussell
Copy link

Not really sure what is wrong, but I cannot now use SSHy with the latest Chrome or Edge browser.
Exactly the same problem I was having with safari a few months back.

The ENTER key is no longer bubbling up to term.textarea.onkeydown in js/SSHyClient.js.

Note if I comment out (delete) "this.bindKeys" from combinedJS.comb.js everything works fine again. This seems to capture a number of events at the lowest DIV levels and does not always bubble up to your event handler. Unfortunately that is part of xterm.min.js. I did try to update the code to the latest xtermjs, but there seems to be an issue with the function "fix", which I couldnt find any documentation on. I did see an xtermjs extension called fix, but that could be a co-incidence.

Incidentally removing this.bindKeys got me working again in Safari, so win-win.

Happy to help if I can.

@agutierrm
Copy link

Hi! Same here. SSHy stops working on all browsers except Mozilla Firefox... Anyone can fix this?
I have recommended my users to change to firefox but... its a workaround!

Thanks!

@drgrussell
Copy link
Author

drgrussell commented Apr 1, 2021

As mentioned above you can edit out the function call and this will get you going.
I also forked the distro and fixed it properly along with updating xtermjs to the latest version, among other things.
I did put in a pull request, but you can get my revision from https://github.com/drgrussell/SSHy

I am probably going to continue some development. I am 90% through some updates to remove all the globals from sshy, so it is possible to run multiple sshy terminals simultaneously... just for fun really but I really wanted to get into mastering some javascript objects. Currently works in wrapper, but index.html needs more work. Maybe push that one in a few weeks time.

@agutierrm
Copy link

@drgrussell I tried to remove this.bindKeys(); on js/combinedJS.comb.js (line 201) but the behaviour is the same... Did I miss something?

Thanks!!!!!!!!!

@drgrussell
Copy link
Author

Well it works for me. You might find the old library is still in your browser cache, which is particularly the case with chrome in my opinion. So changing the library and then pressing refresh or shift refresh doesnt load the new version. In the url for the javascript library I normally just put ?1 straight afterwards, as that would force a refresh so long as the number is different each time. Or clearing the browser data. Or via the developer window.
https://www.hexnode.com/mobile-device-management/help/how-to-clear-cache-and-hard-reload-browsers/
Its the bane of javascript development in my mind.

@agutierrm
Copy link

agutierrm commented Apr 3, 2021

Hi @drgrussell ! thanks for your support. Dont have luck in my case... I just tried to remove the references to bindKeys(); and reload the library , even in a private browse window but the behaviour its the same, if I press intro key nothing happens. Did you have fix this? Wondering if you can paste the combinedJS.comb.js in pastebin or something similar...

Also I have tried to disable google chrome extensions, maybe the problem was related to that, with no luck. :-((((

Thanks again!

@agutierrm
Copy link

Sorry, I found that removing the two references on this.bindKeys(); in combinedJS and combinedLibs works!
But as you said, there are some functions that are lost like using tab keys... so maybe we must investigate this function.

Thank you @drgrussell

@moecake
Copy link

moecake commented Jun 8, 2021

Yes Thanks @drgrussell 's fork, works fine in latest chrome.

@galaxygamon
Copy link

Well it works for me. You might find the old library is still in your browser cache, which is particularly the case with chrome in my opinion. So changing the library and then pressing refresh or shift refresh doesnt load the new version. In the url for the javascript library I normally just put ?1 straight afterwards, as that would force a refresh so long as the number is different each time. Or clearing the browser data. Or via the developer window.
https://www.hexnode.com/mobile-device-management/help/how-to-clear-cache-and-hard-reload-browsers/
Its the bane of javascript development in my mind.

Refreshing with Ctrl + F5 usually does the trick.

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 9, 2022

@drgrussell I try using your fork to cling to my ssh via websockify - nothing comes out. My page turns white and displays this in the console:

изображение

And websockify reacts to the connection like this:

WebSocket server settings:
  - Listen on :222
  - No SSL/TLS support (no cert file)
  - proxying from :222 to 192.168.112.111:22
192.168.100.187 - - [09/Dec/2022 12:34:06] 192.168.100.187: Plain non-SSL (ws://) WebSocket connection
192.168.100.187 - - [09/Dec/2022 12:34:06] connecting to: 192.168.112.111:22
192.168.100.187 - - [09/Dec/2022 12:34:12] 192.168.100.187: Plain non-SSL (ws://) WebSocket connection
192.168.100.187 - - [09/Dec/2022 12:34:12] connecting to: 192.168.112.111:22

I use the connection via wrapper.html

<html>
<head>
	<script type="text/javascript" src="js/combinedJS.comb.js" ></script>
	<script type="text/javascript">
		var wsproxyURL = "ws://192.168.100.187:222"
		setProxyEncoding("binary");
	</script>
	<link rel="stylesheet" href="css/xterm.css" />
	<link rel="stylesheet" href="css/main.css" />
</head>
<body>
	<div id="terminal" style="height:100%;"></div>
</body>
</html>

@drgrussell Have you abandoned your project yet? Are there any improvements?
@stuicey As I understand it, you are no longer support your project?

@drgrussell
Copy link
Author

drgrussell commented Dec 9, 2022 via email

@AlexanderZhirov
Copy link

@drgrussell Yes, it's working now! You were right, the problem was most likely with the encryption algorithm. I am now connecting via websockify without any problems and it works!!!

изображение

The only question I have left is is it possible to somehow transfer authorization data via a post request or using ajax? I want to pull authorization data from the database on my web portal when connecting via SSH.

So that when connecting, I can automatically or via websockify put the token I need using the native websockify TokenFile plugin and transfer the login password for the selected token?

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 9, 2022

@drgrussell Yes, it's working now! You were right, the problem was most likely with the encryption algorithm. I am now connecting via websockify without any problems and it works!!!

@drgrussell The connection passes to openssh, but does not want to dropbear. Strangely, ssh-rsa is enabled on it by default.

@AlexanderZhirov
Copy link

@drgrussell Every time a connection is made to DropBear, the page is empty. Dropbear logs write that there is a connection, htop displays the child process of the connection, but there is nothing on the web page except errors in the console.

Log dropbear:

Dec  9 19:30:04 (none) authpriv.info dropbear[2246]: Child connection from 192.168.100.187:33914
Dec  9 19:30:07 (none) authpriv.info dropbear[2246]: Exit before auth from <192.168.100.187:33914>: Disconnect received
Dec  9 19:30:08 (none) authpriv.info dropbear[2247]: Child connection from 192.168.100.187:33924
Dec  9 19:30:09 (none) authpriv.info dropbear[2247]: Exit before auth from <192.168.100.187:33924>: Disconnect received
Dec  9 19:30:10 (none) authpriv.info dropbear[2248]: Child connection from 192.168.100.187:33928

изображение

изображение

@drgrussell
Copy link
Author

You would have to do the debugging and legwork on this issue. Capture the traffic detail with the ssh protocol decoded to see the difference between openssh and dropbear in the negotiation with sshy. sshy does not support all possible handshakes, and neither does dropbear it appears. I have never used it myself... No doubt there is some inconsistency in the handshake somewhere.

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 9, 2022

You would have to do the debugging and legwork on this issue. Capture the traffic detail with the ssh protocol decoded to see the difference between openssh and dropbear in the negotiation with sshy. sshy does not support all possible handshakes, and neither does dropbear it appears. I have never used it myself... No doubt there is some inconsistency in the handshake somewhere.

@drgrussell I took a dump of packet exchange between a proxy and a remote host with dropbear. To be honest, without your help, I probably won't be able to figure it out.

изображение

I attach pcap files Wireshark.

dropbear.zip

@AlexanderZhirov
Copy link

@drgrussell For comparison, I took a dump of a successful connection with openssh

изображение

openssh.zip

@drgrussell
Copy link
Author

I didnt even see the SSHv2 protocol appear in that first dump, so your issue must be really early. Indeed, I dont see the ssh server banner in the capture, which is the very first data packet in the handshake. The first packet appears to be 498 bytes, which is not likely to be an SSH banner. In the working example the banner is around 40 bytes, which sounds believable. You sure you are actually connecting to the right port and/or ip? You can telnet or netcat to the port at the shell prompt and the banner should appear. Naturally you should ssh normally to that port too just to check. Maybe you meant port 22 rather than 222?

Regrettably I am not able to debug this for you. Didnt even know dropbear existed...

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 9, 2022

@drgrussell The port is specified correctly, since I started a new SSH process using port 222 and I joined it via the openssh-client. And dropbear is a very lightweight server. Here are the sources. Maybe they will clarify the handshake for understanding the omben.

It is convenient to use it for embedded systems. I have just such a situation. I need to ssh to connect to my devices through the web portal.

@AlexanderZhirov
Copy link

@drgrussell Can you arrange your fork so that we can have a discussion there? Otherwise you don't have any contact details. I would be happy to take part in testing or some kind of assistance in the development of the project. Things are very necessary, since I have not found analogues for embedded systems. I will be very grateful to you for further work and assistance.

P.S. And DropBear would still be very cool to embed support.

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 10, 2022

@drgrussell I have identified a small nuance. For some reason, the version of Dropbear v2018.76 on port 22 still raises the SSH protocol, but the version v2022.83 on port 222 does not raise the SSH protocol, but communicates only via the TCP protocol.

I tried to connect via SSHy to the remote Dropbear server again. This time the dump showed that the communication went through SSHv2. Everything is fine. But the page also does not load, although Dropbear has launched a child process.

изображение

изображение

If I kill the Dropbear process, then the website gives out a page with the code 1000. So there is a connection, but something goes wrong anyway. I am providing a connection dump again.

изображение

изображение

изображение

dropbear_ssh_.zip

@AlexanderZhirov
Copy link

@drgrussell At some stage of the connection, it catches a hang, while the web page does not output anything.

2022-12-10.17-34-00.mp4

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 10, 2022

@drgrussell You can try it, I have launched a distribution with dropbear in a virtual machine. OpenSSH-client connects to it without any problems. tcpdump, htop, scp, dropbear are at your disposal.

ssh [email protected]

user:     root
password: poOZp*ZTK-69Y

I can't do anything. I've already reviewed a bunch of dumps, but I don't understand what is hanging on.

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 10, 2022

@drgrussell Debugging JS showed this about the transport object at the time of connection (in the case of Dropbear - at the time of the disconnection):

OpenSSH
{
    "local_version": "SSH-2.0-SSHyClient",
    "remote_version": "SSH-2.0-OpenSSH_9.0",
    "local_kex_message": "\u0014�hÍ\u001dI�i�5}\u0016$-\u0014�©\u0000\u0000\u0000¹diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha256,diffie-hellman-group1-sha1\u0000\u0000\u0000\u0007ssh-rsa\u0000\u0000\u0000\naes128-ctr\u0000\u0000\u0000\naes128-ctr\u0000\u0000\u0000\u0017hmac-sha2-256,hmac-sha1\u0000\u0000\u0000\u0017hmac-sha2-256,hmac-sha1\u0000\u0000\u0000\u0004none\u0000\u0000\u0000\u0004none\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
    "remote_kex_message": "\u0014\u0012PEåÆXißÊÏat 8Êu\u0000\u0000\u0001\[email protected],curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256\u0000\u0000\u0000Arsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519\u0000\u0000\[email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]\u0000\u0000\[email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]\u0000\u0000\u0000Õ[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1\u0000\u0000\u0000Õ[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1\u0000\u0000\u0000\u0015none,[email protected]\u0000\u0000\u0000\u0015none,[email protected]\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
    "preferred_algorithms": [
        "diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha256,diffie-hellman-group1-sha1",
        "ssh-rsa",
        "aes128-ctr",
        "hmac-sha2-256,hmac-sha1",
        "none",
        ""
    ],
    "preferred_kex": {
        "transport": null,
        "SHAVersion": "SHA-256",
        "f": {
            "0": 113399394,
            "1": 250859908,
            "2": 33645938,
            "3": 172944576,
            "4": 70499056,
            "5": 217623844,
            "6": 85804171,
            "7": 229317055,
            "8": 124448300,
            "9": 159658149,
            "10": 104074666,
            "11": 241655041,
            "12": 61698515,
            "13": 202050870,
            "14": 7955005,
            "15": 164094669,
            "16": 218581674,
            "17": 25259463,
            "18": 238496418,
            "19": 229266018,
            "20": 218367115,
            "21": 207049237,
            "22": 16068140,
            "23": 40024177,
            "24": 80829779,
            "25": 61481810,
            "26": 215538899,
            "27": 171643519,
            "28": 4260619,
            "29": 173749633,
            "30": 241398415,
            "31": 93659235,
            "32": 76050280,
            "33": 192107526,
            "34": 133785352,
            "35": 136477524,
            "36": 93871463,
            "37": 156200756,
            "38": 38812657,
            "39": 30632291,
            "40": 154174212,
            "41": 141839462,
            "42": 208631598,
            "43": 254734959,
            "44": 200805188,
            "45": 94388660,
            "46": 119939552,
            "47": 100131945,
            "48": 123066049,
            "49": 223911482,
            "50": 163416574,
            "51": 173430497,
            "52": 72628352,
            "53": 174933616,
            "54": 34300729,
            "55": 164780897,
            "56": 153793713,
            "57": 173136531,
            "58": 191662499,
            "59": 208840597,
            "60": 239550540,
            "61": 260736727,
            "62": 137349556,
            "63": 225521686,
            "64": 245592162,
            "65": 159381205,
            "66": 192600256,
            "67": 88322722,
            "68": 88353751,
            "69": 223652117,
            "70": 80562282,
            "71": 27428328,
            "72": 102924616,
            "73": 8,
            "s": 0,
            "t": 74
        },
        "e": {
            "0": 17924123,
            "1": 105440995,
            "2": 206287925,
            "3": 54915291,
            "4": 33416045,
            "5": 45910411,
            "6": 143765526,
            "7": 114623854,
            "8": 248104355,
            "9": 17387727,
            "10": 219264927,
            "11": 47411577,
            "12": 250481526,
            "13": 199355089,
            "14": 233751789,
            "15": 222096947,
            "16": 13666402,
            "17": 115777376,
            "18": 81715794,
            "19": 160817099,
            "20": 225732208,
            "21": 146392260,
            "22": 241983576,
            "23": 34033420,
            "24": 240215162,
            "25": 21268140,
            "26": 234378507,
            "27": 68124072,
            "28": 199192620,
            "29": 256982319,
            "30": 140855640,
            "31": 161132611,
            "32": 23629809,
            "33": 228151747,
            "34": 137613848,
            "35": 135992537,
            "36": 20271294,
            "37": 208513817,
            "38": 54067880,
            "39": 128434978,
            "40": 69987448,
            "41": 231010707,
            "42": 266693106,
            "43": 211458827,
            "44": 46251529,
            "45": 127035320,
            "46": 158685108,
            "47": 160185380,
            "48": 39567669,
            "49": 66110640,
            "50": 96845716,
            "51": 213857439,
            "52": 212586559,
            "53": 46865749,
            "54": 252605134,
            "55": 105221082,
            "56": 215098293,
            "57": 84789783,
            "58": 253629482,
            "59": 68488018,
            "60": 190432959,
            "61": 156803871,
            "62": 111878134,
            "63": 226941317,
            "64": 178447185,
            "65": 42354949,
            "66": 254213885,
            "67": 183538995,
            "68": 154924665,
            "69": 64634854,
            "70": 66285578,
            "71": 218784782,
            "72": 260165392,
            "73": 0,
            "74": 17924123,
            "75": 105440995,
            "76": 206287925,
            "77": 54915291,
            "78": 33416045,
            "79": 45910411,
            "80": 143765526,
            "81": 114623854,
            "82": 248104355,
            "83": 17387727,
            "84": 219264927,
            "85": 47411577,
            "86": 250481526,
            "87": 199355089,
            "88": 233751789,
            "89": 222096947,
            "90": 13666402,
            "91": 115777376,
            "92": 81715794,
            "93": 160817099,
            "94": 225732208,
            "95": 146392260,
            "96": 241983576,
            "97": 34033420,
            "98": 240215162,
            "99": 21268140,
            "100": 234378507,
            "101": 68124072,
            "102": 199192620,
            "103": 256982319,
            "104": 140855640,
            "105": 161132611,
            "106": 23629809,
            "107": 228151747,
            "108": 137613848,
            "109": 135992537,
            "110": 20271294,
            "111": 208513817,
            "112": 54067880,
            "113": 128434978,
            "114": 69987448,
            "115": 231010707,
            "116": 266693106,
            "117": 211458827,
            "118": 46251529,
            "119": 127035320,
            "120": 158685108,
            "121": 160185380,
            "122": 39567669,
            "123": 66110640,
            "124": 96845716,
            "125": 213857439,
            "126": 212586559,
            "127": 46865749,
            "128": 252605134,
            "129": 105221082,
            "130": 215098293,
            "131": 84789783,
            "132": 253629482,
            "133": 68488018,
            "134": 190432959,
            "135": 156803871,
            "136": 111878134,
            "137": 226941317,
            "138": 178447185,
            "139": 42354949,
            "140": 254213885,
            "141": 183538995,
            "142": 154924665,
            "143": 64634854,
            "144": 66285578,
            "145": 218784782,
            "146": 260165392,
            "147": 0,
            "148": 0,
            "t": 73,
            "s": 0
        },
        "x": {
            "0": 155773364,
            "1": 95460382,
            "2": 37935257,
            "3": 241856031,
            "4": 206703895,
            "5": 6778627,
            "6": 130958804,
            "7": 8032634,
            "8": 210598803,
            "9": 71024600,
            "10": 153062329,
            "11": 61721367,
            "12": 153501234,
            "13": 124956718,
            "14": 70391308,
            "15": 110989736,
            "16": 142664109,
            "17": 183465888,
            "18": 184034634,
            "19": 20697766,
            "20": 265235800,
            "21": 211219069,
            "22": 187802054,
            "23": 160058572,
            "24": 100462525,
            "25": 194924487,
            "26": 97788951,
            "27": 189248658,
            "28": 158946164,
            "29": 139340045,
            "30": 69643825,
            "31": 54913190,
            "32": 193971983,
            "33": 94986975,
            "34": 254196754,
            "35": 99036380,
            "36": 217323934,
            "37": 127715378,
            "38": 243072257,
            "39": 201344888,
            "40": 29736147,
            "41": 152203914,
            "42": 258244325,
            "43": 148006718,
            "44": 46993435,
            "45": 118311913,
            "46": 149774545,
            "47": 262600762,
            "48": 139373220,
            "49": 151043359,
            "50": 5720749,
            "51": 82832568,
            "52": 244909253,
            "53": 164133647,
            "54": 99590451,
            "55": 38818638,
            "56": 56677141,
            "57": 161842634,
            "58": 219486573,
            "59": 69019767,
            "60": 9128134,
            "61": 119266395,
            "62": 24284874,
            "63": 244918743,
            "64": 145971795,
            "65": 92092784,
            "66": 60611666,
            "67": 60091981,
            "68": 232437774,
            "69": 97715477,
            "70": 238995112,
            "71": 68675946,
            "72": 129639713,
            "s": 0,
            "t": 73
        },
        "g": {
            "0": 2,
            "s": 0,
            "t": 1
        },
        "q": null,
        "p": {
            "0": 55012299,
            "1": 172590584,
            "2": 170116392,
            "3": 13934216,
            "4": 208866567,
            "5": 115704062,
            "6": 263015644,
            "7": 169386546,
            "8": 29103045,
            "9": 85448380,
            "10": 157776610,
            "11": 162380574,
            "12": 63540418,
            "13": 144624472,
            "14": 167725742,
            "15": 56045128,
            "16": 139591594,
            "17": 27936225,
            "18": 244312083,
            "19": 190165010,
            "20": 144308942,
            "21": 53041576,
            "22": 225409941,
            "23": 68613234,
            "24": 76805386,
            "25": 156727046,
            "26": 176642480,
            "27": 164072378,
            "28": 124857341,
            "29": 32283016,
            "30": 179479193,
            "31": 53704619,
            "32": 134169823,
            "33": 5648212,
            "34": 100741503,
            "35": 87466286,
            "36": 48832013,
            "37": 153821091,
            "38": 262125061,
            "39": 189818219,
            "40": 239474887,
            "41": 239513648,
            "42": 35675708,
            "43": 78839791,
            "44": 209497352,
            "45": 114883126,
            "46": 36706843,
            "47": 48057852,
            "48": 73458500,
            "49": 15265035,
            "50": 169374974,
            "51": 137262995,
            "52": 88695965,
            "53": 59117968,
            "54": 142907396,
            "55": 108903357,
            "56": 222240813,
            "57": 209538824,
            "58": 49662817,
            "59": 109880246,
            "60": 58098642,
            "61": 19362454,
            "62": 210898665,
            "63": 120075292,
            "64": 60417107,
            "65": 200631677,
            "66": 72340884,
            "67": 228738812,
            "68": 121474646,
            "69": 202218068,
            "70": 265482250,
            "71": 52207666,
            "72": 18347190,
            "73": 12,
            "s": 0,
            "t": 74
        },
        "minBits": 1024,
        "maxBits": 8192,
        "preferredBits": 2048
    },
    "preferred_hash": 32,
    "parceler": {
        "socket": {},
        "transport": null,
        "encrypting": true,
        "outbound_cipher": {
            "cipher": {
                "mode": 6,
                "_key": [
                    [
                        1751030990,
                        -1924698914,
                        330962786,
                        -1797548794,
                        -797641748,
                        1563664178,
                        1317636176,
                        -632152746,
                        -758103365,
                        -1880892023,
                        -1049995815,
                        456673423,
                        -779996908,
                        1583475869,
                        -1626621628,
                        -2076970549,
                        438513227,
                        1145225942,
                        -615941230,
                        1601866329,
                        -799152764,
                        -1809897646,
                        1331059904,
                        271373977,
                        -2119496882,
                        364129308,
                        1524789468,
                        1255056965,
                        1250911640,
                        1597720964,
                        98122072,
                        1326948125,
                        978632988,
                        1701808280,
                        1622585792,
                        799092445,
                        325386249,
                        1980401809,
                        381434193,
                        958207884,
                        -2120915941,
                        -140514166,
                        -517745189,
                        -666975657
                    ],
                    [
                        -2120915941,
                        -666975657,
                        -517745189,
                        -140514166,
                        430896188,
                        -112479553,
                        1841094094,
                        992939902,
                        2063793463,
                        -1795723407,
                        1452528304,
                        578943810,
                        -2063606888,
                        -1033585215,
                        1947347442,
                        1501759093,
                        -244079288,
                        -1233742797,
                        764489607,
                        -579019283,
                        -927842648,
                        -1679311948,
                        -252841366,
                        739211429,
                        839433944,
                        1795836382,
                        -589133105,
                        -457357811,
                        830094592,
                        -1209482479,
                        945802434,
                        -692717355,
                        -1036337220,
                        -1883828269,
                        -286641129,
                        -405813803,
                        455300566,
                        1633500100,
                        153481666,
                        636844649,
                        1751030990,
                        -1797548794,
                        330962786,
                        -1924698914
                    ]
                ]
            },
            "mode": 6,
            "counter": {
                "blocksize": 16,
                "overflow": 0,
                "value": ";lZn��`ø>�B¹æø¤Q"
            }
        },
        "outbound_mac_key": "ì�\u001cw(¼\u001d\u001c\u0001Ìæ/d�R#ï\u000e>«�\u00136ßb- â\\°e",
        "outbound_enc_key": "h^�Î�GlÞ\u0013º\u0017b�Û�\u0006",
        "outbound_enc_iv": ";lZn��`ø>�B¹æø¤P",
        "inbound_cipher": {
            "cipher": {
                "mode": 6,
                "_key": [
                    [
                        -240278605,
                        1944688440,
                        -1803639507,
                        -181463932,
                        -447218603,
                        -1765905555,
                        46190144,
                        -135275836,
                        939581501,
                        -1363244208,
                        -1401010928,
                        1536270292,
                        -1109678076,
                        325395284,
                        -1088723388,
                        -460654192,
                        -884815763,
                        -668472519,
                        1732021629,
                        -2085194515,
                        -1781490303,
                        1308063416,
                        718011333,
                        -1451389144,
                        1252239698,
                        123002858,
                        765404207,
                        -2065519865,
                        -1832817651,
                        -1785351193,
                        -1207265336,
                        1021852879,
                        -1993677082,
                        482301185,
                        -1531591991,
                        -1738670586,
                        -560887392,
                        -1037116255,
                        1721441896,
                        -20520850,
                        1550849563,
                        -1637954886,
                        -121252654,
                        100873404
                    ],
                    [
                        1550849563,
                        100873404,
                        -121252654,
                        -1637954886,
                        2082400227,
                        -2022838606,
                        -1009469910,
                        212740888,
                        -1082618391,
                        1152997528,
                        -814047950,
                        1890635003,
                        1478804108,
                        -1950104150,
                        -1077259831,
                        -808959726,
                        -1596168439,
                        873043043,
                        1879183579,
                        -1746107490,
                        -1733156271,
                        1141605560,
                        -403795131,
                        925951127,
                        -1717124399,
                        -1545267203,
                        -790726702,
                        -1350383930,
                        -441679876,
                        1933271087,
                        2136781076,
                        908330007,
                        -1985773489,
                        208130363,
                        1232647427,
                        -746030101,
                        1037112037,
                        1159685176,
                        -1695494424,
                        1512831908,
                        -240278605,
                        -181463932,
                        -1803639507,
                        1944688440
                    ]
                ]
            },
            "mode": 6,
            "counter": {
                "blocksize": 16,
                "overflow": 0,
                "value": "+4�~Â��¿y\u0015mÚ<½4¦"
            }
        },
        "inbound_mac_key": "�}~�&-D�¢¬¬�¸�=�ÚT\r]ü®C£¨I�s/&Ý�",
        "inbound_enc_key": "ñ­£³sé�8�~¥-õ/\u0014",
        "inbound_iv": null,
        "hmacSHAVersion": "SHA-256",
        "macSize": 32,
        "inbound_sequence_num": 5,
        "outbound_sequence_num": 5,
        "block_size": 16,
        "inbound_buffer": "",
        "prevHeader": "",
        "windowSize": 38190,
        "transmitData": 740,
        "recieveData": 2557,
        "inbound_enc_iv": "+4�~Â��¿y\u0015mÚ<½4¥"
    },
    "auth": {
        "parceler": {
            "socket": {},
            "transport": null,
            "encrypting": true,
            "outbound_cipher": {
                "cipher": {
                    "mode": 6,
                    "_key": [
                        [
                            1751030990,
                            -1924698914,
                            330962786,
                            -1797548794,
                            -797641748,
                            1563664178,
                            1317636176,
                            -632152746,
                            -758103365,
                            -1880892023,
                            -1049995815,
                            456673423,
                            -779996908,
                            1583475869,
                            -1626621628,
                            -2076970549,
                            438513227,
                            1145225942,
                            -615941230,
                            1601866329,
                            -799152764,
                            -1809897646,
                            1331059904,
                            271373977,
                            -2119496882,
                            364129308,
                            1524789468,
                            1255056965,
                            1250911640,
                            1597720964,
                            98122072,
                            1326948125,
                            978632988,
                            1701808280,
                            1622585792,
                            799092445,
                            325386249,
                            1980401809,
                            381434193,
                            958207884,
                            -2120915941,
                            -140514166,
                            -517745189,
                            -666975657
                        ],
                        [
                            -2120915941,
                            -666975657,
                            -517745189,
                            -140514166,
                            430896188,
                            -112479553,
                            1841094094,
                            992939902,
                            2063793463,
                            -1795723407,
                            1452528304,
                            578943810,
                            -2063606888,
                            -1033585215,
                            1947347442,
                            1501759093,
                            -244079288,
                            -1233742797,
                            764489607,
                            -579019283,
                            -927842648,
                            -1679311948,
                            -252841366,
                            739211429,
                            839433944,
                            1795836382,
                            -589133105,
                            -457357811,
                            830094592,
                            -1209482479,
                            945802434,
                            -692717355,
                            -1036337220,
                            -1883828269,
                            -286641129,
                            -405813803,
                            455300566,
                            1633500100,
                            153481666,
                            636844649,
                            1751030990,
                            -1797548794,
                            330962786,
                            -1924698914
                        ]
                    ]
                },
                "mode": 6,
                "counter": {
                    "blocksize": 16,
                    "overflow": 0,
                    "value": ";lZn��`ø>�B¹æø¤Q"
                }
            },
            "outbound_mac_key": "ì�\u001cw(¼\u001d\u001c\u0001Ìæ/d�R#ï\u000e>«�\u00136ßb- â\\°e",
            "outbound_enc_key": "h^�Î�GlÞ\u0013º\u0017b�Û�\u0006",
            "outbound_enc_iv": ";lZn��`ø>�B¹æø¤P",
            "inbound_cipher": {
                "cipher": {
                    "mode": 6,
                    "_key": [
                        [
                            -240278605,
                            1944688440,
                            -1803639507,
                            -181463932,
                            -447218603,
                            -1765905555,
                            46190144,
                            -135275836,
                            939581501,
                            -1363244208,
                            -1401010928,
                            1536270292,
                            -1109678076,
                            325395284,
                            -1088723388,
                            -460654192,
                            -884815763,
                            -668472519,
                            1732021629,
                            -2085194515,
                            -1781490303,
                            1308063416,
                            718011333,
                            -1451389144,
                            1252239698,
                            123002858,
                            765404207,
                            -2065519865,
                            -1832817651,
                            -1785351193,
                            -1207265336,
                            1021852879,
                            -1993677082,
                            482301185,
                            -1531591991,
                            -1738670586,
                            -560887392,
                            -1037116255,
                            1721441896,
                            -20520850,
                            1550849563,
                            -1637954886,
                            -121252654,
                            100873404
                        ],
                        [
                            1550849563,
                            100873404,
                            -121252654,
                            -1637954886,
                            2082400227,
                            -2022838606,
                            -1009469910,
                            212740888,
                            -1082618391,
                            1152997528,
                            -814047950,
                            1890635003,
                            1478804108,
                            -1950104150,
                            -1077259831,
                            -808959726,
                            -1596168439,
                            873043043,
                            1879183579,
                            -1746107490,
                            -1733156271,
                            1141605560,
                            -403795131,
                            925951127,
                            -1717124399,
                            -1545267203,
                            -790726702,
                            -1350383930,
                            -441679876,
                            1933271087,
                            2136781076,
                            908330007,
                            -1985773489,
                            208130363,
                            1232647427,
                            -746030101,
                            1037112037,
                            1159685176,
                            -1695494424,
                            1512831908,
                            -240278605,
                            -181463932,
                            -1803639507,
                            1944688440
                        ]
                    ]
                },
                "mode": 6,
                "counter": {
                    "blocksize": 16,
                    "overflow": 0,
                    "value": "+4�~Â��¿y\u0015mÚ<½4¦"
                }
            },
            "inbound_mac_key": "�}~�&-D�¢¬¬�¸�=�ÚT\r]ü®C£¨I�s/&Ý�",
            "inbound_enc_key": "ñ­£³sé�8�~¥-õ/\u0014",
            "inbound_iv": null,
            "hmacSHAVersion": "SHA-256",
            "macSize": 32,
            "inbound_sequence_num": 5,
            "outbound_sequence_num": 5,
            "block_size": 16,
            "inbound_buffer": "",
            "prevHeader": "",
            "windowSize": 38190,
            "transmitData": 740,
            "recieveData": 2557,
            "inbound_enc_iv": "+4�~Â��¿y\u0015mÚ<½4¥"
        },
        "authenticated": null,
        "awaitingAuthentication": false,
        "hostname": "192.168.100.187",
        "termUsername": "root",
        "failedAttempts": 0,
        "channelOpened": false
    },
    "settings": {
        "localEcho": 0,
        "fsHintEnter": "\u001b[?1",
        "fsHintLeave": "\u001b]0;",
        "autoEchoState": false,
        "autoEchoTimeout": 0,
        "blockedKeys": [
            ":"
        ],
        "fontSize": 16,
        "colorTango": false,
        "colorNames": [
            "0",
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7"
        ],
        "colorCounter": 0,
        "shellString": "",
        "sidenavElementState": 0,
        "rxElement": {},
        "txElement": {},
        "autoEchoElement": {},
        "rsaCheckEnabled": false
    },
    "lastKey": "",
    "closing": false
}
Dropbear
{
    "local_version": "SSH-2.0-SSHyClient",
    "remote_version": "SSH-2.0-dropbear_2018.76\r\n\u0000\u0000\u0001ô\u0007\u0014|ت-ü3\u000fI¦ú»¥�\u0013Ñ\u0000\u0000\u0000»curve25519-sha256,[email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,[email protected]\u0000\u0000\u0000\u0007ssh-rsa\u0000\u0000\u0000=aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc\u0000\u0000\u0000=aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc\u0000\u0000\u0000$hmac-sha1-96,hmac-sha1,hmac-sha2-256\u0000\u0000\u0000$hmac-sha1-96,hmac-sha1,hmac-sha2-256\u0000\u0000\u0000\u0015[email protected],none\u0000\u0000\u0000\u0015[email protected],none\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�û\u001c��",
    "local_kex_message": "\u0014ëÙIí�«Æ\n\u0011¨ÖËð�\u0000\u0000\u0000¹diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha256,diffie-hellman-group1-sha1\u0000\u0000\u0000\u0007ssh-rsa\u0000\u0000\u0000\naes128-ctr\u0000\u0000\u0000\naes128-ctr\u0000\u0000\u0000\u0017hmac-sha2-256,hmac-sha1\u0000\u0000\u0000\u0017hmac-sha2-256,hmac-sha1\u0000\u0000\u0000\u0004none\u0000\u0000\u0000\u0004none\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
    "remote_kex_message": null,
    "preferred_algorithms": [
        "diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha256,diffie-hellman-group1-sha1",
        "ssh-rsa",
        "aes128-ctr",
        "hmac-sha2-256,hmac-sha1",
        "none",
        ""
    ],
    "preferred_kex": null,
    "preferred_mac": null,
    "preferred_hash": null,
    "parceler": {
        "socket": {},
        "transport": null,
        "encrypting": false,
        "outbound_cipher": null,
        "outbound_mac_key": null,
        "outbound_enc_key": null,
        "outbound_enc_iv": null,
        "inbound_cipher": null,
        "inbound_mac_key": null,
        "inbound_enc_key": null,
        "inbound_iv": null,
        "hmacSHAVersion": null,
        "macSize": 0,
        "inbound_sequence_num": 0,
        "outbound_sequence_num": 1,
        "block_size": 8,
        "inbound_buffer": "",
        "prevHeader": "",
        "windowSize": 40674,
        "transmitData": 364,
        "recieveData": 530
    },
    "auth": {
        "parceler": {
            "socket": {},
            "transport": null,
            "encrypting": false,
            "outbound_cipher": null,
            "outbound_mac_key": null,
            "outbound_enc_key": null,
            "outbound_enc_iv": null,
            "inbound_cipher": null,
            "inbound_mac_key": null,
            "inbound_enc_key": null,
            "inbound_iv": null,
            "hmacSHAVersion": null,
            "macSize": 0,
            "inbound_sequence_num": 0,
            "outbound_sequence_num": 1,
            "block_size": 8,
            "inbound_buffer": "",
            "prevHeader": "",
            "windowSize": 40674,
            "transmitData": 364,
            "recieveData": 530
        },
        "authenticated": null,
        "awaitingAuthentication": false,
        "hostname": "192.168.100.187",
        "termUsername": "root",
        "termPassword": "poOZp*ZTK-69Y",
        "failedAttempts": 0,
        "channelOpened": false
    },
    "settings": {
        "localEcho": 0,
        "fsHintEnter": "\u001b[?1",
        "fsHintLeave": "\u001b]0;",
        "autoEchoState": false,
        "autoEchoTimeout": 0,
        "blockedKeys": [
            ":"
        ],
        "fontSize": 16,
        "colorTango": true,
        "colorNames": [
            "0",
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7"
        ],
        "colorCounter": 0,
        "shellString": "",
        "sidenavElementState": 0,
        "rxElement": {},
        "txElement": {},
        "autoEchoElement": {},
        "rsaCheckEnabled": false
    },
    "lastKey": "",
    "closing": false
}

If I understand correctly, then Dropbear did not pass the public key because there is no entry in the parameter remote_kex_message?

@AlexanderZhirov
Copy link

And here are the successful connections to Dropbear using webssh

pcap webssh.zip

@mkj
Copy link

mkj commented Dec 12, 2022

I'm the Dropbear author. I hadn't seen SSHy, looks handy.

I think the problem is that the remote_version isn't parsed correctly in SSHy. It should be looking for the \r\n then passing the remainder on as transport packets. Instead it is assuming the whole contents is remote_version (plus \r\n).

SSHy/js/transport.js

Lines 81 to 82 in 82941c8

// Slice off the '/r/n' from the end of our remote version
self.remote_version = m.slice(0, m.length - 2);

In #45 (comment) the remote_version for Dropbear shows the first kexinit packet appended to the variable. Dropbear sends the banner and initial packet in a single IP packet (it's just a TCP stream), and then the javascript gets it as a single read.

@drgrussell
Copy link
Author

drgrussell commented Dec 12, 2022

Hi mkj...
Yes it does look that way. I cannot find a simple packet exchange in the rfc documents. The best diagram I can find is in wikibooks.... https://en.wikibooks.org/wiki/OpenSSH/SSH_Protocols
Here at least the remote version exchange appears to be separate from the key exchange phase, and even then the client goes first. I have no doubt that your implementation is rfc compliant, but I guess stuicy and I did have some assumptions.
I will have a look at this sometime in the new year and see if I can buffer up the remaining data from the first packet and push that back into the client code at the expected moment.
Thanks for the message and support. I expect it is not a huge change to handle this exchange pattern in sshy. Just pressed for time right now for a few weeks.

@AlexanderZhirov
Copy link

It turns out that the server data comes in one package at once. I tried to sort it out by bytes here. Maybe you'll need it when you watch the package.

SSH-2.0-dropbear_2018.76\r\n\u0000\u0000\u0001ô\u0007\u0014|ت-ü3\u000fI¦ú»¥�\u0013Ñ\u0000\u0000\u0000»curve25519-sha256,[email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,[email protected]\u0000\u0000\u0000\u0007ssh-rsa\u0000\u0000\u0000=aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc\u0000\u0000\u0000=aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc\u0000\u0000\u0000$hmac-sha1-96,hmac-sha1,hmac-sha2-256\u0000\u0000\u0000$hmac-sha1-96,hmac-sha1,hmac-sha2-256\u0000\u0000\u0000\[email protected],none\u0000\u0000\u0000\[email protected],none\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�û\u001c��
  • Protocol (24 byte): SSH-2.0-dropbear_2018.76
  • (2 byte): \r\n
  • Packet Length (4 byte): \u0000\u0000\u0001ô
  • Padding Length (1 byte): \u0007
  • Message Code: Key Exchange Init (1 byte): \u0014
  • Cookie (16 byte): |ت-ü3\u000fI¦ú»¥�\u0013Ñ
  • Kex Algorithms Length (4 byte): \u0000\u0000\u0000»
  • Kex Algorithms String (187 byte): curve25519-sha256,[email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,[email protected]
  • Server Host key Algorithms Length (4 byte): \u0000\u0000\u0000\u0007
  • Server Host key Algorithms String (7 byte): ssh-rsa
  • Encryption Algorithms Client To Server Length (4 byte): \u0000\u0000\u0000=
  • Encryption Algorithms Client To Server String (61 byte): aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc
  • Encryption Algorithms Server To Client Length (4 byte): \u0000\u0000\u0000=
  • Encryption Algorithms Server To Client String (61 byte): aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc,3des-ctr,3des-cbc
  • Mac Algorithms Client To Server Length (4 byte): \u0000\u0000\u0000$
  • Mac Algorithms Client To Server String (36 byte): hmac-sha1-96,hmac-sha1,hmac-sha2-256
  • Mac Algorithms Server To Client Length (4 byte): \u0000\u0000\u0000$
  • Mac Algorithms Server To Client String (36 byte): hmac-sha1-96,hmac-sha1,hmac-sha2-256
  • Compression Algorithms Client To Server Length (4 byte): \u0000\u0000\u0000\u0015
  • Compression Algorithms Client To Server String (21 byte): [email protected],none
  • Compression Algorithms Server To Client Length (4 byte): \u0000\u0000\u0000\u0015
  • Compression Algorithms Server To Client String (21 byte): [email protected],none
  • Languages Client To Server Length (4 byte): \u0000\u0000\u0000\u0000
  • Languages Server To Client Length (4 byte): \u0000\u0000\u0000\u0000
  • First KEX Packet Follows (1 byte): \u0000
  • Reserved (4 byte): \u0000\u0000\u0000\u0000
  • Padding String (10 byte): �û\u001c��

@AlexanderZhirov
Copy link

@drgrussell I think you should take a look at these improvements. There is some progress in the solution, but the problem with the algorithm, I'm probably not sure.

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

No branches or pull requests

6 participants