I'm using netcat to create a backdoor running a python script with the following command:netcat -l -p 1234 -e 'python /script.py'then I'm connecting to the backdoor with another shell using:netcat localhost 1234script.py is a simple loop that reads input, saves it to a file, and then prints it back. Now whatever I write in the second shell goes to the script and is successfully saved to a file. However, I don't see the output of the script on the second shell. I tried both the print and sys.stdout.write  methods of python and both seem to fail. I don't know why the output is relayed back to the second shell if I use this:netcat localhost 1234 /bin/bashBut not with my script. I'm obviously missing something important. Here is my script:import syswhile 1:    kbInput = sys.stdin.readline()    sys.stdout.write( 'Input: '+kbInput)    f  = open(output.txt, w)    f.write(kbInput)    f.close()    print
'netcat -e' not relaying stdout
scripting;python;netcat;nc;backdoor
Your writes to stdout are being buffered by python, and only written  when the buffer is full. There are 2 simple fixes:Add the -u option to your python command to ask for unbuffered output ('python -u /script.py').Alternatively, flush the output after each write. In your example, after the line sys.stdout.write( 'Input: '+kbInput) add the line:sys.stdout.flush()