まず、私が開発しているキーロガーは、攻撃的で破壊的な目的のためではありません。 :)クライアントの監視キーロガーの問題
私はC#.NETでクライアント監視アプリケーションを開発しています。 キーロガーは私のアプリケーションの機能の1つです。 私はkeyloggerのコードを開発しましたが、アプリケーションで正しく実装できませんでした。
私のソリューションには2つのプロジェクトがあります。 UserInterface - サーバー側。 トラッカー - クライアント側のPC用。 keyloggerモジュールKeyloggerはTrackerプロジェクトにあります。
私はそれらを助けるために、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"で処理します。この関数では、メッセージが処理され、フックをインストールするinstallHook()メソッドが呼び出されます(
)。
私がアプリケーションを実行すると、フックがインストールされました。また、KeyboardHookProc()コールバックが正しく呼び出され、キーストロークが処理されました。しかし、この
は、onDataReceivedコールバックメソッドが有効になるまでだけでした。そのメソッドが終了すると、KeyboardHookProc()は呼び出されなくなりました。キー
は、あたかもフックがインストールされていないかのように処理されなくなりました。
もう1つの問題は、フックがインストールされた後、私がキーを押すとシステムがかなり遅くなったということでした。
私の前提は、両方のことがここで発生するスレッドと関係があるということです。しかし、私は正確な問題を得ることができません。 私は状況を説明するために全力を尽くしました。でも、質問は大歓迎です。 誰でも私にソリューションを提供できますか?