1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// mysqlDBinjector.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <my_global.h>
#include <mysql.h>
#include <string>
using namespace std;
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;
int _tmain(int argc, _TCHAR* argv[])
{
char finish;
string DBname;
string USERname;
string password;
cout << "hi";
cin >> DBname;
mysql_init(&mysql);
connection = mysql_real_connect(&mysql,"localhost","root","alphamaletax1234567890!@#$%DASDczxfr","test",0,0,0);
if(connection == NULL){
cout << mysql_error(&mysql) << endl;
return 1;
}
else {
string DOIT = "CREATE DATABASE " + DBname + "; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON " + DBname + ".* TO '" + USERname + "'@'localhost' IDENTIFIED BY '" + password + "';";
query_state = mysql_query(connection, DOIT.c_str());
if (query_state != 0) {
cout << mysql_error(connection) << endl;
return 1;
}
else {
result = mysql_store_result(connection);
while ((row = mysql_fetch_row(result)) != NULL ) {
cout << row[0] << endl;
}
}
cout << "Done? Y/N" << endl;
cin >> finish;
if (finish == 'Y'){
mysql_free_result(result);
mysql_close(connection);
}
}
cout << "test";
system("pause");
return 0;
}
|