Wednesday, March 7, 2012

Word With Random Character Generator In C [Random Word Generator]

I'm in extreme broken stage and need to crack neighbor's WiFi to get Internet at home. Unfortunately there are only few APs that I can see from home and all of them are protected with WPA or WPA2.

I'm using aircrack suite to do the cracking and have managed to capture handshake packets. Now the problem I'm having is cracking the key. Dictionary based attack isn't successful due to following characteristics of key phrases:
  1. Using of name and address from Nepali origin which naturally won't exists in dictionary
  2. Mixing English and Nepali words which is very common in my culture
  3. Clever key phrases which may consists of numbers and combination of words
Brute forcing isn't feasible. It will take ages with my crappy laptop. So I'm trying to brute force by generating random words. First I tried with bash. The algorithm along with bash was miserable with only generating around 20-30 words per seconds.

So today I wrote a similar program in C that generates word with random characters. This program can easily generate more than 1500 words per second on my slow laptop. Here is the program.
#include <stdio.h>
int main()
    int i,j,n;
    char c;
        for (i=8;i<=15;i++) {
            char s[16]="";
            for(j=1;j<=i;j++) {
                n = rand() % 26;
                c = (char)(n+97);
    return 0;
This program will produce infinite number of words with random letters. The generated words will be in 8,9,10,...15 characters in length. The words will consist of only small case letters. If you want to have other letters in your word, you can modify the following lines.
  n = rand() % 26;
   c = (char)(n+97);
The main logic behind this is to generate random number in the range 97 to 122 which are ASCII code for small case English alphabets.

To run this first copy the above code in a text file and save it as randomWordGenerator.c. Now run gcc compiler by:
gcc randomWordGenerator.c -o randomWordGenerator
Now you can run the program by first setting the permission bit and calling it.
chmod +x randomWordGenerator

1 comment: