Anonymous - 2022-09-14

Originally posted by: Dando-Real-ITA

I did more testing, and seems to be related to the way GSON handles data in java side.

For example, testing input by sending is correctly encoded in javascript by JSON.stringify, then is send as binary data via connection.send.
However the terminal output displays a "?"

And writing in the terminal: printf "\u1EA1\n" and executing, deliveres to javascript an e.data already broken (notice the ��� instead of ):

[{"sessionId":75,"output":"\r\n\u001b[?2004l\r���\r\n\u001b[?2004h\u001b]0;ubuntu@gpu01: ~\u0007\u001b[01;32mubuntu@gpu01\u001b[00m:\u001b[01;34m~\u001b[00m$ ","id":1,"displayNm":"gpu01.ashburn","user":"ubuntu","host":"gpu01.ashburn.poc.oraclevp.com","port":22,"authorizedKeys":"~/.ssh/authorized_keys","checked":false,"statusCd":"INITIAL","instanceId":1}]

Maybe could be related for output to using sendText instead of sendBinary here: https://github.com/bastillion-io/Bastillion/blob/d1e88b8578ab81edd7184ea7864bbf7647139422/src/main/java/io/bastillion/manage/task/SentOutputTask.java#L49

And for input, here: https://github.com/bastillion-io/Bastillion/blob/d1e88b8578ab81edd7184ea7864bbf7647139422/src/main/java/io/bastillion/manage/socket/SecureShellWS.java#L70
It is accepting onMessage String which is UTF-16, instead of binary to be decoded as UTF-8 with StandardCharsets.UTF_8 before parsing with GSON