A voir également:
- Scan
- Scan now - Guide
- Scan qr code pc - Guide
- Router scan v2.60 - Forum Logiciels
- Scan manga - Forum Réseaux sociaux
- Scan bd ✓ - Forum Loisirs / Divertissements
1 réponse
import java.net.*;
import java.io.IOException;
public class PortScanner {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
try {
InetAddress ia = InetAddress.getByName(args[i]);
System.out.println("ia = " + ia.toString());
scan(ia);
}
catch (UnknownHostException e) {
System.err.println(args[i] + " is not a valid host name.");
}
}
}
public static void scan(InetAddress remote) {
String hostname = remote.getHostName();
for (int port = 0; port < 65536; port++) {
try {
Socket s = new Socket(remote, port);
System.out.println("\nA server is listening on port " + port
+ " of " + hostname);
s.close();
}
catch (IOException e) {
// The remote host is not listening on this port
System.out.print(".");
}
}
}
public static void scan(String remote) throws UnknownHostException {
InetAddress ia = InetAddress.getByName(remote);
scan(ia);
}
}
Remarque: utilisé sur ton serveur, ce code sera considéré comme un utilitaire. Par contre, si tu t'en sers pour scanner les ports d'un serveur distant, cela paut être considéré comme une agression. A bon entendeur...
;-)
import java.io.IOException;
public class PortScanner {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
try {
InetAddress ia = InetAddress.getByName(args[i]);
System.out.println("ia = " + ia.toString());
scan(ia);
}
catch (UnknownHostException e) {
System.err.println(args[i] + " is not a valid host name.");
}
}
}
public static void scan(InetAddress remote) {
String hostname = remote.getHostName();
for (int port = 0; port < 65536; port++) {
try {
Socket s = new Socket(remote, port);
System.out.println("\nA server is listening on port " + port
+ " of " + hostname);
s.close();
}
catch (IOException e) {
// The remote host is not listening on this port
System.out.print(".");
}
}
}
public static void scan(String remote) throws UnknownHostException {
InetAddress ia = InetAddress.getByName(remote);
scan(ia);
}
}
Remarque: utilisé sur ton serveur, ce code sera considéré comme un utilitaire. Par contre, si tu t'en sers pour scanner les ports d'un serveur distant, cela paut être considéré comme une agression. A bon entendeur...
;-)