You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
the_difference_analysis_of_des/windows.cpp

140 lines
5.5 KiB

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>
#include<string.h>
#include<math.h>
#include"analysis table.h"
#include "des.h"
#include "hack.h"
#include "key table.h"
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<fstream>
using namespace std;
int main() {
int chooseNum;
int q;
printf(" \n\n\n\n\n\n\n \n");
printf(" ################################################################\n");
printf(" ## ##\n");
printf(" ## ##\n");
printf(" ## DES<45><53><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> ##\n");
printf(" ## ##\n");
printf(" ## ##\n");
printf(" ## ##\n");
printf(" ################################################################\n\n");
printf(" <20><EFBFBD>κμ<CEBA><CEBC>Լ<EFBFBD><D4BC><EFBFBD> ,, ");
getchar();
system("cls");
printf("\n\n\n\n\n\n\n <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf(" @ @\n");
printf(" @ ** 1=<3D><><EFBFBD><EFBFBD>1 <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD> ** @\n");
printf(" @ ** 2=<3D><><EFBFBD><EFBFBD>2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD> ** @\n");
printf(" @ ** 3=<3D><><EFBFBD><EFBFBD>3 <20><><EFBFBD>ֲ<EFBFBD><D6B2>ֹ<EFBFBD><D6B9><EFBFBD> ** @\n");
printf(" @ ** 4=<3D><><EFBFBD><EFBFBD>4 <20><><EFBFBD>ֲ<EFBFBD><D6B2>ֹ<EFBFBD><D6B9><EFBFBD> ** @\n");
printf(" @ ** ** @\n");
printf(" @ ** 5= <20>˳<EFBFBD> ** @\n");
printf(" @ @\n");
printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
scanf("%d", &chooseNum);
getchar();
while (chooseNum != 5)
{
switch (chooseNum)
{
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>");
char intput[6];
scanf("%s", intput);
//gets_s(intput);
int intputchafen[6];
for (q = 0; q < 6; q++) {
if (intput[q] == '0')
intputchafen[q] = 0;
else intputchafen[q] = 1; //<2F><>ֹ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD>ֵֹ<D6B9><D6B5><EFBFBD><EFBFBD><EFBFBD>
}
printf("\n");
mainFuntion(intputchafen);
system("PAUSE");
break;
case 2:
char E[6];
char ee[6]; //E*
char hello[4]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("s<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>E:<3A><><36><CEBB>");
scanf("%s",E);
printf("s<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e:<3A><><36><CEBB>");
scanf("%s",ee);
printf("s<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>hello:<3A><><34><CEBB>");
scanf("%s",hello);
mainFuntion4(E, ee, hello);
system("PAUSE");
break;
case 3:
system("3rnd.exe");
break;
case 4:
ull inA = 0, inB = 0, outA = 0, outB = 0;
ull inC = 0, inD = 0, outC = 0, outD = 0;
ull key;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ64λ<EFBFBD><EFBFBD>Կ(ʮ<><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x<30><78>ͷ)<29><>\n");
cin >> hex >> key;
//ull key = 0xF0F0F0F0F0F0F0F0;
/* ull key = 0xF1F2F3F4F5F6F7F8;*/
DesHacker hacker;
for (int i = 0; i < 2; i++) {
constructCipherPlaintexts(key, 1, inA, inB, outA, outB); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>
hacker.addCipherPlaintexts(inA, inB, outA, outB); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĶԴ<C4B6><D4B4><EFBFBD>DesHacker<65><72>
}
for (int i = 0; i < 2; i++) {
constructCipherPlaintexts(key, 2, inC, inD, outC, outD); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>
hacker.addCipherPlaintexts(inC, inD, outC, outD);
}
if (hacker.hack()) { // <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
ull result_key = hacker.getKey();
printf("Success\n");
print_long_hex(result_key);
}
else {
printf("Failed...\n");
}
system("PAUSE");
break;
}
system("cls");
printf("\n\n\n\n\n\n\n <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf(" @ @\n");
printf(" @ ** 1=<3D><><EFBFBD><EFBFBD>1 <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD> ** @\n");
printf(" @ ** 2=<3D><><EFBFBD><EFBFBD>2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD> ** @\n");
printf(" @ ** 3=<3D><><EFBFBD><EFBFBD>3 <20><><EFBFBD>ֲ<EFBFBD><D6B2>ֹ<EFBFBD><D6B9><EFBFBD> ** @\n");
printf(" @ ** 4=<3D><><EFBFBD><EFBFBD>4 <20><><EFBFBD>ֲ<EFBFBD><D6B2>ֹ<EFBFBD><D6B9><EFBFBD> ** @\n");
printf(" @ ** ** @\n");
printf(" @ ** 5= <20>˳<EFBFBD> ** @\n");
printf(" @ @\n");
printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
scanf("%d", &chooseNum);
getchar();
}
return 0;
}