Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <dirent.h>
- #include <string>
- #include <string.h>
- std::vector<std::string> split(std::string str, char delim) {
- std::vector<std::string> st;
- std::string temp = "";
- for (int pos = 0; pos < str.size(); pos++) {
- if (str[pos] != delim)
- temp += str[pos];
- else {
- st.push_back(temp);
- temp = "";
- }
- }
- if (temp.size()!=0)
- st.push_back(temp);
- temp = "";
- return st;
- }
- bool contains(std::string s1, std::string s2){
- return strstr(s1.c_str(),s2.c_str());
- }
- std::vector<std::string> getfiles(std::string ext) {
- std::vector<std::string> output;
- std::string path = ".";
- DIR *dir;
- struct dirent *ent;
- dir = opendir(".");
- while ((ent = readdir(dir)) != NULL) {
- std::string name = ent->d_name;
- if (strstr(name.c_str(),ext.c_str()))
- output.push_back(name);
- }
- closedir(dir);
- return output;
- }
- int main(int argc, char** argv) {
- int counter = 0;
- std::vector<std::string> files = getfiles(".txt");
- std::string line;
- std::ofstream fs2("test.sql", std::ios_base::app);
- std::vector<std::string> theme;
- std::string login;
- std::string password;
- for (int s = 0; s<files.size();s++) {
- std::ifstream fs(files[s].c_str());
- while (getline(fs,line)) {
- theme = split(line, ':');
- if (theme.size()==1)
- continue;
- login = theme[0];
- password = theme[1];
- if (contains(login, "'") || contains(password, "'"))
- continue;
- fs2 << "INSERT INTO `users` (`login`,`password`,`ip`) VALUES ('" << login << "', '" << password << "', '');\n";
- std::cout << "Written: " << counter << "\r";
- counter++;
- }
- fs.close();
- }
- fs2.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement