diff --git a/highlyoptimized.c b/highlyoptimized.c new file mode 100644 index 0000000..fa47dcd --- /dev/null +++ b/highlyoptimized.c @@ -0,0 +1,467 @@ +/* This file was generated by the Hex-Rays decompiler version 8.4.0.240320. + Copyright (c) 2007-2021 Hex-Rays + + Detected compiler: GNU C++ +*/ + +#include + + +//------------------------------------------------------------------------- +// Function declarations + +__int64 (**init_proc())(void); +void sub_1020(); +void sub_1030(); +void sub_1040(); +void sub_1050(); +// int __fastcall _cxa_finalize(void *); +// int putchar(int c); +// int puts(const char *s); +void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void)); +char *sub_1250(); +__int64 sub_1280(); +char *sub_12C0(); +__int64 sub_1300(); +void term_proc(); +// int __fastcall _libc_start_main(int (__fastcall *main)(int, char **, char **), int argc, char **ubp_av, void (*init)(void), void (*fini)(void), void (*rtld_fini)(void), void *stack_end); +// int __fastcall __cxa_finalize(void *); +// __int64 _gmon_start__(void); weak + +//------------------------------------------------------------------------- +// Data declarations + +_UNKNOWN main; +void *off_4008 = &off_4008; // idb +_QWORD qword_4020[265] = +{ + 0LL, + 58541471996096977LL, + 0LL, + 131LL, + 2LL, + 1LL, + 0LL, + 131LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 42044768350026761LL, + 0LL, + 130LL, + 2LL, + 1LL, + 0LL, + 130LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 104093991169115492LL, + 0LL, + 146LL, + 2LL, + 1LL, + 0LL, + 146LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 128563766204312876LL, + 0LL, + 120LL, + 2LL, + 1LL, + 0LL, + 120LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 118183210859642192LL, + 0LL, + 121LL, + 2LL, + 1LL, + 0LL, + 121LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 31759579751918036LL, + 0LL, + 160LL, + 2LL, + 1LL, + 0LL, + 160LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 37922191436980238LL, + 0LL, + 143LL, + 2LL, + 1LL, + 0LL, + 143LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 139168641091494270LL, + 0LL, + 147LL, + 2LL, + 1LL, + 0LL, + 147LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 152909243010516658LL, + 0LL, + 138LL, + 2LL, + 1LL, + 0LL, + 138LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 88946238250907572LL, + 0LL, + 163LL, + 2LL, + 1LL, + 0LL, + 163LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 179824179782506694LL, + 0LL, + 170LL, + 2LL, + 1LL, + 0LL, + 170LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 45174131531571636LL, + 0LL, + 52LL, + 2LL, + 1LL, + 0LL, + 52LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 58562759984008198LL, + 0LL, + 65LL, + 2LL, + 1LL, + 0LL, + 65LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 60481677685756789LL, + 0LL, + 120LL, + 2LL, + 1LL, + 0LL, + 120LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 67459793699055203LL, + 0LL, + 141LL, + 2LL, + 1LL, + 0LL, + 141LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 33046999828954552LL, + 0LL, + 137LL, + 2LL, + 1LL, + 0LL, + 137LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 67963425659164234LL, + 0LL, + 135LL, + 2LL, + 1LL, + 0LL, + 135LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 43796972412552174LL, + 0LL, + 117LL, + 2LL, + 1LL, + 0LL, + 117LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 6408227318773632LL, + 0LL, + 68LL, + 2LL, + 1LL, + 0LL, + 68LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 75570635003173892LL, + 0LL, + 68LL, + 2LL, + 1LL, + 0LL, + 68LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 26842364308653847LL, + 0LL, + 122LL, + 2LL, + 1LL, + 0LL, + 122LL, + 3LL, + 4LL, + 9LL, + 5LL, + 0LL, + 60541299067063520LL, + 0LL, + 147LL, + 2LL, + 1LL, + 0LL, + 147LL, + 3LL, + 4LL, + 9LL, + 5LL, + 6LL +}; // weak +char byte_4868; // weak + + +//----- (0000000000001000) ---------------------------------------------------- +__int64 (**init_proc())(void) +{ + __int64 (**result)(void); // rax + + result = &_gmon_start__; + if ( &_gmon_start__ ) + return (__int64 (**)(void))_gmon_start__(); + return result; +} +// 48A0: using guessed type __int64 _gmon_start__(void); + +//----- (0000000000001020) ---------------------------------------------------- +void sub_1020() +{ + JUMPOUT(0LL); +} +// 1026: control flows out of bounds to 0 + +//----- (0000000000001030) ---------------------------------------------------- +void sub_1030() +{ + sub_1020(); +} + +//----- (0000000000001040) ---------------------------------------------------- +void sub_1040() +{ + sub_1020(); +} + +//----- (0000000000001050) ---------------------------------------------------- +void sub_1050() +{ + sub_1020(); +} + +//----- (00000000000010B0) ---------------------------------------------------- +__int64 __fastcall main(int a1, char **a2, char **a3) +{ + int v3; // ebx + int v4; // edx + int v5; // r13d + __int64 v6; // rdx + __int64 v7; // rax + __int64 v8; // rax + __int64 v10[137]; // [rsp+0h] [rbp-448h] BYREF + + v3 = 0; + v10[131] = __readfsqword(0x28u); + puts("I will tell you the flag, if you don't mind waiting a few moments..."); + memset(v10, 0, 0x410uLL); + v4 = 0; + while ( 1 ) + { + v5 = v4 + 1; + switch ( qword_4020[v4] ) + { + case 0LL: + v8 = v3; + v4 += 2; + ++v3; + v10[v8 + 1] = qword_4020[v5]; + break; + case 1LL: + v6 = v10[v3]; + v7 = v3++; + v10[v7 + 1] = v6; + v4 = v5; + break; + case 2LL: + v10[v3 - 1] -= v10[v3]; + --v3; + ++v4; + break; + case 3LL: + v10[v3 - 1] = v10[v3] < (unsigned __int64)v10[v3 - 1]; + --v3; + ++v4; + break; + case 4LL: + --v3; + v4 += 2; + if ( v10[v3 + 1] ) + v4 -= LODWORD(qword_4020[v5]); + break; + case 5LL: + putchar(SLOBYTE(v10[v3--])); + v4 = v5; + break; + case 6LL: + return 0LL; + default: + ++v4; + break; + } + } +} +// 4020: using guessed type _QWORD qword_4020[265]; + +//----- (0000000000001220) ---------------------------------------------------- +// positive sp value has been detected, the output may be wrong! +void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void)) +{ + __int64 v3; // rax + int v4; // esi + __int64 v5; // [rsp-8h] [rbp-8h] BYREF + char *retaddr; // [rsp+0h] [rbp+0h] BYREF + + v4 = v5; + v5 = v3; + _libc_start_main((int (__fastcall *)(int, char **, char **))main, v4, &retaddr, 0LL, 0LL, a3, &v5); + __halt(); +} +// 122A: positive sp value 8 has been found +// 1231: variable 'v3' is possibly undefined + +//----- (0000000000001250) ---------------------------------------------------- +char *sub_1250() +{ + return &byte_4868; +} +// 4868: using guessed type char byte_4868; + +//----- (0000000000001280) ---------------------------------------------------- +__int64 sub_1280() +{ + return 0LL; +} + +//----- (00000000000012C0) ---------------------------------------------------- +char *sub_12C0() +{ + char *result; // rax + + if ( !byte_4868 ) + { + if ( &__cxa_finalize ) + _cxa_finalize(off_4008); + result = sub_1250(); + byte_4868 = 1; + } + return result; +} +// 4868: using guessed type char byte_4868; + +//----- (0000000000001300) ---------------------------------------------------- +// attributes: thunk +__int64 sub_1300() +{ + return sub_1280(); +} + +//----- (000000000000130C) ---------------------------------------------------- +void term_proc() +{ + ; +} + +// nfuncs=22 queued=12 decompiled=12 lumina nreq=0 worse=0 better=0 +// ALL OK, 12 function(s) have been successfully decompiled