Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

FTP packets

by curtisb (Monk)
on Jan 10, 2002 at 03:29 UTC ( #137610=perlquestion: print w/replies, xml ) Need Help??
curtisb has asked for the wisdom of the Perl Monks concerning the following question:

Hello Everyone,
I have a question about FTP packets. I want to write an FTP packet viewer. Which would tell me who is coming and going accross my FTP port, which files are being transfered, and display any errors that occur either coming or going. I think that I should use the Net::FTP module to do this. The only problem is that I'm not sure on how to get started. This is the first time that I have taken on this big of a project. Just would like some help getting started.
thanks for your wisdom and understanding;

Replies are listed 'Best First'.
Re: FTP packets
by VSarkiss (Monsignor) on Jan 10, 2002 at 03:46 UTC

    Well, Net::FTP is an FTP client, not a server. There is a module Net::FTPServer, which I haven't used, but which seems to do what you want. It's an FTP server written in Perl, and itlooks like all you would have to do is extend it to add logging capability. The documentation looks pretty good, anyway.


    Ah, this link works much better.

Re: FTP packets
by Anonymous Monk on Jan 10, 2002 at 03:43 UTC
    If you want to *listen* rather than *speak*, I imagine your going to need the Net::Pcap module that interfaces with the pcap system library. Beyond that, you might want to try the NetPacket module collection to take care of packet decoding for you. Once you have the packets decoded down to the TCP level you can look at ports and other factors to determine if a given packet is indeed ftp traffic.

    Alternatively you could use tcpdump to listen in and only report on FTP traffic. You could pipe this output into a file for later analysis, or right into a perl script for real-time analysis.


    - danboo

Re: FTP packets
by webengr (Pilgrim) on Jan 10, 2002 at 06:39 UTC

    Do you want to do this in real-time? This is not an elegant solution, but it is easy... just write a script that will follow your ftp server's logfile, and format the lines as they come in. If you don't need the real-time aspect, then write a script that runs on demand, or from cron, to parse the server log.

    You didn't mention the platform or server prduct, but with ProFTP on my Linux box the files of interest are /var/log/proftpd.log and /var/log/xferlog.

    Like I said, it ain't glamorous, but it will work, and you don't have to go through the hassle of examining raw network data (as interesting as that sounds ;^)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://137610]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-05-22 16:18 GMT
Find Nodes?
    Voting Booth?