Debug Technique

Size: px
Start display at page:

Download "Debug Technique"

Transcription

1 Windows Hook Jerald Lee Contact Me : lucid7@paran.com 본문서는저자가 Windows Hook을공부하면서알게된것들을정리할목적으로작성되었습니다. 본인이 Windows System에대해아는것의거의없기때문에기존에존재하는문서들을짜집기한형태의문서로밖에만들수가없었습니다. 문서를만들면서참고한책, 관련문서등이너무많아일일이다기술하지못한점에대해원문저자들에게매우죄송스럽게생각합니다. 본문서의대상은운영체제와 Win32 API를어느정도알고있다는가정하에쓰여졌습니다. 본문서에기술된일부기법에대한자세한설명은책을참조하시길바랍니다. 제시된코드들은 Windows XP Service Pack2, Visual Studio.net 2003에서테스트되었습니다. 문서의내용중틀린곳이나수정해야할부분이있으면연락해주시기바랍니다. - 1 / 27 -

2 목 차 1. 사용되는기법들 디버그모드로해당프로세스의주소공간으로침투하기 Debug API를이용한 DLL Injection Debug API를이용한 API Hooking 참고문서 / 27 -

3 1. 사용되는기법들 이번에는 Debuging Technique을이용해 Hook을하는방법을다루어본다. 이기술은타겟프로세스를디버그모드로접근한뒤 Dll Injection으로도 Api Hooking으로도사용할수있으나난이도에비해결과가썩훌륭하지는않다. 무엇보다도디버깅을중지하면타겟프로세스까지중지되므로실제공격용으로는사용하기가벅차고 ( 멀티스레딩을통한방법이있다고는하는데.. 글쎄본인의실력으로는구현불가능이다. - -) 그냥원리를이해한다는측면에서정리해보았다 디버그모드로해당프로세스의주소공간으로침투하기 Windows는두가지종류의디버거를제공하는데사용자모드디버거와커널모드디버거가바로그것이다. 사용자모드디버거의경우응용프로그램을디버깅하기위해, 커널모드디버거의경우는운영체제의커널을디버깅하기위해사용되며일반적으로디바이스드라이버개발자들이대부분사용한다. 사용자모드디버거의특징은 Win32 Debugging API를사용한다는점이며우리는이 API를이용해서타겟프로세스의주소공간으로침투할것이다. 사용자모드디버거는타겟프로세스를디버깅하기위해 CreateProcess API를이용하는데, 함수의전달인자중 dwcreationflags 변수에 DEBUG_ONLY_THIS_PROCESS 값을사용하여디버깅을시작한다. 그리고발생하는다양한이벤트들을받기위해 WaitForDebugEvent API를호출하고특정한이벤트를처리한후에는 ContinueDebugEvent 함수를호출한다. 이방법의문제점은디버거가실행되는동안타겟프로세스도멈춰있다는것인데이문제는멀티스레드를사용해서해결할수있다. WaitForDebugEvent API가호출되었을때전달되는이벤트정보를저장하는 DEBUG_EVENT 구조체는다음과같다. typedef struct _DEBUG_EVENT { DWORD dwdebugeventcode; DWORD dwprocessid; DWORD dwthreadid; union { EXCEPTION_DEBUG_INFO Exception; CREATE_THREAD_DEBUG_INFO CreateThread; CREATE_PROCESS_DEBUG_INFO CreateProcessInfo; EXIT_THREAD_DEBUG_INFO ExitThread; - 3 / 27 -

4 EXIT_PROCESS_DEBUG_INFO ExitProcess; LOAD_DLL_DEBUG_INFO LoadDll; UNLOAD_DLL_DEBUG_INFO UnloadDll; OUTPUT_DEBUG_STRING_INFO DebugString; RIP_INFO RipInfo; u; DEBUG_EVENT; 디버그가위구조체의유니온안에나열된이벤트를처리하는동안타겟프로세스는멈춰있게되며 ContinueDebugEvent 함수가호출되면타겟프로세스는다시실행이된다. 일단여기까지의내용을의사코드를통해살펴보자. void _tmain(int argc, TCHAR *argv[]) { CreateProcess( NULL, // No module name (use command line). strprogrampath, // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. CREATE_NEW_CONSOLE DEBUG_ONLY_THIS_PROCESS, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) ; // Pointer to PROCESS_INFORMATION structure. while(waitfordebugevent(lpdebugevent, 1000) == 1) { if(exit_process) break; else { Do..something ; ContinueDebugEvent(dwProcessId, dwthreadid, dwcontinuestatus); - 4 / 27 -

5 먼저 strprogrampath 인자로넘어온프로그램을 CreateProcess 함수를이용하여디버그모드로디버깅을시작한다음 WaitForDebugEvent 함수로특정이벤트를기다린다. 특정이벤트에대한처리를해준뒤 ContinueDebugEvent 함수로진행을계속한다. 발생하는디버깅이벤트는아래의표와같다. 디버깅이벤트 CREATE_PROCESS_DEBUG_EVENT CREATE_THREAD_DEBUG_EVENT EXCEPTION_DEBUG_EVENT EXIT_PROCESS_DEBUG_EVENT EXIT_THREAD_DEBUG_EVENT LOAD_DLL_DEBUG_EVENT OUTPUT_DEBUG_STRING_EVENT UNLOAD_DLL_DEBUG_EVENT 설명새로운프로세스가디버깅되는프로세스내에서생성될때나디버거가이미활성화되어있는프로세스를디버깅할때마다생성된다. 디버깅되고있는프로세스에서새로운스레드가생성되거나디버거가이미활성화되어있는프로세스에대한디버깅을시작할때마다발생하며새로운스레드가사용자모드에서실행되기전에생성된다. 디버깅되고있는프로세스에서예외가발생할때마다생성된다. 액세스가불가능한메모리에대한액세스시도, 브레이크포인트명령실행, 0으로나눔명령실행또는 MSDN의 Structured Exception Handling 에서설명하고있는다른예외들을포함한다. 프로세스에있는마지막스레드가디버거를나갈때나 ExitProcess 함수를호출할때마다생성된다. 이이벤트는커널이프로세스의 DLL을언로드하고프로세스의종료코드를업데이트한후에곧바로발생한다. 디버깅되고있는프로세스의일부인스레드가종료할때마다생성된다. 커널은스레드의종료코드를업데이트하자마자이이벤트를생성한다. 디버깅되는프로세스가 DLL을로드할때마다생성된다. 이이벤트는시스템로더가 DLL을연결하거나디버깅되는프로세스가 LoadLibrary 함수를사용할때발생하며 DLL이해당주소공간에로드될때마다호출된다. 디버깅되는프로세스가 OutputDebugString 함수를호출할때생성된다. 디버깅되는프로세스가 FreeLibrary 함수를사용하여 DLL을언로드할때마다생성되며 DLL이프로세스의주소공간으로부터마지막으로언로드될때만발생한다. WaitForDebugEvent API 에서반환되는디버그이벤트를처리하고있는동안에타겟프로세스 - 5 / 27 -

6 의주소공간으로부터읽거나쓰기작업을할수있다. 디버깅당하는타겟프로세스의메모리로부터데이터를읽기위해서 ReadProcessMemory API를호출한다. ReadProcessMemory API 의원형은아래와같다. BOOL ReadProcessMemory( HANDLE hprocess, LPCVOID lpbaseaddress, LPVOID lpbuffer, SIZE_T nsize, SIZE_T* lpnumberofbytesread ); hprocess : [in], 메모리를읽어들일타겟프로세스의핸들, PROCESS_VM_READ 권한이있어야한다. lpbaseaddress : [in], 타겟프로세스의 Base Address lpbuffer : [out], 읽어들인메모리를저장할버퍼의포인터 nsize : [in], 메모리로부터읽어들일바이트의갯수 lpnumberofbytesread : [out], 버퍼에저장된바이트의개수 메모리에직접쓰는 API 는 WriteProcessMemory 이며 API 의원형은아래와같다. BOOL WriteProcessMemory( HANDLE hprocess, LPVOID lpbaseaddress, LPCVOID lpbuffer, SIZE_T nsize, SIZE_T* lpnumberofbyteswritten ); hprocess : [in], 수정할메모리프로세스의핸들, PROCESS_VM_WRITE 권한과 PROCESS_VM_OPERATION 권한이있어야한다. lpbaseaddress : [in], 타겟프로세스의 Base Address lpbuffer : [in], 타겟프로세스의메모리에쓸데이터를가지고있는버퍼의포인터 nsize : [in], 메모리에쓰여질바이트의개수 lpnumberofbyteswritten : [out], 메모리에쓰여진바이트의개수 - 6 / 27 -

7 일반적으로 WriteProcessMemony API를이용하여메모리에직접브레이크포인트를삽입한뒤발생하는 EXCEPTION_DEBUG_EVENT를잡아채서이후의작업을하게된다. 브레이크포인트를설정하기위해서는브레이크포인트를설정하고자하는메모리주소를갖고해당위치의 opcode를저장한후해당주소에브레이크포인트명령을쓰면되며 Intel Pentium 계열에서브레이크포인트를뜻하는명령은 INT 3 또는 opcode 값 0xCC이다. 브레이크포인트를설정해서원하는작업을수행한후에는원래의 opcode를다시원상태로복원시켜주어야한다. 브레이크포인트설정후특정 DLL을삽입하거나또는특정 DLL로부터발생하는특정 API를 Hook 할수있다. 전자는 DLL Injection이될것이고후자는 API Hook이될것이다. - 7 / 27 -

8 1.2. Debug API 를이용한 DLL Injection 먼저 Dll Injection 을알아보자. 1 대상프로그램을디버그모드로실행한다. 2 EXCEPTION_DEBUG_EVENT의 EXCEPTION_BREAKPOINT가발생하면 ( 디버그모드로시작하자마자발생하는첫번째예외 ) 타겟프로세스의컨텍스트와코드섹션의첫페이지를저장한다. 3 저장한영역에 LoadLibrary로특정 dll을로드하는코드와 0xcc를삽입한다. 4 EIP에실행시킬코드의주소를삽입한다. 5 ContinueDebugEvent를실행한다. 6 삽입한 LoadLibrary 실행후브레이크포인트가발생하면저장했던컨텍스트와코드섹션의첫페이지, 그리고 EIP를원상태로복귀한다. 7 ContinueDebugEvent를실행한다. 주의할것은디버그모드로들어가자마자첫번째 EXCEPTION_BREAKPOINT가발생한다는것이며이때타겟프로세스는실행되기전이다. 코드를삽입하는시기가바로이때이며두번째예외발생시에는원래코드를복원시켜주어야한다. 2 번에서첫번째코드페이지를가져오는코드는아래와같다. ( 전역변수 ) CProcessInfo = DebugEvent.u.CreateProcessInfo; pprocessbase = CProcessInfo.lpBaseOfImage; LPVOID CKeyboardHookDlg::GetFirstCodePage(HANDLE hprocess, PVOID pprocessbase) { DWORD baseofcode; DWORD pehdroffset; DWORD dwread; BOOL bret; // IMAGE_NT_HEADER의시작오프셋값을읽어옴 bret = ReadProcessMemory(hProcess, (PBYTE)pProcessBase + offsetof(image_dos_header, e_lfanew),&pehdroffset, sizeof(pehdroffset), &dwread); if (!bret sizeof(pehdroffset)!= dwread) { - 8 / 27 -

9 OutputDebugString("ERROR"); // Read in the IMAGE_NT_HEADERS.OptionalHeader.BaseOfCode field bret = ReadProcessMemory(hProcess, (PBYTE)pProcessBase + pehdroffset IMAGE_SIZEOF_FILE_HEADER + offsetof(image_optional_header, BaseOfCode), &baseofcode, sizeof(baseofcode), &dwread); if(!bret sizeof(baseofcode)!= dwread) { OutputDebugString("ERROR"); return (LPVOID)((DWORD)pProcessBase + baseofcode); // 첫번째섹션코드의 RVA 코드를자세히살펴보자. bret = ReadProcessMemory(hProcess, (PBYTE)pProcessBase + offsetof(image_dos_header, e_lfanew),&pehdroffset, sizeof(pehdroffset), &dwread); 파일의선두로부터 IMAGE_DOS_HEADER 구조체의 e_lfanew 값을읽어들여이값을 pehdroffset 변수에저장시킨다. e_lfanew에는 IMAGE_NT_HEADER 구조체의시작오프셋값이저장되어있다. bret = ReadProcessMemory(hProcess, (PBYTE)pProcessBase + pehdroffset IMAGE_SIZEOF_FILE_HEADER + offsetof(image_optional_header, BaseOfCode), &baseofcode, sizeof(baseofcode), &dwread); 파일의선두로부터 IMAGE_NT_HEADER 구조체로접근한다음 (pehdroffset) 4바이트를더하고 (PE x0 x0), IMAGE_SIZEOF_FILE_HEADER의값을더한뒤 (IMAGE_FILE_HEADER 구조체다음에 IMAGE_OPTINAL_HEADER 구조체가위치하고있다.) IMAGE_OPTINAL_HEADER 구조체의 BaseOfCode 값을읽어들여이값을 baseofcode 변수에저장한다. BaseOfCode에는코드영역의시작주소가저장되어있다.( 물론첫번째코드섹션이시작되는 RVA를의미한다.) 무슨말인지이해가가지않는사람을위해다시한번 PE 파일포맷을살펴보자 - 9 / 27 -

10 return (LPVOID)((DWORD)pProcessBase + baseofcode); 첫번째코드섹션이시작되는주소를반환한다. 다음으로 3 번에서 dll 을로드하고브레이크포인트를삽입한뒤실행하는코드는아래와같다. BOOL CKeyboardHookDlg::InjectionDll(HANDLE hprocess, HANDLE hthread, VOID * HModuleBase, CString szpathnamedll) { FARPROC LoadLibProc; DWORD dwread=0; BOOL bret; *poriginalcodepage=0; - 10 / 27 -

11 pfirstcodepage=null; *poriginalcodepage=null; // LoadLibraryA 의주소얻어옴 LoadLibProc = GetProcAddress(GetModuleHandle("KERNEL32.dll"), "LoadLibraryA"); if (!LoadLibProc) { OutputDebugString("ERROR"); // 타겟프로세스의첫번째코드페이지의주소를알아옴 pfirstcodepage = GetFirstCodePage(hProcess, HModuleBase); if(!pfirstcodepage) { OutputDebugString("ERROR"); OriginalContext.ContextFlags = CONTEXT_CONTROL; if(!getthreadcontext(hthread, &OriginalContext)) { OutputDebugString("ERROR"); // 실행프로세스의첫번째페이지백업 bret = ReadProcessMemory(hProcess, pfirstcodepage, poriginalcodepage, sizeof(poriginalcodepage), &dwread); if(!bret sizeof(poriginalcodepage)!= dwread) { OutputDebugString("ERROR"); // 구조체초기화 pmyloadlibrarya pnewcode = (pmyloadlibrarya)pfakecodepage; // sup esp, 1000h pnewcode->instr_sub = 0xEC81; pnewcode->operand_sub_value = PAGE_SIZE; // 페이지크기 (4096) - 11 / 27 -

12 // push < 매개변수 > pnewcode->instr_push = 0x68; pnewcode->operand_push_value = (DWORD)pFirstCodePage + offsetof(myloadlibrarya, DllName); // call < 함수주소 > ; LoadLibraryA() 호출 pnewcode->instr_call = 0xE8; pnewcode->operand_call_offset = (DWORD)LoadLibProc - (DWORD)pFirstCodePage offsetof(myloadlibrarya, instr_call) - 5; // 마지막에브레이크포인트삽입 pnewcode->instr_int_3 = 0xCC; strcpy(pnewcode->dllname, szpathnamedll.getbuffer(szpathnamedll.getlength())); // 우리의루틴을실행프로세스에 Write!! bret = WriteProcessMemory(hProcess, pfirstcodepage, &pfakecodepage, sizeof(pfakecodepage), &dwread); if(!bret sizeof(pfakecodepage)!= dwread) { OutputDebugString("ERROR"); // 실행포인터 (EIP) 를첫번째페이지로설정 FakeContext = OriginalContext; FakeContext.Eip = (DWORD)pFirstCodePage; // 실행스레드컨텍스트설정 if(!setthreadcontext(hthread, &FakeContext)) { OutputDebugString("ERROR"); return TRUE; 코드를자세히살펴보자 LoadLibProc = GetProcAddress(GetModuleHandle("KERNEL32.dll"), "LoadLibraryA"); pfirstcodepage = GetFirstCodePage(hProcess, HModuleBase); - 12 / 27 -

13 먼저 KERNEL32.dll 로부터 LoadLibraryA 의주소를얻어온다. 이후에 LoadLibProc 를이용해 임의의특정 dll 을로드한다. 주소를얻어온뒤첫번째코드섹션의주소를가져온다. OriginalContext.ContextFlags = CONTEXT_CONTROL; bret = ReadProcessMemory(hProcess, pfirstcodepage, poriginalcodepage, sizeof(poriginalcodepage), &dwread); 프로세스의컨텍스트를컨트롤하기위해 ContextFlags에 CONTEXT_CONTROL 값을할당한다. ContextFlags는여러값들이들어갈수있는데아래와같다. CONTEXT_CONTROL // SS:SP, CS:IP, FLAGS, BP CONTEXT_INTEGER // AX, BX, CX, DX, SI, DI CONTEXT_SEGMENTS // DS, ES, FS, GS CONTEXT_FLOATING_POINT // 387 state CONTEXT_DEBUG_REGISTERS // DB 0-3,6,7 CONTEXT_FULL=(CONTEXT_CONTROL CONTEXT_INTEGER > CONTEXT_SEGMENTS) 프로세스는시스템의현재상태의총합으로생각할수있는데프로세스는실행될때마다프로세스의레지스터와스택등을사용하며이것을프로세스컨텍스트라고한다. 일반적으로 GetThreadContext API를이용하여특정스레드의컨텍스트값을가져오기위해서는먼저적절한값들로초기화시켜야하는데사용된 CONTEXT_CONTROL을설정할경우주석과같이 SS:SP, CS:IP, FLAGS, BP를저장할수있게된다. 그리고첫번째코드섹션을읽어와서 poriginalcodepage에저장한다. pmyloadlibrarya pnewcode = (pmyloadlibrarya)pfakecodepage; // sup esp, 1000h pnewcode->instr_sub = 0xEC81; pnewcode->operand_sub_value = PAGE_SIZE; // 페이지크기 (4096) // push < 매개변수 > pnewcode->instr_push = 0x68; // push pnewcode->operand_push_value = (DWORD)pFirstCodePage + offsetof(myloadlibrarya, DllName); // call < 함수주소 > ; LoadLibraryA() 호출 pnewcode->instr_call = 0xE8; // call pnewcode->operand_call_offset = (DWORD)LoadLibProc - (DWORD)pFirstCodePage - 13 / 27 -

14 offsetof(myloadlibrarya, instr_call) - 5; // 마지막에브레이크포인트삽입 pnewcode->instr_int_3 = 0xCC; strcpy(pnewcode->dllname, szpathnamedll.getbuffer(szpathnamedll.getlength())); 이제첫번째코드페이지에삽입할구조체를설정하며해당구조체는 LoadLibraryA를호출하게된다. 삽입하게될구조체의모양은다음과같다. typedef struct _MyLoadLibraryA { WORD instr_sub; DWORD operand_sub_value; BYTE instr_push; DWORD operand_push_value; BYTE instr_call; DWORD operand_call_offset; BYTE instr_int_3; char DllName[1]; MyLoadLibraryA, *pmyloadlibrarya; LoadLibrary( load.dll ); 을호출하는코드를기계어로작성하기위해만든구조체이다. LoadLibrary를호출하는코드를어셈블리어로표현하면아래와같다. push ebp mov ebp,esp sub esp,40h push [dll의주소 ] call [LoadLibraryA의주소 ] LoadLibraryA의주소는각윈도우의버전, 서비스팩의버전에따라달라지는데 Dependency Walker를이용해서 Kernel32.dll의 Base Address에서 LoadLibraryA API의 Offset을더한값을사용하는것이가장쉽지만각윈도우버전, 서비스팩의버전만큼구현해야한다는것이다소번거롭다. 성상훈님의강좌에서는다음과같이해당주소를구해서사용하였다. pnewcode->operand_call_offset = (DWORD)LoadLibProc - (DWORD)pFirstCodePage offsetof(myloadlibrarya, instr_call) - 5; - 14 / 27 -

15 call이나 jmp 명령등의실행제어를변경하는명령어들은 (OP Code) 32비트환경에서보통 5바이트의크기를가지는데 OP Code 1바이트 + 이동할주소 4바이트가결합된크기이다. 이때이동할주소는 RVA이므로현재 OP Code를수행하고돌아올리턴주소를실제이동할주소에서뺀값으로기계어코드를생성하게된다. 위의코드에서 LoadLibraryA의주소 : LoadLibProc 현재실행중인코드의주소 : pfirstcodepage offsetof(myloadlibrarya, instr_call) 현재명령어 (OP Code) 의크기 : 5 가되는것이다. pnewcode->instr_int_3 = 0xCC; strcpy(pnewcode->dllname, szpathnamedll.getbuffer(szpathnamedll.getlength())); 이제마지막에 Break Point를삽입하고삽입할 Dll 이름을복사한다. 여기까지오면이제삽입할구조체가다완성된것이다. 자료를다채워넣은구조체를 WriteProcessMemory API를이용해서실행되고있는타겟프로세스에쓴다. bret = WriteProcessMemory(hProcess, pfirstcodepage, &pfakecodepage, sizeof(pfakecodepage), &dwread); 타겟프로세스 (hprocess) 의첫번째코드페이지에 (pfirstcodepage) 임의의 Dll을로드하는코드가들어있는구조체를 (pfakecodepage) 삽입한다. 자이제 4 번, 즉 EIP 를변경시키기만하면된다. FakeContext = OriginalContext; FakeContext.Eip = (DWORD)pFirstCodePage; // 실행스레드컨텍스트설정 if(!setthreadcontext(hthread, &FakeContext)) { OutputDebugString("ERROR"); 변조할컨텍스트에현재프로세스의컨텍스트를저장한후 EIP를첫번째코드페이지를가리키도록수정한다. 이후 SetThreadContext API를이용해현재프로세스의스레드에변조한컨텍스트를삽입한다. 다음은첨부한코드의실행화면이다 / 27 -

16 실행중이아닌프로세스를선택하여임의의 Dll 을주입할수있다. 소스파일은아래의주소에서받을수있다.( 실행파일포함 : KeyboardHook) 소스파일 : / 27 -

17 1.3. Debug API를이용한 API Hooking 이번에는 API Hook을알아보자. 전자에서는실행중이아닌프로그램을 CreateProcess API에 DEBUG_ONLY_THIS_PROCESS 플래그를주어서디버그모드로진입했었다. 이번에는실행중인프로그램을 Attach하여디버그모드에서 API를 Hooking하는방법을알아본다. 현재실행중인 Process를 Debug 모드로 Attach하기위해서 DebugActiveProcess API를사용한다. BOOL DebugActiveProcess( DWORD dwprocessid ); DebugActiveProcess API에넘겨주어야할정보는단지 Process ID뿐이다. 타겟프로세스의 ID만넘겨주면나머지는알아서하게된다. DebugActiveProcess를사용하여타겟프로세스를 Debug Mode로 Attach한이후진행되는과정은 CreateProcess와같다. 본문서에서는 Dual님의 Win32 유저계층에서의 API 문서에서소개된소스를바탕으로진행을한다. 다만소스에서약간틀린곳이있어수정하였음을미리밝힌다.(Dual님이누락한것같아보이는데정확히는알수가없다 -_-;) 방법은거의똑같다. 앞절에서는첫번째코드페이지에 Break Point를삽입했지만이번에는 Hooking하기원하는타겟 API의첫번째바이트에 Break Point를삽입하는것뿐이다. 다만이번에는실행중인프로세스에접근하는것이기때문에 VirtualQueryEx API와 VirtualProtectEx API를사용하여보호모드속성을조정한후 WriteProcessMemory를써야한다. 왜냐하면 CreateProcess API를사용하여프로세스를실행시켰을경우에는자연스럽게해당프로그램에대한제어권이 CreateProcess API를사용한프로그램으로넘어오지만다른사용자가실행시킨, 실행중인프로세스의메모리는다른프로세스에게는읽기전용으로되어있을것이기때문이다. 여기서앞절에서빼먹어버린 Copy-On-Write 라는, 매우중요한개념을설명하기로한다. Windows는가능한많은메모리페이지를다른프로세스와공유하려한다. 만약해당페이지를사용하는프로세스중어느하나가디버거에서실행중이어서이들페이지중하나가브레이크포인트를갖고있다면, 브레이크포인트는모든프로세스가공유하는해당페이지에있어서는안된다. 만약그렇다면디버거외부에서실행중인프로세스가해당코드를실행하자마자, 해당프로세스는충돌하게될것이다. 이러한상황을피하기위해서운영체제는특정한프로세 - 17 / 27 -

18 스를위해서변경된페이지가있는지살펴보고브레이크포인트가쓰인페이지를특정한프로세스만접근할수있도록복사본을만든다. 따라서프로세스가페이지에쓰자마자, 운영체제는해당페이지를복사한다.(Debugging Applications for Microsoft.net and Microsoft Windows 에서발췌함 ) 따라서 VirtualQueryEx API로보호모드속성을얻은후 VirtualProtectEx API로보호모드속성을조정하는데 (PAGE_EXECUTE_READWRITE) 이때 Windows는 Copy-On-Write를준비한다. VritualQueryEx API 의함수원형은아래와같다. SIZE_T VirtualQueryEx( HANDLE hprocess, LPCVOID lpaddress, PMEMORY_BASIC_INFORMATION lpbuffer, SIZE_T dwlength ); hprocess : [in], 메모리정보가필요한타겟프로세스의핸들 lpaddress : [in], 메모리지역정보 lpbuffer : [out], 반환된메모리의정보가담긴 MEMORY_BASIC_INFORMATION 구조체를가리키는포인터 dwlength : [in], lpbuffer의사이즈, Byte 이 API를이용하면해당프로세스의메모리영역에대한정보를얻을수있다. VirtualProtectEx API 의함수원형은아래와같다. BOOL VirtualProtectEx( HANDLE hprocess, LPVOID lpaddress, SIZE_T dwsize, DWORD flnewprotect, PDWORD lpfloldprotect ); hprocess : [in], 보호모드속성을조정할메모리의프로세스핸들 lpaddress : [in], 보호모드속성을조정할메모리의지역정보 dwsize : [in], 접근하는보호모드속성메모리의크기 flnewprotect : [in], 변경할보호모드의속성 - 18 / 27 -

19 lpfloldprotect : [out], 원래보호모드의속성을가리키는포인터 기본적인설명은대충했으니이제코드를살펴보도록한다. 기본적인것은앞절과대부분동일하므로핵심적인부분만보도록한다. // 프로세스를처음 Attach 했을때발생하는메시지 (case 3) case CREATE_PROCESS_DEBUG_EVENT: { // 실행된프로세스의정보를얻어옴 CProcessInfo = DebugEvent.u.CreateProcessInfo; // Send API의주소를가진라이브러리의핸들을가져옴 if(!(wsock_handle = GetModuleHandle("WS2_32.DLL")) ) { if(!(wsock_handle = LoadLibrary("WS2_32.DLL")) ) // 없을경우 Load한다. break; // 로드에실패하면 Break // Send API의주소를구한다. if(!(send_adr = GetProcAddress(Wsock_Handle,"send")) ) break; // 주소값을가져오지못하면 Break // send API의메모리정보를가져온다. VirtualQueryEx(CProcessInfo.hProcess, Send_Adr, &mbi, sizeof(mbi)); // send API의메모리프로텍트를가져와수정한다. NewProtect = mbi.protect; NewProtect &= ~(PAGE_READONLY PAGE_EXECUTE_READ); // 제외시키고 NewProtect = (PAGE_READWRITE); // ReadWrite 추가 // 보호모드조정 VirtualProtectEx(CProcessInfo.hProcess, Send_Adr, sizeof(char), NewProtect, &OldProtect); // 첫바이트를읽어온다. ReadProcessMemory(CProcessInfo.hProcess, Send_Adr, &FirstByte, sizeof(firstbyte), &cbbyte); - 19 / 27 -

20 // 읽어온첫바이트에 Break Point 설정. EXCEPTION_EVENT(0xCC) 기록 WriteProcessMemory(CProcessInfo.hProcess, Send_Adr, &BreakByte, sizeof(breakbyte), &cbbyte); // 보호모드다시원래대로조정 VirtualProtectEx(CProcessInfo.hProcess, Send_Adr, sizeof(char), OldProtect, &NewProtect); CREATE_PROCESS_DEBUG_EVENT 발생시작동하는코드이다. 코드에주석을상세히달아놓았으니별어려움을없으리라고본다. SEND API의주소를가지고있는 WS2_32.DLL을로드한다음 GetProcAddress API를이용해 SEND API의주소를구한다. VirtualQueryEx API로 SEND API의메모리정보를가져온다음메모리보호모드설정을가져와 Read-Write 권한을추가한다. 수정한보호모드를 VirtualProtectEx API를이용해서적용시킨다음 SEND API의첫바이트를읽어와 Break Point를삽입하고다시보호모드를원래대로복원시킨다. case EXCEPTION_BREAKPOINT: // 브레이크포인트이벤트이면 { if(firsthit == FALSE) // 첫번째브포변수체크 FirstHit = TRUE; else { // 첫바이트를원래대로돌림 WriteProcessMemory(CProcessInfo.hProcess, Send_Adr, &FirstByte,sizeof(FirstByte), &cbbyte); // Context Mode Org_Context.ContextFlags = CONTEXT_FULL; GetThreadContext(CProcessInfo.hThread, &Org_Context); // Context를구해온다. ESP = Org_Context.Esp; // API가끝나고리턴 ( 돌아갈 ) 주소 ESP4 = ESP + 4; //S ESP8 = ESP + 8; //buf Adr ESPC = ESP + 0xC; //len - 20 / 27 -

21 ESP10 = ESP + 0x10; //flag // len읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)ESPC, &Len, sizeof(dword), &cbbyte); buffer = malloc(len); // 길이만큼메모리할당 // Buffer 주소읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)ESP8, &BufAdr, sizeof(dword), &cbbyte); /* // Buffer 읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)BufAdr, buffer, Len, &cbbyte); */ memset(buffer, 0x44, Len); // 내용조작 WriteProcessMemory(CProcessInfo.hProcess, (void *)BufAdr, buffer, Len, &cbbyte); New_Context = Org_Context; // 복사본을만든다. New_Context.Eip = (unsigned long)debugevent.u.exception.exceptionrecord.exceptionaddress; SetThreadContext(CProcessInfo.hThread,&New_Context); // Context 를적용한다. ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, dwcontinuestatus); // 대상프로그램에결과반영 /* // 첫바이트를읽어온다. ReadProcessMemory(CProcessInfo.hProcess, Send_Adr, &FirstByte, sizeof(firstbyte), &cbbyte); */ // 0xCC 를다시기록 WriteProcessMemory(CProcessInfo.hProcess, Send_Adr, &BreakByte, sizeof(breakbyte), - 21 / 27 -

22 &cbbyte); free(buffer); // 동적할당한메모리를놓아준다. AfxMessageBox("send 함수가발생하였습니다."); // 시각적효과 dwcontinuestatus = DBG_CONTINUE; dwcontinuestatus = DBG_CONTINUE; EXCEPTION_BREAKPOINT, 즉 Break Point 발생시작동하는함수이다. Break Point 이벤트가발생하면먼저변경했던 SEND API의첫번째바이트를원래대로돌려놓는다. 이제 SEND API의 Parameter를조작하기위해 GetThreadContext API를이용해 CONTEXT를정보를가져온다. Stack Overflow를이해한사람이라면무슨말인지알겠지만혹시나기억이가물가물한사람들을위해간단히살펴본다. #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int i=10; char c='a'; printf("%d %c", i, c); return 0; 위의소스코드는간단하게콘솔에 i와 c를출력하는프로그램이다. #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { 00411A30 push ebp 00411A31 mov ebp,esp 00411A33 sub esp,0d8h 00411A39 push ebx 00411A3A push esi - 22 / 27 -

23 00411A3B push 00411A3C lea 00411A42 mov 00411A47 mov 00411A4C rep stos int i=10; 00411A4E mov char c='a'; 00411A55 mov edi edi,[ebp-0d8h] ecx,36h eax,0cccccccch dword ptr [edi] dword ptr [i],0ah byte ptr [c],41h printf("%d %c", i, c); 00411A59 movsx eax,byte ptr [c] 00411A5D push eax 00411A5E mov ecx,dword ptr [i] 00411A61 push ecx 00411A62 push offset string "%d %c" (4240C8h) 00411A67 (411497h) 00411A6C add esp,0ch return 0; 00411A6F xor eax,eax 위는원래의소스코드를 Disassembly 한화면이다. 파란색글씨를보면 Parameter인 i 값과 c 값을먼저 Stack에 push 한다음 printf를 CALL 하고있다. 즉, SEND API가 CALL 되기직전에 Break Point에의해멈추어진상태라면 SEND API 에들어가는 Parameter 값은이미 Stack에 push된상태임을짐작할수있다. ( 기억이잘나지는않는데이게아마파스칼방식이던가? 뭐그랬던것같다. 그리고 Intel은파스칼방식을사용한다.) 자다시앞으로돌아가서얻어온 CONTEXT 정보중에서 ESP 값을기준으로 Return Address 를수정한다.( 왜 ESP 값을기준으로하는지모른다면 Statck Overflow 강좌를한번읽어볼것을권한다. int send(socket s, const char* buf, int len, int flags); 주석에도설명을해놓았지만위의 SEND API의원형에서볼수있듯이 (MFC에서는 CSocket::Send를사용하며 Parameter가틀리지만내부적으로는 send() 함수를이용하기때문에이상없이작동한다.) ESP4는 Parameter s를, ESP8은 Parameter buf의주소를, ESPC는 - 23 / 27 -

24 Parameter len 을, ESP10 은 Parameter flags 를가리킨다. 위의변수중우리가주목해야할것은바로 ESP8과 ESPC이다. ESP8에는 Send API를사용해전송되는문자열이, ESPC는전송된문자열의길이를가리키게된다. // len읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)ESPC, &Len, sizeof(dword), &cbbyte); buffer = malloc(len); // 길이만큼메모리할당 // Buffer 주소읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)ESP8, &BufAdr, sizeof(dword), &cbbyte); // Buffer 읽어옴 ReadProcessMemory(CProcessInfo.hProcess, (void *)BufAdr, buffer, Len, &cbbyte); 위의코드가실제 Send API를통해전송되는문자열을읽어오는핵심적인부분이다. 보내진문자열의길이를읽어와서그길이만큼메모리를할당한다. 문자열이저장된곳의주소를읽어온다음그주소에위치한문자열을읽어와 buffer 변수에저장한다. (buffer에저장된값을문자열로변환하는방법을몇일고민했지만본인의내공이딸리는관계로그냥넘어갔다 -_-;) 이후의소스는 buffer 변수에임의의문자를덮어써서전송되는문자열을조작하는것을나타내고있다. memset(buffer, 0x44, Len); // 내용조작 WriteProcessMemory(CProcessInfo.hProcess, (void *)BufAdr, buffer, Len, &cbbyte); New_Context = Org_Context; // 복사본을만든다. New_Context.Eip = (unsigned long)debugevent.u.exception.exceptionrecord.exceptionaddress; SetThreadContext(CProcessInfo.hThread,&New_Context); // Context를적용한다. ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, dwcontinuestatus); - 24 / 27 -

25 // 0xCC를다시기록 WriteProcessMemory(CProcessInfo.hProcess, Send_Adr, &BreakByte, sizeof(breakbyte), &cbbyte); free(buffer); // 동적할당한메모리를놓아준다. Buffer 변수에 0x44로값으로채운후 WriteProcessMemory API를이용해메모리에덮어쓴다. 그리고변경한 CONTEXT 값을다시설정하는데설정하기전 EIP 값을변경시킨다. DebugEvent.u.Exception.ExceptionRecord.ExceptionAddress 값은 Exception이발생한곳의주소를가리킨다. 즉 EIP 값을 Debug Event가발생한곳으로돌려줌으로써마치 Debug Event 가발생하지않았던것처럼위장할수있다. 지금까지설명했던동작들을계속반복하기위해 Break Point를다시설정한후 buffer의메모리를해제한다. 다음은해당프로그램을이용해실제로전송되는내용을조작하는방법과화면이다. 간단하게제작한 C/S 프로그램과 API Hooking 프로그램을사용해전송되는문자열을 DDD로조작할수있다. ( 해당프로그램은버그가꽤많이존재한다. 역시나내공이부족해버그를다잡지못했으니알아서고쳐쓰기를바랄뿐이다. - -) 1. SimpleServer.exe 를실행한후 START 버튼을누른다. 2. SimpleClient.exe 를실행한후 Connect 버튼을누른다 / 27 -

26 3. API Hook Program 을실행하여 Find 버튼을눌러 SimpleClient 를선택한뒤 Injection 버튼 을누른다. 4. SimpleClient 의에디트창에임의의문자를쓴다음 Send 버튼을누른다. 5. SimpleServer 화면에 DDDDDDDD 이전송되었음을알수있다. APIHook 의소스파일및 SimpleC/S 의실행파일은아래의주소에서받을수있다. 소스파일 (APIHook) : 소스파일 (SimpleC/S) : / 27 -

27 1.4. 참고문서 WebSite 1. Microsoft PE File Pormat API Hooking Revealed ( 3. 동우의홈페이지 4. #44u6115f:p 5. 지니야닷넷 6. WIN32 - Inside Debug API Book 1. Debugging Applications for.net and windows, Microsoft Press 2. Visual C++.net programming bible 2 nd Edition, 김용성저 Special Thanks to Code Test and Modify : 이재익 (fishacker, duckgu9@nate.com) 박경호 (gafim2@nate.com) - 27 / 27 -

Deok9_Exploit Technique

Deok9_Exploit Technique Exploit Technique CodeEngn Co-Administrator!!! and Team Sur3x5F Member Nick : Deok9 E-mail : DDeok9@gmail.com HomePage : http://deok9.sur3x5f.org Twitter :@DDeok9 > 1. Shell Code 2. Security

More information

Microsoft Word - UFuz3 분석.doc

Microsoft Word - UFuz3 분석.doc 파일퍼저 UFuz3 분석 이용일 (foryou2008@nate.com) 2008-07-26 0. 개요 UFuz3 는 eeye 에서공개한파일퍼저입니다. UFuz3 의기능분석및상세분석을통해, 퍼저는어떤모 습을갖추고있는지, 또한퍼저는내부적으로어떤방식으로동작하는지살펴보려고합니다. 1. 기능분석 UFuz3 는파일을파싱하는루틴내에 Integer Overflow 가존재하는지를검사합니다.

More information

hlogin2

hlogin2 0x02. Stack Corruption off-limit Kernel Stack libc Heap BSS Data Code off-limit Kernel Kernel : OS Stack libc Heap BSS Data Code Stack : libc : Heap : BSS, Data : bss Code : off-limit Kernel Kernel : OS

More information

Microsoft Word - building the win32 shellcode 01.doc

Microsoft Word - building the win32 shellcode 01.doc Win32 Attack 1. Local Shellcode 작성방법 By 달고나 (Dalgona@wowhacker.org) Email: zinwon@gmail.com Abstract 이글은 MS Windows 환경에서 shellcode 를작성하는방법에대해서설명하고있다. Win32 는 *nix 환경과는사뭇다른 API 호출방식을사용하기때문에조금복잡하게둘러서 shellcode

More information

API 매뉴얼

API 매뉴얼 PCI-DIO12 API Programming (Rev 1.0) Windows, Windows2000, Windows NT and Windows XP are trademarks of Microsoft. We acknowledge that the trademarks or service names of all other organizations mentioned

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

목 차 1. 개요 취약점분석추진배경 취약점요약 취약점정보 취약점대상시스템목록 분석 공격기법및기본개념 시나리오 공격코드

목 차 1. 개요 취약점분석추진배경 취약점요약 취약점정보 취약점대상시스템목록 분석 공격기법및기본개념 시나리오 공격코드 취약점분석보고서 [Aviosoft Digital TV Player Professional 1.x Stack Buffer Overflow] 2012-08-08 RedAlert Team 강동우 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 1.2. 취약점요약... 1 1.3. 취약점정보... 1 1.4. 취약점대상시스템목록... 1 2. 분석...

More information

Microsoft PowerPoint - a10.ppt [호환 모드]

Microsoft PowerPoint - a10.ppt [호환 모드] Structure Chapter 10: Structures t and Macros Structure 관련된변수들의그룹으로이루어진자료구조 template, pattern field structure를구성하는변수 (cf) C언어의 struct 프로그램의 structure 접근 entire structure 또는 individual fields Structure는

More information

No Slide Title

No Slide Title Copyright, 2017 Multimedia Lab., UOS 시스템프로그래밍 (Assembly Code and Calling Convention) Seong Jong Choi chois@uos.ac.kr Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul Seoul, Korea

More information

제목

제목 Development Technology Seminar 작 성 자 : 고형호 이 메 일 : hyungho.ko@gmail.com 최초작성일 : 2007.01.19 최종작성일 : 2007.02.05 버 전 : 01.05 홈 피 : www.innosigma.com Goal Exception Handling 1. SEH vs. CEH Exception Handling

More information

Deok9_PE Structure

Deok9_PE Structure PE Structure CodeEngn Co-Administrator!!! and Team Sur3x5F Member Nick : Deok9 E-mail : DDeok9@gmail.com HomePage : http://deok9.sur3x5f.org Twitter :@DDeok9 1. PE > 1) PE? 2) PE 3) PE Utility

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2 제 17 장동적메모리와연결리스트 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

UI TASK & KEY EVENT

UI TASK & KEY EVENT T9 & AUTOMATA 2007. 3. 23 PLATFORM TEAM 정용학 차례 T9 개요 새로운언어 (LDB) 추가 T9 주요구조체 / 주요함수 Automata 개요 Automata 주요함수 추후세미나계획 질의응답및토의 T9 ( 2 / 30 ) T9 개요 일반적으로 cat 이라는단어를쓸려면... 기존모드 (multitap) 2,2,2, 2,8 ( 총 6번의입력

More information

In this tutorial i'll try to cover all of the known methods(or at least, those that I know =p) of injecting dll's into a proce

In this tutorial i'll try to cover all of the known methods(or at least, those that I know =p) of injecting dll's into a proce DLL injection Written by Darawk 편역 : poc@securityproof.net * 이글은 Codebreakers Journal Vol.1, No.1, 2007 에서발표된것이며, 오역이나 오타가있을수있으니원문을참고시기바랍니다. 이문서에서, 나는프로세스에 dll을삽입하는알려진 ( 적어도내가아는한에서 ) 방법들모두를다룰것이다. Dll injection은

More information

<4D F736F F F696E74202D204B FC7C1B7CEB1D7B7A55F F6E48616E646C6572B8A6C5EBC7D1BFA1B7AFB0CBC3E2B9D7BCF6C1A

<4D F736F F F696E74202D204B FC7C1B7CEB1D7B7A55F F6E48616E646C6572B8A6C5EBC7D1BFA1B7AFB0CBC3E2B9D7BCF6C1A 강연소개 Exception Handler 를통한에러검출및수정 디버깅을즐겨하십니까..? 에러를만나면반갑습니까..? 전화로버그보고를받았나요..? 잡히지않는버그!!!! 따분한강의 졸아도좋습니다!!!! 강연자소개 테스터 온라인게임클라이언트개발 로컬라이즈및해외지원업무 디버깅, 최적화, 호환성향상에관심 강연대상 x86 환경에서 Windows 프로그래밍 디버깅 / 에러추적은

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

IDA 5.x Manual 07.02.hwp

IDA 5.x Manual 07.02.hwp IDA 5.x Manual - Manual 01 - 영리를 목적으로 한 곳에서 배포금지 Last Update 2007. 02 이강석 / certlab@gmail.com 어셈블리어 개발자 그룹 :: 어셈러브 http://www.asmlove.co.kr - 1 - IDA Pro 는 Disassembler 프로그램입니다. 기계어로 되어있는 실행파일을 어셈블리언어

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

Chapter 4. LISTS

Chapter 4. LISTS C 언어에서리스트구현 리스트의생성 struct node { int data; struct node *link; ; struct node *ptr = NULL; ptr = (struct node *) malloc(sizeof(struct node)); Self-referential structure NULL: defined in stdio.h(k&r C) or

More information

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Example 3.1 Files 3.2 Source code 3.3 Exploit flow

More information

Content 1. DLL? 그게뭐야?

Content 1. DLL? 그게뭐야? DLL Injection 은어떻게이루어지는가? By bl4ck3y3 (http://hisjournal.net/blog) Abstract 루트킷을비롯하여바이러스, 악성코드등여러분야에두루쓰이는기법이 DLL Injection입니다. Windows에한정되어적용되는것이지만, Windows 자체의점유율이높은이유로아주효과적으로공격자가원하는작업을수행할수있는방법이죠. 최근루트킷에대해공부하면서이

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

Microsoft Word - [Windows Hook] 6.HideProcess.doc

Microsoft Word - [Windows Hook] 6.HideProcess.doc Hide Process Last Update : 2007 년 6 월 11 일 Written by Jerald Lee Contact Me : lucid78@gmail.com 본문서는 SSDT Hook을이용한프로세스를감추는기술에대해정리한것입니다. 제가알고있는지식이너무짧아가급적이면다음에언제보아도쉽게이해할수있도록쓸려고노력하였습니다. 기존에나와있는여러훌륭한문서들을토대로짜집기의형태로작성되었으며기술하지못한원문저자들에게매우죄송할따름입니다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C

02.Create a shellcode that executes /bin/sh Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes /bin/sh C 02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C language Assembly code Change permissions(seteuid())

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 9 장포인터 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 포인터란? 포인터 (pointer): 주소를가지고있는변수 메모리의구조 변수는메모리에저장된다. 메모리는바이트단위로액세스된다. 첫번째바이트의주소는 0, 두번째바이트는 1, 변수와메모리

More information

INTRO Basic architecture of modern computers Basic and most used assembly instructions on x86 Installing an assembly compiler and RE tools Practice co

INTRO Basic architecture of modern computers Basic and most used assembly instructions on x86 Installing an assembly compiler and RE tools Practice co Basic reverse engineering on x86 This is for those who want to learn about basic reverse engineering on x86 (Feel free to use this, email me if you need a keynote version.) v0.1 SeungJin Beist Lee beist@grayhash.com

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

UI TASK & KEY EVENT

UI TASK & KEY EVENT 2007. 2. 5 PLATFORM TEAM 정용학 차례 CONTAINER & WIDGET SPECIAL WIDGET 질의응답및토의 2 Container LCD에보여지는화면한개 1개이상의 Widget을가짐 3 Container 초기화과정 ui_init UMP_F_CONTAINERMGR_Initialize UMP_H_CONTAINERMGR_Initialize

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 10 포인터 01 포인터의기본 02 인자전달방법 03 포인터와배열 04 포인터와문자열 변수의주소를저장하는포인터에대해알아본다. 함수의인자를값과주소로전달하는방법을알아본다. 포인터와배열의관계를알아본다. 포인터와문자열의관계를알아본다. 1.1 포인터선언 포인터선언방법 자료형 * 변수명 ; int * ptr; * 연산자가하나이면 1 차원포인터 1 차원포인터는일반변수의주소를값으로가짐

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF 개발환경및사용툴 Shellcode 작성하기... 4 가. cmd 쉘 ) 소스코드작성 ) 디스어셈블리 ) 어셈블리코드편집 간단

목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF 개발환경및사용툴 Shellcode 작성하기... 4 가. cmd 쉘 ) 소스코드작성 ) 디스어셈블리 ) 어셈블리코드편집 간단 기술문서 `09. 11. 02. 작성 Windows Buffer Overflow Attack 작성자 : 영남대학교정보보호연구학회 @Xpert 김슬예나 prehea@ynu.ac.kr 1 목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF... 3 2. 개발환경및사용툴... 3 3. Shellcode 작성하기... 4 가. cmd 쉘... 4

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

KNK_C_05_Pointers_Arrays_structures_summary_v02

KNK_C_05_Pointers_Arrays_structures_summary_v02 Pointers and Arrays Structures adopted from KNK C Programming : A Modern Approach 요약 2 Pointers and Arrays 3 배열의주소 #include int main(){ int c[] = {1, 2, 3, 4}; printf("c\t%p\n", c); printf("&c\t%p\n",

More information

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D> 뻔뻔한 AVR 프로그래밍 The Last(8 th ) Lecture 유명환 ( yoo@netplug.co.kr) INDEX 1 I 2 C 통신이야기 2 ATmega128 TWI(I 2 C) 구조분석 4 ATmega128 TWI(I 2 C) 실습 : AT24C16 1 I 2 C 통신이야기 I 2 C Inter IC Bus 어떤 IC들간에도공통적으로통할수있는 ex)

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

취약점분석보고서 [Photodex ProShow Producer v ] RedAlert Team 안상환

취약점분석보고서 [Photodex ProShow Producer v ] RedAlert Team 안상환 취약점분석보고서 [Photodex ProShow Producer v5.0.3256] 2012-07-24 RedAlert Team 안상환 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 2. Photodex ProShow Producer Buffer Overflow 취약점분석... 2 2.1. Photodex ProShow Producer Buffer

More information

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures 단일연결리스트 (Singly Linked List) 신찬수 연결리스트 (linked list)? tail 서울부산수원용인 null item next 구조체복습 struct name_card { char name[20]; int date; } struct name_card a; // 구조체변수 a 선언 a.name 또는 a.date // 구조체 a의멤버접근 struct

More information

Microsoft Word - MSOffice_WPS_analysis.doc

Microsoft Word - MSOffice_WPS_analysis.doc MS Office.WPS File Stack Overflow Exploit 분석 (http://milw0rm.com/ 에공개된 exploit 분석 ) 2008.03.03 v0.5 By Kancho ( kancholove@gmail.com, www.securityproof.net ) milw0rm.com에 2008년 2월 13일에공개된 Microsoft Office.WPS

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

hlogin7

hlogin7 0x07. Return Oriented Programming ROP? , (DEP, ASLR). ROP (Return Oriented Programming) (excutable memory) rop. plt, got got overwrite RTL RTL Chain DEP, ASLR gadget Basic knowledge plt, got call function

More information

PowerPoint Template

PowerPoint Template BoF 원정대서비스 목차 환경구성 http://www.hackerschool.org/hs_boards/zboard.php?id=hs_notice&no=1170881885 전용게시판 http://www.hackerschool.org/hs_boards/zboard.php?id=bof_fellowship Putty War game 2 LOB 란? 해커스쿨에서제공하는

More information

슬라이드 1

슬라이드 1 핚국산업기술대학교 제 14 강 GUI (III) 이대현교수 학습안내 학습목표 CEGUI 라이브러리를이용하여, 게임메뉴 UI 를구현해본다. 학습내용 CEGUI 레이아웃의로딩및렌더링. OIS 와 CEGUI 의연결. CEGUI 위젯과이벤트의연동. UI 구현 : 하드코딩방식 C++ 코드를이용하여, 코드내에서직접위젯들을생성및설정 CEGUI::PushButton* resumebutton

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 얇지만얇지않은 TCP/IP 소켓프로그래밍 C 2 판 4 장 UDP 소켓 제 4 장 UDP 소켓 4.1 UDP 클라이언트 4.2 UDP 서버 4.3 UDP 소켓을이용한데이터송싞및수싞 4.4 UDP 소켓의연결 UDP 소켓의특징 UDP 소켓의특성 싞뢰할수없는데이터젂송방식 목적지에정확하게젂송된다는보장이없음. 별도의처리필요 비연결지향적, 순서바뀌는것이가능 흐름제어 (flow

More information

Lab 3. 실습문제 (Single linked list)_해답.hwp

Lab 3. 실습문제 (Single linked list)_해답.hwp Lab 3. Singly-linked list 의구현 실험실습일시 : 2009. 3. 30. 담당교수 : 정진우 담당조교 : 곽문상 보고서제출기한 : 2009. 4. 5. 학과 : 학번 : 성명 : 실습과제목적 : 이론시간에배운 Singly-linked list를실제로구현할수있다. 실습과제내용 : 주어진소스를이용해 Singly-linked list의각함수를구현한다.

More information

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

how_2_write_Exploit_4_the_MSF_v3.x.hwp

how_2_write_Exploit_4_the_MSF_v3.x.hwp Metasploit v3.0 을이용한 Exploit 작성하기 2008.1.18 본문서는 Jerome 님의 Writing Windows Exploits 을기반으로작성된문서임을밝힙니다. rich4rd rich4rd.lim@gmail.com - 1 - 목차. 1. 소개및개요 2. 배경지식 3. Exploit module 실습 3.1 Exploit module 수정하기

More information

초보자를 위한 C# 21일 완성

초보자를 위한 C# 21일 완성 C# 21., 21 C#., 2 ~ 3 21. 2 ~ 3 21.,. 1~ 2 (, ), C#.,,.,., 21..,.,,, 3. A..,,.,.. Q&A.. 24 C#,.NET.,.,.,. Visual C# Visual Studio.NET,..,. CD., www. TeachYour sel f CSharp. com., ( )., C#.. C# 1, 1. WEEK

More information

CKKeyPro 적용가이드

CKKeyPro 적용가이드 3.20 사이버테러악성코드분석보고서 라온시큐어보안기술연구팀 작성일 : 2013. 03 페이지 : 1/15 Introduction 2013년 3월 20일오후, MBC, KBS, YTN, 농협, 신한은행, 제주은행전산망장애가동시에발생하였다. 피해기관들의호스트약 500여대에오류메시지가화면에나타났으며악성코드에감염된호스트는사용할수없는상태가되었다. 현재까지정확한침투경로가밝혀지지않고있다.

More information

Microsoft Word - Heap_Spray.doc

Microsoft Word - Heap_Spray.doc Heap Spray 본문서는 최근 웹 브라우저를 이용한 공격에 사용되는 Heap Spray 기법에 대한 내용을 수록하였다. 관련 내용에 대하여 많은 도움이 되기 바란다. 문서 내용은 초보자도 쉽게 이해할 수 있도록 관련 내용에 대한 설명을 포함하였다. Hacking Group OVERTIME force< forceteam01@gmail.com > 2007.05.13

More information

UI TASK & KEY EVENT

UI TASK & KEY EVENT KEY EVENT & STATE 구현 2007. 1. 25 PLATFORM TEAM 정용학 차례 Key Event HS TASK UI TASK LONG KEY STATE 구현 소스코드및실행화면 질의응답및토의 2 KEY EVENT - HS TASK hs_task keypad_scan_keypad hs_init keypad_pass_key_code keypad_init

More information

<4D F736F F F696E74202D B3E22032C7D0B1E220C0A9B5B5BFECB0D4C0D3C7C1B7CEB1D7B7A1B9D620C1A638B0AD202D20C7C1B7B9C0D320BCD3B5B5C0C720C1B6C0FD>

<4D F736F F F696E74202D B3E22032C7D0B1E220C0A9B5B5BFECB0D4C0D3C7C1B7CEB1D7B7A1B9D620C1A638B0AD202D20C7C1B7B9C0D320BCD3B5B5C0C720C1B6C0FD> 2006 년 2 학기윈도우게임프로그래밍 제 8 강프레임속도의조절 이대현 한국산업기술대학교 오늘의학습내용 프레임속도의조절 30fps 맞추기 스프라이트프레임속도의조절 프레임속도 (Frame Rate) 프레임속도란? 얼마나빨리프레임 ( 일반적으로하나의완성된화면 ) 을만들어낼수있는지를나타내는척도 일반적으로초당프레임출력횟수를많이사용한다. FPS(Frame Per Sec)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning C Programming Practice (II) Contents 배열 문자와문자열 구조체 포인터와메모리관리 구조체 2/17 배열 (Array) (1/2) 배열 동일한자료형을가지고있으며같은이름으로참조되는변수들의집합 배열의크기는반드시상수이어야한다. type var_name[size]; 예 ) int myarray[5] 배열의원소는원소의번호를 0 부터시작하는색인을사용

More information

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D> 학습목표 통신프로그램이무엇인지이해한다. 을이용한 IPC 기법을이해한다. 함수를사용해프로그램을작성할수있다. IT CookBook, 유닉스시스템프로그래밍 2/20 목차 의개념 함수 해제함수 의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 의개념 파일을프로세스의메모리에매핑 프로세스에전달할데이터를저장한파일을직접프로세스의가상주소공간으로매핑 read, write

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

Frama-C/JESSIS 사용법 소개

Frama-C/JESSIS 사용법 소개 Frama-C 프로그램검증시스템소개 박종현 @ POSTECH PL Frama-C? C 프로그램대상정적분석도구 플러그인구조 JESSIE Wp Aorai Frama-C 커널 2 ROSAEC 2011 동계워크샵 @ 통영 JESSIE? Frama-C 연역검증플러그인 프로그램분석 검증조건추출 증명 Hoare 논리에기초한프로그램검증도구 사용법 $ frama-c jessie

More information

익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost

익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost 익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter 2.7.3 ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost Easy RM to MP3 Converter_v2.7.3을이용하여 ROP 공격에대하여알아볼것이다. 익스플로잇을위해구성된환경은아래와같다. - Windows XP Professional

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

API 매뉴얼

API 매뉴얼 PCI-TC03 API Programming (Rev 1.0) Windows, Windows2000, Windows NT, Windows XP and Windows 7 are trademarks of Microsoft. We acknowledge that the trademarks or service names of all other organizations

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

1. Execution sequence 첫번째로 GameGuard 의실행순서는다음과같습니다 오전 10:10:03 Type : Create 오전 10:10:03 Parent ID : 0xA 오전 10:10:03 Pro

1. Execution sequence 첫번째로 GameGuard 의실행순서는다음과같습니다 오전 10:10:03 Type : Create 오전 10:10:03 Parent ID : 0xA 오전 10:10:03 Pro #44u61l5f GameGuard 에대한간단한분석. By Dual5651 (http://dualpage.muz.ro) 요약 : 이문서는분석자의입장에서 GameGuard의동작을모니터링한것에대한것입니다. 실제 GameGuard의동작방식과는다소차이가있을수있습니다. 이문서에등장하는모든등록상표에대한저작권은해당저작권자에게있습니다. 1. Execution sequence

More information

Microsoft PowerPoint - o8.pptx

Microsoft PowerPoint - o8.pptx 메모리보호 (Memory Protection) 메모리보호를위해 page table entry에 protection bit와 valid bit 추가 Protection bits read-write / read-only / executable-only 정의 page 단위의 memory protection 제공 Valid bit (or valid-invalid bit)

More information

vi 사용법

vi 사용법 유닉스프로그래밍및실습 gdb 사용법 fprintf 이용 단순디버깅 확인하고자하는코드부분에 fprintf(stderr, ) 를이용하여그지점까지도달했는지여부와관심있는변수의값을확인 여러유형의단순한문제를확인할수있음 그러나자세히살펴보기위해서는디버깅툴필요 int main(void) { int count; long large_no; double real_no; init_vars();

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

61 62 63 64 234 235 p r i n t f ( % 5 d :, i+1); g e t s ( s t u d e n t _ n a m e [ i ] ) ; if (student_name[i][0] == \ 0 ) i = MAX; p r i n t f (\ n :\ n ); 6 1 for (i = 0; student_name[i][0]!= \ 0&&

More information

Chapter ...

Chapter ... Chapter 4 프로세서 (4.9절, 4.12절, 4.13절) Contents 4.1 소개 4.2 논리 설계 기초 4.3 데이터패스 설계 4.4 단순한 구현 방법 4.5 파이프라이닝 개요*** 4.6 파이프라이닝 데이터패스 및 제어*** 4.7 데이터 해저드: 포워딩 vs. 스톨링*** 4.8 제어 해저드*** 4.9 예외 처리*** 4.10 명령어 수준

More information

Reusing Dynamic Linker For Exploitation Author : Date : 2012 / 05 / 13 Contact : Facebook : fb.me/kwonpwn

Reusing Dynamic Linker For Exploitation Author :  Date : 2012 / 05 / 13 Contact : Facebook : fb.me/kwonpwn Reusing Dynamic Linker For Exploitation Author : pwn3r @ B10S @WiseGuyz Date : 2012 / 05 / 13 Contact : austinkwon2@gmail.com Facebook : fb.me/kwonpwn3r Abstract 대부분의 Unix 에선공유라이브러리를메모리에로드하고프로그램과 link

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

More information

슬라이드 1

슬라이드 1 2007 년 2 학기윈도우게임프로그래밍 제 7 강프레임속도의조절 이대현 핚국산업기술대학교 학습내용 프레임속도의조절 30fps 맞추기 스프라이트프레임속도의조절 프레임속도 (Frame Rate) 프레임속도란? 얼마나빨리프레임 ( 일반적으로하나의완성된화면 ) 을만들어낼수있는지를나타내는척도 일반적으로초당프레임출력횟수를많이사용핚다. FPS(Frame Per Sec)

More information

AhnLab_template

AhnLab_template Injection 기법및분석법 공개버전 2014.04.17 안랩시큐리티대응센터 (ASEC) 분석팀차민석책임연구원 Contents 01 02 03 04 05 06 07 왜 Injection 기법인가? Injection 기법배경지식 DLL Inection 기법 Code Injection 기법유용한도구 Case study 맺음말및과제 01 왜 Injection 기법인가?

More information

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

More information

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

More information

DLL Injection

DLL Injection DLL Injection REVERSING CreateRemoteThread() 를중점으로 DLL Injection 에대하여설명 [ Rnfwoa] 김경민 목차 목차 1 개요 1 2 DLL ( Dynamic Link Library ) 2 3 AppInit_DLLs 3 4 원격스레드생성 5 4.1 핸들확보 6 4.2 공간할당 7 4.3 DLL Name 기록 8

More information

본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasplo

본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasplo 본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasploit Framework(MSF) 이란? bluearth in N@R 2003년오픈소스로발표된취약점발견및공격을위한

More information

Microsoft PowerPoint - a8a.ppt [호환 모드]

Microsoft PowerPoint - a8a.ppt [호환 모드] 이장의내용 8 장고급프로시저 스택프레임 재귀 (Recursion) Invoke, Addr, Proc, Proto 디렉티브 다중모듈프로그램작성 2 8.2 스택프레임 Stack Frame ( 또는 activation record) procedure 의다음사항을저장한 영역 urn address passed parameter ( 스택매개변수 ) saved register

More information

<B1E2BCFAB9AEBCAD28C0CCB5BFBCF6295F494454486F6F6B696E672E687770>

<B1E2BCFAB9AEBCAD28C0CCB5BFBCF6295F494454486F6F6B696E672E687770> IDT Hooking을 이용한 Simple KeyLogger 이동수 alonglog@is119.jnu.ac.kr 개 요 커널 Hooking에 관하여 공부하는 중에 IDT Hooking에 관하여 알게 되었다. 이전에 공부하 였던 SSDT Hooking과는 다른 요소가 많다. IDT Hooking을 공부하면서 컴퓨터의 인터럽트 과정을 이해할 수 있는 좋은 계기가

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7> 제14장 동적 메모리 할당 Dynamic Allocation void * malloc(sizeof(char)*256) void * calloc(sizeof(char), 256) void * realloc(void *, size_t); Self-Referece NODE struct selfref { int n; struct selfref *next; }; Linked

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

DCL Debugging Support

DCL Debugging Support DCL Runtime Debugging Support 2005.06.08 김대중 http://www.sysdeveloper.net/daejung 요약 버그없는소프트웨어를개발하는것은결코쉬운일이아니다. 대부분의상업적개발도구들이소스프로그램을추적할수있도록하는디버깅환경을제공하고있고이러한것들은단위함수들을디버깅하는데있어서매우유용한건사실이다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 메모리매핑 IT CookBook, 유닉스시스템프로그래밍 학습목표 통신프로그램이무엇인지이해한다. 메모리매핑을이용한 IPC 기법을이해한다. 메모리매핑함수를사용해프로그램을작성할수있다. 2/20 목차 메모리매핑의개념 메모리매핑함수 메모리매핑해제함수 메모리매핑의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 3/20 메모리매핑의개념 메모리매핑 파일을프로세스의메모리에매핑

More information

Lab 4. 실습문제 (Circular singly linked list)_해답.hwp

Lab 4. 실습문제 (Circular singly linked list)_해답.hwp Lab 4. Circular singly-linked list 의구현 실험실습일시 : 2009. 4. 6. 담당교수 : 정진우 담당조교 : 곽문상 보고서제출기한 : 2009. 4. 12. 학과 : 학번 : 성명 : 실습과제목적 : 이론시간에배운 Circular Singly-linked list를실제로구현할수있다. 실습과제내용 : 주어진소스를이용해 Circular

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information