Follow us on Twitter!
It is the path of least resistance that makes rivers and men crooked. - Bj Palmer
Saturday, April 19, 2014
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Members Online
Total Online: 32
Guests Online: 30
Members Online: 2

Registered Members: 82838
Newest Member: w1zarrd
Latest Articles

Port Scanner

Arrow Image This, though a bit slow, is very thorough. A v2.0 will be coming out soon with some major threading to put the speed on crack. But for now, here is the concept. Feel free to use the code and scan away.

Ok, here is our java code....with some comments. more on it at the bottom

public class socketTest
public static void main(String args[])
String save = "";
String in = "";
BufferedReader input = new BufferedReader(new InputStreamReader(; //initialize the input stream so that we can tell what needs to be searched

Socket sock;
System.out.print("IP> ");
in = input.readLine();
System.out.print("Starting port> ");
int sport = Integer.parseInt(input.readLine());
System.out.print("End port> ");
int eport = Integer.parseInt(input.readLine());
String ip = in;
save = ip + " scanned on ports " + sport + " to " + eport + "\n";

HttpURLConnection http = (HttpURLConnection)new URL("http://www." + in).openConnection(); //sets up a http scanner. will run on any http capable host
save = save + "HTTP detection \n";
save = save + "Proxy: " + http.usingProxy() + "\n";
String temp = http.getPermission().toString();
int stop = 0;
for(int k = 0; k < temp.length(); k++)

if(temp.charAt(k) == ')')
stop = k ;
String perm = temp.substring(27,stop);
save = save + "Permission: " + perm + "\n";
save = save + "Request Method: " + http.getRequestMethod() + "\n";

}catch(Exception x2){System.out.println("Http scan failed.");}

//begin port scanning here
for(int port = sport; port < eport+1; port++)//runs through all the ports you selected
System.out.print("Testing port " + port + ":");
sock = new Socket(ip, port);
save = save + (port + " " + sock.toString() + "\n");//build output stream for saving to a file.

}catch(Exception x)
if(port > 999)//im OCD and need it formated correctly.
else if(port > 99)
System.out.println(" Failed");
else if(port > 9)
System.out.println(" Failed");
else if(port <10)
System.out.println(" Failed");
}catch(Exception x1){x1.printStackTrace();}

BufferedWriter out = new BufferedWriter(new FileWriter( new File(in + ".log")));//writes found info to a file
}catch(Exception x)


Alrighty. now that you've looked at that and gone ZOMG WTF or if you know java, your thinking, man this guy doesnt know anything. Well, for the former, ill explain, and the later....go write a better one...then say something. otherwise, STFU.

So we begin with just basic keyboard input. This allows the program to by dynamic and not required for hardcoded scans.
This is JDK 1.4, newer programmers may see
BufferedReader input = new BufferedReader(new InputStreamReader(;
and be confused...this is the old school(and in my opinion better) version of your
Scanner s = new Scanner(; //i think thats right

We then run through getting the inputs we hoping you can figure that one out on your own.

Next, we scan this for http capabilities.
HttpURLConnection http = (HttpURLConnection)new URL("http://www." + in).openConnection();
That will initialize a http object for the IP or webaddres you gave. If it exisits it will check for things like proxies and such. This is really more of just an addon...not the real purpose of the program, in v2.0 this will be further implemented.

OKAY, now to the juicy part. :)
Here all we do is set a socket on each port and check if we can connect, if not it throws a connection exception and skips it trying the next one. Again, this version is slow, going one at a time, v2.0 will have a multiple threads to speed things up. This buys time by letting them sit for a bit waiting for that connection while the others do. It cant check them simultaniously, but why wait for one to connect when you could be setting another 20 or 30?

Finally we initialize a file writer (another JDK 1.4 setup) to save this so you dont have to watch. Set it, goto bed, wake up, hack. Enjoy.


[edit 10-9-06]
I have currently completed version 2.0. It is much faster and has many more options and is graphical. I will be uploading the source, and a .jar file for usage. Most likely I will post a tutorial ( or a series) on how I built each module

[edit 13-11-06]
Version 2.0 is fully packed and ready to go as an .exe. Both .exe and source are available.

No Comments have been Posted.
Post Comment


You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.