26277 total geeks with 3498 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: May 31
May Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Google builds
crowdsourcing into
new Maps code stack
Google"s Native
Code browser tech
goes cross-platform
Yahoo! to "share
something special"
in New York on
Monday
Adobe"s Creative
Cloud fails at
being a cloud
NASA signs off on
sampling mission to
Earth-threatening
asteroid
US military
welcomes Apple iOS
6 kit onto its
networks
Jailed Romanian
hacker repents,
invents ATM
security scheme
Climate scientists
agree: Humans cause
global warming
MIT takes
battery-powered
robot cheetah for a
gallop
Google research
chief: "Emergent
artificial
intelligence?
Hogwash!"
Slashdot
Of 1000 Americans
Polled, Most Would
Ban Home Printing
of Guns
Happy Culture
Freedom Day!
RPiCluster: Another
Raspberry Pi
Cluster, With Neat
Tricks
NASA
Meteoroid-Spotting
Program Captures
Brightest-Yet Moon
Impact
Password Strength
Testers Work For
Important Accounts
Crowdsourced
Network Planning
For
Connection-Bridging
Startup
Cell Phones As a
Dirty Bomb
Detection Network
Linux Mint 15
"Olivia" Release
Candidate Is Out
Australian
Government Backdoor
Internet Filter
Shuts Down 1,000
Websites
Nintendo Hijacks Ad
Revenue From
Fan-Created YouTube
Playthroughs
Article viewer

yaps -Tcp and Udp simple port scanneer



Written by:dimport
Published by:SAJChurchey
Published on:2003-06-21 07:19:46
Topic:Java
Search OSI about Java.More articles by dimport.
 viewed 8566 times send this article printer friendly

Digg this!
    Rate this article :
YAPS - Yet Another Port Scanner
Ok, I'm learning socket programming in java so i made a port scanner. Hope this will help people with the idea of error checking within the program, and starting a connection with a host.

The udp is a little buggy, so every one post code and ways to improve it, or ideas.

 //--------------------------------------------------------------
// 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);
}
}


This article was originally written by sygoon

Did you like this article? There are hundreds more.

Comments:
<none>
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
goldie
using javamail i am getting excetion like this on Tue 5th May 6am
avax.mail.MessagingException: Unknown SMTP host: pop3.gmail.com; nested exception is: java.net.UnknownHostException: pop3.gmail.com at com.sun.mail.smtp.SMTPTransport.openServ er(SMTPTransport.java:1543) at com.sun.mail.smtp.SMTPTransport.protocol
kdemetter
Blog entry for Wed 11th Apr 1pm on Wed 11th Apr 1pm
lately i've been playing with Java a little . I'm working on a application that can create a list of meals for one week from a large list of meals . well , it works . just some problems with Swing not doing what i want it to do :-) http://www.os

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Java tricks by berry120

Think you really know Java? This won't test you on elaborate and never heard of APIs. It will test you on stuff that isn't always as it seems...
Java Programming - Level 1 by D-Cypell

A first level Java programming test. The test contains 10 questions on Java syntax, concepts and the API.
History and Basic Programming Knowledge by HackMaster321

A test of your knowledge of java history and programming. Tests your ability to recall java historical facts, and remember what some of javas more common commands and syntax are and do.


     
Your Ad Here
 
Copyright Open Source Institute, 2006