1. 程式人生 > >類似九宮格演算法的CrackMe

類似九宮格演算法的CrackMe

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char RegKey[200];        // 320816081632163208
    int tip[21] = {80, 108, 101, 97, 115, 101, 0, 105, 110, 112, 117, 116, 0,
        82, 101, 103, 75, 101, 121, 58, 0};
    // Please input RegKey: 
    int ok[32] = {86, 101, 114, 121
, 0, 103, 111, 111, 100, 33, 0, 89, 111, 117, 114, 0, 82, 101, 103, 75, 101, 121, 0, 105, 115, 0, 82, 105, 103, 104, 116, 33}; // Very good! Your RegKey is Right! int no[28] = {83, 111, 114, 114, 121, 33, 0, 89, 111, 117, 114, 0, 82, 101, 103, 75, 101, 121, 0, 105, 115, 0, 87, 114, 111, 110, 103, 33};
// Sorry! Your RegKey is Wrong! int TestLen[25] = {82, 101, 103, 75, 101, 121, 0, 108, 101, 110, 103, 116, 104, 0, 109, 117, 115, 116, 0, 98, 101, 0, 49, 56, 46}; // RegKey length must be 18. for(int i = 0; i < 21; i++) cout << (char)tip[i]; cin >> RegKey; int
key1 = 32, key2, key3, key4, key5 = 16, key6, key7, key8, key9; // 判斷輸入位數是否為 18 若不等於 18 輸出提示 if(strlen(RegKey) != 18) { for(int i = 0; i < 25; i++) cout << (char)TestLen[i]; cout << endl; } else { /* ━━━━━━━━━━━━━━━━ ┃ 32 ┃ xx ┃ xx ┃ ━━━━━━━━━━━━━━━━ ┃ xx ┃ 16 ┃ xx ┃ ━━━━━━━━━━━━━━━━ ┃ xx ┃ xx ┃ xx ┃ ━━━━━━━━━━━━━━━━ */ // 判斷左上角是否為 32 且中心是否為 16 if((RegKey[0] - '0') * 10 + (RegKey[1] - '0') == key1 && (RegKey[8] - '0') * 10 + (RegKey[9] - '0') == key5) { key2 = (RegKey[2] - '0') * 10 + (RegKey[3] - '0'); key3 = (RegKey[4] - '0') * 10 + (RegKey[5] - '0'); key4 = (RegKey[6] - '0') * 10 + (RegKey[7] - '0'); key6 = (RegKey[10] - '0') * 10 + (RegKey[11] - '0'); key7 = (RegKey[12] - '0') * 10 + (RegKey[13] - '0'); key8 = (RegKey[14] - '0') * 10 + (RegKey[15] - '0'); key9 = (RegKey[16] - '0') * 10 + (RegKey[17] - '0'); // 這裡判斷一下右下角是否為 0 因為右下角為 0 則除了已給出的 32 和 16 // 其他部位全部填 0 則可正確註冊 if(key9 != 0) { // 判斷橫排三組數相乘是否相等 if(key1 * key2 * key3 == key4 * key5 * key6 && key4 * key5 * key6 == key7 * key8 * key9) { // 判斷豎排三組數相乘是否相等 if(key1 * key4 * key7 == key2 * key5 * key8 && key2 * key5 * key8 == key3 * key6 * key9) { // 判斷對角兩組數相乘是否相等 if(key1 * key5 * key9 == key3 * key5 * key7) { for(int i = 0; i < 32; i++) cout << (char)ok[i]; cout << endl; } else { for(int i = 0; i < 28; i++) cout << (char)no[i]; cout << endl; } } else { for(int i = 0; i < 28; i++) cout << (char)no[i]; cout << endl; } } else { for(int i = 0; i < 28; i++) cout << (char)no[i]; cout << endl; } } else { for(int i = 0; i < 28; i++) cout << (char)no[i]; cout << endl; } } else { for(int i = 0; i < 28; i++) cout << (char)no[i]; cout << endl; } } return 0; }