ruvolof / nc-for-android

GNU General Public License v3.0
17 stars 3 forks source link

cannot use -e or -c for any non-trivial command #3

Closed bashtanov closed 4 months ago

bashtanov commented 4 months ago

If a command contains a space (e.g. cat /storage/emulated/0/foo/bar) netcat will not recognize it as a single token. As a result, the second part of the command is not recognized as part of -c or -e argument, but is processed as a separate ncat argument. I tried quoting it in single and double quotes. I tried using tab character instead of space too, but this way it seems to be ignored.

bashtanov commented 4 months ago

pipes or redirects don't seem to be supported either

ruvolof commented 4 months ago

Hi @bashtanov, thanks for the report. Indeed, the app as it was was not able to correctly parse the commands you were trying to issue.

I pushed a commit that will wrap the whole command in a shell, so pipes and redirects should be supported too now (please note that however the app does not request any permission to write and read files, so you are very limited with the redirects). In case of the '-c' flag, the command and its argument need to be wrapped in quotes.

Would you be able to test this one in your specific use case and let me know if it works as expected before I push the update to the play store?

Thanks!

ruvolof commented 4 months ago

In case you can't build the apk in your own environment, I have uploaded a version of the apk that includes the latest changes here: https://werebug.com/nc-for-android.apk

Cheers

ruvolof commented 4 months ago

The way I tested this is to create a file in the app local storage as follows:

echo 'abcd' > /data/data/com.werebug.androidnetcat/files/test.txt

I opened a listener and from the android app I typed the following command:

nc 192.168.1.244 6543 -c "cat /data/data/com.werebug.androidnetcat/files/test.txt | tr '[:lower:]' '[:upper:]'"

And I received ABCD on my listener.