SRE/02-Easy2/code.c

40 lines
1.2 KiB
C
Raw Permalink Normal View History

2025-02-27 19:27:10 +01:00
#include <stdio.h>
#include <stdint.h>
#include <string.h>
int main(int param_1,char* *param_2) {
char* input_string;
size_t input_length;
char* pcVar2;
char* pcVar3;
uint32_t uVar4;
if (param_1 == 2) {
input_string = (char *)param_2[1];
input_length = strlen(input_string);
if (input_length == 12) {
uVar4 = 0x56253667;
pcVar2 = input_string;
do {
pcVar3 = pcVar2 + 4;
uVar4 = uVar4 ^ ((uint8_t)pcVar2[0] << 24 | (uint8_t)pcVar2[1] << 16 | (uint8_t)pcVar2[2] << 8 | (uint8_t)pcVar2[3]);
pcVar2 = pcVar3;
} while (input_string + 12 != pcVar3);
if (uVar4 == 0x3c3e386b) {
fprintf(stderr,"\nCongratulations ! A right password is indeed %s :-)\n\n",input_string);
return 0;
}
fwrite("\nWrong password ! Try again...\n\n", 1, 0x20,stderr);
} else {
fwrite("\nWrong password length ! Try again...\n\n", 1, 0x20,stderr);
}
}
else {
fwrite("\nMSE-SRE Challenge E2 --- Enjoy !\n", 1, 0x22,stderr);
fwrite("\nWhat I need is 1024 passwords passing the check!\n",1,0x32,stderr);
fprintf(stderr, "\nUsage: %s <password>\n\n", *param_2);
}
return 1;
}