Finding out available FTP servers on LAN
Its summer vacation now and I have again started doing bc work (as I call it), though I am not so free this vacation :) Shwetabh and I are trying to build a FTP Search which will allow you to find out movies, etc. available on FTP servers on our LAN. I know there is already a similar site built by Paresh Jain on 150/media. But (SEEMS TO ME that) it only scans a list of manually specified servers, which were specified long long back. [Update: The server list is PROGRAMATICALLY updated once in a while (around a month)]. Other thing is that, its interface does not allow a proper search (although you can of course use ctrl+f). Also, we wish to provide a DC++ like interface for browsing FTP servers. And not to forget, having something showable is a plus point during job interviews.
So in the process of searching about how to best do this, I came across nmap - the network security tool written by Fyodor. It has lots and lots of options and the corresponding uses... quite a good tool.. awesome. This is how I get a list of available FTP servers at any point of time:-
// basic command. can be optimized.where IPs.txt contains the range of IPs to look for. This is my IPs.txt :-
$ nmap -p 21 -iL IPs.txt -oG ftpLog.gnmap ; grep open ftpLog.gnmap | cut -d ' ' -f 2
172.16.1-16.*
172.16.18-20.*
172.16.22.*
172.16.24-32.*
172.17.0.*
172.17.8-10.*
172.17.16.*
192.168.36.*
[ Do tell me if I have missed any IP ]
I adjusted the timings, etc. to find the best configuration for scanning our LAN. Actually, I am still tinkering with it and will post the exact command later. Any suggestions for improving the performance? At present it takes around 5 mins.
Part 2.