使用PR_GET_NO_NEW_PRIVS 避免安全漏洞
来源:互联网 发布:禁止上网软件 编辑:程序博客网 时间:2024/06/05 17:01
PR_SET_NO_NEW_PRIVS当一个进程或其子进程设置了PR_SET_NO_NEW_PRIVS 属性,则其不能访问一些无法share的操作,如setuid, 和chroot.这是kernel 3.5 以后加的feature.主要用于安全目的.下面这个程序编译并执行后, 就无法使用 sudo su 命令,
http://lwn.net/Articles/478062/
Test it like this:---- begin test case#include <sys/prctl.h>#include <stdio.h>#include <unistd.h>#include <errno.h>
#define PR_SET_NO_NEW_PRIVS 36#define PR_GET_NO_NEW_PRIVS 37int main(){ int nnp = prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0); if (nnp == -EINVAL) { printf("Failed!\n"); return 1; } printf("nnp was %d\n", nnp); if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) != 0) { printf("Failed!\n"); return 1; } nnp = prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0); if (nnp == -EINVAL) { printf("Failed!\n"); return 1; } printf("nnp is %d\n", nnp); printf("here goes...\n"); execlp("bash", "bash", NULL); printf("Failed to exec bash\n"); return 1;}
0 0
- 使用PR_GET_NO_NEW_PRIVS 避免安全漏洞
- 安全漏洞
- 安全漏洞
- 安全漏洞
- 安全漏洞
- 使用 Rational AppScan 检测 Web 服务安全漏洞
- 避免使用实例陷阱
- 避免使用终结函数
- 避免使用if-else
- 避免不安全使用文件
- 避免使用宏
- 避免多次使用if
- C++ 避免使用宏
- 避免使用vector<bool>
- 避免使用宏
- 避免使用vector<bool>
- 避免使用vector<bool>
- 使用git避免冲突
- Centos 7 相关操作与配置
- String的equals方法和contentEquals方法的比较
- SQL SERVER 数学函数
- 利用反射机制编写一个程序,这个程序能把类中所有的成员变量赋值,并把操作信息输出到控制台。
- Android studio 使用JitPack发布library到Github开源库
- 使用PR_GET_NO_NEW_PRIVS 避免安全漏洞
- Android Studio Failed to complete Gradle execution
- Time类中的运算符重载(3)-前置++,后置++
- Linux下计划任务 crontab
- Java用SAX和DOM解析器解析Xml
- 单调队列 HDU 3530 Subsequence
- 【GDOI2014模拟】旅行(水法)
- ViewPropertyAnimator源码分析
- AndroidEventBus使用----基本操作(1)