TITOLO Scanner di rete on JAVA Vedi allegato
OGGETTO Scanner Java
Un ottimo scanner di rete in JAVA che ho trovato; ho lasciato, giustamente, le licenze all\'interno del codice: Pscan.java import java.io.*; import javax.swing.Timer; import java.net.*; import java.util.*; import java.lang.Thread; public class Pscan { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print(\"\\nAD ASTRA! PortScanner 2.0 2008\\nCreated By eddiewrc\"); System.out.print(\"\\nTarget IP address: \"); String ip = in.next(); System.out.print(\"\\nStart at port: \"); int start = in.nextInt(); System.out.print(\"\\nFinish at port: \"); int finish = in.nextInt(); System.out.print(\"\\nNumber of Threads (50 < Suggested < 100): \"); int trd = in.nextInt(); System.out.print(\"\\nStart scanning... \\n\"); Thread[] socks = new Thread[trd]; class ScanThread extends Thread { ScanThread(String ip1, int i) { porta = i; ip = ip1; } public void run() { try { Socket s = new Socket(ip, porta); System.out.println(\"Port: \" + porta + \" Status: OPEN\"); } catch (IOException ex) { //System.out.println(\"Port: \" + porta + \" Status: CLOSE\"); this.stop(); } } private int porta; private String ip; } int i, j; StopWatch time = new StopWatch(); time.start(); for (i = start; i < finish; ) for (j = 0; j < trd; j++, i++) { socks[j] = new ScanThread(\"127.0.0.1\", i); socks[j].start(); } time.stop(); System.out.println(\"Scan finished at port: \" + i); System.out.println(\"Scan time: \" + time.getElapsedTimeSecs() + \" secs\"); } } StopWatch.java public class StopWatch { private long startTime = 0; private long stopTime = 0; private boolean running = false; public void start() { this.startTime = System.currentTimeMillis(); this.running = true; } public void stop() { this.stopTime = System.currentTimeMillis(); this.running = false; } //elaspsed time in milliseconds public long getElapsedTime() { long elapsed; if (running) { elapsed = (System.currentTimeMillis() - startTime); } else { elapsed = (stopTime - startTime); } return elapsed; } //elaspsed time in seconds public long getElapsedTimeSecs() { long elapsed; if (running) { elapsed = ((System.currentTimeMillis() - startTime) / 1000); } else { elapsed = ((stopTime - startTime) / 1000); } return elapsed; } /*//sample usage public static void main(String[] args) { StopWatch s = new StopWatch(); s.start(); //code you want to time goes here s.stop(); System.out.println(\"elapsed time in milliseconds: \" + s.getElapsedTime()); }*/ }