July 3, 2010

My uncle just created a neat little tool in his free time that compares the contents of files, by way of an MD5 checksum, in order to discover duplicate files on your system. It's fairly handy for finding duplicate images. Feel free to download it here and give it a try. You'll need .Net Framework 2.0 in order to run it though.

May 19, 2010

I was playing around with Java again, and decided to attempt to create a GUI for my SubDomainer app. Here is the resulting code:

import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;

public class SubDomainerGUI extends JFrame implements ActionListener
{
DataOutputStream output;

JPanel firstRow = new JPanel();
JPanel secondRow = new JPanel();

JPanel fieldPanel = new JPanel();
JPanel buttonPanel = new JPanel();

JLabel targetLabel = new JLabel("Target URL: ");
JTextField targetURL = new JTextField(20);
JLabel reminderOne = new JLabel("Please enter the target URL without 'www.' attached.");

JButton scanButton = new JButton("Scan");
JButton exitButton = new JButton("Exit");

public static void main(String[] args)
{
SubDomainerGUI f = new SubDomainerGUI();
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.setSize(400,170);
f.setTitle("SubDomainer");
f.setResizable(false);
f.setLocation(200,200);
f.setVisible(true);
}

public SubDomainerGUI()
{
Container c = getContentPane();
c.setLayout((new BorderLayout()));
fieldPanel.setLayout(new GridLayout(4,2));
FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
firstRow.setLayout(rowSetup);
secondRow.setLayout(rowSetup);
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

firstRow.add(targetLabel);
firstRow.add(targetURL);

secondRow.add(reminderOne);

fieldPanel.add(firstRow);
fieldPanel.add(secondRow);

buttonPanel.add(scanButton);
buttonPanel.add(exitButton);

c.add(fieldPanel, BorderLayout.CENTER);
c.add(buttonPanel, BorderLayout.SOUTH);

scanButton.addActionListener(this);
exitButton.addActionListener(this);

try
{
output = new DataOutputStream(new FileOutputStream("SubDomainer_Results.txt"));
}

catch (IOException ex)
{
System.exit(1);
}

addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
int answer = JOptionPane.showConfirmDialog(null, "Are you sure you want to exit?", "Exit", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION)
finish();
}
}
);
}

public void actionPerformed(ActionEvent e)
{
String arg = e.getActionCommand();

if (arg == "Scan")
{
try
{
String subdomains[] = {"access", "admin", "backup", "backup2", "beta", "cgi", "code", "customers", "database", "db", "dev", "download", "downloads", "email", "finance", "ftp", "gateway", "guest", "help", "helpdesk", "internal", "intranet", "kb", "login", "mail", "mailhost", "mailserver", "ns1", "ns2", "partners", "products", "proxy", "secret", "secure", "server", "test", "webmail", "www2", "www3"};
try
{
InetAddress ipaddress = InetAddress.getByName(targetURL.getText());
output.writeUTF("\n");
output.writeUTF("Scanning " + targetURL.getText() + " (" + ipaddress.getHostAddress() + ") \n");
output.writeUTF("-----------------------------------------------\n");
}
catch ( UnknownHostException e1)
{
JOptionPane.showMessageDialog(null,"ERROR: Host IP address cannot be resolved.", "Error in URL", JOptionPane.ERROR_MESSAGE);
finish();
}

for (int i = 0; i <>
{
String newhostname = subdomains[i] + "." + targetURL.getText();
try
{
InetAddress newipaddress = InetAddress.getByName(newhostname);
output.writeUTF("\n");
output.writeUTF(newhostname + " (" + newipaddress.getHostAddress() + ") EXISTS \n");
}
catch(UnknownHostException e2)
{
output.writeUTF("");
}
}


JOptionPane.showMessageDialog(null,"The scan results have been saved.","Scan Successful", JOptionPane.INFORMATION_MESSAGE);
}

catch(IOException ex)
{
System.exit(1);
}
finish();
}

else
{
try
{
output.close();
}
catch(IOException c)
{
System.exit(1);
}
finish();
}
}

public static void finish()
{
System.exit(0);
}
}

April 1, 2010

While listening to a lecture the other day about computer networks, I spent my time working on a port scanner in Java. Oh how fun it is to be a geek...

Anyhow, here's CryptScanner (*Again, some code was borrowed*):

import java.net.*;
import java.io.*;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;

public class CryptScanner
{
public static void main(String[] args) throws IOException
{
InetAddress target=null;
String hostAddr=null;

try
{
BufferedReader input = new BufferedReader ( new InputStreamReader(System.in) );
System.out.print("Host name to scan: ");
hostAddr = input.readLine();

if(hostAddr!=null)
{
target = InetAddress.getByName(hostAddr);
scan(target);
}

}

catch (UnknownHostException e)
{
System.err.println(e);
}

finish();
}

public static void scan(final InetAddress remote) throws UnknownHostException
{
int port=0;
String hostname = remote.getHostName();

InetAddress ipAddress = InetAddress.getByName(hostname);
System.out.print("\nScan results for " + hostname + " (" + ipAddress.getHostAddress() + ")" +"\n");
System.out.print("---------------------------------------------------------\n");

for (port = 0; port < 65536; port++)
{
try
{
Socket sock = new Socket(remote,port);
System.out.print("Listening on port " + port +"\n");
sock.close();
}

catch (IOException ex)
{
System.out.print("Not Listening on port " + port +"\n");
}
}
}

public static void finish()
{
System.exit(0);
}
}

February 1, 2010

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);
}
}
Subscribe to RSS Feed Follow me on Twitter!