Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

NT - - 3dapple.

com

1 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

2005316 00:57:07 GMT http://www.3dapple.com/safe/lang/2004/1113/19636.html G o o g l e


G o o g l e

http://www.google.com/search?q=cache:eJ1qYFSCbJAJ:www.3dapple.com/safe/lang/2004/1113/19636.html+ntcmd&hl=zh-TW&client=fir

Google
ntcmd

guest
*****

| | | | | | | | | |
| |

,,,,,,,,,,,

NT
2004-11-13 15:23:29
NT

ey4s
.
NT
IDOpenProcessTerminateProcess
WINLOGON
GetCurrentProcess
OpenProcessTokenLookupPrivilegeValue
AdjustTokenPrivilegesSeDebugPrivilege
Idle
OK!
<1>IPC
<2>admin$\system32killsrv.exe
<3>OpenSCManagerService Control Manager[SCM]
<4>CreateService<2>killsrv.exe
<5>StartServiceID
<6>killsrv.exe
<7>
Killsrv.exe
/***********************************************************************
Module:Killsrv.c
Date:2001/4/27
Author:ey4s<ey4s@21cn.com>
Http://www.ey4s.org
***********************************************************************/
#include <stdio.h>
#include <windows.h>
#include "function.c"
#define ServiceName "PSKILL"

3/21/2005 5:24 PM

NT - - 3dapple.com

2 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

Ads by Google

SERVICE_STATUS_HANDLE ssh;
SERVICE_STATUS ss;
/////////////////////////////////////////////////////////////////////////
void ServiceStopped(void)
{
ss.dwServiceType=SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
ss.dwCurrentState=SERVICE_STOPPED;
ss.dwControlsAccepted=SERVICE_ACCEPT_STOP;
ss.dwWin32ExitCode=NO_ERROR;
ss.dwCheckPoint=0;
ss.dwWaitHint=0;
SetServiceStatus(ssh,&ss);
return;
}
/////////////////////////////////////////////////////////////////////////
void ServicePaused(void)
{
ss.dwServiceType=SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
ss.dwCurrentState=SERVICE_PAUSED;
ss.dwControlsAccepted=SERVICE_ACCEPT_STOP;
ss.dwWin32ExitCode=NO_ERROR;
ss.dwCheckPoint=0;
ss.dwWaitHint=0;
SetServiceStatus(ssh,&ss);
return;
}
void ServiceRunning(void)
{
ss.dwServiceType=SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
ss.dwCurrentState=SERVICE_RUNNING;
ss.dwControlsAccepted=SERVICE_ACCEPT_STOP;
ss.dwWin32ExitCode=NO_ERROR;
ss.dwCheckPoint=0;
ss.dwWaitHint=0;
SetServiceStatus(ssh,&ss);
return;
}
/////////////////////////////////////////////////////////////////////////
void WINAPI servier_ctrl(DWORD Opcode)//
{
switch(Opcode)
{
case SERVICE_CONTROL_STOP://Service
ServiceStopped();
break;
case SERVICE_CONTROL_INTERROGATE:
SetServiceStatus(ssh,&ss);
break;
}
return;
}
//////////////////////////////////////////////////////////////////////////////
//SERVICE_STOPPED
//SERVICE_PAUSED
//
void WINAPI ServiceMain(DWORD dwArgc,LPTSTR *lpszArgv)
{
ssh=RegisterServiceCtrlHandler(ServiceName,servier_ctrl);
if(!ssh)
{
ServicePaused();
return;
}
ServiceRunning();
Sleep(100);
//argv[0]argv[1]pskill,1
//argv[2]=target,argv[3]=user,argv[4]=pwd,argv[5]=pid
if(KillPS(atoi(lpszArgv[5])))
ServiceStopped();
else
ServicePaused();
return;
}
/////////////////////////////////////////////////////////////////////////////
void main(DWORD dwArgc,LPTSTR *lpszArgv)
{
SERVICE_TABLE_ENTRY ste[2];
ste[0].lpServiceName=ServiceName;
ste[0].lpServiceProc=ServiceMain;
ste[1].lpServiceName=NULL;
ste[1].lpServiceProc=NULL;
StartServiceCtrlDispatcher(ste);
return;
}
/////////////////////////////////////////////////////////////////////////////
function.cID,

