質問

まず第一に、私が開発していますキーロガーは、すべての攻撃と破壊的な目的のためではありません。 :)

私はC#.NETでのクライアント監視アプリケーションを開発しています。 キーロガーは、自分のアプリケーションの機能の一つです。 私はキーロガーのためのコードを開発してきたけれども、私は自分のアプリケーションで正しくそれを実装することができていない。

私の溶液中の二つのプロジェクトがあります。 たUserInterface - サーバ側のために。 トラッカー - クライアント側のPC用。 キーロギングモジュールキーロガーは、トラッカーのプロジェクトである。

彼らを助けるためにれるtcpClient、TcpListenerとNetworkStream

-

私は、ソケットプログラミングのためのヘルパークラスを使用していました。

また、私は通信のための非同期モードを使用しています。

私は私が問題に直面していたとのコードの一部を掲載しています:

//This code resides on the server-side monitoring interface.When //the administrator hits a btnKeyLog button, a 

message //"StartKeyLog" is sent to the respective client, and the keylogging //is handled on the client.

ます。private void btnKeyLog_Click(オブジェクト送信者、EventArgsの電子) {         メッセージバッファ=新しいバイト[100];

    if ( btnKeyLog1.Text == "Start Keylogging" )
    {
        btnKeyLog1.Text = "Stop Keylogging";
        message = "StartKeyLog";

        messageBuffer = Encoding.ASCII.GetBytes ( message );
        try
        {
                //begin writing on the stream.
        clientConnections[0].networkStream.BeginWrite (messageBuffer, 0, messageBuffer.Length, new 

AsyncCallback ( onDataWrite ), null );
        }
        catch ( Exception exc )
        {
            MessageBox.Show ( exc.Message + exc.StackTrace );
        }
    }
    else
    {
        btnKeyLog1.Text = "Start Keylogging";
        message = "StopKeyLog";

        messageBuffer = Encoding.ASCII.GetBytes ( message );
        try
        {
        clientConnections[0].networkStream.BeginWrite ( messageBuffer, 0, messageBuffer.Length, new 

AsyncCallback ( onDataWrite ), null );
        }
        catch ( Exception exc )
        {
            MessageBox.Show ( exc.Message + exc.StackTrace );
        }
    }
}

さて、クライアント側のコード:

public void onDataReceived ( IAsyncResult ar )
{
    int nBytesRead = 0;
    try
    {
        nBytesRead = clientConnection.networkStream.EndRead ( ar );
    }
    catch ( Exception exc )
    {
        MessageBox.Show ( exc.Message + exc.StackTrace );
    }
    message = Encoding.ASCII.GetString ( messageBuffer,0, nBytesRead);
    switch (message)
    {
        case "StartKeyLog" :
            MessageBox.Show ( "Keylogger started." );
                       //the following static method wraps the Win32 //implementation of SetWindowsHookEx - all given in Keylogger //module
            KeyboardHook.installHook ( );
                       //after this method is called, the hook is //actually installed; the callback function KeyboardHookProc is also //called.        

    Here, keylogger seems to be working fine, except that the //system slows down considerably when i type keystrokes.
        break;

        case "StopKeyLog":
            MessageBox.Show ( "Keylogger stopped." );
                        // the following method releases the hook
            KeyboardHook.releaseHook ( );
        break;
    }

    try
    {
        messageBuffer = new byte[100];
        clientConnection.networkStream.BeginRead ( messageBuffer, 0, messageBuffer.Length, new AsyncCallback ( onDataReceived ), null );
    }
    catch ( Exception exc )
    {
        MessageBox.Show ( exc.Message + exc.StackTrace );
    }
    //MessageBox.Show ( "Stop" );
//as soon as this function ends, however, the callback function of //the keyboard hook stops being called; keystrokes are not //processed.
//the keystrokes are caught until this function the control is in this //function. i assume that it has to do something with the thread.
}

私はここで状況を説明しようとしています。 キーロギングを開始するには、サーバーのUIは、クライアントへのメッセージ「StartKeyLog」を送信します。 メッセージを受信すると、クライアントは、コールバック関数でそれを処理する「onDataReceived」この機能.IN、メッセージが処理され、

installHook()メソッドはフックを取り付けることになる、と呼ばれている。

私は、アプリケーションを実行した

するとき、フックがインストールされてしまいました。また、KeyboardHookProc()コールバックが適切に呼ばれました、そしてキーストロークが処理されました。しかし、この

onDataReceivedコールバックメソッドが生きていただけになるまでそうでした。すぐにそのメソッドが終了したとして、KeyboardHookProcは()が呼び出さ取得を停止しました。キー

フックがインストールされなかったかのように

もはや、処理されませんでした。

もう一つの問題は、フックが取り付けてしまった後、私は任意のキーを押したときに、システムがかなり遅くてしまったということでした。

私の仮定は、物事の両方がここで起こるスレッドとは何かを持っているということです。しかし、私は、問題を正確に取得することはできませんよ。 私はsituation.Stillを説明するために全力を試してみましたが、ご質問は歓迎されています。 誰もが解決策を私に提供することができます??

役に立ちましたか?

解決 2

まあ、私は私の問題を解決するために管理しています。問題は、私は自分のアプリケーションのメインスレッドが呼び出されていたことをスレッドにフックを設定したということでした。 Infactは、私はちょうどフックをインストールするには、そのスレッドを開始していました。フックは、メインスレッド上にインストールされたように、私はちょうど私のコードを再構築します。これは、全体の問題を解決しました。 :)

他のヒント

あなたはKeyboardHookのコードを追加する必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top