diff --git a/pwg/pcoatl b/pwg/pcoatl deleted file mode 100755 index fcadff7..0000000 Binary files a/pwg/pcoatl and /dev/null differ diff --git a/pwg/pwt b/pwg/pwt deleted file mode 100755 index 23ee063..0000000 Binary files a/pwg/pwt and /dev/null differ diff --git a/pwstor/pcoatl b/pwstor/pcoatl new file mode 100755 index 0000000..ea7170e Binary files /dev/null and b/pwstor/pcoatl differ diff --git a/pcoatl.cpp b/pwstor/pcoatl.cpp similarity index 98% rename from pcoatl.cpp rename to pwstor/pcoatl.cpp index 6f9274f..f2ae1e5 100644 --- a/pcoatl.cpp +++ b/pwstor/pcoatl.cpp @@ -38,10 +38,6 @@ void attemptCombination(const string &charSet, int maxLength, const string &pass return; } - if (debug == true){ - cout << currentString << "\n"; - } - for (char c : charSet) { guesses++; attemptCombination(charSet, maxLength, passwordHash, currentString + c, found, guesses); @@ -88,6 +84,8 @@ int main(int argc, char* argv[]){ argIndex += 2; } + argIndex++; + if (argIndex < argc && string(argv[argIndex]) == "-o") { debug = true; argIndex++; diff --git a/pwg/pw b/pwstor/pw similarity index 100% rename from pwg/pw rename to pwstor/pw diff --git a/pw.cpp b/pwstor/pw.cpp similarity index 100% rename from pw.cpp rename to pwstor/pw.cpp diff --git a/pwg/pwa b/pwstor/pwa similarity index 100% rename from pwg/pwa rename to pwstor/pwa diff --git a/pwa.cpp b/pwstor/pwa.cpp similarity index 100% rename from pwa.cpp rename to pwstor/pwa.cpp diff --git a/pwg/pwh b/pwstor/pwh similarity index 100% rename from pwg/pwh rename to pwstor/pwh diff --git a/pwh.cpp b/pwstor/pwh.cpp similarity index 100% rename from pwh.cpp rename to pwstor/pwh.cpp diff --git a/pwg/pwr b/pwstor/pwr similarity index 100% rename from pwg/pwr rename to pwstor/pwr diff --git a/pwr.cpp b/pwstor/pwr.cpp similarity index 100% rename from pwr.cpp rename to pwstor/pwr.cpp diff --git a/pwg/pws b/pwstor/pws similarity index 100% rename from pwg/pws rename to pwstor/pws diff --git a/pws.cpp b/pwstor/pws.cpp similarity index 100% rename from pws.cpp rename to pwstor/pws.cpp diff --git a/pwstor/pwt b/pwstor/pwt new file mode 100755 index 0000000..3b44e44 Binary files /dev/null and b/pwstor/pwt differ diff --git a/pwstor/pwt.cpp b/pwstor/pwt.cpp new file mode 100644 index 0000000..0ee5f88 --- /dev/null +++ b/pwstor/pwt.cpp @@ -0,0 +1,69 @@ +// Test file +// aid! 0.184227 in 9.95 Million +// 56.9 Million Guesses Per Second +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace chrono; + +atomic found(false); + +void generateCombinations(const string &charSet, int maxLength, const string &password, string currentString, int &guesses) { + if (found) return; + + if (currentString == password) { + found = true; + cout << "Found " << password << " with " << guesses << " guesses" << endl; + return; + } + + for (char c : charSet) { + if (found) return; + + currentString.push_back(c); + ++guesses; + + if (currentString.length() <= maxLength) { + generateCombinations(charSet, maxLength, password, currentString, guesses); + } + + currentString.pop_back(); + } +} + +int main() { + string charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+[]{}|,'.<>?~"; + string password; + int maxLength; + int guesses = 0; + + cout << "Password: "; + cin >> password; + + cout << "Length: "; + cin >> maxLength; + + auto start = high_resolution_clock::now(); + + vector threads; + int numThreads = thread::hardware_concurrency(); + + for (int i = 0; i < numThreads; ++i) { + threads.emplace_back(generateCombinations, cref(charSet), maxLength, cref(password), string(), ref(guesses)); + } + + for (auto &t : threads) { + t.join(); + } + + auto end = high_resolution_clock::now(); + duration elapsed_seconds = end - start; + cout << "Time elapsed: " << elapsed_seconds.count() << "s\n"; + + return 0; +} diff --git a/pwt.cpp b/pwt.cpp deleted file mode 100644 index faad8e0..0000000 --- a/pwt.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Test file -// aid! 0.115973 in 5.7 Million -// 49.4 Million Guesses Per Second -#include -#include -#include -#include - -using namespace std; -using namespace chrono; - -// Function to generate combinations using recursive backtracking -void generateCombinations(const string& charSet, int maxLength, const string& password, string currentString, int& guesses) { - static auto start = steady_clock::now(); - - if (currentString == password) { - auto end = steady_clock::now(); - double elapsed_seconds = duration(end - start).count(); - cout << "Found " << password << " with " << guesses << " guesses" << " in " << elapsed_seconds << " seconds" << endl; - exit(0); - } - - for (char c : charSet) { - currentString.push_back(c); - ++guesses; - - if (currentString.length() <= maxLength) { - generateCombinations(charSet, maxLength, password, currentString, guesses); - } - - currentString.pop_back(); - } -} - -int main() { - string charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+[]{}|,'.<>?~"; - - string password; - int maxLength; - - cout << "Password: "; - cin >> password; - - cout << "Length: "; - cin >> maxLength; - - string currentString; - int guesses = 0; - - generateCombinations(charSet, maxLength, password, currentString, guesses); - - return 0; -} diff --git a/sha b/sha new file mode 100755 index 0000000..1360608 Binary files /dev/null and b/sha differ diff --git a/sha.cpp b/sha.cpp new file mode 100644 index 0000000..107f183 --- /dev/null +++ b/sha.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +std::string sha256(const std::string &str) { + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, str.c_str(), str.size()); + SHA256_Final(hash, &sha256); + + std::stringstream ss; + for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { + ss << std::hex << std::setw(2) << std::setfill('0') << static_cast(hash[i]); + } + return ss.str(); +} + +int main(int argc, char* argv[]) { + if (argc < 2) { + std::cerr << "Usage: " << argv[0] << " \n"; + return 1; + } + + std::string input = argv[1]; + std::string hashed = sha256(input); + std::cout << "SHA256 hash of '" << input << "': " << hashed << std::endl; + + return 0; +}