/***********************************************************************
Module:function.c
Date:2001/4/28
Author:ey4s<ey4s@21cn.com>
Http://www.ey4s.org

Fire resistant safes


"Gardex Safes" UL listed
for fire & burglary. Drop
ship from factory.
www.dansanna.com

Need a Good Safe?


Effective safes for all uses
Large and Small, We
Have Them All
www.NotRobbed.Com

3/21/2005 5:24 PM

NT - - 3dapple.com

3 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

***********************************************************************/
#include <windows.h>
////////////////////////////////////////////////////////////////////////////
BOOL SetPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege,BOOL bEnablePrivilege)
{
TOKEN_PRIVILEGES tp;
LUID luid;
if(!LookupPrivilegeValue(NULL,lpszPrivilege,&luid))
{
printf("\nLookupPrivilegeValue error:%d", GetLastError() );
return FALSE;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if (bEnablePrivilege)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
// Enable the privilege or disable all privileges.
AdjustTokenPrivileges(
hToken,
FALSE,
&tp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL);
// Call GetLastError to determine whether the function succeeded.
if (GetLastError() != ERROR_SUCCESS)
{
printf("AdjustTokenPrivileges failed: %u\n", GetLastError() );
return FALSE;
}
return TRUE;
}
////////////////////////////////////////////////////////////////////////////
BOOL KillPS(DWORD id)
{
HANDLE hProcess=NULL,hProcessToken=NULL;
BOOL IsKilled=FALSE,bRet=FALSE;
__try
{
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hProcessToken))
{
printf("\nOpen Current Process Token failed:%d",GetLastError());
__leave;
}
//printf("\nOpen Current Process Token ok!");
if(!SetPrivilege(hProcessToken,SE_DEBUG_NAME,TRUE))
{
__leave;
}
printf("\nSetPrivilege ok!");
if((hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE,id))==NULL)
{
printf("\nOpen Process %d failed:%d",id,GetLastError());
__leave;
}
//printf("\nOpen Process %d ok!",id);
if(!TerminateProcess(hProcess,1))
{
printf("\nTerminateProcess failed:%d",GetLastError());
__leave;
}
IsKilled=TRUE;
}
__finally
{
if(hProcessToken!=NULL) CloseHandle(hProcessToken);
if(hProcess!=NULL) CloseHandle(hProcess);
}
return(IsKilled);
}
//////////////////////////////////////////////////////////////////////////////////////////////
OK!killsrv.exe COPY
exekillsrv.exebuff
buffexePskill.c

/*********************************************************************************************
Module:PsKill.c
Create:2001/4/28
Modify:2001/6/23
Author:ey4s<ey4s@21cn.com>
Http://www.ey4s.org
PsKill ==>Local and Remote process killer for windows 2k
**************************************************************************/
#include "ps.h"
#define EXE "killsrv.exe"
#define ServiceName "PSKILL"
#pragma comment(lib,"mpr.lib")

3/21/2005 5:24 PM

NT - - 3dapple.com

4 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

