从管理员身份获得SYSTEM-权限的四种方法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1. 以服务方式运行
因为以服务方式运行程序时,相当于运行程序的是系统进程,所以,
被指定运行的程序自然而然的继承了系统进程的权限,也就是SYSTEM 权限。
;@echo off
;goto make
;===================================================================== ===============
; 以SYSTEM 权限运行程序- GetSys1
; 采用以服务方式运行的方法
;===================================================================== ===============
.386
.model flat, stdcall
option casemap :none
include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\advapi32.inc
include c:\masm32\include\masm32.inc
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\advapi32.lib
includelib c:\masm32\lib\masm32.lib
_ReLaunch proto
CTXT MACRO text
local lbl
.const
lbl db text,0
.code
exitm
ENDM
.code
start proc
LOCAL stStartupInfo : STARTUPINFO
LOCAL procinfo : PROCESS_INFORMA TION
invoke CreateMutex, NULL, TRUE, CTXT("GetSys1_Mutex")
invoke GetLastError
.if eax==ERROR_ALREADY_EXISTS
invoke RtlZeroMemory, addr stStartupInfo, sizeof stStartupInfo mov stStartupInfo.cb, sizeof stStartupInfo
invoke CreateProcess, 0, CTXT("regedit.exe"), 0, 0, 0, 0, 0, 0, addr stStartupInfo, addr procinfo
invoke CloseHandle, procinfo.hProcess
invoke CloseHandle, procinfo.hThread
.else
invoke _ReLaunch
.endif
invoke ExitProcess, NULL
start endp
_ReLaunch proc
LOCAL hSCManager
LOCAL hService
LOCAL szName[MAX_PA TH] : byte
invoke OpenSCManager, NULL, NULL, SC_MANAGER_CREATE_SERVICE .if eax!=0
mov hSCManager, eax
invoke OpenService, hSCManager, CTXT("GetSys1Temp"), DELETE
.if eax!=0
push eax
invoke DeleteService, eax
call CloseServiceHandle
.endif
invoke GetModuleFileName, NULL, addr szName, MAX_PA TH
invoke CreateService, hSCManager, CTXT("GetSys1Temp"), CTXT("GetSys1 Temp Service"), \
SERVICE_START + SERVICE_QUERY_STATUS + DELETE, \
SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS, SERVICE_DEMAND_START, \
SERVICE_ERROR_IGNORE, addr szName, NULL, NULL, NULL, NULL, NULL
.if eax!=0
mov hService, eax
invoke StartService, hService, 0, NULL
invoke DeleteService, hService
invoke CloseServiceHandle, hService
.endif
invoke CloseServiceHandle, hSCManager
.endif
ret
_ReLaunch endp
end start
:make
set path=%path%;c:\masm32\bin
set appname=GetSys1