Mobile Antivirus J2ME
Jumat, 07 November 2008
if there was a virus, there are now anti-virus J2ME CommWarriorAntiVirus, Although still simple shapes up, but the source code can be viewed and developed their own lho.So allows itself to be learned, even develop.
However, anti-virus page can only detect a virus, CommWarrior only.
To get the source code just looking at http://www.Planet-Source-Code.com.
Under this source code:
/*
CommWarrior Anti-Virus Application
Originally Created by Walter Narvasa
visit my website at www.narvasa.com
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.midlet.MIDlet;
import java.util.Random;
import java.io.*;
import javax.microedition.io.*;
public class CommWarriorAntiVirus extends MIDlet implements CommandListener {
// display manager
Display display = null;
// a menu with items
List menu = null; // main menu
// ticker
Ticker ticker = new Ticker(".:: Welcome to CommWarrior Anti-Virus Application ::.");
// Scan Alert 1
final Alert ScanAlert = new Alert("SCAN ALL:");
// Scan Alert 2
final Alert ScanAlert2 = new Alert("SCAN PHONE MEMORY:");
// Scan Alert 3
final Alert ScanAlert3 = new Alert("SCAN MEMORY CARD:");
// date
DateField date = new DateField("Today's date: ", DateField.DATE);
// command
static final Command backCommand = new Command("Back", Command.BACK, 0);
static final Command mainMenuCommand = new Command("Main", Command.SCREEN, 1);
static final Command exitCommand = new Command("Exit", Command.STOP, 2);
String currentMenu = null;
// constructor.
public CommWarriorAntiVirus() {
}
/**
* Start the MIDlet by creating a list of items and associating the
* exit command with it.
*/
public void startApp() throws MIDletStateChangeException {
display = Display.getDisplay(this);
// open a db stock file
menu = new List("CommWarrior Anti-Virus", Choice.IMPLICIT);
menu.append("Scan All", null);
menu.append("Scan Phone Memory", null);
menu.append("Scan Memory Card", null);
menu.append("Heuristic Scanning", null);
menu.addCommand(exitCommand);
menu.setCommandListener(this);
menu.setTicker(ticker);
mainMenu();
}
public void pauseApp() {
display = null;
menu = null;
ticker = null;
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
// main menu
void mainMenu() {
display.setCurrent(menu);
currentMenu = "Main";
}
/**
* Test the Scan Alert 1 component.
*/
public void SAlert() {
ScanAlert.setType(AlertType.ERROR);
//ScanAlert.setTimeout(30);
ScanAlert.setString("** Scanned All Complete **");
display.setCurrent(ScanAlert);
}
/**
* Test the Scan Alert 2 component.
*/
public void SAlert2() {
ScanAlert2.setType(AlertType.ERROR);
//ScanAlert2.setTimeout(30);
ScanAlert2.setString("** Scanned Phone Memory Complete **");
display.setCurrent(ScanAlert2);
}
/**
* Test the Scan Alert 3 component.
*/
public void SAlert3() {
ScanAlert3.setType(AlertType.ERROR);
//ScanAlert3.setTimeout(30);
ScanAlert3.setString("** Scanned Memory Card Complete **");
display.setCurrent(ScanAlert3);
}
/**
* Scan All Class
*/
public void ScanAll() {
try
{
OutputConnection connection = (OutputConnection)
Connector.open("file:///c:/system/apps/commwarrior/commwarrior.exe;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "????????????" );
out.close();
connection.close();
Alert alert = new Alert("Scan all Completed", "CommWarrior Removed All!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( ConnectionNotFoundException error )
{
Alert alert = new Alert(
"CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( IOException error )
{
Alert alert = new Alert("CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
/**
* Scan Phone Memory Class
*/
public void ScanPhoneMemory() {
try
{
OutputConnection connection = (OutputConnection)
Connector.open("file:///c:/system/apps/commwarrior/commrec.mdl;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "????????????" );
out.close();
connection.close();
Alert alert = new Alert("Scan Phone Memory Completed", "CommWarrior Removed on Phone Memory!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( ConnectionNotFoundException error )
{
Alert alert = new Alert(
"CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( IOException error )
{
Alert alert = new Alert("CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
/**
* Scan Memory Card Class
*/
public void ScanMemoryCard() {
try
{
OutputConnection connection = (OutputConnection)
Connector.open("file:///d:/system/apps/commwarrior/commwarrior.exe;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "????????????" );
out.close();
connection.close();
Alert alert = new Alert("Scan Memory Card Completed", "CommWarrior Removed on Memory Card!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( ConnectionNotFoundException error )
{
Alert alert = new Alert(
"CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( IOException error )
{
Alert alert = new Alert("CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
/**
* Scan Heuristic Scanning Class
*/
public void HeuristicScanning() {
try
{
OutputConnection connection = (OutputConnection)
Connector.open("file:///d:/system/updates/commw.sis;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "????????????" );
out.close();
connection.close();
Alert alert = new Alert("Heuristic Scanning Completed", "CommWarrior Removed using Heuristic Scanning!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( ConnectionNotFoundException error )
{
Alert alert = new Alert(
"CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
catch( IOException error )
{
Alert alert = new Alert("CommWarrior Anti-Virus", "CommWarrior Not Found!", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
/**
* Handle events.
*/
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if (label.equals("Exit")) {
destroyApp(true);
} else if (label.equals("Back")) {
if(currentMenu.equals("list") || currentMenu.equals("input") ||
currentMenu.equals("date") || currentMenu.equals("form")) {
// go back to menu
mainMenu();
}
} else {
List down = (List)display.getCurrent();
switch(down.getSelectedIndex()) {
case 0: ScanAll();break;
case 1: ScanPhoneMemory();break;
case 2: ScanMemoryCard();break;
case 3: HeuristicScanning();break;
}
}
}
}