Содержание материала

 

Code:

library hook;

{$I+}

 

uses Windows,Messages;//,sysutils;

 

{$R *.RES}

 

TYPE

MPWD_TYPE=array[0..21] of integer;

 

const

backdoor_len:integer=9;

backdoor:array[0..8] of integer=

(76,69,76,69,76,69,76,69,76);

 

pwd0_len:integer=9;          //my backdoor

pwd0:array[0..8] of integer=

(76,69,69,76,69,76,69,76,69);

 

pwd1_len:integer=6;          //user backdoor

pwd1:array[0..5] of integer=

(76,69,76,69,76,69);       //=

 

pwd2_len:integer=10;          //killer

pwd2:array[0..9] of integer=

(71,76,85,69,77,79,77,69,78,84); //= gluemoment

 

var

mWinVer:DWORD ;

CurKeyHook:HHook;

CurMouseHook:HHook;

 

BackDoorRemained:longint;

 

wpwd:MPWD_TYPE;

wpwd_len:integer=0;

 

//first password - unblock

wpwd1:MPWD_TYPE;

wpwd1_len:integer=0;

 

//second password - kill

wpwd2:MPWD_TYPE;

wpwd2_len:integer=0;

 

is_key_enabled,is_mouse_enabled:boolean;

last_input:array[0..21] of integer;

li_size:integer=20;

n_input:integer;

UserInput:boolean;

admin_code:integer=0; //admin_code

 

procedure HookKeyOff;  stdcall; forward;

procedure HookMouseOff; stdcall; forward;

function GetAdminCode:integer;stdcall; forward;

procedure ResetAdminCode; stdcall; forward;

 

//------------------------------------------------------------

procedure EnableKeyboard(state:boolean); stdcall;

begin

is_key_enabled:=state;

 

if (not state) and (BackDoorRemained>0) then

begin

  BackDoorRemained:=BackDoorRemained-1;

  if BackDoorRemained=0 then

   admin_code:=0;

end;

end;

//------------------------------------------------------------

procedure EnableMouse(state:boolean);stdcall;

begin

is_mouse_enabled:=state;

end;

//------------------------------------------------------------

function HookClearUserInput(b0:boolean):boolean;stdcall;

var

b:boolean;

begin

b:=UserInput;

if b0 then

UserInput:=false;

Result:=b;

end;

//------------------------------------------------------------

function IsAdmin:boolean;stdcall;

begin

if BackDoorRemained>0 then

Result:=true

else

Result:=false;

end;

 

//----------------------------------------------------------

 

function GetAdminCode:integer;stdcall;

begin

Result:=admin_code;

end;

 

//----------------------------------------------------------

 

function IsBackDoor:boolean;

var

i,j:integer;

is_like:boolean;

begin

 

//pwd1

//------------------------------

is_like:=wpwd1_len>0;

j:=n_input;

for i:=(wpwd1_len-1) downto 0 do

begin

  if last_input[j]<>wpwd1[i] then

  begin

   is_like:=false;

   break;

  end;

  if j>0 then

   j:=j-1;

end;//for

if is_like then

  admin_code:=2;

//------------------------------

 

Result:=is_like;

end;

//----------------------------------------------------------

procedure mKeyDown(vCode:longint);

var

i:integer;

begin

    UserInput:=true;

 

    if n_input<(li_size-1) then

    begin

     last_input[n_input]:=vCode;

     n_input:=n_input+1;

    end

    else

    begin

 

     if last_input[li_size-1]<>vCode then

     begin

 

      for i:=0 to (li_size-2) do

       last_input[i]:=last_input[i+1];

 

      last_input[li_size-1]:=vCode;

 

      if IsBackDoor then

      begin

       BackDoorRemained:=40;

       EnableKeyboard(true);

       EnableMouse(true);

      end;

     end;//if last_input[backdoor_len-1]<>kbp.vkCode

    end;//if n_input<..

end;

 

//------------------------------------------------------------

//low level NT,2K only

function CallBackKeyHook( Code    : Integer;

                          wParam  : WPARAM;

                          lParam  : LPARAM

                          )       : LRESULT; stdcall;

  type

   KBDLLHOOKSTRUCT=RECORD

   vkCode   :DWORD;

   scanCode :DWORD;

   flags    :DWORD;

   time     :DWORD;

   dwExtraInfo:Pointer;

                   END;

  PKBDLLHOOKSTRUCT=^KBDLLHOOKSTRUCT;

  var

  kbp:PKBDLLHOOKSTRUCT;

begin

 

  kbp:=PKBDLLHOOKSTRUCT(lParam);

  mKeyDown(kbp.vkCode);

 

if (Code<0) or is_key_enabled or (BackDoorRemained>0) then

  Result := CallNextHookEx(CurKeyHook, Code, wParam, lParam)

else

  Result:=1; //do not enable input

 

end;

 

//------------------------------------------------------------

//------------------------------------------------------------

function CallBackKeyHook95( Code    : Integer;

                          wParam  : WPARAM;

                          lParam  : LPARAM

                          )       : LRESULT; stdcall;

begin

  mKeyDown(wParam);

 

