Skip to content

Instantly share code, notes, and snippets.

@exp111
Created October 13, 2023 13:30
Show Gist options
  • Save exp111/7db1bd05f9fee30503858620d3893130 to your computer and use it in GitHub Desktop.
Save exp111/7db1bd05f9fee30503858620d3893130 to your computer and use it in GitHub Desktop.
No Way Hose
// cpp.sh
#include <iostream>
#include <string>
#include <stdio.h>
size_t serialHash(const std::string& input)
{
if ( input.empty() || input.size() != 19 )
{
return 0;
}
int i = 0;
size_t hash = 0;
for ( auto it : input )
{
if ( it == '\0' || it == '\n' )
{
break;
}
hash += static_cast<size_t>(it) * (i * i);
++i;
}
return hash;
}
char allowedLetters[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','-'};
int allowedLettersCount = 63;
void generateNextSerialKey(char *key, int length) {
int i = length - 1;
while (i >= 0) {
int index = 0;
for (; index < allowedLettersCount;index++) // find index in allowedLetters array
{
if (key[i] == allowedLetters[index])
break;
}
if (key[i] != allowedLetters[allowedLettersCount-1]) { // Check if the character is not the last one
key[i] = allowedLetters[index + 1];
return;
} else {
key[i] = allowedLetters[0]; // Reset to the first allowed character
i--;
}
}
}
int main()
{
int hash1 = 144425;
bool hash1Found = false;
int hash2 = 135398;
bool hash2Found = false;
int keyLength = 19;
char serialKey[keyLength + 1]; // +1 for the null-terminator
// Initialize the key to the first possible key
memset(serialKey, (int)allowedLetters[0], keyLength);
serialKey[keyLength] = '\0';
while (1) {
//printf("Generated Serial Key: %s\n", serialKey);
// Generate the next key
generateNextSerialKey(serialKey, keyLength);
auto key = std::string(serialKey);
auto hash = serialHash(key);
if (!hash1Found && hash == hash1)
{
std::cout << "Found key " << key << " for myth hash " << std::to_string(hash) <<std::endl;
hash1Found = true;
}
if (!hash2Found && hash == hash2)
{
std::cout << "Found key " << key << " for legends hash " << std::to_string(hash) <<std::endl;
hash2Found = true;
}
if (hash1Found && hash2Found)
{
break;
}
// Break the loop after generating all possible keys
if (serialKey[0] == 127) { // The last possible character (ASCII 127)
std::cout << "End" << std::endl;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment