diff options
Diffstat (limited to 'crash/10123.c')
| -rw-r--r-- | crash/10123.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/crash/10123.c b/crash/10123.c index 48a9304..b7c30a9 100644 --- a/crash/10123.c +++ b/crash/10123.c | |||
| @@ -1,9 +1,13 @@ | |||
| 1 | /* | 1 | /* |
| 2 | *Excerpt of the bug's description: | 2 | *Excerpt of the bug's description: |
| 3 | GDB fails to interrupt the program being debugged if the program is blocking SIGINT. | 3 | GDB fails to interrupt the program being debugged if the program is blocking SIGINT. |
| 4 | 4 | ||
| 5 | When using the sigwait function to retrieve signals, the program is expected to block them. SIGINT is a commonly handled signal. Any | 5 | When using the sigwait function to retrieve signals, |
| 6 | program using sigwait to retrieve signals and handling SIGINT this way will not be interruptible by GDB. | 6 | the program is expected to block them. SIGINT is a commonly handled signal. |
| 7 | |||
| 8 | Any program using sigwait to retrieve signals and handling SIGINT this way will not be interruptible by GDB. | ||
| 9 | |||
| 10 | The dectection process used here is the SIGTRAP trick. Fell free to use another one. | ||
| 7 | */ | 11 | */ |
| 8 | 12 | ||
| 9 | #include <stddef.h> | 13 | #include <stddef.h> |
| @@ -11,22 +15,25 @@ | |||
| 11 | #include <unistd.h> | 15 | #include <unistd.h> |
| 12 | #include <signal.h> | 16 | #include <signal.h> |
| 13 | 17 | ||
| 18 | void no_gdb(int s){ | ||
| 19 | signal(SIGTRAP, SIG_DFL); | ||
| 20 | printf("[*] No GBD detected\n"); | ||
| 21 | /* | ||
| 22 | * Put your code here | ||
| 23 | */ | ||
| 24 | _exit(0); | ||
| 25 | } | ||
| 26 | |||
| 14 | int main(){ | 27 | int main(){ |
| 28 | signal(SIGTRAP, &no_gdb); | ||
| 15 | sigset_t sigs; | 29 | sigset_t sigs; |
| 16 | sigfillset(&sigs); | 30 | sigemptyset(&sigs); |
| 17 | sigprocmask(SIG_SETMASK, &sigs, NULL); | 31 | sigaddset(&sigs, SIGINT); |
| 32 | sigprocmask(SIG_BLOCK, &sigs, NULL); | ||
| 33 | |||
| 34 | raise(SIGTRAP); | ||
| 18 | 35 | ||
| 19 | if(fork()){ | 36 | printf("[*] GDB detected\n"); |
| 20 | sleep(1); // to be sure that | 37 | while(1); |
| 21 | kill(getppid(), SIGINT); | ||
| 22 | _exit(0); | ||
| 23 | } | ||
| 24 | while(1){ | ||
| 25 | pause(); | ||
| 26 | printf("[*] No GBD detected\n"); | ||
| 27 | /* | ||
| 28 | * Put your code here | ||
| 29 | */ | ||
| 30 | } | ||
| 31 | return 0; | 38 | return 0; |
| 32 | } | 39 | } |
