using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; using System.Net.Sockets; namespace TCP_Server_Test___Client { class Program { static void Main(string[] args) { Console.Write("root[.]$ "); string cmd = Console.ReadLine(); if (cmd.StartsWith("connect ")) { string op = cmd.Substring(8); string ipaddress = op.Substring(0, op.IndexOf(":")); ipaddress = ipaddress.Replace(" ", ""); int port = Convert.ToInt32(op.Substring(op.IndexOf(":") + 1)); Console.Clear(); Console.Write("password: "); string pass = Console.ReadLine(); if (pass == "password") { try { TcpClient tcpclnt = new TcpClient(); Console.WriteLine("Connecting..."); Connect: tcpclnt.Connect(ipaddress, port); Console.WriteLine("Connected"); Begin: Console.Write("Klunus[.]$ "); string str = Console.ReadLine(); byte[] data = Encoding.ASCII.GetBytes(str); NetworkStream netStream = tcpclnt.GetStream(); if (netStream.CanWrite) { netStream.Write(data, 0, data.Length); } goto Begin; } catch (Exception e) { Console.WriteLine(e.Message); } } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)