--------------------------------------------------------------------- // Function declarations __int64 (**init_proc())(void); void sub_670(); // int puts(const char *s); // size_t strlen(const char *s); // int printf(const char *format, ...); // int strcmp(const char *s1, const char *s2); // __int64 __isoc99_scanf(const char *, ...); weak // int __fastcall _cxa_finalize(void *); void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void)); char *deregister_tm_clones(); __int64 register_tm_clones(); char *_do_global_dtors_aux(); __int64 frame_dummy(); _BYTE *__fastcall lock(__int64 a1, __int64 a2, const char *a3, int a4); _BOOL8 __fastcall authentication(const char *a1); unsigned __int64 jackpot(); int __fastcall main(int argc, const char **argv, const char **envp); void _libc_csu_fini(void); // idb 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 _libc_csu_init; __int64 (__fastcall *_frame_dummy_init_array_entry)() = &frame_dummy; // weak __int64 (__fastcall *_do_global_dtors_aux_fini_array_entry)() = &_do_global_dtors_aux; // weak void *_dso_handle = &_dso_handle; // idb char _bss_start; // weak //----- (0000000000000650) ---------------------------------------------------- __int64 (**init_proc())(void) { __int64 (**result)(void); // rax result = &_gmon_start__; if ( &_gmon_start__ ) return (__int64 (**)(void))_gmon_start__(); return result; } // 201068: using guessed type __int64 _gmon_start__(void); //----- (0000000000000670) ---------------------------------------------------- void sub_670() { JUMPOUT(0LL); } // 676: control flows out of bounds to 0 //----- (00000000000006F0) ---------------------------------------------------- // 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, (void (*)(void))_libc_csu_init, _libc_csu_fini, a3, &v5); __halt(); } // 6F6: positive sp value 8 has been found // 6FD: variable 'v3' is possibly undefined //----- (0000000000000720) ---------------------------------------------------- char *deregister_tm_clones() { return &_bss_start; } // 201010: using guessed type char _bss_start; //----- (0000000000000760) ---------------------------------------------------- __int64 register_tm_clones() { return 0LL; } //----- (00000000000007B0) ---------------------------------------------------- char *_do_global_dtors_aux() { char *result; // rax if ( !_bss_start ) { if ( &__cxa_finalize ) _cxa_finalize(_dso_handle); result = deregister_tm_clones(); _bss_start = 1; } return result; } // 201010: using guessed type char _bss_start; //----- (00000000000007F0) ---------------------------------------------------- __int64 frame_dummy() { return register_tm_clones(); } //----- (00000000000007FA) ---------------------------------------------------- _BYTE *__fastcall lock(__int64 a1, __int64 a2, const char *a3, int a4) { _BYTE *result; // rax int i; // [rsp+28h] [rbp-8h] int v8; // [rsp+2Ch] [rbp-4h] v8 = strlen(a3); for ( i = 0; i < a4; ++i ) *(_BYTE *)(i + a2) = a3[i % v8] ^ *(_BYTE *)(i + a1); result = (_BYTE *)(a4 + a2); *result = 0; return result; } //----- (0000000000000881) ---------------------------------------------------- _BOOL8 __fastcall authentication(const char *a1) { char v2[9]; // [rsp+15h] [rbp-1Bh] BYREF char s2[10]; // [rsp+1Eh] [rbp-12h] BYREF unsigned __int64 v4; // [rsp+28h] [rbp-8h] v4 = __readfsqword(0x28u); strcpy(v2, ">78,"); v2[5] = 23; v2[6] = 74; v2[7] = 16; v2[8] = 93; lock((__int64)v2, (__int64)s2, "key", 9); return strcmp(a1, s2) == 0; } //----- (000000000000090D) ---------------------------------------------------- unsigned __int64 jackpot() { char v1[32]; // [rsp+0h] [rbp-60h] BYREF char v2[56]; // [rsp+20h] [rbp-40h] BYREF unsigned __int64 v3; // [rsp+58h] [rbp-8h] v3 = __readfsqword(0x28u); v1[0] = 19; v1[1] = 20; v1[2] = 53; v1[3] = 8; v1[4] = 71; v1[5] = 82; v1[6] = 20; v1[7] = 17; v1[8] = 16; v1[9] = 32; v1[10] = 96; v1[11] = 50; v1[12] = 1; v1[13] = 111; v1[14] = 75; v1[15] = 3; v1[16] = 48; v1[17] = 4; v1[18] = 108; v1[19] = 45; v1[20] = 27; v1[21] = 52; v1[22] = 115; v1[23] = 14; lock((__int64)v1, (__int64)v2, "P@ssw0rd4CTF2023Ev3n+", 45); v2[24] = 0; printf("Here is your Flag: %s\n", v2); return __readfsqword(0x28u) ^ v3; } //----- (00000000000009D3) ---------------------------------------------------- int __fastcall main(int argc, const char **argv, const char **envp) { char v4[56]; // [rsp+0h] [rbp-40h] BYREF unsigned __int64 v5; // [rsp+38h] [rbp-8h] v5 = __readfsqword(0x28u); printf("Enter the password: "); __isoc99_scanf("%49s", v4); if ( authentication(v4) ) { puts("Access granted!"); jackpot(); } else { puts("Access denied! Try again."); } return 0; } // 6D0: using guessed type __int64 __isoc99_scanf(const char *, ...); //----- (0000000000000A70) ---------------------------------------------------- void __fastcall _libc_csu_init(unsigned int a1, __int64 a2, __int64 a3) { signed __int64 v3; // rbp __int64 i; // rbx v3 = &_do_global_dtors_aux_fini_array_entry - &_frame_dummy_init_array_entry; init_proc(); if ( v3 ) { for ( i = 0LL; i != v3; ++i ) (*(&_frame_dummy_init_array_entry + i))(); } } // 200D90: using guessed type __int64 (__fastcall *_frame_dummy_init_array_entry)(); // 200D98: using guessed type __int64 (__fastcall *_do_global_dtors_aux_fini_array_entry)(); //----- (0000000000000AE4) ---------------------------------------------------- void term_proc() { ; } // nfuncs=30 queued=13 decompiled=13 lumina nreq=0 worse=0 better=0 // ALL OK, 13 function(s) have been successfully decompiled
Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++
and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter name:";
getline (cin, name);
cout << "Hello " << name;
return 0;
}
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
//code
}
else {
//code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression){
case value1:
// code
break; // optional
case value2:
// code
break; // optional
......
default:
code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
return_type function_name(parameters);
function_name (parameters)
return_type function_name(parameters) {
// code
}