Skip to content

Commit

Permalink
Only run the bruteforce code on unknown entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockoS committed Oct 18, 2023
1 parent c016530 commit 6c82dc2
Showing 1 changed file with 88 additions and 2 deletions.
90 changes: 88 additions & 2 deletions examples/youkai_douchuuki/password.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,101 @@ wchar_t alphabet_ch[42] = {
L'G',L'N',L'U',L'.',L'む',L'こ'
};

// taken from https://tcrf.net/Youkai_Douchuki_(TurboGrafx-16)
const wchar_t *known_passwords[] = {
L"PC-ENGINE",
L"NAMCO",
L"NAMCOT",
L"6502",
L"6809",
L"68000",
L"756-2311",
L"YAMASHITA",
L"AKIRA",
L"KOMAI",
L"KAZUHIKO",
L"KAWADA",
L"HAL",
L"NAUSICAA",
L"LAPUTA",
L"MICHIYO",
L"MONITOR",
L"YAGI",
L"YUKIHIKO",
L"NAGAMATSU",
L"UDADAGAWA",
L"818-6104",
L"HENTAIOSUGI",
L"なむこむな!756-2311",
L"KUMI.HANAOKA",
L"HARUHISA.UDAGAWA",
L"NEC",
L"KID",
L"MIZUNO"
};

const size_t known_passwords_count = sizeof(known_passwords) / sizeof(known_passwords[0]);

void wchar_to_code(const wchar_t *in) {
*password_len = 0;
for(size_t i = 0; in[i] != L'\0'; ++i, *password_len+=1) {
size_t j;
for(j = 0; (j < 42) && (alphabet_ch[j] != in[i]) ; ++j) {
}
if(j < 42) {
password_str[i] = alphabet_code[j];
} else {
// should never happen but who knows?
fwprintf(stderr, L"Unknown character %lc in %ls\n", in[i], in);
}
}
}

int main() {
uint8_t str[256];
uint8_t code[8];
sp = 0xFF;

password_extract();

printf("password count %zu\n", password_count);

// remove known passwords
for(size_t j=0; j<known_passwords_count; j++) {
wchar_to_code(known_passwords[j]);
bool found = false;
size_t i;
for(i=0; i<password_count; i++) {
if(password_infos[i].len == *password_len) {
password_encode();
if(memcmp(password_encoded, blob+password_infos[i].offset, 8) == 0) {
found = true;
break;
}
}
}
if(found) {
wprintf(L"%lld \"%ls\" ", password_infos[i].offset, known_passwords[j]);
for(size_t k=0; k<8; k++) {
printf("%02x ", password_encoded[k]);
}
fputc('\n', stdout);

if(i < password_count) {
--password_count;
memmove(&password_infos[i], &password_infos[password_count], sizeof(password_info_t));
}
} else {
wprintf(L"%ls not found\n", known_passwords[j]);
}
}

printf("remaining entries:\n");
for(size_t i=0; i<password_count; i++) {
printf("%lld %d\n", password_infos[i].offset, password_infos[i].len);
}

for(size_t i=0; i<password_count; i++) {
// if(password_infos[i].len > 6) continue;
*password_len = password_infos[i].len;

memset(code, 0, 8);
Expand Down Expand Up @@ -484,4 +570,4 @@ void password_extract() {
}
}
}
}
}

0 comments on commit 6c82dc2

Please sign in to comment.