Sitemap
Malekith

Malekith

Hack the Login

Hack the Login

2 min readNov 10, 2025

Start the machine, hack the system, and find the hidden flags to complete this challenge and earn points!

On this challenge from @hackerdna we must find a way to login on the system, the challenge can be found here https://hackerdna.com/labs/hack-the-login

Get Malekith’s stories in your inbox

Join Medium for free to get updates from this writer.

Once we startup the lab and connect we notice there is login screen

Press enter or click to view image in full size

So, the very first thing I always do is check the source code, so if we inspect it we will see a js is called, script.js

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Authentication</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="login-box">
<h2>Login</h2>
<form id="loginForm">
<div class="input-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</div>
<div class="input-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit">Login</button>
</form>
<div id="message"></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>

If we click on it

document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();

const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const messageDiv = document.getElementById('message');

// Simple authentication check
if (username === "admin" && password === "SecretPassword123!") {
messageDiv.textContent = "Authentication successful! Retrieving flag...";
messageDiv.className = "success";

// Read the flag from the random folder
fetch('7d9f3b2e1c8a5f6d4e0/flag.txt')
.then(response => response.text())
.then(flag => {
messageDiv.textContent = `Success! Flag: ${flag}`;
})
.catch(error => {
messageDiv.textContent = "Error reading flag file";
messageDiv.className = "";
});
} else {
messageDiv.textContent = "Invalid username or password";
messageDiv.className = "";
}
});

We can see several things:

  • The username: admin
  • The password: SecretPassword123!
  • The path to the flag: 7d9f3b2e1c8a5f6d4e0/flag.txt

So, to grab the flag we can simple type username and password or simplier, just add the path to the url to get the flag

--

--