0

I am connecting to a proftpd server via netcat

nc 10.10.239.150 21

Then I am doing some copy operations like "The mod_copy module implements SITE CPFR and SITE CPTO commands"

enter image description here

After "250 Copy successful" i want to exit this netcat connection and continue with the bash script.

I already tried following call, with CPFR and CPTO instructions outsourced to a msg.txt file

nc 10.10.115.253 21 < msg.txt

But still I dont know how to exit the netcat proftpd connection after successful proftpd operations.

Several tried EOF instructions are not understood by nc/proftpd: Only the CTRL C user input does the job, but this should be done automatically.

enter image description here

1 Answers1

0

I don't have either a kali linux system or a ProFTPD server available to test with, so this is somewhat speculative, but I see a couple of things that might work.

First, a bit of explanation: it's really up to the client to terminate the connection to the server, not by sending a command, but by closing the TCP connection (technically, by sending a TCP/IP packet with the "fin" (finish) flag). So what's really needed here is to find a way to tell the nc program to close the connection after all operations are finished. And how you do that depends on the nc program (they're not all the same).

Possibility 1: some versions of nc need a -N option to tell them to close the TCP session after hitting EOF on their input. Check your man page to see if the version you have needs this.

Possibility 2: some versions have a -w option that lets you specify an "idle timeout" (in seconds) for the connection. Basically, if you specify nc -w 5 ... it'll close the connection after 5 seconds of inactivity. Again, check your man page.