I tried to make a simple port scanning programs from java and I make it like this:
package PortScanning;
/**
*
* @author fonts
*/
import java.net.*;
import java.io.*;
public class port {
static int scan=20;
public void load() {
try {
if (scan <= 587)
{
System.out.print(" Scanning...");
scan++;
Socket gw = new Socket("127.0.0.1",scan);
System.out.println(scan + "\t\t opened");
port lagi=new port();
lagi.load();
}
else
{
System.out.println("\n—————————————–\n—————————————–\n Finish... \n\n");
}
}
catch (Exception e)
{
System.out.println(scan + "\开发者_如何学Ct\t closed");
port lagi=new port();
lagi.load();
}
}
public static void main(String[]args)
{
System.out.print(" Try Scanning \n—————————————–\n—————————————–\n\n");
scan--;
port panggil=new port();
panggil.load();
}
}
but I wanted to ask how the process of scanning ports on the capture of data that I previously inserted into the database, so will the system work becomes automatic scanning of the database table before I make like this:
=================
ip | port
=================
127.0.0.1 | 80
127.0.0.1 | 25
etc. | etc.
=================
I hope anyone can help my problem and thanks a lot
For accessing databases in Java, one can use JDBC. Have a look at Jdbc-Tutorial for getting started.
Concerning your port scanning program, you can follow the following path for building it :
- Open database
Connection
- Get the list of ports (with ip) to scan from database with a
Statement
- For each ports found, scan it with its associated ip; use
ResultSet
- Close
Statement
and databaseConnection
Good luck !
精彩评论