Code/Python

SendMessage by winappdbg

badcob 2013. 6. 12. 15:27

특정 Control에 특정 메세지를 전송.

target window 아래 child window을 뒤져 원하는 핸들값을 찾아내고 메시지를 전송.


from winappdbg import System, version, HexDump, win32
import sys, time

def send_input(hwnd, msg):
    for c in msg:
            win32.SendMessage(hwnd, user32.WM_CHAR, ord(c), 0)
            time.sleep(0.5)

user32 = win32.user32

txt = 'I am Legend.\n'

system = System()

for window in system.get_windows():
    if window.classname == 'Notepad':
        tmp =  user32.EnumChildWindows(window)
        for x in tmp:
            if user32.GetClassNameA(x) == 'Edit':
                send_input(x, txt)