all about ftp must read

Upload: mikefcebu

Post on 03-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 All About Ftp Must Read

    1/2

    file:///F|/References/Computer/1000+%20Hacking%20Tutorials/200%20Hacking%20Tutorials(ewares.org)/All%20about%20ftp%20must%20read.txt

    Setting Up AFtp:

    Well, since many ofushave always wondered this, here it is.Long and drawn out.Also, before attempting this, realize one thing; You will have to give up yourtime,e ffort,bandwidth, and security to have a quality ftp server.

    That being said,here it goes. First ofall, findout ifyour IP(Internet Protocol)is static (not changing)ordynamic (changese verytime you log on). To dothis,first considerthe fact ifyou have a dial up modem. Ifyou do,chance sare about 999 999 out of1 000000that your IPis dynamic. Tomake it static, just go toa place like h*tp://www.myftp.org/ to registerfora static ip address.

    You'll then need to get yourIP. Thiscanbe done by doing this:

    Goingto Start -> Run -> winipcfgorwww .ask.com and asking 'What ismy IP?'

    Afterdoing so,you'll need todownload an FTPserverclient. Personally, I'd recommend G6 FTPServer, Serv-UFTPor Bullitproofv2.15 all three ofwhich are extremely reliable,and the norm ofthe ftp world.

    Youcan download them onthis site: h*tp://www.liaokai.com/softw_en/d_index.htm

    First, you'll have to set up yourftp. Forthis guide, Iwill use step-by-step instructionsforG 6. First, you'll have togo into 'Setup -> General'. From here,type in yourport # (default is21). Irecommend somethingunique, orsomething a bit larger(ex: 3069). Ifyouwant to, check the numberofmax users(thissets the amount ofsimultaneousmaximum userson yourserver at once performingactions- The more on at once, the slowerthe connectionand vice versa).

    The belowoptionsare then chooseable:

    -Launch with windows

    -Activate FTPServeron Start-up

    -Put intotray on startup-Allowmultiple instances

    -Show"Loading..."status at startup

    -Scandrive(s)at startup

    -Confirm exit

    Youcan do what you want withthese, as theyare pretty selfe xplanatory. The scan drive feature isnice, asisthe 2nd and the last option.From here,click the 'options'text on the left column.

    To protect yourserver, youshouldcheck 'loginche ck'and 'password check', 'Showrelative path (a must!)',and any otheroptionsyou feel you'll need.After doing so,click the 'advanced'text in the left column. Youshould then leave the buffersize on the default (unlessofc ourse you knowwhat you're doing), andthen allowthe type offtp you want.

    Uploading and downloadingisusually good, but it'sup to you ifyou want to allowuploadsa nd/ordownloads. Forthe serverpriority, that will determine howmuch conventional memory will be used and howmuch 'effort'will go into making yourserver runsmoothly.

    Anti-hammering isalso good, asit preventspeople from slowing down your speed. From here, click 'Log Options'from the left column.If you would like to see and record everysingle command and clutterup yourscreen, leave the defaults.

    But, ifyou would like to see what isgoingon withthe lowest possible space taken, click 'Screen'in the top column. You should then check off'Log successful logins', and all ofthe optionsin the client directry,except 'Log directory changes'.After doing so, click 'Ok'in the bottom left corner.

    Youwill then have to go into 'Setup-> UserA ccounts'(orc trl & u). From here, you should click on the right most column, and right click. Choose 'Add',and choose the username(s)you wouldlike people to have access to.

    Aftergiving a name (ex: themoonlanding), you will have to give them a set password in the bottom column (ex: wasfaked). Forthe 'Home IP'directory,(if you registered with a static server, check 'All IPHomes'.If yourIP isstatic by default, choose yourIP from the list. Youwill thenhave to right clickin the very center column, and choose 'Add'.

    From here,you will have toset the directoryyou want the people to have accessto. Afterchoosing the directory, Isuggest you choose the options'Read', 'List',and 'Subdirs',unlessofcourse you knoww hat you're doing . Afterdoing so, make an 'upload'folderinthe directory, and choose to'add'this folderseperately tothe center column. Choose 'write', 'append', 'make', 'list', and'subdirs'. Thiswill allowthem toupload onlyto specific folders(youruploa d folder).

    Nowclick on 'Miscellaneous'from the left column. Choose 'enable account', yourtime-out (howlong it takes forpeople to remain idle before you automaticallykick them off),the maximum number ofusers forthisna me,the maximum numberof connectionsallowed simultaneously forone ipaddress, showrelative path (a must!), anda nyother thingsat the bottom you'dlike to have. Nowclick 'Ok'.**Requested**

    From thismain menu,click the little boxingglove icon in the top corner, and right click and unchoose the hit-o-meterfor both uploadsanddownloads (with thisyou can monitorIPactivity). Now clickthe lightning bolt,and yourserver isnow up and running.

    Post yourftp info,like this:

    213.10.93.141 (orsomethingelse, suchas: 'f*p://example.getmyip.com')

    User: *** (The username ofthe client)

    Pass: *** (The password)

    Port: *** (The port numberyou chose)

    So make a FTPand join the FTPsection

    ListingThe ContentsOf AFtp:

    Listingthe content ofa FTPisvery simple.

    Youwill need FTPContent Maker, whichcan be downloaded from here:

    ht*p://www.etplanet.com/download/application/FTP%20Content%20Maker%201.02.zip

    1. Put in the IPofthe server. Donot put "ftp://" ora "/"be cause it will not work ifyou do so.

    2. Put in the port.Ifthe port isthe default number, 21, you do not have to enterit.

    3. Put in the username andpasswordin the appropriate fields. Ifthe login isanonymous, you do not have to enterit.

    4. Ifyou want to list a specific directory ofthe FTP, place it in the directory field. Otherwise, do not enteranything in the directory field.

    5. Click "Take the List!"

    6. Afterthe list hasbeen taken, click the UBB output tab, and copy and paste to whereveryou want it.

    IfFTPContent Makeris not working, it isprobablybecause the serverdoesnot utilize Serv-USoftware.

    Ifyou get thiserrormessage:

    StatusCode = 550LastResponse was: 'Unable toopen local file test-ftp'

    Error= 550 (Unable to openlocal file test-ftp)

    Error= Unable to open local file test-ftp = 550

    Close and restart FTPContent Maker, thentryagain.

    errormessages:

    110 Restart markerreply. Inthisc ase, the text isexact and not left to the particularimplementation; it must read: MARKyyyy= mmmm Where yyyy isUser-process data stream marker, and mmmm server'sequivalent marker(note the spacesbetween markers and"=").120 Service ready in nnn minutes.

    125 Data connection alreadyopen; transferstarting.

    150 File statusokay; about to opendata connection.

    200 Command okay.

    202 Command not implemented, superfluousat thissite.

    211 System status,orsystem helpreply.212 Directory status.

    213 File status.

    214 Help message.On howto use the serverorthe meaning ofa particularn on-standard command. Thisreply isuseful only to the humanuser.

    215 NAME system type. Where NAME isan official system name from the list in the Assigned Numbersdocument.

    220 Service ready fornewuser.

    221 Service closing control connection. Loggedout ifappropriate.225 Data connection open; no transfer in progress.

    226 Closing data connection. Requestedfile action successful (forexample, file transferorfile abort).

    227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).

    230 Userlogged in,proceed.

    250 Requested file action okay, completed.

    257 "PATHNAME"created.331 Username okay,need password.

    332 Need account forlogin.

    350 Requested file action pending furtherinformation.

    421 Too many userslogged tothe same account

    425 Can't open data connection.426 Connection closed; transferaborted.

    450 Requested file action not taken. File unavailable (e.g., file busy).

    451 Requested action aborted: local errorin processing.

    452 Requested action not taken. Insufficient storage space in system.

    500 Syntax error,commandunrecognized. Thismay include errorssuch ascommand line too long.

    501 Syntax errorin parametersor arguments.502 Command not implemented.

    503 Bad sequence ofcommands.

    504 Command not implementedfor that parameter.

    530 Not logged in.

    532 Need account forstoringfiles.

    550 Requested action not taken. File unavailable (e.g., file not found, no access).551 Requested action aborted: page type unknown.

    552 Requested file action aborted. Exceededstorage allocation (forcurrent directory ordataset).

    553 Requested action not taken. File name not allowed.

    Active FTPvs.Passive FTP, a Definitive Explanation

    Introduction

    One ofthe most commonlyseenquestions whendealing with firewallsand other Internet connectivity issuesisthe difference between active andpassive FTPand howbest to support eitherorboth of them.Hopefully the following text will help toclear up some ofthe confusionoverhow to support FTPin a firewalledenvironment.

    Thismay not be the definitive explanation, asthe title claims, however, I've heard enough good feedback and seen thisdocument linked in enough placesto knowthat quite a few people have found it to be useful.Iam always looking forwaysto improve things though, and ifyoufind something that isnot quite clearor needsmore explanation, please let me know!Recent additions tothis document include the examplesof bothactive and passive command line FTPsessions. These sessionexamplesshould help make thingsa bit clearer. They also provide a nice picture into what goeson behind the scenesduring an FTPsession. Now, on to the information...

    The Basics

    FTPisa TCP based service exclusively. There isno UDPcomponent to FTP. FTPis an unusual service in that it utilizestwo ports,a 'data'port and a 'command'port (also known asthe control port). Traditionally these are port 21 forthe command port andport 20for the data port. The confusion beginshowever, when we findthat dependingon the mode, the data port isnot alwayson port 20.

    Active FTP

    In active mode FTPthe client connectsfrom a random unprivileged port (N> 1024) to the FTPserver'scommand port, port 21.Then, the client startslistening to port N+1 and sendsthe FTPcommand PORT N+1 to the FTPserver.The server will then connect back tothe client'sspecified data port from itslocal data port, whichisport 20.

    From the server-side firewall'sstandpoint, tosupport active mode FTPthe following communication channelsneed to be opened:

    FTPserver'sport 21 from anywhere (Client initiatesconnection)

    FTPserver'sport 21 to ports> 1024(Serverrespondsto client'scontrol port)

    FTPserver'sport 20 to ports> 1024(Server initiatesdata connection to client'sdata port)

    FTPserver'sport 20 from ports> 1024(Client sendsACKs to server'sdata port)

    In step 1, the client'scommand port contactsthe server'scommand port and sendsthe command PORT 1027. The serverthen sendsa nACK back to the client'scommand port in step 2.In step3 the server initiatesa connection on itslocal data port to the data port the client specifiedearlier. Finally, the client sendsan ACKback as shown instep 4.

    The main problem with active mode FTPactually fallson the client side. The FTPclient doesn't make the actual connection to the data port ofthe server--it simply tellsthe serverwhat port it islistening on and the serverconnects back to the specified port onthe client. From the client side firewall thisappearsto be an outside system initiating a connectiontoan internal client--something that isusually blocked.

    Active FTPExample

    Belowis an actual example ofan active FTPsession. The only thingsthat have been changed are the server names, IPaddresses,and user names.In thisexample an FTP session isinitiated from testbox1.slacksite.com (192.168.150.80), a linux box runningthe standardFTP commandline client, to testbox2.slacksite.com (192.168.150.90), a linuxbox running ProFTPd 1.2.2RC2. The debugging (-d)flag isused withthe FTP client to showwhat isgoing on behind the scenes. Everything inredis the debugging output which showsthe actual FTPcommands being sent to the serverand the responsesgenerated from those commands. Normal serveroutput isshown in black, and userinput is in bold.

    There are a fewinterestingthings toconsider about thisdialog. Notice that when the PORT command isissued, it specifiesa port on the client (192.168.150.80)system, ratherthan the server. We will see the opposite behaviorwhen we use passive FTP. While we are onthe subject, a quicknote about the format ofthe PORT command. Asyou cansee in the example belowit is formatted asa seriesof sixnumbers separatedby commas. The first fouroctetsare the IPaddress while the second twooctets comprise the port that will be used forthe data connection. To find the actual port multiply the fifth octet by 256 and then add the sixth octet to the total. Thusin the example belowthe port numberis ((14*256) + 178), or3762. Aquick check with netstat should confirm thisinformation.

    testbox1: {/home/p-t/slacker/public_html} %ftp-d testbox2

    Connected to testbox2.slacksite.com.

    220 testbox2.slacksite.com FTPserver ready.

    Name (testbox2:slacker): slacker

    ---> USER slacker

    331 Password required forslacker.Password: TmpPass

    ---> PASSXXXX

    230 Userslackerlogged in.

    ---> SYST

    215 UNIXType: L8Remote system type isUNIX.

    Usingbinary mode to transferfiles.

    ftp> ls

    ftp: setsockopt (ignored): Permissiondenied

    ---> PORT 192,168,150,80,14,178

    200 PORT command successful.---> LIST

    150 Opening ASCIImode data connectionforfile list.

    drwx------3 slackerusers 104 Jul 27 01:45 public_html

    226 Transfercomplete.

    ftp> quit

    ---> QUIT221 Goodbye.

    Passive FTP

    In orderto resolve the issue ofthe serverinitiating the connection to the client a different method forFTPconnections wasdeveloped. Thiswasknow n aspassive mode, orPASV,after the command used by the client to tell the serverit isin passive mode.

    In passive mode FTPthe client initiatesboth connectionsto the server, solving the problem offirewalls filtering the incoming data port connectionto the client from the server.When opening an FTPconnection,the client openstwo random unprivileged portslocally (N> 1024and N+1). The first port contactsthe serveron port 21, but insteadof thenissuing a PORT commandandallowing the servertoc onnect backto itsdata port, the client will issue the PASVcommand. The result ofthisisthat the serverthen opensa random unprivileged port (P> 1024)and sendsthe PORT Pcommand back to the client. The client then initiatesthe connection from port N+1 to port Pon the serverto transferdata.

    file:///F|/References/Computer/1000+%20Hacking%20Tutorials/200%20Hacking%20Tutorials(ewares.org)/All%20about%20ftp%20must%20read.txt (1 of2)[7/20/2013 8:13:35 AM]

  • 7/28/2019 All About Ftp Must Read

    2/2

    file:///F|/References/Computer/1000+%20Hacking%20Tutorials/200%20Hacking%20Tutorials(ewares.org)/All%20about%20ftp%20must%20read.txt

    From the server-side firewall'sstandpoint, tosupport passive mode FTPthe following communication channelsneed to be opened:

    FTPserver'sport 21 from anywhere (Client initiatesconnection)

    FTPserver'sport 21 to ports> 1024(Serverrespondsto client'scontrol port)

    FTPserver'sports > 1024 from anywhere (Client initiatesdata connection to random port specified by server)FTPserver'sports > 1024 toremote ports> 1024 (ServersendsACKs (and data)to client'sdata port)

    In step 1, the client contactsthe serveron the command port and issuesthe PASVcommand. The serverthen repliesin step 2 with PORT 2024,telling the client whichport it islistening to forthe data connection. In step 3 the client then initiatesthe data connectionfrom itsda ta port to the specifiedserver data port. Finally, the serversendsback anACK instep 4to the client'sdata port.

    While passive mode FTPsolves many ofthe problemsfrom the client side,it opensup a whole range ofproblemson the serverside. The biggest issue isthe need to allowany remote connection to high numbered portson the server. Fortunately, manyFTP daemons, including the popularWU-FTPDallowthe administratorto specify a range ofportswhich the FTPserverwill use. See Appendix1 formore information.

    The second issue involvessupporting andtroubleshooting clientswhich do (or do not)support passive mode. Asan example, the command line FTPutility provided with Solarisdoes not support passive mode,necessitating a third-party FTPclient, such asncftp.

    Withthe massive popularityof the WorldWide Web, many people preferto use theirweb browserasan FTP client. Most browsersonly support passive mode when accessing ftp:// URLs.Thiscan eitherbe good orbad depending on what the serversand firewallsare configuredto support.

    Passive FTPExample

    Belowis an actual example ofa passive FTPsession. The only thingsthat have been changed are the servernames, IPaddresses,and user names. In thisexample an FTPsessionis initiated from testbox1.slacksite.com (192.168.150.80), a linux box runningthe standardFTP command line client, totestbox2.slacksite.com (192.168.150.90), a linux boxrunningProFTPd1.2.2RC2. The debugging(-d) flag isused withthe FTPc lient toshow what isgoing on behind the scenes. Everything in red isthe debugging output which showsthe actual FTPcommands being sent to the serverand the responsesgenerated from those commands. Normal serveroutput isshown in black, and userinput is in bold.

    Notice the difference in the PORT command in thisexample asopposed to the active FTPexample. Here, we see a port beingopened on the server(192.168.150.90)system, ratherthan the client. See the discussion about the format ofthe PORT commandabove, inthe Active FTPExample section.

    testbox1: {/home/p-t/slacker/public_html} %ftp-d testbox2

    Connected to testbox2.slacksite.com.

    220 testbox2.slacksite.com FTPserver ready.

    Name (testbox2:slacker): slacker---> USER slacker

    331 Password required forslacker.

    Password: TmpPass

    ---> PASSXXXX

    230 Userslackerlogged in.

    ---> SYST215 UNIXType: L8

    Remote system type isUNIX.

    Usingbinary mode to transferfiles.

    ftp> passive

    Passive mode on.

    ftp> lsftp: setsockopt (ignored): Permissiondenied

    ---> PASV

    227 Entering Passive Mode (192,168,150,90,195,149).

    ---> LIST

    150 Opening ASCIImode data connectionforfile listdrwx------3 slackerusers 104 Jul 27 01:45 public_html

    226 Transfercomplete.

    ftp> quit

    ---> QUIT

    221 Goodbye.

    Summary

    The following chart should helpadmins rememberhow each FTPmode works:

    Active FTP:

    command : client >1024 -> server21data : client >1024 1024 -> server21

    data : client >1024 -> server>1024

    Aquick summary ofthe prosand consofactive vs. passive FTPisalso in order:

    Active FTPisbeneficial to the FTPserverad min, but detrimental to the client side admin. The FTPserverattempts to make connectionsto random high portson the client, which would almost certainly be blocked by a firewall on the client side. Passive FTPisbene ficial to the client, but detrimental to the FTPserver admin. The client will make bothconnectionsto the server, but one ofthem will be to a random highport, whichwould almost certainly be blocked bya firewall on the serverside.

    Luckily, there issomewhat ofa compromise. Since adminsrunning FTP serverswill need to make theirservers accessible to the greatest numberofclients, they will almost certainly needto support passive FTP. The exposure ofhigh level portson the server can be minimizedby specifying a limited port range forthe FTPserverto use. Thus, everythingexcept forthis range ofportsc an be firewalledon the serverside. While thisdoesn't eliminate all risk to the server, it decreasesit tremendously.

    file:///F|/References/Computer/1000+%20Hacking%20Tutorials/200%20Hacking%20Tutorials(ewares.org)/All%20about%20ftp%20must%20read.txt (2 of2)[7/20/2013 8:13:35 AM]