pythonbashnetcatparrot-os

NetCat Execute - File Not Found


So this is an odd issue.

python script.py -a 1234 works

/usr/bin/python /tmp/script.py -a 1234 works

nc 127.0.0.1 443 -e /bin/bash works

nc 127.0.0.1 443 -e /usr/bin/python /tmp/script.py -a 1234 fails with all-A-records NIY

nc 127.0.0.1 443 -e "/usr/bin/python /tmp/script.py -a 1234" fails with failed : No such file or directory

Am I missing something here? I'm not sure why this isn't working.


Solution

  • Okay I'm not sure what's up with netcat but doing an old fashion bash reverse shell works just fine and solves the problem.

    /usr/bin/python -u /tmp/script.py >& /dev/tcp/127.0.0.1/443 0>&1

    A quick note here, make sure you include the -u otherwise you'll get the incoming data from the socket but nothing output from your script will get sent back over the socket.