diff options
Diffstat (limited to '')
| -rw-r--r-- | detect/env.c | 37 | ||||
| -rw-r--r-- | detect/env.h | 7 | ||||
| -rw-r--r-- | detect/gdb.c | 1 | ||||
| -rw-r--r-- | detect/main.c | 25 |
4 files changed, 69 insertions, 1 deletions
diff --git a/detect/env.c b/detect/env.c new file mode 100644 index 0000000..6782f8d --- /dev/null +++ b/detect/env.c | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Detect GDB using env | ||
| 3 | * | ||
| 4 | */ | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | |||
| 10 | int gdb_columns() { | ||
| 11 | return (getenv("COLUMNS") != NULL); | ||
| 12 | } | ||
| 13 | |||
| 14 | int gdb_lines() { | ||
| 15 | return (getenv("LINES") != NULL); | ||
| 16 | } | ||
| 17 | |||
| 18 | int gdb_path() { | ||
| 19 | char *gdb_path = getenv("_"); | ||
| 20 | if (gdb_path == NULL) { | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | char *block_path = strtok(gdb_path, "/"); | ||
| 24 | char *str = NULL; | ||
| 25 | while (block_path != NULL) { | ||
| 26 | str = block_path; | ||
| 27 | block_path = strtok(NULL, "/"); | ||
| 28 | } | ||
| 29 | if (str == NULL) { | ||
| 30 | return 0; | ||
| 31 | } | ||
| 32 | else { | ||
| 33 | return !strcmp(str,"gdb"); | ||
| 34 | } | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
diff --git a/detect/env.h b/detect/env.h new file mode 100644 index 0000000..7cde9af --- /dev/null +++ b/detect/env.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #ifndef _ENV_ | ||
| 2 | #define _ENV_ | ||
| 3 | int gdb_columns(); | ||
| 4 | int gdb_lines(); | ||
| 5 | int gdb_path(); | ||
| 6 | #endif | ||
| 7 | |||
diff --git a/detect/gdb.c b/detect/gdb.c index fd0dacd..00336d6 100644 --- a/detect/gdb.c +++ b/detect/gdb.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <signal.h> | 7 | #include <signal.h> |
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <unistd.h> | ||
| 9 | #include <stdlib.h> | 10 | #include <stdlib.h> |
| 10 | #include <string.h> | 11 | #include <string.h> |
| 11 | #include <sys/ptrace.h> | 12 | #include <sys/ptrace.h> |
diff --git a/detect/main.c b/detect/main.c index 09e7515..47b9c19 100644 --- a/detect/main.c +++ b/detect/main.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "gdb.h" | 7 | #include "gdb.h" |
| 8 | #include "various.h" | 8 | #include "various.h" |
| 9 | 9 | #include "env.h" | |
| 10 | 10 | ||
| 11 | int main(int argc, char** argv){ | 11 | int main(int argc, char** argv){ |
| 12 | unsigned int res = 0; | 12 | unsigned int res = 0; |
| @@ -68,5 +68,28 @@ int main(int argc, char** argv){ | |||
| 68 | else | 68 | else |
| 69 | printf("\n[ ] Everything seems fine\n"); | 69 | printf("\n[ ] Everything seems fine\n"); |
| 70 | 70 | ||
| 71 | res = 0; | ||
| 72 | printf("\n\n"); | ||
| 73 | printf(".: GDB env detector :.\n\n"); | ||
| 74 | |||
| 75 | if(res += gdb_columns()) | ||
| 76 | printf("[x] COLUMNS_ENV\n"); | ||
| 77 | else | ||
| 78 | printf("[ ] COLUMNS_ENV\n"); | ||
| 79 | |||
| 80 | if(res += gdb_lines()) | ||
| 81 | printf("[x] LINES_ENV\n"); | ||
| 82 | else | ||
| 83 | printf("[ ] LINES_ENV\n"); | ||
| 84 | |||
| 85 | if(res += gdb_path()) | ||
| 86 | printf("[x] GDB_ENV\n"); | ||
| 87 | else | ||
| 88 | printf("[ ] GDB_ENV\n"); | ||
| 89 | |||
| 90 | if(res) | ||
| 91 | printf("\n[*] GDB detected\n"); | ||
| 92 | else | ||
| 93 | printf("\n[ ] No GDB detected\n"); | ||
| 71 | return 0; | 94 | return 0; |
| 72 | } | 95 | } |
