Scanner IP

Escanea un IP pasado ,nos muestra los puertos abiertos.
Para ejecutarlo se debe escribir en consola: java -jar scannerip.jar.

Run.java



package BackEnd;

import FrontEnd.Ventana;

public class Run implements Runnable{
  int puerto = 0;
  Ventana v;
  int fin;
  public Run(int port,int fin,Ventana v){
     this.v=v;
     puerto = port;
     this.fin=fin;
  }
     
  public void run(){
     Scanner Scanner = new Scanner(puerto,fin,v);
  }
}

Scanner.java


package BackEnd;

import java.net.Socket;

import FrontEnd.Ventana;

public class Scanner {

 public Scanner(int puerto,int fin,Ventana v){
  Socket dame;
  String ip=v.getCampoIP().getText();
       
          for(int port =puerto;port<=fin;port++){
           try{
           dame = new Socket(ip,port);
           v.getAreaTexto().setText(v.getAreaTexto().getText()+"\n"+"Puerto "+port+" Abierto");
           System.out.println("Puerto "+port+" Abierto");
           dame.close();
           
           }
           catch(Exception ex){}
           
        } 
     }
}

Scaneando.java


package BackEnd;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import FrontEnd.Ventana;

public class Scaneando {

 private Ventana v;
 
 public Scaneando(Ventana v){
  this.v=v;
  v.getBuscar().setEnabled(false);
  v.getCampoIP().setEditable(false);
  ExecutorService executor = Executors.newCachedThreadPool();
       int ini=1,fin=100;
       while(fin<=65500){
       executor.execute(new Run(ini,fin,v));
       fin+=100;
       ini+=100;
       }
       executor.execute(new Run(65501,65535,v));
 }
}

Ventana.java



package FrontEnd;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;

import BackEnd.Scaneando;

public class Ventana extends JFrame implements ActionListener{
 
 private JLabel mensajes,labelIP;
 private JTextPane areaTexto;
 private JButton buscar;
 private JTextField campoIP;
 private JScrollPane scroll;
 private JPanel panelSup;
 private Scaneando scan;
 
 public Ventana(){
  super("Scanner IP 0.2");
  this.setBounds(0, 0, 600, 600);
  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  panelSup = new JPanel(new FlowLayout());
  labelIP = new JLabel("IP: ");
  campoIP = new JTextField(20);
  buscar = new JButton("Buscar");
  panelSup.add(labelIP);
  panelSup.add(campoIP);
  panelSup.add(buscar);
  this.add(panelSup,BorderLayout.NORTH);
  areaTexto = new JTextPane();
  areaTexto.setEditable(false);
  scroll = new JScrollPane(areaTexto);
  this.add(scroll,BorderLayout.CENTER);
  mensajes = new JLabel("Listo.");
  this.add(mensajes,BorderLayout.SOUTH);
  buscar.addActionListener(this);
  //Aca van los oyentes
  
  this.setVisible(true);
 }

 public JTextPane getAreaTexto() {
  return areaTexto;
 }

 public void setAreaTexto(JTextPane areaTexto) {
  this.areaTexto = areaTexto;
 }

 public void actionPerformed(ActionEvent e) {
  if(e.getSource()==buscar){
   scan = new Scaneando(this);
  }
 }

 public JTextField getCampoIP() {
  return campoIP;
 }

 public void setCampoIP(JTextField campoIP) {
  this.campoIP = campoIP;
 }

 public JLabel getMensajes() {
  return mensajes;
 }

 public void setMensajes(JLabel mensajes) {
  this.mensajes = mensajes;
 }

 public JLabel getLabelIP() {
  return labelIP;
 }

 public void setLabelIP(JLabel labelIP) {
  this.labelIP = labelIP;
 }

 public JButton getBuscar() {
  return buscar;
 }

 public void setBuscar(JButton buscar) {
  this.buscar = buscar;
 }

}

Main.java


package FrontEnd;

public class Main {

 public static void main(String[] args) {
  Ventana v = new Ventana();
 }

}
 


Descargar scannerip.jar
 

https://drive.google.com/file/d/0B0sBXdZ8aJgdbzFqTU1qdlZ2TFU/edit?usp=sharing
 
Scanner IP en ejecucion 

 
 
Diagrama generado con objectaid 
 
 
 

Comentarios