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; }

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; }

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; }