diff --git a/modules/utilities/unix/ctf/metactf/files/repository/src_csp/Ch3.1-3.5/Ch3_00_GdbSetmem/program.c.template b/modules/utilities/unix/ctf/metactf/files/repository/src_csp/Ch3.1-3.5/Ch3_00_GdbSetmem/program.c.template index bfee2e204..be09f94ac 100644 --- a/modules/utilities/unix/ctf/metactf/files/repository/src_csp/Ch3.1-3.5/Ch3_00_GdbSetmem/program.c.template +++ b/modules/utilities/unix/ctf/metactf/files/repository/src_csp/Ch3.1-3.5/Ch3_00_GdbSetmem/program.c.template @@ -10,6 +10,34 @@ void printflag(); +void printflag() +{ + int fd; + int len; + unsigned char data[128]; + + fd = open("flag", O_RDONLY); + + if ( fd <= 0 ) { + printf("Failed to open flag.\n"); + return; + } + + len = lseek( fd, 0, SEEK_END); + lseek(fd, 0, SEEK_SET); + + if ( len > 128 ) { + len = 128; + } + + memset(data, 0, 128); + read( fd, data, len); + close(fd); + + printf("%s\n", data); + return; +} + //Hash function created by Thomas Wang and taken from https://naml.us/post/inverse-of-a-hash-function/ unsigned long long int hash(unsigned long long int key) { @@ -100,34 +128,6 @@ void print_msg() { printf("%s",msg); } -void printflag() -{ - int fd; - int len; - unsigned char data[128]; - - fd = open("flag", O_RDONLY); - - if ( fd <= 0 ) { - printf("Failed to open flag.\n"); - return; - } - - len = lseek( fd, 0, SEEK_END); - lseek(fd, 0, SEEK_SET); - - if ( len > 128 ) { - len = 128; - } - - memset(data, 0, 128); - read( fd, data, len); - close(fd); - - printf("%s\n", data); - return; -} - int main(void) { signal(SIGSEGV, segv_handler); int x=1024; diff --git a/modules/utilities/unix/ctf/metactf/files/repository/src_malware/Ch01-08/Ch08Dbg_GdbSetmem/program.c.template b/modules/utilities/unix/ctf/metactf/files/repository/src_malware/Ch01-08/Ch08Dbg_GdbSetmem/program.c.template index a424b6459..a9911f897 100644 --- a/modules/utilities/unix/ctf/metactf/files/repository/src_malware/Ch01-08/Ch08Dbg_GdbSetmem/program.c.template +++ b/modules/utilities/unix/ctf/metactf/files/repository/src_malware/Ch01-08/Ch08Dbg_GdbSetmem/program.c.template @@ -8,6 +8,8 @@ #define USERDEF0 AAAAAA #define USERDEF1 BBBBBB +void printflag(); + //Hash function created by Thomas Wang and taken from https://naml.us/post/inverse-of-a-hash-function/ unsigned long long int hash(unsigned long long int key) { @@ -61,11 +63,6 @@ void print_pswd(unsigned long long int key) { printf("%llu\n", inverse_hash(key)); } -void print_good(void) { - puts("Good Job."); - printflag(); -} - void printflag() { int fd; @@ -94,6 +91,11 @@ void printflag() return; } +void print_good(void) { + puts("Good Job."); + printflag(); +} + void segv_handler(int sig) { printf("Segmentation fault. Try again.\n"); exit(0);