Crypto/Reverse Challenge

THISPASSWORDISVERYSTRONG

forget about my method,

I decompile it and get the source in c (decompilation might not too similar with the original one)

#include <stdio.h>
#include <string.h>

char* encrypt_input(char *str, char shift) {
    char *ptr;
    for (ptr = str; *ptr != '\0'; ptr++) {
        char c = (*ptr - 'A') + shift;
        
        if (c < 0) {
            c = c + 26;
        } else {
            c = c % 26;
        }
        
        *ptr = c + 'A';
    }
    return str;
}

int manual_strncmp(char *input, char *target, int len) {
    while (len > 0) {
        if (*input != *target) {
            break;
        }
        input++;
        target++;
        len--;
    }
    return len; 
}

int main() {
    char input_buffer[1024];
    char *target_password = "VJKURCUUYQTFKUXGTAUVTQPI";
    
    puts("0x00sec Reverse/Crypto Challenge");
    puts("by pico");
    
    printf("Passwd: ");
    if (fgets(input_buffer, sizeof(input_buffer), stdin) == NULL) {
        return 1;
    }
    
    size_t length = strlen(input_buffer);
    if (length > 0) {
        input_buffer[length - 1] = '\0';
    }
    
    encrypt_input(input_buffer, 2);
    
    int result = manual_strncmp(input_buffer, target_password, 25);
    
    if (result == 0) {
        puts("Access granted!");
    } else {
        puts("Access denied!");
    }
    
    return 0;
}
2 Likes