Ejemplo n.º 1
0
        public Peer(Socket PeerHandle, Server server)
        {
            this.PeerHandle = PeerHandle;
            this.server = server;
            this.Buffer = new byte[128];
            this.rnd = new Random();

            this.SystemDate = DateTime.Now.Subtract(new TimeSpan(rnd.Next(-12, 12), rnd.Next(-5, 5), rnd.Next(-60, 60)));
            this.TimeConnectedSW = Stopwatch.StartNew();

            this.W_LoggedInUsers = 1; // rnd.Next(1, 10);

            try
            {
                this.LogStream = new FileStream("./" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + "__" + PeerHandle.RemoteEndPoint.ToString().Split(':')[0].Replace(":", "_").Replace(".", "_") + ".log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                LogToFile("IP Address: " + PeerHandle.RemoteEndPoint.ToString().Split(':')[0]);
                LogToFile("Time: " + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"));
                LogToFile("");

                if (!String.IsNullOrEmpty(server.ConnectMessage))
                {
                    SendMessage(server.ConnectMessage + "\r\n");
                }

                WriteCurPath();

                try
                {
                    this.PeerHandle.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, ReceiveCallback, null);
                }
                catch
                {
                    IsPortScanner = true;
                }
            }
            catch(Exception ex)
            {
                LogToFile("Peer disconnected in Peer Constructor, Possible PortScanner, " + ex.Message);
            }
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     Server server = new Server("0.0.0.0", "Welcome to the National Security Agency Remote Terminal\r\n");
     Process.GetCurrentProcess().WaitForExit();
 }