-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (50 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const antiPhishingFilters = [
noFilter,
blackListFilter,
caseInsensitiveFilter,
baseFilter
];
let antiPhishingFilterIndex = 0;
/**
* Update the selected anti-phishing filter index
*/
function antiPhishingFilterChange() {
antiPhishingFilterIndex = parseInt(document.getElementById('anti-phishing-filter-select').value);
sendEmail();
}
/**
* On attacker form submission
* display the attacker email in the victim card and parse it.
* The corresponding alert is displayed
*/
function sendEmail() {
// Get the typed email in the attacker input
const email = document.getElementById('email-preparation-input').value;
// Get the HTML switch state
const isHTML = document.getElementById('html-switch').checked;
// Display the email in the victim card
const emailContent = document.getElementById('email-content');
if (isHTML)
emailContent.innerHTML = email;
else
emailContent.innerText = email;
parseEmail(email);
// Return false to prevent webpage reloading
return false;
}
/**
* Parse the attacker email and display the corresponding alert
* @param email The attacker email
*/
function parseEmail(email) {
const filterAcceptAlert = document.getElementById('filter-accept');
const filterBlockAlert = document.getElementById('filter-block');
// Hide the two alerts
filterAcceptAlert.style.display = 'none';
filterBlockAlert.style.display = 'none';
const isAccepted = antiPhishingFilters[antiPhishingFilterIndex](email);
if (isAccepted)
filterAcceptAlert.style.display = 'block';
else
filterBlockAlert.style.display = 'block';
}