I was looking for something about js so I decided to make a simple scan port with dialogs.
If you got any question please ask.
I also got the .jar so if someone wants it let me know.
Code:import java.net.*; import java.io.IOException; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Main { public static void main(String[] args) { InetAddress ia=null; String host=null; String getPort = null; String showDialog = null; Object[] result_show = {"Console","Dialog"}; int port = 0; try { host=JOptionPane.showInputDialog("Enter the Host name to scan:\n example: xxx.ro"); getPort=JOptionPane.showInputDialog("Port?"); showDialog = (String)JOptionPane.showInputDialog(null,"Were do you want to see the result?","Question",JOptionPane.PLAIN_MESSAGE,null,result_show,"Console"); port = Integer.parseInt(getPort); if(host!=null){ ia = InetAddress.getByName(host); scan(ia,port,showDialog); } } catch (UnknownHostException e) { System.err.println(e ); } System.exit(0); } public static void scan(final InetAddress remote,int port,String showDialog){ String hostname = remote.getHostName(); try{ Socket s = new Socket(remote,port); if((showDialog != null) && (showDialog.length() > 0 ) && (showDialog == "Dialog")){ JOptionPane.showMessageDialog(null, "Port (open): " + port + " on host " + hostname); }else{ System.out.println("Port (open): " + port + " on host "+ hostname); } s.close(); } catch(IOException ex){ if((showDialog != null) && (showDialog.length() > 0 ) && (showDialog == "Dialog")){ JOptionPane.showMessageDialog(null, "Port (close): " + port + " on host " + hostname); }else{ System.out.println("Port (close): " + port + " on host " + hostname); } } }


Reply With Quote
Bookmarks