Saturday, November 19, 2016
I'll get back to this in a bit
If you read my blogs on a regular basis you probably noticed I've been out for a while. There isn't internet service where I've been spending a lot of my time.
Sunday, October 30, 2016
CSV maker C++
I hastily put this program together to add contacts to a gmail account from a text file. I have school papers and books and I want to scrape those for email addresses and save them to a text file. After that I'll port the text file to a correctly formatted CSV file so I can import the email address list into my contacts then add people on facebook. First I'll use grep to get the email addresses from all of the documents.
Next I'll make sure there no .gov or .mil addresses. I'm only adding people with college email addresses or commercial email address. You can apply further expressions to the earlier grep statement and just get emails from certain domains if you want.
If the count is more than 5,000 lines I'll have to split the emails list up into smallers files.
Now I'll run this hastily coded C++ program
Now you can import your CSV into gmail and add your the email addresses to your contact list. Then you can invite friends on facebook from your gmail account. Even if you don't actually know the people facebook will invite them because you have their email addresses. You can also do this with Yahoo! and other email services but the CSV file formats may be a little different. It's mostly a matter of getting the header information correct and having the correct number of commas.
grep -hrio "\b[a-z0-9.-]\+@[a-z0-9.-]\+\.[a-z]\{2,4\}\+\b" /root/Desktop/docs/ > emails.txtNext I'll sort them for uniqueness.
sort -i emails.txt | uniq -u > emails1.txt
Next I'll make sure there no .gov or .mil addresses. I'm only adding people with college email addresses or commercial email address. You can apply further expressions to the earlier grep statement and just get emails from certain domains if you want.
sed -i '/.gov/d' emails1.txtNow I'll count the lines in my text file and see if I'm over 5,000 contacts. gmail will not let you import more than 5,0000 at a time. There's a few ways to get a line count.
sed -i '/.mil/d' emails1.txt
sed -n '$=' emails1.txtOr
cat emails1.txt | wc -l
If the count is more than 5,000 lines I'll have to split the emails list up into smallers files.
split --suffix-length=8 --lines=2500 emails1.txt
Now I'll run this hastily coded C++ program
//application to sort email addresses and put them into a CSV for use with gmail.
#include <string>
#include <sstream>
#include <iostream>
#include <cctype>
#include <fstream>
#include <iomanip>
using namespace std;
int main (int argc, char* argv[])
{
//build command line statement from string variables
{ofstream myfile;
myfile.open ("/root/Desktop/emails.csv");
{ string line; ifstream infile ("/root/file.txt");
//input the layout information for CSV file
myfile << "Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value,E-mail 2 - Type,E-mail 2 - Value" << endl;
if (infile.is_open())
{ while ( getline (infile,line) )
//output conacts to contact list. Comas delimit contact information fields.
myfile << ",,,,,,,,,,,,,,,,,,,,,,,,,,,* ," << line << ",," << endl;
infile.close();
myfile.close();
} else cout << "Unable to open file" << endl;
}
}
return 0; }
Now you can import your CSV into gmail and add your the email addresses to your contact list. Then you can invite friends on facebook from your gmail account. Even if you don't actually know the people facebook will invite them because you have their email addresses. You can also do this with Yahoo! and other email services but the CSV file formats may be a little different. It's mostly a matter of getting the header information correct and having the correct number of commas.
Tuesday, October 11, 2016
Monday, August 22, 2016
Really simple remote administration tool for linux (To simple to be useful)
I hammered out the basics of this tool. Basically it will do a conditional get request every second then if the remote file is newer than the file on the system it will download the remote file and read the file and imput the line of text into a system call to execute the command. Afterword it will delete the text file.
#include <string>
#include <sstream>
#include <iostream>
#include <cctype>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
//time interval for checking file
const int NUM_SECONDS = 1;
int main()
{
int count = 1;
double time_counter = 0;
clock_t this_time = clock();
clock_t last_time = this_time;
while(true)
{
this_time = clock();
time_counter += (double)(this_time - last_time);
last_time = this_time;
if(time_counter > (double)(NUM_SECONDS * CLOCKS_PER_SEC))
{
time_counter -= (double)(NUM_SECONDS * CLOCKS_PER_SEC);
time_counter -= (double)(NUM_SECONDS * CLOCKS_PER_SEC);
//We'll need to make this a conditional get and check if the file already exists. Error handling as well.
//download file
system("wget http://192.168.1.7/commands.txt");
//open a stream reader and read from the file
{ string line; ifstream infile ("commands.txt");
//check if file is open
if (infile.is_open())
//if file is open we'll get lines each line of text from the file as a string
{ while (getline (infile,line)){
//convert string to std::string whatever fuck strings in c++
std::string str = static_cast<std::ostringstream&>(std::ostringstream().seekp(0) << line).str();
//convert string to something system(); can use
const char * c = str.c_str();
//make system call
system(c);
//remove text file we'll need to change this later
system("rm commands.txt");
}
}
}
count++;
}
}
return 0;
}
Monday, August 8, 2016
wordlist to plain text / hash pairs output as xml C++
I'll get to the point here. I forgot the additional white spaces that make the xml document valid. A couple of " " to make things right.
#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; }
#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; }
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.
#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; }
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; }
Friday, August 5, 2016
create a web page from wordlist or other text document
Create a webpage with plain text / hash pairs. Yes I'm considering a project that will enable people to search a hash on Google or major search engines and return a plaintext value for known unsalted hashing algorithms for known or weak passwords.
//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]);
myfile << "<html>" << endl;
myfile << "<head>"<< endl;
//output meta tags for SEO purposes
myfile << "<meta name=" << "\"" << "description" << "\"" << " " << "content=" << "\"" << md5(line) << "," << "plaintext," << "plain text," << "md5," << "md5 hash" << "\"" << ">" <<endl;
myfile << "<meta name=" << "\"" << "keywords" << "\"" << " " << "content=" << "\"" << md5(line) << "," << "plaintext," << "plain text," << "md5," << "md5 hash" << "\"" << ">" <<endl;
myfile << "<meta name=" << "\"" << "author" << "\"" << " " << "content=" << "\"" << "Vailixi" << "\"" << ">" << endl;
//output link to stylesheet for formatting hypertext in cool way
myfile << "<link rel=" << "\"" << "stylesheet type=" << "\"" << "text/css" << "\"" << " " << "href=" << "\"" << "theme.css" << "\"" << ">" << endl;
myfile << "</head>"<< endl;
myfile << "<body>" << endl;
//include header put your file logo and nav bar in the header file
myfile << "<?php include " << "\'" << "header.php" << "\'" << ";" << " ?>" << endl;
myfile << "<p>" << endl;
myfile << "<table>" << endl;
myfile << "<tr><td><b>md5</b></td><td><b>plaintext</b></td>" << endl;
{ string line; ifstream infile (argv[1]);
if (infile.is_open())
{ while ( getline (infile,line) )
//output plaintext hash pairs
myfile << "<tr><td>" << "<p>" << md5(line) << "</p>" << "</td><td>" << "<p>" << line << "</p>" << "</td></tr>" << endl;
infile.close();
myfile << "</table>" << endl;
myfile << "</p>" << endl;
//include footer file you can use this for a nav bar or showing ads if you want
myfile << "<?php include " << "\'" << "footer.php" << "\'" << ";" << " ?>" << endl;
myfile << "</body>" << "</html>" << endl;
myfile.close();
} else cout << "Unable to open file" << endl;
}
}
}
return 0; }
Subscribe to:
Posts (Atom)