I am using crunch to generate wordlists, but I want to mix the contains of two of my wordlist files, can I do that using some kind of program? You know that no one want to do that manually......:o
Printable View
I am using crunch to generate wordlists, but I want to mix the contains of two of my wordlist files, can I do that using some kind of program? You know that no one want to do that manually......:o
Try a combination of "cat" and "sort -u" (others will tell you "sort | uniq").
If you seriously can't work it out from there come back to us.
Thank you Gitsnik, But the combination I mean is for example, there are dict A and dict B. Dict A got "a b c" in it, and dict B got "1 2 3" in it. after mix I got a dict C, which is contain "a1 a2 a3 b1 b2 b3 c1 c2 c3 1a 2a 3a...................." can "cat" and "sort -u" achieve this? :confused:
Strictly no, but then you're not necessarily doing something many people would elect to do.
The following code I literally just hacked up in this reply panel, I haven't tested it nor will I provide support on it. It contains only very basic perl code, so if you can not read it I suggest you do one of those "learn perl in 24 hours" courses and then figure it out from there.
The essence of the code is: read a line from file 1, read a line from file 2, as you read each character from file 1, insert the same character (position) from file 2 and print it out.
Assuming no typo's and that I understood you properly this time around, it should do what you wish, again - no willingness to provide support.
Code:#!/usr/bin/perl
open(FILE_ONE, "fileone.txt");
open(FILE_TWO, "filetwo.txt");
while($f1l = <FILE_ONE>) {
$f2l = <FILE_TWO>;
chomp($f1l);
chomp($f2l);
my @f1a = split //, $f1l;
my @f2a = split //, $f2l;
my $i = 0;
foreach my $char (@f1a) {
print $char, $f2a[$i];
$i += 1;
}
print "\n";
}
close(FILE_ONE);
close(FILE_TWO);
This looks like fun, I'm gonna give it a go in C++:
Compile as follows:Code:#include <iostream> /* cout, endl */
#include <fstream> /* ifstream */
#include <string> /* string */
using std::cout;
using std::endl;
using std::ifstream;
using std::string;
int main(int argc, char **argv)
{
if ( 3 != argc )
{
cout << "Usage: " << argv[0] << " in1.txt in2.txt > out.txt" << endl;
return 0;
}
ifstream a( argv[1] ); /* Open the first file */
if ( !a.is_open() )
{
cout << "Could not open " << argv[1] << endl;
return 0;
}
string str_a;
while ( a >> str_a )
{
string str_b;
ifstream b( argv[2] );
if ( !b.is_open() )
{
cout << "Could not open " << argv[2] << endl;
return 0;
}
while ( b >> str_b )
{
cout << str_a << str_b << endl;
}
}
}
And run as follows:Code:g++ concat.cpp -D NDEBUG -s -O3 -o concat
Code:./concat in1.txt in2.txt > out.txt
Virchanza I think your method produces a different output to mine (It has been a while since I read << notation in C++ though so I could be wrong).
Mine should produce:
f1: abc
f2: 123
out: a1b2c3
But yours produces:
abc123 from the same input (at least on my FreeBSD test box).
A good chance for you to have a play with arrays. You might even notice that if you have only two characters in the second line, but 3 in the first you may run into some buffering issues when you do it.
Edit: Oh yes, and I intentionally didn't blow out the lines properly to be a1 b1 c1 a2 b2 c2, but the basic premise is there - you just need to add an extra loop somewhere and shift the choice of i.
Your FreeBSD box is right (the code I posted is fully-portable so it will work on any machine).
I'm pretty sure that the OP meant the following...
in1.txt as follows:
in2.txt as follows:Code:a
b
c
So if you append every word of the second file to every word of the first file, you get:Code:1
2
3
That's what my little program does.Code:a1
a2
a3
b1
b2
b3
c1
c2
c3