//--------------------------------------------------------------
// YAPS - Yet Another Port Scanner
//Developed by: Sygoon of CPC-DEV
http://www.cpc-net.org
//Contact:
scrumped0000@hotmail.com
//Disclaimer: You may modify any peice of this code but this
//header cannot be removed, however you can add to the header
//just not modify the above^^^^^^^^^^^^ thanx.
//--------------------------------------------------------------
import java.net.*;
public class yaps{
static String HOST;
static int TYPE, MAX_PORT, MIN_PORT, CUR_PORT;
public yaps() {
}
public static void main(String[] args){
if(args.length != 4){
// Checks to see if there is correct info here
System.out.println("yaps - Created by Sygoon of CPC-DEV @
www.cpc-net.org");
System.out.println("Usage: yaps host low_port high_port type_flag");
System.exit(1);
}else{
//Now Taking the arguments and changing them into integers
//The Try statment is here for error checking, Catch is used for
//just in case sothing fails it will display an error message
try{
HOST=args[0];
}catch(Exception e){
System.out.println("Ummmm Somthings really wrong if this error comes up.");
}
try{
MIN_PORT = Integer.parseInt(args[1]);
}catch(Exception e){
System.out.println("Error converting MAX_PORT to integer value");
}
try{
MAX_PORT = Integer.parseInt(args[2]);
}catch(Exception e){
System.out.println("Error converting LOW_PORT to integer value");
}
try{
TYPE = Integer.parseInt(args[3]);
}catch(Exception e){
System.out.println("Error converting TYPE to inger value");
}
//this is where the scan starts
System.out.println("yaps - Created by Sygoon of CPC-DEV @
www.cpc-net.org");
System.out.println("Starting scan on " + HOST + " from " + MIN_PORT + " to " + MAX_PORT);
if(TYPE < 1){
for(MIN_PORT = MIN_PORT; MIN_PORT <= MAX_PORT; MIN_PORT++){
//checks to see if the host has any ports open with try and catch if its closed
//then the vm sends us a error and that is what catch does it just tells the
//user what is wrong
try{
new Socket(HOST, MIN_PORT);
System.out.println("Port " + MIN_PORT + " is open");
}catch(Exception e){
System.out.println("Port " + MIN_PORT + " is closed");
}
}
}else{
for(MIN_PORT = MIN_PORT; MIN_PORT <= MAX_PORT; MIN_PORT++){
try{
//i have a feeling that this is buggy im working on setting a time out
// i think without the time out it wont give he host enough time to respond
new DatagramSocket(MIN_PORT, InetAddress.getByName(HOST));
System.out.println("Port " + MIN_PORT + " is open");
}catch(Exception e){
System.out.println("Port " + MIN_PORT + " is closed");
}
}
}
}
//Exiting the proggie
System.exit(0);
}
}