-->

  • All about ftp network services





    Understanding FTP



    What is FTP?


    File Transfer Protocol (FTP) is, as the name suggests , a protocol used to allow remote transfer of files over a network. It uses a client-server model to do this, and- as we'll come on to later- relays commands and data in a very efficient way.
    All about ftp network services



    How does FTP work?



    A typical FTP session operates using two channels:

    •     a command (sometimes called the control) channel
    •     a data channel.


    As their names imply, the command channel is used for transmitting commands as well as replies to those commands, while the data channel is used for transferring data.


    FTP operates using a client-server protocol. The client initiates a connection with the server, the server validates whatever login credentials are provided and then opens the session.


    While the session is open, the client may execute FTP commands on the server.





    Active vs Passive




    The FTP server may support either Active or Passive connections, or both.

    In an Active FTP connection, the client opens a port and listens. The server is required to actively connect to it.
    In a Passive FTP connection, the server opens a port and listens (passively) and the client connects to it. 


    This separation of command information and data into separate channels is a way of being able to send commands to the server without having to wait for the current data transfer to finish. If both channels were interlinked, you could only enter commands in between data transfers, which wouldn't be efficient for either large file transfers, or slow internet connections.



    More Details:


    You can find more details on the technical function, and implementation of, FTP on the Internet Engineering Task Force website: https://www.ietf.org/rfc/rfc959.txt. The IETF is one of a number of standards agencies, who define and regulate internet standards.



    #1 What communications model does FTP use?



    Ans :- client-server


    #2 What's the standard FTP port?

    Ans :- 21



    #3 How many modes of FTP connection are there?  


    Ans :-  2


    Enumerating FTP


    Lets Get Started


    Before we begin, make sure to deploy the room and give it some time to boot. Please be aware, this can take up to five minutes so be patient!



    Enumeration



    By now, I don't think I need to explain any further how enumeration is key when attacking network services and protocols. You should, by now, have enough experience with nmap to be able to port scan effectively. If you get stuck using any tool- you can always use "tool [-h / -help / --help]" to find out more about it's function and syntax. Equally, man pages are extremely useful for this purpose. They can be reached using "man [tool]".



    Method



    We're going to be exploiting an anonymous FTP login, to see what files we can access- and if they contain any information that might allow us to pop a shell on the system. This is a common pathway in CTF challenges, and mimics a real-life careless implementation of FTP servers.





    As we're going to be logging in to an FTP server, we're going to need to make sure therre is an ftp client installed on the system. There should be one installed by default on most Linux operating systems, such as Kali or Parrot OS. You can test if there is one by typing "ftp" into the console. If you're bought to a prompt that says: "ftp>" Then you have a working FTP client on your system. If not, it's a simple matter of using "sudo apt install ftp" to install one.
    Alternative Enumeration Methods


    It's worth noting  that some vulnerable versions of in.ftpd and some other FTP server variants return different responses to the "cwd" command for home directories which exist and those that don’t. This can be exploited because you can issue cwd commands before authentication, and if there's a home directory- there is more than likely a user account to go with it. While this bug is found mainly within legacy systems, it's worth knowing about, as a way to exploit FTP.


    This vulnerability is documented at: https://www.exploit-db.com/exploits/20745

    Now we understand our toolbox, let's do this.                


    #1 Run an nmap scan of your choice.

    How many ports are open on the target machine?

    Ans :- 2



    #2 What port is ftp running on?

    Ans :- 21



    #3 What variant of FTP is running on it? 

    Ans :- vsftpd



    #4 Great, now we know what type of FTP server we're dealing with we can check to see if we are able to login anonymously to the FTP server. We can do this using by typing "ftp [IP]" into the console, and entering "anonymous", and no password when prompted.


    What is the name of the file in the anonymous FTP directory?


    Ans :- PUBLIC-NOTEICE.txt


    #5 What do we think a possible username
    could be?



    Ans :- mike



    #6 Great! Now we've got details about the FTP server and, crucially, a possible username. Let's see what we can do with that...





    Exploiting FTP

    Types of FTP Exploit


    Similarly to Telnet, when using FTP both the command and data channels are unencrypted. Any data sent over these channels can be intercepted and read.

    With data from FTP being sent in plaintext, if a man-in-the-middle attack took place an attacker could reveal anything sent through this protocol (such as passwords). An article written by JSCape demonstrates and explains this process using APR-Poisoning to trick a victim into sending sensitive information to an attacker, rather than a legitimate source.

    When looking at an FTP server from the position we find ourselves in for this machine, an avenue we can exploit is weak or default password configurations.




    Method Breakdown



    So, from our enumeration stage, we know:

        - There is an FTP server running on this machine

        - We have a possible username

    Using this information, let's try and bruteforce the password of the FTP Server.





    Hydra


    Hydra is a very fast online password cracking tool, which can perform rapid dictionary attacks against more than 50 Protocols, including Telnet, RDP, SSH, FTP, HTTP, HTTPS, SMB, several databases and much more. Hydra comes by default on both Parrot and Kali, however if you need it, you can find the GitHub here.


    The syntax for the command we're going to use to find the passwords is this:
    "hydra -t 4 -l dale -P /usr/share/wordlists/rockyou.txt -vV 10.10.10.6 ftp"


    Let's break it down:





    SECTION             FUNCTION

    hydra                   Runs the hydra tool

    -t 4                    Number of parallel connections per target

    -l [user]               Points to the user who's account you're trying to compromise

    -P [path to dictionary] Points to the file containing the list of possible passwords

    -vV                     Sets verbose mode to very verbose, shows the login+pass combination for each attempt

    [machine IP]            The IP address of the target machine

    ftp / protocol          Sets the protocol

    Let's crack some passwords!






    #1 What is the password for the user "mike"?

    Ans :- password


    #2 Bingo! Now, let's connect to the FTP server as this user using "ftp [IP]" and entering the credentials when prompted



    #3 What is ftp.txt?




    Expanding Your Knowledge




    Further Learning


    There is no checklist of things to learn until you've officially learnt everything you can. There will always be things that surprise us all, especially in the sometimes abstract logical problems of capture the flag challenges. But, as with anything, practice makes perfect. We can all look back on the things we've learnt after completing something challenging and I hope you feel the same about this room.



    Reading



    Here's some things that might be useful to read after completing this room, if it interests you:


       
       
       

    I hope you liked this post, then you should not forget to share this post at all.
    Thank you so much :-)

       

  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.