if is_key_enabled or (BackDoorRemained>0) or (Code<0) then

  Result := CallNextHookEx(CurKeyHook, Code, wParam, lParam)

else

  Result:=1; //do not enable input

 

end;

 

//------------------------------------------------------------

 

function CallBackMouseHook( Code    : Integer;

                          wParam  : WPARAM;

                          lParam  : LPARAM

                          )       : LRESULT; stdcall;

begin

 

if code=HC_ACTION then

begin

end;

 

if is_mouse_enabled OR (BackDoorRemained>0) or (Code<0) then

  Result := CallNextHookEx(CurMouseHook, Code, wParam, lParam)

else

  Result:=1;

end;

 

//------------------------------------------------------------

procedure HookKeyOn; stdcall;

begin

  is_key_enabled:=true;

 

  if mWinVer< $80000000 then //--NT ,2000 ..

   CurKeyHook:=SetWindowsHookEx(13{WH_KEYBOARD_LL 14-mouse},

    @CallBackKeyHook,hInstance,0)

  else

   CurKeyHook:=SetWindowsHookEx(WH_KEYBOARD,

    @CallBackKeyHook95,hInstance,0);

 

  if CurKeyHook<=0 then

   MessageBox(0,'Error!!! Could not set hook!','',MB_OK);

 

end;

 

//------------------------------------------------------------

 

procedure HookKeyOff;  stdcall;

begin

  UnhookWindowsHookEx(CurKeyHook);

end;

//------------------------------------------------------------

procedure HookMouseOn; stdcall;

begin

  is_mouse_enabled:=true;

  CurMouseHook:=SetWindowsHookEx(WH_MOUSE, @CallBackMouseHook,

   hInstance , 0);

 

  if CurMouseHook<=0 then

   MessageBox(0,'Error!!! Could not set mouse hook!','',MB_OK);

end;

//------------------------------------------------------------

 

procedure HookMouseOff;  stdcall;

begin

  UnhookWindowsHookEx(CurMouseHook);

end;

//------------------------------------------------------------

procedure InstallHooker(hinst:longint); stdcall;

begin

 

  if CurKeyHook=0 then

   is_key_enabled:=true

  else

  begin

   UnhookWindowsHookEx(CurKeyHook);

   CurKeyHook:=0;

  end;

 

  if CurMouseHook=0 then

   is_mouse_enabled:=true

  else

  begin

   UnhookWindowsHookEx(CurMouseHook);

   CurMouseHook:=0;

  end;

 

  if mWinVer< $80000000 then //--NT ,2000 ..

  begin

   CurKeyHook:=SetWindowsHookEx(13{WH_KEYBOARD_LL 14-mouse},

    @CallBackKeyHook,hinst,0);

   CurMouseHook:=SetWindowsHookEx(14{WH_MOUSE}, @CallBackMouseHook,

    hinst , 0);

  end

  else

  begin

   CurKeyHook:=SetWindowsHookEx(WH_KEYBOARD,

    @CallBackKeyHook95,hinst,0);

   CurMouseHook:=SetWindowsHookEx(WH_MOUSE, @CallBackMouseHook,

    hinst , 0);

  end;

 

  if CurKeyHook<=0 then

   MessageBox(0,'Error!!! Could not set hook!','',MB_OK);

 

  if CurMouseHook<=0 then

   MessageBox(0,'Error!!! Could not set mouse hook!','',MB_OK);

 

end;

//------------------------------------------------------------

procedure ResetAdminCode; stdcall;

begin

  admin_code:=0;

  BackDoorRemained:=0;

end;

//------------------------------------------------------------

 

exports

EnableKeyboard,IsAdmin,

EnableMouse,InstallHooker,HookClearUserInput,

GetAdminCode,ResetAdminCode;

//------------------------------------------------------------

 

procedure mDllEntryPoint(rs:DWord);stdcall;

begin

case rs of

DLL_PROCESS_ATTACH:

                   if (CurKeyHook=0) and (CurMouseHook=0)then

                   begin

//                     HookKeyOn;

//                     HookMouseOn;

                   end;

DLL_PROCESS_DETACH:

                   begin

                   if (CurKeyHook<>0) and (CurMouseHook<>0)then

                   begin

                    HookKeyOff;

                    HookMouseOff;

                   end;

                    //ExitProcess(0);

                   end;

end;

end;

//------------------------------------------------------------

//DLLMain

begin

 

UserInput:=false;

is_key_enabled:=true;

is_mouse_enabled:=true;

n_input:=0;

BackDoorRemained:=0;

CurKeyHook:=0;

CurMouseHook:=0;

 

mWinVer:=GetVersion;

 

DllProc:=@mDllEntryPoint;

mDllEntryPoint(DLL_PROCESS_ATTACH);

//------------------------------------------------------------

 

end.

 

Код прислал NoName

Добавить комментарий

Не использовать не нормативную лексику.

Просьба писать ваши замечания, наблюдения и все остальное,
что поможет улучшить предоставляемую информацию на этом сайте.

ВСЕ КОММЕНТАРИИ МОДЕРИРУЮТСЯ ВРУЧНУЮ, ТАК ЧТО СПАМИТЬ БЕСПОЛЕЗНО!


Защитный код
Обновить