Selasa, 25 September 2012

Port Scanner with Java

Hello guys, it's been a while. Let's continue.

(Yeah, that's it. I'm not a big fan of being talkative. Sue me.)

In this post, I'm about to show you how easy it is to make simple port scanner application using our everyday - lo and behold - Java SE language.

The idea is simple; just check all the ports available, one by one, and if you got lucky (you know what I mean) we memorize the port number. In this code example, we use the Socket class from the client to try to connect to all the ports available in a host (Too many "to"? Sue me).

The only drawback from this simple source code is that it runs very slow. Hell, it takes one port a second to scan on my AMD C-60 netbook. You don't like it? Well, I did say this is a simple program. You still don't like it? Sue me.

And since this is - again - a simple program, I only used the basic text interface, so you might want to run this app from DOS mode or the Terminal Linux equivalent. Why? It makes you look cool, working on text-based program and such. You don't like it? Sue me.