.

Non-interactive ftp on linux

<<

caissyd

User avatar

Hero Member
Hero Member

Posts: 894

Joined: Thu Dec 31, 2009 11:20 am

Location: Ottawa, Canada

Post Thu Jun 03, 2010 5:07 pm

Non-interactive ftp on linux

Hi,

I am currently searching for a way to use the basic ftp client on linux machines to download a file in a non-interactive way. So let say I want to download netcat, I would have a file named "ftp.txt" looking like this:

open 192.168.10.10 21
ftpuser
ftppwd
bin
GET nc
bye


I know on Windows, I could type ftp -s:ftp.txt and it would download the file automaticaly.

But the "-s" command doesn't exist on linux systems... What can I use instead? I just can't seem to find it...

Thanks
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
(aka H1t.M0nk3y)
<<

hayabusa

User avatar

Hero Member
Hero Member

Posts: 1662

Joined: Mon Jan 29, 2007 2:59 pm

Post Thu Jun 03, 2010 9:29 pm

Re: Non-interactive ftp on linux

I'd write a script to do it all with input, or use the info on this page (the Linux one):

http://www.walkernews.net/2007/05/08/au ... h-scripts/

Quote section from that URL:

1.) In the user home directory, create a hidden file called .netrc that contains these auto-ftp commands

machine 10.1.1.10
login walker-login-id-here
password walker-login-password-here
macdef init
prompt
mget *.*
quit
Leave one mandatory blank line here
Leave one mandatory blank line here

machine ftp.walkernews.net
login walker-login-id-here
password walker-login-password-here
macdef init
pwd
quit
Leave one mandatory blank line here
Leave one mandatory blank line here

2.) # Execute chmod 600 .netrc to limit only read and write permission for the login user ownership only. This is a must in order ftp client to automate file transfer!

3.) # Now, if you want to auto-ftp with ftp host 10.1.1.10, just type this command
ftp 10.1.1.10

and the Linux ftp client will automatically execute the series of ftp commands in .netrc file for the matching ftp host.

Similarly, you can type ftp ftp.walkernews.net for auto-ftp file transfer with the second ftp host.


If I scripted my own, I'd just do a

read filename

get $filename

and change the username, password, and ip / hostname for the ftp server (or you could even read them as variables, also, etc...

my 2 cents
Last edited by hayabusa on Thu Jun 03, 2010 9:33 pm, edited 1 time in total.
~ hayabusa ~ 

"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'


OSCE, OSCP , GPEN, C|EH
<<

Ketchup

User avatar

Hero Member
Hero Member

Posts: 1021

Joined: Fri Jul 04, 2008 7:44 pm

Location: Philadelphia, PA

Post Thu Jun 03, 2010 9:36 pm

Re: Non-interactive ftp on linux

I would probably just CURL if I was doing this on Linux. 

  Code:
curl ftp://ftp.coolsite.com/file.ext --user me:mypass
~~~~~~~~~~~~~~
Ketchup
<<

rattis

User avatar

Hero Member
Hero Member

Posts: 1172

Joined: Mon Jul 27, 2009 1:25 pm

Post Thu Jun 03, 2010 10:49 pm

Re: Non-interactive ftp on linux

Ketchup wrote:I would probably just CURL if I was doing this on Linux.   

  Code:
curl ftp://ftp.coolsite.com/file.ext --user me:mypass



It's been a while, but I think wget (my cli get of choice) does this too.
OSWP, Sec+
<<

caissyd

User avatar

Hero Member
Hero Member

Posts: 894

Joined: Thu Dec 31, 2009 11:20 am

Location: Ottawa, Canada

Post Fri Jun 04, 2010 6:50 am

Re: Non-interactive ftp on linux

Thanks guys, but I should have mentioned that:

1) curl is not installed on the client machine;

2) Even though I am using the very basic ftp client on the client machine, I am using Pure-FTPD as a server.

So both solutions proposed aren't working (unless it is me!).

I will keep looking and post my findings, unless one of you can help me same some time...  ;D
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
(aka H1t.M0nk3y)
<<

Ketchup

User avatar

Hero Member
Hero Member

Posts: 1021

Joined: Fri Jul 04, 2008 7:44 pm

Location: Philadelphia, PA

Post Fri Jun 04, 2010 7:25 am

Re: Non-interactive ftp on linux

What about Chris's solution?  WGET should be able to pull down a file from FTP. 

http://serverfault.com/questions/25199/using-wget-to-recursively-download-whole-ftp-directories
~~~~~~~~~~~~~~
Ketchup
<<

hayabusa

User avatar

Hero Member
Hero Member

Posts: 1662

Joined: Mon Jan 29, 2007 2:59 pm

Post Fri Jun 04, 2010 7:46 am

Re: Non-interactive ftp on linux

OK, I'll say it again...  BASH script?
~ hayabusa ~ 

"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'


OSCE, OSCP , GPEN, C|EH
<<

caissyd

User avatar

Hero Member
Hero Member

Posts: 894

Joined: Thu Dec 31, 2009 11:20 am

Location: Ottawa, Canada

Post Fri Jun 04, 2010 8:01 am

Re: Non-interactive ftp on linux

wget did the trick...

But I was surprised to see that ftp -s exists on Windows but not on Linux. At least for the default basic ftp client.

Anyway, thanks guys!
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
(aka H1t.M0nk3y)

Return to Network Pen Testing

Who is online

Users browsing this forum: No registered users and 1 guest

cron
.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software