View Single Post
  #1  
Old 07-19-2015, 05:00
dila dila is offline
Friend
 
Join Date: Jan 2010
Posts: 60
Rept. Given: 12
Rept. Rcvd 32 Times in 14 Posts
Thanks Given: 35
Thanks Rcvd at 74 Times in 20 Posts
dila Reputation: 32
Post Keygenme (Easy?)

Hi, I made a keygenme for you all to try. I am very interested to see how you solve it. Perhaps it is very easy for you!

Code:
/*
  ::::::::::::::::::::::
  :: Keygenme by dila ::
  ::    July 2015     ::
  ::::::::::::::::::::::
*/

#include <iostream>
#include <stdint.h>

uint64_t rol(const uint64_t value, const int places) {
  return (value<<places)|(value>>(64-places)); 
}

uint64_t ror(const uint64_t value, const int places) {
  return (value>>places)|(value<<(64-places)); 
}

bool stringToInteger(const std::string& input, uint64_t* r) {
  static const std::string lut = "0123456789abcdef";
  if (input.length() == 16) {
    *r = 0;
    for (size_t i = 0; i < input.length(); ++i) {
      size_t digit = lut.find_first_of(input[i]);
      if (digit == std::string::npos) {
        return false;
      }
      *r |= digit << (60 - i * 4);
    }
    return true;
  }
  return false;
}

uint64_t h0(const std::string& name) {
  uint64_t r = ~0x3141592653589793ULL;
  for (size_t k = 1; k <= 16; ++k) {
    for (size_t i = 0; i < name.length(); ++i) {
      int c = (13 + i * k) % 64;
      r ^= rol(uint64_t(name[i]), c);
    }
  }
  return r;
}

uint64_t h1(const uint64_t x) {
  return x ^ ror(x, 13);
}

bool check(const std::string& name, const std::string& serial) {
  uint64_t s;
  if (stringToInteger(serial, &s)) {
    if (h0(name) == h1(s)) {
      return true;
    }
  }
  return false;
}

int main() {
  std::string name;
  std::cout << "Name: ";
  std::getline(std::cin, name);

  std::string serial;
  std::cout << "Serial: ";
  std::getline(std::cin, serial);

  if (check(name, serial)) {
    std::cout << "Success! Thank you for registering." << std::endl;
  } else {
    std::cout << "Error. Invalid name/serial combination." << std::endl;
  }

  return 0;
}
To make sure that it is solvable, I generated one working serial for you:

Code:
Name: exetools
Serial: f7fb22fb6d474cb3
Reply With Quote
The Following User Gave Reputation+1 to dila For This Useful Post:
mr.exodia (07-19-2015)
The Following 2 Users Say Thank You to dila For This Useful Post:
arnix (07-21-2015), chessgod101 (07-19-2015)