多年收藏的嵌入式视频全集种子分享了
时间:2011-11-18
来源:互联网
网上几乎所有的资料都在说:
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
作者: lianggj 发布时间: 2011-11-18
网上几乎所有的资料都在说:
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
作者: lianggj 发布时间: 2011-11-18
网上几乎所有的资料都在说:
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
被跟踪程序执行系统调用之前,内核会先检查当前进程是否处于被“跟踪”(traced)的状态。如果是的话,内核暂停当前进程并将控制权交给跟踪进程,使跟踪进程得以察看或者修改被跟踪进程的寄存器。。
也就是说通过ptrace,我们可以让阻止子进程执行我们认为“非法”的系统调用。
但是我通过测试,却发现:子进程在执行了“非法”的系统调用之后,才被父进程捕获,就算此时的父进程KILL掉子进程也为时已晚了,“非法”系统调用还是执行了!!!!!!!!这是为什么?????百思不得其解啊。
下面我给出两个程序,一个是son.cpp,代码只有一个系统调用:unlink('test.txt"), 作用是删除一个文件。另一个是father.cpp,它的作用是跟踪son的运行,不让son调用unlink这个系统调用。从实验结果来看,son进程总是成功调用了unlink系统调用之后,father才发现,但为时已晚,test.txt文件还是被son删除掉了。如下是代码,望得到高手的指点!!!!
son.cpp代码如下:
#include <sys/user.h>
using namespace std;
int main()
{
unlink("test.txt");
return 0;
}
father.cpp代码如下:
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <iostream>
#include <sys/user.h>
pid_t child;
int status, syscall;
struct user_regs_struct regs;
int main()
{
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("son", "son", NULL);
}
else {
while(1)
{
wait(&status);
if(WIFEXITED(status) break;
ptrace(PTRACE_GETREGS,child,NULL,®s);
syscall = regs.orig_eax;
if(syscall == 10) // syscall == SYS_unlink
{
ptrace(PTRACE_KILL,child,NULL,NULL);
cout<<"You Are Deleting A File!!!!"<<endl;
return 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
}
}
return 0;
}
作者: lianggj 发布时间: 2011-11-18
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28