Saturday, August 6, 2016

Turn wordlist into a database of plain text hash pairs part 1

I'm still working with the MD5 hashing algorithm here because it's simple to implement. The concept here is to read from the wordlist line by line and create and plaintext and hash as two columns in a database row. I figure the simplest way to do that is to write the output to an xml file then import the xml data to a database with something like this.

Since I suck at MySQL I'm just going to link to the manual page on the MySQL site. Also note the MySQL manual is over 5,000 pages. If you are an expert at MySQL kudos for reading all of that. Import XML data into MySQL database

Here's C++ code. The output is a lot simpler than writing data to a web page as I did in previous examples.


//Simple example that converts a wordlist from plaintext to plaintext and hash pair tab delimited.
#include <string>
#include <sstream>
#include <iostream>
#include <cctype>
#include <fstream>
#include "md5.h"
using namespace std;


int main (int argc, char* argv[3])
{


{ofstream myfile;
myfile.open (argv[2]);

{ string line; ifstream infile (argv[1]);



{ string line; ifstream infile (argv[1]);

if (infile.is_open())


{ while ( getline (infile,line) )
//output plaintext hash pairs to xml


myfile << "<row column1=" << "\"" << line << "\"" << "column2=" << "\"" <<md5(line) << "\"" << "/>" << endl;

//<row column1="value1" column2="value2" .../>

infile.close();

myfile.close();
} else cout << "Unable to open file" << endl;

}
}
}
return 0; }

No comments:

Post a Comment