Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 22 guests and 1 member online
 
Advertisement

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Network Pen Testingarrow Non-interactive ftp on linux
EH-Net
May 25, 2013, 06:46:48 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Non-interactive ftp on linux  (Read 6402 times)
0 Members and 1 Guest are viewing this topic.
H1t M0nk3y
Hero Member
*****
Offline Offline

Posts: 865



View Profile
« on: June 03, 2010, 05:07:58 PM »

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:

Quote
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
Logged

OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
hayabusa
Hero Member
*****
Offline Offline

Posts: 1633



View Profile
« Reply #1 on: June 03, 2010, 09:29:40 PM »

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/auto-file-transfer-via-ftp-batch-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 Edit: June 03, 2010, 09:33:43 PM by hayabusa » Logged

~ 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
Hero Member
*****
Offline Offline

Posts: 1021



View Profile
« Reply #2 on: June 03, 2010, 09:36:56 PM »

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

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

~~~~~~~~~~~~~~
Ketchup
chrisj
Hero Member
*****
Offline Offline

Posts: 1163


View Profile WWW
« Reply #3 on: June 03, 2010, 10:49:59 PM »

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.
Logged

OSWP, Sec+
H1t M0nk3y
Hero Member
*****
Offline Offline

Posts: 865



View Profile
« Reply #4 on: June 04, 2010, 06:50:44 AM »

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...  Grin

Logged

OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
Ketchup
Hero Member
*****
Offline Offline

Posts: 1021



View Profile
« Reply #5 on: June 04, 2010, 07:25:52 AM »

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
Logged

~~~~~~~~~~~~~~
Ketchup
hayabusa
Hero Member
*****
Offline Offline

Posts: 1633



View Profile
« Reply #6 on: June 04, 2010, 07:46:30 AM »

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

~ 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
H1t M0nk3y
Hero Member
*****
Offline Offline

Posts: 865



View Profile
« Reply #7 on: June 04, 2010, 08:01:16 AM »

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!
Logged

OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.062 seconds with 23 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Advertisement

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.