Who's Scanning My Box?
saurus asks: "A fellow *nix person says I probably get scanned everyday. I say, "No way -- I'd know!" Uhm, actually, if I sat on my box all day running sniffit+netstat+iptraf I might. Could you share a low maintenance monitoring [Open Source] solution ? How would it fare against stealth probes?
"
The simplest method is to do a continous tcpdump and then use the shadow package from U.S. Naval Research (yes, its GPLed) to analyse everything. Alternatively you can just log everything with paranoid options on in your syslog..i.e. debug mode or something. your logs usually detail any such things.
Setup your firewall to log all packets it denies (or log all packets period). This creates a possible DOS atttack, however. Then write a perl script that parses the log file and produces reports based on src ip or whatever you want to group by.
I don't know how well this would deal with stealth scans, but I run a firewall on my FreeBSD box. It doesen't do much other than cover up Samba against outside hosts.
/etc/ip.hostile and sh /etc/rc.firewall
/etc/rc.firewall
However, There are a whole ton of ports I never ever use, including telnet, and many others. I have my firewall set to leave these packets alone, BUT TELL ME WHEN IT GETS THEM. This means a scanner doesent know he's been seen, and I get my daily security mailing with any losers who are portscanning me. Then I just toss 'em in
For those running a FreeBSD box that's reasonably recent, here's the commands I use on my 3.2-RELEASE machine
in
$fwcmd add allow log tcp from any to $ip 23
Change allow to deny depending on your policy ( mine's a fairly insecure default allow ) and tcp/udp and ports as needed. I log 4 tcp ports and only 1 udp port, which I should probably fix.
"Binaries may die but source code lives forever"
-- Unknown
SkyHawk
Andrew Fremantle
Portsentry + logcheck availible at www.psionic.com will probably fit most of your needs. Portsentry checks for people scanning your computer in a myriad of ways and logcheck mails you when something goes wrong.
Now for the bad news, the licence isn't the best. It appears to be free to use (commercial or private) and while the source could is distributed and you can modifiy it you can not distribute those modifications. The worst aspect may be the words "Some of the software at this site is PATENT PENDING."
I've used these programs for several months now and been satisfied but if someone knows of a similar program with a nicer licence please let us all know.
There's a tool in the FreeBSD ports collection called 'clog' - this logs all connection attempts
to a specified interface. A fine lump of software.
Get the source here. Yes, it really is just one C file.
-A.P.
--
"One World, one Web, one Program" - Microsoft promotional ad
"Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
Aug 17 05:21:45 tettie-gw scanlogd: From 209.30.64.27 to 167.206.46.15 ports 12345, 30100, 20034, 1243, 55555, 54321, 6670, 1257, 30303,
- A.P.
--
"One World, one Web, one Program" - Microsoft promotional ad
"Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
It's in the SECurity diskset of SuSE. If it's installed, it'll start up on boot, no user intervention required.
I haven't been portscanned in over a month, I don't get portscanned very often. The last time I was portscanned, the little fscker tried to ADMmountd me.
He failed, of course. I also reported him to his ISP (cable provider in Georgia). I couldn't find their AUP, but my provider (RoadRunner in Newfoundland) responds to that stuff with a termination of service, as I told his ISP. I'm guessing (based on much experience) that he's using daddy's computer and cable modem. Daddys don't appreciate their punk kids getting their service terminated (lost email address).
Usually they give up after the ADMmountd fails, because anything else requires you to actually learn something.
As for portscans themselves, they're not as dangerous as people might think. The article where scanlogd was first posted explains all that (I forget where I read it, though). Just because someone portscans doesn't mean they're a script-kiddy. Nmap is a great tool to find out if a certain port that should be open is, in fact open. I used it to find out what ports are filtered by RoadRunner (web, ftp, X (I have to use VNC instead), SMTP (damn)). It can also be used by an ISP as an impromptu way of finding out what percentages of their users are running what OS.
For actually detecting scans, tcp wrappers comes in handy as does a sniffer called snort. Snort allows you to write rulesets -- and several people have -- to watch and detect activity on your network. Check it out at http://www.clark.net/~roesch/security.html
It's worth pointing out that such activity can be dangerous, because an attacker may be using a spoofed IP. I've seen setups where a spoofed attack from the gateway will cut off the machine.
/dev/netlink, by telling it to pick up the raw packet output of another tcpdump session. Or you could just run tcpdump and give it filter rules equivelent to what ipchains will block.
You should always do some sanity checking first, if you are planning to take automated checking.
Also, I believe you can tell tcpdump to read
DoS indeed. Kiddies that scan my boxes throw thousands of packets at it in the course of checking EVERY damned port on the thing. syslog throws a serious fit when you slam it with that much crap. The solution? The netlink device!
... then make the device itself (mknod /dev/firewall c 36 3) and finally edit your ipchains lines...
/dev/firewall, and parse it according to the headers as documented in the book.
In 2.2/2.3 kernels, just turn on CONFIG_IP_FIREWALL_NETLINK and CONFIG_NETLINK. Then recompile and reboot and all of that
The basic idea is to throw the headers from rejected crap at the netlink. So stick "-o 128" on the ipchains lines that deal with things you want to hear about.
NOW the fun part comes. Get a good book on TCP/IP (Stevens, ahem), write a loop to read
What happens now is up to you. I recommend tracking the stuff and logging a generic message *once* per lamer that's scanning you. You can even get creative and add a DROP rule for the twit to thwart any future checking. Just system() out to ipchains and be done with it.
As a gamer, it is necessary for me to have Winblows 98 installed on one partition of one of my computers, just so I can play games that don't work with WINE for whatever reason. All of these options look great for my linux systems, but what about Windows? Is there anything at all out there that resembles a port scanner detector for windows?
SupremeOverlord
---- "A programmer is a person who solves a problem you didn't know you had in a way you don't understand."