Nekobee
[mirrors/Programs.git] / c / brute.c
CommitLineData
21c4e167
H
1//BruteForCer - A permutation sequence generator
2//Harvie 2oo7
3/*
4 * I hope, that this can show you that BF is the most suxing idea.
5 * You can use GREP pipe, if you know part of password.
6 * Brutforcing is the only way to be the real hacker. (Please don't pwn me ;)
7 * More info? UTFS!
8 */
9
10#include <stdio.h>
11
12int main() {
13
14 int minlen = 4;
15 int maxlen = 4; //Lenght of string
16 char full = 0; //0=Alphabet, 1=All possibilities
17 unsigned char alpha[] = "1234"; //"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "; //Alphabet
18
19 unsigned int alphmax = sizeof(alpha)-1;
20 char loop;
21 int i, pos, len;
22 unsigned char comb[maxlen];
23
24
25 for(len=minlen;len<=maxlen;len++) {
26
27
28 //Fill string with NULL bytes
29 for(i=0;i<len;i++) {
30 comb[i] = 0;
31 }
32
33 loop = 1;
34 while(loop) {
35
36 //Make next string
37 pos = 0;
38 comb[pos]++; if(!full && comb[pos]>=alphmax) comb[pos] = 0;
39 while(comb[pos]==0) {
40 pos++;
41 if(pos >= len) loop = 0;
42 comb[pos]++; if(!full && comb[pos]>=alphmax) comb[pos] = 0;
43 }
44
45 //Print string in reversed order
46 for(i=(len-1);i>=0;i--) {
47 if(full) {
48 putc(comb[i], stdout);
49 } else {
50 if(comb[i]<alphmax && alpha[comb[i]] != 0) putc(alpha[comb[i]], stdout);
51 }
52 }
53 putc('\n', stdout);
54 }
55
56
57 }
58
59}
This page took 0.757957 seconds and 4 git commands to generate.