Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrophobis committed Mar 30, 2024
1 parent eac0759 commit c11a6cc
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 57 deletions.
Binary file removed pwg/pcoatl
Binary file not shown.
Binary file removed pwg/pwt
Binary file not shown.
Binary file added pwstor/pcoatl
Binary file not shown.
6 changes: 2 additions & 4 deletions pcoatl.cpp → pwstor/pcoatl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -88,6 +84,8 @@ int main(int argc, char* argv[]){
argIndex += 2;
}

argIndex++;

if (argIndex < argc && string(argv[argIndex]) == "-o") {
debug = true;
argIndex++;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added pwstor/pwt
Binary file not shown.
69 changes: 69 additions & 0 deletions pwstor/pwt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Test file
// aid! 0.184227 in 9.95 Million
// 56.9 Million Guesses Per Second
#include <iostream>
#include <string>
#include <vector>
#include <chrono>
#include <thread>
#include <atomic>

using namespace std;
using namespace chrono;

atomic<bool> 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<thread> 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<double> elapsed_seconds = end - start;
cout << "Time elapsed: " << elapsed_seconds.count() << "s\n";

return 0;
}
53 changes: 0 additions & 53 deletions pwt.cpp

This file was deleted.

Binary file added sha
Binary file not shown.
32 changes: 32 additions & 0 deletions sha.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include <string>
#include <sstream>
#include <openssl/sha.h>
#include <iomanip>

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<int>(hash[i]);
}
return ss.str();
}

int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <string_to_hash>\n";
return 1;
}

std::string input = argv[1];
std::string hashed = sha256(input);
std::cout << "SHA256 hash of '" << input << "': " << hashed << std::endl;

return 0;
}

0 comments on commit c11a6cc

Please sign in to comment.