Thursday, February 12, 2009
Pendrive Virus-launcher Cleaner v005
/*
* Pendrive virus Launcher Cleaner
* by Paul Chin
* Feb 12, 2009
*/
package pendriveviruslaunchercleaner;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class PendriveVirusLauncherCleaner extends JFrame {
//private JButton btnClean;
//private JButton btnInnoculate;
private JButton btnCleanInnoc;
private JButton btnHelp;
//private JButton btnClearscreen;
private JLabel lbIP;
private JTextArea taOutput;
private JScrollPane jsp;
private JComboBox cbDrive;
String[] slist = {"D", "E", "F", "G", "H", "I", "J", "K", "L", "M"};
String sHelp =
"1. Select your pen drive Letter.\n2. Click Clean and Innoculate.\n" +
"\nA Pendive infection consists of a virus-launcher and the actual virus.\n" +
"The virus-launcher file is autorun.inf whilst, the virus can be of any name.\n" +
"Whenever a user double-clicks on a pendrive icon, the autorun.inf\n" +
"file is triggerred, it will then launch the actual virus.\n" +
"The virus will then infect the PC. By deleting this autorun.inf file,\n" +
"the virus will not be able to launch when a user double-clicks on \n" +
"the pendrive.\n\n" +
"Innoculation means to create a fake autorun.inf folder.\n" +
"This prevents the real autorun.inf virus-launcher from being\n" +
"copied to your pendrive from an infected PC.\n";
public static void main(String[] args) {
PendriveVirusLauncherCleaner pdvlc = new PendriveVirusLauncherCleaner();
pdvlc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pdvlc.setSize(500, 400);
pdvlc.setVisible(true);
}
public PendriveVirusLauncherCleaner() {
super("Pendrive Virus-Launcher Cleaner v005");
setLayout(new FlowLayout()); // set frame layout
lbIP = new JLabel("Drive: ");
cbDrive = new JComboBox(slist);
//btnClean = new JButton("Clean");
//btnInnoculate = new JButton("Innoculate");
btnCleanInnoc = new JButton("Clean and Innoculate");
btnHelp = new JButton("Help");
//btnClearscreen = new JButton("ClearScreen");
taOutput = new JTextArea(18, 40);
taOutput.append("1. Select your pen drive Letter.\n2. Click Clean and Innoculate.\n");
jsp = new JScrollPane(taOutput);
add(lbIP);
add(new JScrollPane(cbDrive));
//add(btnClean);
//add(btnInnoculate);
add(btnCleanInnoc);
add(btnHelp);
//add(btnClearscreen);
add(jsp);
ButtonHandler handler = new ButtonHandler();
btnHelp.addActionListener(handler);
//btnClean.addActionListener(handler);
//btnInnoculate.addActionListener(handler);
btnCleanInnoc.addActionListener(handler);
//btnClearscreen.addActionListener(handler);
}
private class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnCleanInnoc) {
taOutput.setText("");
doScan();
doInnoculate();
}
//if (e.getSource() == btnInnoculate) {
// doInnoculate();
//}
if (e.getSource() == btnHelp) {
taOutput.setText("");
taOutput.append(sHelp);
}
//if (e.getSource() == btnClearscreen) {
// taOutput.setText("");
//}
}
}
private void doScan() {
String drive = cbDrive.getSelectedItem().toString();
File d = new File(drive + ":\\");
if (d.exists() == false) {
taOutput.append("Drive: " + drive + " not found, Please try again.\n");
return;
}
taOutput.append("Starting scan on Drive: " + drive + "\nPlease wait...\n");
File f = new File(drive + ":\\autorun.inf");
if (f.exists() && f.isFile()) {
taOutput.append("FOUND: \'autorun.inf\' virus-launcher\n");
int response = JOptionPane.showConfirmDialog(null,
"Found: \'autorun.inf\' virus launcher. Shall I delete it?");
if (response == 0) {
try {
f.delete();
taOutput.append("Virus launcher successfully deleted\n\n");
} catch (Exception x) {
taOutput.append(x.getMessage() + "\n");
JOptionPane.showMessageDialog(null, x.getMessage());
}
}
} else {
if (f.isDirectory() == true) {
taOutput.append("autorun.inf folder found.\nPendrive already innoculated\n");
} else {
taOutput.append("\'autorun.inf\' virus launcher NOT found\n");
}
}
}
private void doInnoculate() {
String drive = cbDrive.getSelectedItem().toString();
File d = new File(drive + ":\\autorun.inf");
if (d.exists() == false) {
d.mkdir();
File dummy = new File(d, "DoNotDeleteThisFolder.txt");
try {
dummy.createNewFile();
taOutput.append("Innoculation succeeded. Fake autorun.inf folder created.\n");
taOutput.append("Do not delete this autorun.inf folder, it prevents the real\n");
taOutput.append("autorun.inf virus launcher from infecting your pendrive.\n");
} catch (Exception ex) {
taOutput.append(ex.getMessage() + "\n");
}
} else {
taOutput.append("autorun.inf folder exists. Your pendrive is already innoculated.\n");
}
}
}