Skip to content

Commit 47c0a62

Browse files
ransomware js added for mission 2
1 parent 4504808 commit 47c0a62

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="stylesheet" href="style.css" />
77
<title>Error!</title>
8+
<script src="script.js" defer></script>
89
</head>
910
<body>
1011
<header id="site-header"><h1>Your system has been Encrypted</h1></header>
@@ -79,7 +80,7 @@
7980
></textarea
8081
><br /><br />
8182

82-
<button type="submit">Restore Data</button>
83+
<button type="submit" id="restoreBtn">Restore Data</button>
8384
</form>
8485
</main>
8586
<footer>

script.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// get elements from page
2+
const restoreBtn = document.getElementById("restoreBtn");
3+
const authInput = document.getElementById("authcode");
4+
const keyInput = document.getElementById("name");
5+
const messageBox = document.createElement("p");
6+
document.querySelector("main").appendChild(messageBox);
7+
8+
// fake data for testing
9+
const validKeys = ["alpha123", "bravo456", "charlie789"];
10+
const expectedAuthCode = "unlock";
11+
12+
// check inputs and show result
13+
function simulateRestore() {
14+
const key = keyInput.value.trim();
15+
const auth = authInput.value.trim();
16+
17+
// compare values
18+
if (validKeys.includes(key) && auth === expectedAuthCode) {
19+
messageBox.textContent = "✅ data successfully restored";
20+
messageBox.style.color = "limegreen";
21+
} else {
22+
messageBox.textContent = "❌ invalid credentials, try again";
23+
messageBox.style.color = "red";
24+
}
25+
}
26+
27+
// run when button clicked
28+
restoreBtn.addEventListener("click", (event) => {
29+
event.preventDefault(); // stop form reload
30+
simulateRestore();
31+
});

style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,14 @@ footer {
9797
font-size: 0.9rem;
9898
padding: 10px 0;
9999
}
100+
101+
#restoreBtn:hover {
102+
background-color: crimson;
103+
color: white;
104+
cursor: pointer;
105+
transition: 0.3s;
106+
}
107+
108+
p {
109+
font-family: monospace;
110+
}

0 commit comments

Comments
 (0)