Attacking the Attacking the User User-
- Machine
Machine Interface Interface
A A speach speach from from Volker Birk, Volker Birk, dingens dingens@ @bumens bumens. .org
- rg
Attacking the Attacking the User- -Machine Machine User - - PowerPoint PPT Presentation
Attacking the Attacking the User- -Machine Machine User Interface Interface A speach speach from from Volker Birk, Volker Birk, dingens dingens@ @bumens bumens. .org org A Chaos Computer Club ERFA Kreis Ulm Chaos Computer Club
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
I' I'm m in! ! That That was was eas easy! y! Mainfram Mainframe at the he ban bank Webs bserv erver PC PC
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
WM_NC WM_NCHITTE HITTEST ST
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
int int WinMain WinMain(HINSTANCE (HINSTANCE hInstance hInstance, , HINSTANCE HINSTANCE hPrevInstance hPrevInstance, , LPSTR LPSTR lpCmdLine lpCmdLine, , int nCmdShow int nCmdShow) { ) { MSG MSG msg msg; ; if (! if (!hPrevInstance hPrevInstance) ) InitApp InitApp( (hInstance hInstance); ); InitInstance InitInstance( (hInstance hInstance, , nCmdShow nCmdShow); ); while ( while (GetMessage GetMessage(& (&msg msg, NULL, 0, 0)) { , NULL, 0, 0)) { TranslateMessage TranslateMessage(& (&msg msg); ); DispatchMessage DispatchMessage(& (&msg msg); ); } } return msg. return msg.wParam wParam; ; } }
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
ATOM ATOM InitApp InitApp(HINSTANCE (HINSTANCE hInstance hInstance) { ) { WNDCLASSEX WNDCLASSEX wcex wcex; ; memset memset(& (&wcex wcex, 0, , 0, sizeof sizeof(WNDCLASSEX)); (WNDCLASSEX)); wcex wcex. .cbSize cbSize = = sizeof sizeof(WNDCLASSEX); (WNDCLASSEX); wcex wcex.style = CS_HREDRAW | CS_VREDRAW; .style = CS_HREDRAW | CS_VREDRAW; wcex wcex. .lpfnWndProc lpfnWndProc = (WNDPROC) = (WNDPROC) WndProc WndProc; ; wcex wcex. .hInstance hInstance = = hInstance hInstance; ; wcex wcex. .hIcon hIcon = = LoadIcon LoadIcon(NULL, IDI_APPLICATION); (NULL, IDI_APPLICATION); wcex wcex. .hCursor hCursor = = LoadCursor LoadCursor(NULL, IDC_ARROW); (NULL, IDC_ARROW); wcex wcex. .hbrBackground hbrBackground = (HBRUSH)(COLOR_WINDOW+1); = (HBRUSH)(COLOR_WINDOW+1); wcex wcex. .lpszClassName lpszClassName = " = "HelloWorldClass HelloWorldClass"; "; return return RegisterClassEx RegisterClassEx(& (&wcex wcex); ); } }
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
LRESULT CALLBACK LRESULT CALLBACK WndProc WndProc(HWND (HWND hWnd hWnd, UINT message, , UINT message, WPARAM WPARAM wParam wParam, LPARAM , LPARAM lParam lParam) { ) { PAINTSTRUCT PAINTSTRUCT ps ps; ; HDC HDC hdc hdc; ; switch (message) { switch (message) { case WM_PAINT: case WM_PAINT: hdc hdc = = BeginPaint BeginPaint( (hWnd hWnd, & , &ps ps); ); RECT RECT rt rt; ; GetClientRect GetClientRect( (hWnd hWnd, & , &rt rt); ); DrawText DrawText( (hdc hdc, "hello, world", 12, & , "hello, world", 12, &rt rt, , DT_CENTER); DT_CENTER); EndPaint EndPaint( (hWnd hWnd, & , &ps ps); ); break; break; case WM_CLICK: case WM_CLICK: ... ... } }
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
void void InstallHook InstallHook() { () { m_ m_hLib hLib = = LoadLibrary LoadLibrary("Hook. ("Hook.dll dll"); "); FARPROC FARPROC pSysMsgProc pSysMsgProc = = GetProcAddress GetProcAddress(m_ (m_hLib hLib, , " "KeyboardProc KeyboardProc"); "); PSETHOOKHANDLE PSETHOOKHANDLE pSetHookHandle pSetHookHandle = = (PSETHOOKHANDLE) (PSETHOOKHANDLE) GetProcAddress GetProcAddress(m_ (m_hLib hLib, , " "SetInfo SetInfo"); "); m_ m_hHook hHook = = SetWindowsHookEx SetWindowsHookEx(WH_KEYBOARD, (WH_KEYBOARD, (HOOKPROC) (HOOKPROC) pSysMsgProc pSysMsgProc, m_ , m_hLib hLib, 0); , 0); (* (*pSetHookHandle pSetHookHandle)(m_ )(m_hHook hHook); ); } }
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
static HHOOK static HHOOK hHook hHook = 0; = 0; void void SetInfo SetInfo(HHOOK (HHOOK newHook newHook) { ) {hHook hHook = = newHook newHook;} ;} LRESULT CALLBACK LRESULT CALLBACK KeyboardProc KeyboardProc( (int nCode int nCode, WPARAM , WPARAM wParam wParam, , LPARAM LPARAM lParam lParam) { ) { if ( if (nCode nCode == HC_ACTION && == HC_ACTION && wParam wParam == VK_DECIMAL) { == VK_DECIMAL) { // // hPlayback hPlayback = = SetWindowsHookEx SetWindowsHookEx(WH_JOURNALPLAYBACK, (WH_JOURNALPLAYBACK, // // JournalPlaybackProc JournalPlaybackProc, , theApp theApp.m_ .m_hInstance hInstance, 0); , 0); if ( if (lParam lParam & 0x80000000) & 0x80000000) keybd keybd_event(13502, 52, KEYEVENTF_KEYUP, 0); _event(13502, 52, KEYEVENTF_KEYUP, 0); else else keybd keybd_event(13502, 52, 0, 0); _event(13502, 52, 0, 0); return 1; return 1; } } return return CallNextHookEx CallNextHookEx( (hHook hHook, , nCode nCode, , wParam wParam, ,lParam lParam); ); } }
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org
CCC ERFA Kreis Ulm, Volker Birk dingens@bumens.org