I have a small Java program that reads list of IPs from text file and inside a loop it create ssl session with the ip. The session might succeed or fail depend whether the port 443 is enabled in the other side or not.
My problem:
1. If port 443 is not enabled in the other side, the session will fail. The problem is that my program stops here and go to exception handling and print me the error and ends. I want the program to continue creating the next session with the next IP and so on. How can I make it continue and print out a message saying that the session failed for that IP?
Another issue: How can I get the enabled cipher suite? I tried to print socket.getEnabledCipherSuites(); but printed strange text not a type of cipher suite at all.
EDIT:
public static void main(String[] argv) {
try{
while ((there are IPs)
{
try{
//call for Connect function which has try/catch on it the same way
}catch (Exception e){
System.err.println("Error: " + e.getMessage());
}//catch
}//end while loop
catch (Exception e){
System.err.println("Error: " + e.getMessage());
}//catch
}//end void main </i>
your point #1 seems to be something exception handling should take care of: enclose each iteration on all_ips within its own try/catch block.
You could greatly benefit from some multithreading and time-out here, as some firewall will just drop your SYN packet silently and let your scanner tool wait indefinitely.
BUT before you do that, take care: you’re going to look very much like a malicious tool scanning a network for some vulnerabilities. You may get into administrative trouble if you’re too aggressive or target someone you don’t know. A pool of thread or some similar technique to ensure you’re not exceeding fair amount of connection establishment/second is a bare minimum.