开发者

my java socket application

开发者 https://www.devze.com 2023-02-21 08:21 出处:网络
I tried to make a simple port scanning programs from java and I make it like this: package PortScanning;

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 :

  1. Open database Connection
  2. Get the list of ports (with ip) to scan from database with a Statement
  3. For each ports found, scan it with its associated ip; use ResultSet
  4. Close Statement and database Connection

Good luck !

0

精彩评论

暂无评论...
验证码 换一张
取 消