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

10
  • 1
    Does typing Control-D terminate it? If not, OS and version of netcat are you using? – Gordon Davisson Feb 21 at 23:13
  • alternately, you could use lftp which supports site commands. – A.B Feb 21 at 23:55
  • Read man expect. expect can automate some or all interactions with a program. – waltinator Feb 22 at 0:40
  • @GordonDavisson CTRL C terminates , yes. But I want to run the whole script without user input. – florian.isopp Feb 22 at 8:22
  • @A.B should be designed specifically for proftpd – florian.isopp Feb 22 at 8:22
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.