
Originally Posted by
thorin
Hmm when you searched on "wordlist" and memorized everything I would have thought that you'd find "Giga Wordlist Creator: .
Yes I've realized that I missed that page
It is not directly related with the subject but forum's search engine is not working very effective or I don't know to use it in effective way. In many times I am giving the exact words with the exact order in the page written, but froum's search results doesn't give that page even in the first results page. I often need to use google to find that page instead of forum's search engine.
................
Anyway I see that there is no way I can find to do what I need. So with the help of some programmer guys we created some scripts which gives the needed outputs. I want to share here.
This is a simple but effective code in python which adds the numbers at the end of each line in a wordlist:
Code:
import sys
def main():
if len(sys.argv) != 3:
print 'Usage: python ' + sys.argv[0] + ' input.txt output.txt'
sys.exit(1)
try:
i = open(sys.argv[1],'r')
except:
print 'Error: file not found (' + sys.argv[1] + ')'
sys.exit(1)
o = open(sys.argv[2],'w')
for line in i.xreadlines():
for i in xrange(0,100):
o.write(line.strip() + str(i) + "\n")
o.close()
if __name__ == '__main__':
main()
This solution is okay for numbers but it doesn't cover other manipulations beside numbers. So these two different codes (one of them is in C and other is in Perl) are combining each lines of TWO different wordlists (for example wordlist1.txt and wordlist2.txt) and gives new wordlist (for example wordlistCombined.txt) as an output file:
C Script
Code:
#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';
rewind(input_2);
while (1)
{
if (fgets(buffer_2, 256, input_2) != NULL)
{
fprintf(output, "%s%s", buffer_1, buffer_2);
}
else
{
break;
}
}
}
else
{
break;
}
}
fclose(input_1);
fclose(input_2);
fclose(output);
return 0;
}
Perl Script
Code:
#!/usr/bin/perl
use strict;
# Check we have enough command line arguments
# for more complex options use the Getopt::Std or Getopt::Long modules
if($#ARGV<1)
{
die "Usage: combine <prefixFile> <postfixFile>\n";
}
# build the two hashes one from each file
# we use hashes as it is an easy way to make sure that we don't have exact duplicates in the lists.
my %prefix=getLines($ARGV[0]);
my %postfix=getLines($ARGV[1]);
# for each of our prefix lines loop through the postfix lines and output the concatenated result
# to STDOUT.
foreach my $pre (keys(%prefix))
{
foreach my $post (keys(%postfix))
{
print "$pre$post\n";
}
}
# Sub to get all the lines (without carriage returns, line breaks or spaces at the end)
sub getLines
{
# Get the filename from the parameters
my ($file)=@_;
my %lines;
# open the file and fail with an error message if it doesn't open
open FILE, "<$file" or die "Unable to open $file\n";
# loop through each line in the file
while(my $line=<FILE>)
{
# strip out the carriage returns, new lines and spaces at the end of the line
$line=~s/[\r\n\s]*$//;
# create a hash entry with the line as the key (simple way to remove duplicates)
$lines{$line}=1;
}
# close the file as we have finished with it.
close FILE;
# pass the lines hash back to the caller of the function.
return %lines;
}
They are working bug free. But the main problem is some problems can be occur in operating very huge files.
.