After putting off learning a new programming language for quite some time, I finally decided to start learning Java. My first thought after looking at some of the sample code, "Holy crap, this is easy."
Apart from coding the standard "Hello, World!" app, I jumped right into making something that I thought would be a bit fun...an application that would scan a given website to discover what subdomains the site is using based off of an array containing some commonly used subdomains. For lack of a better term, I dubbed it the "SubDomainer."
[Note: I did use some code I found online that would find the IP address of a given website, but as you can see, I have added a large amount of my own code to it.]
import java.net.*;
import java.io.*;
public class SubDomainer
{
public static void main ( String[] args ) throws IOException
{
String hostname;
String newhostname;
String wwwhostname;
String subdomains[] = {"access", "admin", "backup", "backup2", "beta", "cgi", "code", "customers", "database", "db", "email", "finance", "ftp", "gateway", "guest", "help", "helpdesk", "intranet", "login", "mail", "mailhost", "mailserver", "ns1", "ns2", "partners", "products", "proxy", "secret", "server", "test", "webmail", "www2", "www3"};
BufferedReader input = new BufferedReader ( new InputStreamReader(System.in) );
System.out.print("Note: Host name must be entered without 'www.' attached.\n");
System.out.print("Host name: ");
hostname = input.readLine();
wwwhostname = "www." + hostname;
try
{
InetAddress ipaddress = InetAddress.getByName(wwwhostname);
System.out.print("\n");
System.out.print("Scanning " + wwwhostname + " (" + ipaddress.getHostAddress() + ") \n");
System.out.print("-----------------------------------------------\n");
}
catch ( UnknownHostException e )
{
System.out.print("\n");
System.out.print("ERROR: Host IP address cannot be resolved. \n");
finish();
}
for (int i = 0; i < subdomains.length; i++)
{
newhostname = subdomains[i] + "." + hostname;
try
{
InetAddress newipaddress = InetAddress.getByName(newhostname);
System.out.print("\n");
System.out.print(newhostname + " (" + newipaddress.getHostAddress() + ") EXISTS \n");
}
catch(UnknownHostException e)
{
System.out.print("");
}
}
}
public static void finish()
{
System.exit(0);
}
}
Apart from coding the standard "Hello, World!" app, I jumped right into making something that I thought would be a bit fun...an application that would scan a given website to discover what subdomains the site is using based off of an array containing some commonly used subdomains. For lack of a better term, I dubbed it the "SubDomainer."
[Note: I did use some code I found online that would find the IP address of a given website, but as you can see, I have added a large amount of my own code to it.]
import java.net.*;
import java.io.*;
public class SubDomainer
{
public static void main ( String[] args ) throws IOException
{
String hostname;
String newhostname;
String wwwhostname;
String subdomains[] = {"access", "admin", "backup", "backup2", "beta", "cgi", "code", "customers", "database", "db", "email", "finance", "ftp", "gateway", "guest", "help", "helpdesk", "intranet", "login", "mail", "mailhost", "mailserver", "ns1", "ns2", "partners", "products", "proxy", "secret", "server", "test", "webmail", "www2", "www3"};
BufferedReader input = new BufferedReader ( new InputStreamReader(System.in) );
System.out.print("Note: Host name must be entered without 'www.' attached.\n");
System.out.print("Host name: ");
hostname = input.readLine();
wwwhostname = "www." + hostname;
try
{
InetAddress ipaddress = InetAddress.getByName(wwwhostname);
System.out.print("\n");
System.out.print("Scanning " + wwwhostname + " (" + ipaddress.getHostAddress() + ") \n");
System.out.print("-----------------------------------------------\n");
}
catch ( UnknownHostException e )
{
System.out.print("\n");
System.out.print("ERROR: Host IP address cannot be resolved. \n");
finish();
}
for (int i = 0; i < subdomains.length; i++)
{
newhostname = subdomains[i] + "." + hostname;
try
{
InetAddress newipaddress = InetAddress.getByName(newhostname);
System.out.print("\n");
System.out.print(newhostname + " (" + newipaddress.getHostAddress() + ") EXISTS \n");
}
catch(UnknownHostException e)
{
System.out.print("");
}
}
}
public static void finish()
{
System.exit(0);
}
}