forked from gdbinit/onyx-the-black-cat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gdbinit#3 from Lichtso/master
Improved ptrace patch and added a appropriate test
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
/* | ||
* test PT_DENY_ATTACH | ||
*/ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <sys/types.h> | ||
#include <sys/ptrace.h> | ||
|
||
int main() | ||
{ | ||
ptrace(PT_DENY_ATTACH, -1, 0, 0); | ||
ptrace(PT_DENY_ATTACH, 0, 0, 0); | ||
sleep(2); | ||
printf("Buh!\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* test PT_DENY_ATTACH and SIGSEGV | ||
*/ | ||
#include <stdio.h> | ||
#include <signal.h> | ||
#include <unistd.h> | ||
#include <sys/types.h> | ||
#include <sys/ptrace.h> | ||
|
||
unsigned int trap = 1; | ||
|
||
void signalHandler(int signal) | ||
{ | ||
trap = 0; | ||
} | ||
|
||
int main() | ||
{ | ||
ptrace(PT_DENY_ATTACH, 0, 0, 0); | ||
signal(11, signalHandler); | ||
ptrace(PT_ATTACH, getpid(), 0, 0); | ||
signal(11, 0); | ||
if(trap) | ||
((unsigned int*)0)[0] = 0; | ||
sleep(2); | ||
printf("Buh!\n"); | ||
} |