Go4Expert (http://www.go4expert.com/)
-   Ethical hacking (http://www.go4expert.com/forums/ethical-hacking-forum/)
-   -   How to create a Wordlist From a Wordlist? (http://www.go4expert.com/forums/create-wordlist-wordlist-t14609/)

damlays 18Oct2008 15:16

How to create a Wordlist From a Wordlist?
I read the forum but I couldn't find the answer of my question about what I am looking for. Let me tell what I am looking for:

I have a wordlist. Let's say "names" and it goes like (john, tom, william..)
and I want to create an other new list by using this list, like;


This is the most simple manuplation that I want to make to the first list but according to the possible needs which will appear in future, I would like to make some other manuplations and create new lists like;



(Putting something inside words)


(Combining words within other words in an other wordlist)
Let's say I have a second wordlist like (TABLE, DESK, ...)

and new (third) wordlist should be like;


So I hope I can make it understandable what I am looking for. I don't know if classic programs can do it like John the Ripper, etc.. But I didn't see any example in anywhere that show they can do it. Examples that I saw were always about creating some wordlists for brute forse attack.

SO, my main question is : Is there a way (software) which allows me to generate wordlists by making this kind of intelligent choices?

oogabooga 19Oct2008 03:27

Re: How to create a Wordlist From a Wordlist?
You could use Perl. It takes very little code to do the things you want.

Basic skeleton:

  open FILEIN, "names";
  open FILEOUT, ">names2";
  while ($name = <FILEIN>) { # Read a line from FILEIN into $name
      chomp($name); # Remove the newline
  close FILEOUT;
  close FILEIN;

Where ... would be:

# To append numbers:
    for ($n = 1; $n < 10000; ++$n) {
        print FILEOUT "$name$n\n";

# To combine with words from another file:
    open FILEIN2, "words";
    while ($word = <FILEIN2>) {
        print FILEOUT "$name$word\n";
    close FILEIN2;

# To upcase individual letters (not just the first):
    for ($i = 0; $i < length($name); ++$i) {
        $name2 = $name;
        $name2 =~ s/^(.{$i})(.)(.*)$/$1.uc($2).$3/e;
        print FILEOUT "$name2\n";
# With a little more trouble you could upcase all combinations.

damlays 20Oct2008 12:36

Re: How to create a Wordlist From a Wordlist?
I wish I could. I know it is very simple for a programmer but I don't know how to make it.

xpi0t0s 20Oct2008 15:41

Re: How to create a Wordlist From a Wordlist?
This is a programming forum so you're bound to get programming-type answers.
I think it's unlikely someone will have written software just to do this. If they have then it'll be part of a suite of functions, so one way or another you're going to have to specify exactly what you want the computer to do.

And that my friend is a program.

So the only question left is what language you want to learn. BASIC is a good one for beginners; many people started with that (myself included, ZX81 BASIC), it's often used by non-programmers who think they can program. There are loads of variants of BASIC, free and paid.
Or you can use something like Perl as oogabooga suggested, or you could learn C which will do what you want very easily and very quickly, and being industry standard C will be a very marketable skill, even if you don't have much of it.
Unix command line utilities (see GnuWin32 if you're on Windows) can also do this kind of stuff; have a look at swk and sed. The languages are a bit on the cryptic side but I think both of these would be capable.

Here's a quick C program to do two parts of what you want:

        FILE *fp;
        int i;
        if (fp)
                char buf[64];
                        // read a name in from the file
                        if (feof(fp))

                        // clean up any terminating whitespace
                        for (i=0; buf[i]; i++) ;
                        for (i--; isspace(buf[i]); buf[i--]=0) ;

                        // loop, printing the name and a number
                        for (i=0; i<3; i++)
                        // print the name and an embedded string


damlays 20Oct2008 21:57

Re: How to create a Wordlist From a Wordlist?
The logic of programming is not very hard to understand but the main answer I need to have is how can I make a code executable in the computer.

I had some search for perl and and I will try the perl scrip according to my findings in linux . I will try by writing the code in "vi" editor as text in a *.pl file and making the file executable. with chmod +x command, I hope it works. If it works, I can make some changes by playing on the code.

Is there any easy way like this to run C program in linux (or windows if it is easy) or do I have to download and run some other software?

xpi0t0s 21Oct2008 15:43

Re: How to create a Wordlist From a Wordlist?
How to make code executable depends on what language you're using. There are two main types of executable code: that which is executed directly by the CPU, and that which is interpreted by another program. C falls into the first, Perl into the second, and Java is a hybrid (the code is compiled into Java byte codes, but those byte codes are interpreted by the JVM). BASIC also falls into the second, although there are compileable BASICs out there, just to muddy the waters.

To run a C program on a computer (Linux, Windows or any other OS) you will need a C compiler. This will usually come with the other tools you need, which are a preprocessor, linker and there could be others depending on the installation. Compilers also often come with the SDK - software development kit, which contains header files and libraries suitable to the environment you're working in.

So to avoid typing in a huge if/else tree, what language do you want to use, and what OS do you prefer?

A quick google finds http://www.thefreecountry.com/compilers/basic.shtml
Since you repeat "easy" over and over, I would strongly recommend using some kind of BASIC. With BASIC you can just type the program into the IDE (integrated development environment) and run it straight away, without all that messing around with compiling and the rest of it. The appropriate language depends on what you want to do with it; if you want to look into becoming a professional programmer at some point in the future then you absolutely must know C. OTOH, if it's just hobby messing around, BASIC will probably cover 99% of your needs.

damlays 22Oct2008 13:33

Re: How to create a Wordlist From a Wordlist?
I worked on pyton and with some help of wise guys (thanks for them) I can have script that works perfect for the function which I was looking for. I would like to share my script:


import sys

def transformer(word):
    result = []
    for i in xrange(0,100):
        result.append(word + str(i))
    return result

def main():
    if len(sys.argv) != 3:
        print 'Usage: python ' + sys.argv[0] + ' input.txt output.txt'
        i = open(sys.argv[1],'r')
        print 'Error: file not found (' + sys.argv[1] + ')'
    o = open(sys.argv[2],'w')
    for line in i.xreadlines():

if __name__ == '__main__':

now I am thinking about an other code which will solve all problems about generating wordlist from a wordlist:

If we have two different text files like one.txt and two.txt,
one.txt contains;
in it. And two.txt has

The command we need is a function which combines these two files and creates a third text file like;

Which kind of changes do I need to make in my code to do so. Is it hard to do?

damlays 24Oct2008 12:20

Re: How to create a Wordlist From a Wordlist?
Okay, here is the code in C that makes what I want (written in the last message of mine). It combines two wordlist files and makes a third one with writing the combination of each line together.

But in this stage I need the help of some master programmers. This code is unfunctional in files more that 2GB. Can expert programmers show how we should make the necessary changes in the script to make the program work with very huge files? (more than 2GB)


#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
  if (argc < 4)
    printf("Usage: %s input1.txt input2.txt output.txt\n", argv[0]);
    return 1;
  FILE *input_1 = fopen(argv[1], "r");
  if (input_1 == NULL)
    printf("Error opening input file (%s)\n", argv[1]);
    return 1;
  FILE *input_2 = fopen(argv[2], "r");
  if (input_2 == NULL)
    printf("Error opening input file (%s)\n", argv[2]);
    return 1;
  FILE *output = fopen(argv[3], "w");
  if (output == NULL)
    printf("Error opening output file (%s)\n", argv[3]);
    return 1;
  char buffer_1[256];
  char buffer_2[256];

  while (1)
    if (fgets(buffer_1, 256, input_1) != NULL)
      buffer_1[strlen(buffer_1)-1] = '\0';
      while (1)
        if (fgets(buffer_2, 256, input_2) != NULL)
          fprintf(output, "%s%s", buffer_1, buffer_2);

  return 0;
}It's C code, and it's about as efficient as it gets, holding only the current line in memory, reusing the file descriptor of the second input file by rewinding the read position.

Here's how to run it:

All times are GMT +5.5. The time now is 22:51.