Please help! Language : Java A PhishingScanner Program Overview In this challeng
ID: 3727008 • Letter: P
Question
Please help!
Language : Java
A PhishingScanner Program Overview In this challenge, you will create a simple PhishingScanner program that checks the contents of an input file against a list of 30 words commonly seen in phishing messages. Your program will open the file and count the number of occurrences of each of the common words found in the file. A summary will th count and points (count times weighted value). The summary will also display total points for all matching words found in the scan.Explanation / Answer
// create a program with name PhishingScanner and create main class same name with project name
// Compile the program first
// Then run the porgram according to question and send filename as parameter
// Code as given below
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
/**
*
* @author SDinesh
*/
class PhishingScanner {
private static final String[] phishingWords = {"amazon", "official", "bank", "security", "urgent", "alert",
"important", "information", "ebay", "password", "credit", "verify",
"confirm", "account", "bill", "immediately", "address", "telephone",
"ssn", "charity", "check", "secure", "personal", "confidential",
"atm", "warming", "fraud", "citibank", "irs", "paypal"};
private static final int phishingPoints[] = {2, 2, 1, 1, 1, 1, 1, 2, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 3, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1};
private static int finalPoints[] = new int[30];
public static void main(String[] args) {
ArrayList<String> result=new ArrayList<String>();
if (args.length < 1) {
System.out.println("Please specify a file name");
return;
}
try {
File fe2 = new File(args[0]);
FileInputStream fis2 = new FileInputStream(fe2);
byte data2[] = new byte[fis2.available()];
fis2.read(data2);
fis2.close();
String sg2[] = new String(data2).split(" ");
for (int i = 0; i < phishingWords.length; i++) {
int count = 0;
String pointWord = phishingWords[i];
for (int j = 0; j < sg2.length; j++) {
if (sg2[j].equalsIgnoreCase(pointWord)) {
count++;
}
}
if (count > 0) {
int pointValue=phishingPoints[i];
int points=count*pointValue;
result.add(pointWord+"#"+count+"#"+points);//store all final result of phishing word
}
}
if(result.size()>0)
{
int totatlPoints=0;
System.out.println("Word Count Points");
for(int i=0;i<result.size();i++)
{
String rr[]=result.get(i).toString().split("#");
totatlPoints+=Integer.parseInt(rr[2]);
System.out.println(rr[0]+" "+rr[1]+" "+rr[2]);
}
System.out.println("Total Points: "+totatlPoints);
}
} catch (FileNotFoundException e) {
System.out.println("Please specify a file name");
} catch (IOException e) {
System.out.println("Please specify a file name");
}
}
}
//Ping for further queries