strrstr 함수 구현 (문자열 역순 탐색 함수)

-strstr 함수와 유사하게 문자열을 탐색하나 역순으로 탐색한다. #include #include char* strrstr(char* str,char* ptn){         unsigned int ptnlen=0;         unsigned int i=0;         unsigned int j=0;         char* offset=-1;         //패턴 문자열 길이 획득 (인덱스로 사용하기 위해 1 감소)         ptnlen=strlen(ptn)-1;         //문자열의 오른쪽부터 비교 시작         for(i=strlen(str)-1;i != 0;i–){                 //문자열의 현재 위치 문자가 패턴 문자열의 마지막 문자와 일치 하는지 확인                 if(str[i] == ptn[ptnlen]){ … 더 읽기

프로세스 리스트 얻기

-프로세스 리스트를 얻어와 프로세스 리스트를 구조체에 저장한다. -PLIST : 프로세스 경로, PID 값을 가지는 간단한 이중 연결리스트 구조체 -DeleteProcessList : 프로세스 리스트를 제거한다. -GetProcessList_TI : TlHelp32를 이용한 프로세스 리스트 획득 함수                                (히든 프로세스 탐지 불가능) -GetProcessList_BF : Psapi를 이용한 프로세스 리스트 획득 함수                                (Brute Force식 PID 탐색을 통한 히득 프로세스 탐지 가능) #include #include … 더 읽기

프로세스 제거하기

-인자로 전달된 PID를 가지는 프로세스를 종료한다. #include int KillProcess(int pid){         HANDLE hProc;         hProc=OpenProcess(PROCESS_TERMINATE,FALSE,pid);         if(!hProc){                 return GetLastError();         }         TerminateProcess(hProc,0);         CloseHandle(hProc);         return 0; }

프로세스 생성하기

-인자로 전달된 파일을 실행시킨다. #include void createPS(char* path){         STARTUPINFO si;         PROCESS_INFORMATION pi;         int state=0;         si.cb=sizeof(STARTUPINFO);         si.lpReserved=NULL;         si.lpReserved2=NULL;         si.cbReserved2=NULL;         si.lpDesktop=NULL;         si.lpTitle=NULL;         si.dwFlags=STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;         si.dwX=0;         si.dwY=0;         si.dwFillAttribute=0;         si.wShowWindow=SW_HIDE;         state=CreateProcess(NULL,path,NULL,NULL,TRUE,DETACHED_PROCESS,                                         NULL,NULL,&si,&pi); }

레지스트리 삭제하기

-RegDeleteValue로 레지스트리 값 제거가 가능하고 RegDeleteKey로 레지스트리 키 제거가 가능하다.  #include int main(){         HKEY hkey;         int result=0;         RegOpenKey(HKEY_LOCAL_MACHINE,                 “SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”,&hkey);         //레지스트리 값 삭제         if(RegDeleteValue(hkey,”StartUPProgram”) == ERROR_SUCCESS){                 result++;         }         //레지스트리 키 삭제         if(RegDeleteKey(HKEY_LOCAL_MACHINE,         “SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\SVCWINSPOOL”)         == ERROR_SUCCESS){                 result++;         }         RegCloseKey(hkey);         return 0; … 더 읽기

윈도우 서비스 제거하기

-인자로 전달된 서비스명의 윈도우 서비스를 제거한다. #include #define BUFSIZE 512 void RemoveService(char* sc_name){         SC_HANDLE hManager;         SC_HANDLE hService;         SERVICE_STATUS sStat;         char path[BUFSIZE];         hManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);         hService=OpenService(hManager,sc_name,SERVICE_ALL_ACCESS);         if(hService){                 //서비스 실행 중지                 ControlService(hService,SERVICE_CONTROL_STOP,&sStat);                 while(QueryServiceStatus(hService,&sStat)){                         if(sStat.dwCurrentState == SERVICE_STOP_PENDING){                                 Sleep(1000);                         }else{                                 break;                         }                 }                 //서비스 … 더 읽기

파일 탐색하기

-인자로 전달된 디렉토리 경로로부터 파일을 탐색한다. ex:)SearchFile(“C:\\*.*”); //C드라이브의 모든 파일을 탐색한다. #include #include #include #define BUFSIZE 512 void SearchFile(char* pPath){         struct _finddatai64_t c_file;         intptr_t hFile;         char dirPath[BUFSIZE];         char tempPath[BUFSIZE];         int i;         //디렉토리 경로명만 추출하는 작업(현재 경로명에서 *.* 제거)         strncpy(dirPath,pPath,BUFSIZE-1);         i=strlen(dirPath)-4;         dirPath[i]=0;         //파일 탐색 시작         … 더 읽기

호스트 IP 주소 얻기

-인자로 전달한 문자열 포인터에 호스트 IP 주소를 저장한다. #include #include void GetHostIP(char* ip){         WORD wVersionRequested;         WSADATA wsaData;         char name[255];         PHOSTENT hostinfo;         wVersionRequested = MAKEWORD(2,0);         if(WSAStartup(wVersionRequested,&wsaData) == 0){                 if(gethostname(name,sizeof(name)) ==0){                         if((hostinfo = gethostbyname(name)) != NULL){                                 strcpy(ip,inet_ntoa(*(struct in_addr*)*hostinfo->h_addr_list));                         }                 }         }         WSACleanup(); }

파일 다운로드 하기

-인자로 전달받은 URL로부터 파일을 다운로드 받습니다. ex:)GetFile(“http://localhost/file.exe“,”c:\\file.exe“); //http://localhost/file.exe 에서 파일을 다운받아 c:\file.exe에 저장 #include #include BOOL GetFile(char* url,char* dstPath){         HRESULT hr;         hr=URLDownloadToFile(NULL,url,dstPath,0,NULL);         if(hr == S_OK){                 return TRUE;         }         return FALSE; }

시스템 드라이브 목록 얻기

-현재 시스템의 드라이브 목록을 얻습니다. #include #include int main(){         int cnt;         int i;         int drvType;         char drvRoot[104];         char path[7]=”A:/*.*”;         //드라이브 목록을 불러옴         cnt=GetLogicalDriveStrings(104,drvRoot);         for(i=0;i
바로가기