//////////////////////////////////////////////////////////////////////////
//
SERVICE_STATUS ssStatus;
SC_HANDLE hSCManager=NULL,hSCService=NULL;
BOOL bKilled=FALSE;
char szTarget[52]=;
//////////////////////////////////////////////////////////////////////////
BOOL ConnIPC(char *,char *,char *);//IPC
BOOL InstallService(DWORD,LPTSTR *);//
BOOL WaitServiceStop();//
BOOL RemoveService();//
/////////////////////////////////////////////////////////////////////////
int main(DWORD dwArgc,LPTSTR *lpszArgv)
{
BOOL bRet=FALSE,bFile=FALSE;
char tmp[52]=,RemoteFilePath[128]=,
szUser[52]=,szPass[52]=;
HANDLE hFile=NULL;
DWORD i=0,dwIndex=0,dwWrite,dwSize=sizeof(exebuff);
//
if(dwArgc==2)
{
if(KillPS(atoi(lpszArgv[1])))
printf("\nLoacl Process %s have beed killed!",lpszArgv[1]);
else
printf("\nLoacl Process %s can't be killed!ErrorCode:%d",
lpszArgv[1],GetLastError());
return 0;
}
//
else if(dwArgc!=5)
{
printf("\nPSKILL ==>Local and Remote Process Killer"
"\nPower by ey4s<ey4s@21cn.com>"
"\nhttp://www.ey4s.org 2001/6/23"
"\n\nUsage:%s <PID> <==Killed Local Process"
"\n %s <IP> <User> <PWD> <PID> <==Killed Remote Process\n",
lpszArgv[0],lpszArgv[0]);
return 1;
}
//
strncpy(szTarget,lpszArgv[1],sizeof(szTarget)-1);
strncpy(szUser,lpszArgv[2],sizeof(szUser)-1);
strncpy(szPass,lpszArgv[3],sizeof(szPass)-1);
//exe
sprintf(RemoteFilePath,"\\\\%s\\admin$\\system32\\%s",szTarget,EXE);
__try
{
//IPC
if(!ConnIPC(szTarget,szUser,szPass))
{
printf("\nConnect to %s failed:%d",szTarget,GetLastError());
return 1;
}
printf("\nConnect to %s success!",szTarget);
//exe
hFile=CreateFile(RemoteFilePath,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRIT
E,
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
{
printf("\nCreate file %s failed:%d",RemoteFilePath,GetLastError());
__leave;
}
//
while(dwSize>dwIndex)
{
if(!WriteFile(hFile,&exebuff[dwIndex],dwSize-dwIndex,&dwWrite,NULL))
{
printf("\nWrite file %s
failed:%d",RemoteFilePath,GetLastError());
__leave;
}
dwIndex+=dwWrite;
}
//
CloseHandle(hFile);
bFile=TRUE;
//
if(InstallService(dwArgc,lpszArgv))
{
//
if(WaitServiceStop())
{
//printf("\nService was stoped!");
}
else
{
//printf("\nService can't be stoped.Try to delete it.");

3/21/2005 5:24 PM

NT - - 3dapple.com

5 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

}
Sleep(500);
//
RemoveService();
}
}
__finally
{
//
if(bFile) DeleteFile(RemoteFilePath);
//,~
if(hFile!=NULL) CloseHandle(hFile);
//Close Service handle
if(hSCService!=NULL) CloseServiceHandle(hSCService);
//Close the Service Control Manager handle
if(hSCManager!=NULL) CloseServiceHandle(hSCManager);
//ipc
wsprintf(tmp,"\\\\%s\\ipc$",szTarget);
WNetCancelConnection2(tmp,CONNECT_UPDATE_PROFILE,TRUE);
if(bKilled)
printf("\nProcess %s on %s have been
killed!\n",lpszArgv[4],lpszArgv[1]);
else
printf("\nProcess %s on %s can't be
killed!\n",lpszArgv[4],lpszArgv[1]);
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
BOOL ConnIPC(char *RemoteName,char *User,char *Pass)
{
NETRESOURCE nr;
char RN[50]="\\\\";
strcat(RN,RemoteName);
strcat(RN,"\\ipc$");
nr.dwType=RESOURCETYPE_ANY;
nr.lpLocalName=NULL;
nr.lpRemoteName=RN;
nr.lpProvider=NULL;
if(WNetAddConnection2(&nr,Pass,User,FALSE)==NO_ERROR)
return TRUE;
else
return FALSE;
}
/////////////////////////////////////////////////////////////////////////
BOOL InstallService(DWORD dwArgc,LPTSTR *lpszArgv)
{
BOOL bRet=FALSE;
__try
{
//Open Service Control Manager on Local or Remote machine
hSCManager=OpenSCManager(szTarget,NULL,SC_MANAGER_ALL_ACCESS);
if(hSCManager==NULL)
{
printf("\nOpen Service Control Manage failed:%d",GetLastError());
__leave;
}
//printf("\nOpen Service Control Manage ok!");
//Create Service
hSCService=CreateService(hSCManager,// handle to SCM database
ServiceName,// name of service to start
ServiceName,// display name
SERVICE_ALL_ACCESS,// type of access to service
SERVICE_WIN32_OWN_PROCESS,// type of service
SERVICE_AUTO_START,// when to start service
SERVICE_ERROR_IGNORE,// severity of service
failure
EXE,// name of binary file
NULL,// name of load ordering group
NULL,// tag identifier
NULL,// array of dependency names
NULL,// account name
NULL);// account password
//create service failed
if(hSCService==NULL)
{
//
if(GetLastError()==ERROR_SERVICE_EXISTS)
{
//printf("\nService %s Already exists",ServiceName);
//open service
hSCService = OpenService(hSCManager, ServiceName,
SERVICE_ALL_ACCESS);
if(hSCService==NULL)
{
printf("\nOpen Service failed:%d",GetLastError());
__leave;
}
//printf("\nOpen Service %s ok!",ServiceName);
}

3/21/2005 5:24 PM

NT - - 3dapple.com

6 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

else
{
printf("\nCreateService failed:%d",GetLastError());
__leave;
}
}
//create service ok
else
{
//printf("\nCreate Service %s ok!",ServiceName);
}
//
if ( StartService(hSCService,dwArgc,lpszArgv))
{
//printf("\nStarting %s.", ServiceName);
Sleep(20);//100ms
while( QueryServiceStatus(hSCService, &ssStatus ) )
{
if ( ssStatus.dwCurrentState == SERVICE_START_PENDING)
{
printf(".");
Sleep(20);
}
else
break;
}
if ( ssStatus.dwCurrentState != SERVICE_RUNNING )
printf("\n%s failed to run:%d",ServiceName,GetLastError());
}
else if(GetLastError()==ERROR_SERVICE_ALREADY_RUNNING)
{
//printf("\nService %s already running.",ServiceName);
}
else
{
printf("\nStart Service %s failed:%d",ServiceName,GetLastError());
__leave;
}
bRet=TRUE;
}//enf of try
__finally
{
return bRet;
}
return bRet;
}
/////////////////////////////////////////////////////////////////////////
BOOL WaitServiceStop(void)
{
BOOL bRet=FALSE;
//printf("\nWait Service stoped");
while(1)
{
Sleep(100);
if(!QueryServiceStatus(hSCService, &ssStatus))
{
printf("\nQueryServiceStatus failed:%d",GetLastError());
break;
}
if(ssStatus.dwCurrentState==SERVICE_STOPPED)
{
bKilled=TRUE;
bRet=TRUE;
break;
}
if(ssStatus.dwCurrentState==SERVICE_PAUSED)
{
//
bRet=ControlService(hSCService,SERVICE_CONTROL_STOP,NULL);
break;
}
else
{
//printf(".");
continue;
}
}
return bRet;
}
/////////////////////////////////////////////////////////////////////////
BOOL RemoveService(void)
{
//Delete Service
if(!DeleteService(hSCService))
{
printf("\nDeleteService failed:%d",GetLastError());
return FALSE;
}
//printf("\nDelete Service ok!");
return TRUE;
}
/////////////////////////////////////////////////////////////////////////

3/21/2005 5:24 PM

NT - - 3dapple.com

7 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

ps.h
/////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <windows.h>
#include "function.c"
unsigned char exebuff[]="killsrv.exe";
/////////////////////////////////////////////////////////////////////////////////////////////
Windows2000VC++6.0pskill.exehttp://www.ey4s.org
killsrv.execmd.exeadmin
IPCwww.sysinternals.compsexec.exentcmd.exe
UltraEdit
"\xAB\x77\xCD"
[~_*]
/*******************************************************************************************
Module:exe2hex.c
Author:ey4s<ey4s@21cn.com>
Http://www.ey4s.org
Date:2001/6/23
****************************************************************************/
#include <stdio.h>
#include <windows.h>
int main(int argc,char **argv)
{
HANDLE hFile;
DWORD dwSize,dwRead,dwIndex=0,i;
unsigned char *lpBuff=NULL;
__try
{
if(argc!=2)
{
printf("\nUsage: %s <File>",argv[0]);
__leave;
}
hFile=CreateFile(argv[1],GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FI
LE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
{
printf("\nOpen file %s failed:%d",argv[1],GetLastError());
__leave;
}
dwSize=GetFileSize(hFile,NULL);
if(dwSize==INVALID_FILE_SIZE)
{
printf("\nGet file size failed:%d",GetLastError());
__leave;
}
lpBuff=(unsigned char *)malloc(dwSize);
if(!lpBuff)
{
printf("\nmalloc failed:%d",GetLastError());
__leave;
}
while(dwSize>dwIndex)
{
if(!ReadFile(hFile,&lpBuff[dwIndex],dwSize-dwIndex,&dwRead,NULL))
{
printf("\nRead file failed:%d",GetLastError());
__leave;
}
dwIndex+=dwRead;
}
for(i=0;i<dwSize;i++)
{
if((i%16)==0)
printf("\"\n\"");
printf("\\x%.2X",lpBuff[i]);
}
}//end of try
__finally
{
if(lpBuff) free(lpBuff);
CloseHandle(hFile);
}
return 0;
}
exe2hex killsrv.exekillsrv.exetxt
exe2hex killsrv.exe >killsrv.txtcopyps.hOK
OK!ey4s@21cn.com)

3/21/2005 5:24 PM

NT - - 3dapple.com

8 of 8

http://64.233.179.104/search?q=cache:eJ1qYFSCbJAJ:www.3dapple...

()

| | | TOP |
3dapple

3dapple

| | | | | | |
Copyright www.esang.cn 2002-2005 All reserved. Design by:Apple Multimedia,,

3/21/2005 5:24 PM

You might also like