JusticeRage / FFM

Freedom Fighting Mode: open source hacking harness
GNU General Public License v3.0
333 stars 49 forks source link

echo -n end_marker being printed to stdout #13

Closed ice-wzl closed 1 year ago

ice-wzl commented 1 year ago

Steps to reproduce

┌──(kali㉿kali)-[/opt/justice-ffm/FFM] echo -n IJVzPmNFQumMGiuPRRpyZMPFRUVkHHeo

- I did not enter the `echo -n` command
### SSH'ed with no `pty` 

!os cat /etc/release echo -n WNGwrqHpyzOhRwRghOvenIHUzGXWNsVk DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS" PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy


- Happy to assist you trying to fix this issue.  Cheers.
JusticeRage commented 1 year ago

Hi! It's been a long time since I've worked on this project, but I vaguely remember this being an issue on occasion. Basically, something challenging is detecting when a command has finished printing output. When using a PTY, there is usually a prompt (i.e., root@kali #>) which can be used as a delimiter. FFM tries to detect such a string with a regular expression that mostly worked back then, but not so much now that prompts have those weird characters ("┌──") in them.

When FFM cannot detect the presence of a prompt, it falls back to an alternate solution, which is printing a random string before and after the command. This string then acts as a delimiter which is used to figure out when the command's output ends.

This is where my memory is a bit fuzzy. I do recall that using the echo -n fallback where it is not needed causes it to become visible. In your examples, I also see that the commands generated by the framework (like cat /etc/*release*) are also printed back in the terminal, which shouldn't be the case. This could be either linked to your specific terminal's settings, or it could be another bug in FFM...

I hope this helps!

ice-wzl commented 1 year ago

Thanks a lot for your explanation. I was able to deduce some of the potential issue but certainly not that fuller picture. Do you plan on ever returning to this project in the near-ish future? If so I would be happy to assist and begin looking into this open issue / other future development. Cheers.

JusticeRage commented 1 year ago

Not in the near future at least, maybe not ever. Since I now work on defense full-time, I don't have any occasion to play with the framework and use it in real-life. If that were to change, then I would surely start adding features again, but this is just not planned at the moment. I'll still happily merge any contributions from the community and fix critical bugs though!