Page 1 of 1

A Fake Telnet Server effective?

Posted: Mon Dec 01, 2008 5:11 am
by BerryTheWest
As I have seen several people rely on telnet functionality to do the hacking for them, but I find that unreliable and outdated. So I decided to make a "make-shift" program to host a fake telnet that logged their activity. Would this be effective to teaching them that action may have consequences for their action?

You can use this code for whatever you want.

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;

namespace FakeServer
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing");
            System.Net.Sockets.TcpListener listen = new System.Net.Sockets.TcpListener(23);
            List<System.Net.Sockets.TcpClient> clients = new List<System.Net.Sockets.TcpClient>();
            listen.Start();
            Console.WriteLine("Initialized");
            while (listen != null)
            {
                string log = "";
                if (listen.Pending())
                {
                    clients.Add(listen.AcceptTcpClient());
                    Console.WriteLine("A client connected... " + clients.ToArray()[clients.ToArray().Length - 1].Client.RemoteEndPoint.ToString());
                    log += clients.ToArray()[clients.ToArray().Length - 1].Client.RemoteEndPoint.ToString() + "\r\n";
                    clients.ToArray()[clients.ToArray().Length - 1].GetStream().Write(Encoding.Default.GetBytes("Hello and welcome to Telnet Server\r\n"), 0, Encoding.Default.GetByteCount("Hello and welcome to Telnet Server\r\n"));
                }

                foreach (System.Net.Sockets.TcpClient client in clients.ToArray())
                {
                    if (client.GetStream().DataAvailable == true)
                    {
                        byte[] info = new byte[2048];
                        client.GetStream().Read(info, 0, info.Length);
                        for (int I = info.Length - 1; I > -1; I--)
                        {
                            if (info[I] == 0)
                                Array.Resize(ref info, info.Length - 1);
                            else
                                break;
                        }
                        Console.Write(Encoding.Default.GetString(info));
                        log += client.Client.RemoteEndPoint.ToString() + ": " + Encoding.Default.GetString(info) + "\r\n";
                    }
                }

                if (log != "")
                {
                    System.IO.File.AppendAllText("Log.txt", log);
                    log = "";
                }
            }
        }
    }
}

Posted: Mon Dec 01, 2008 5:15 am
by PaRaDoX
I have to say, you're pretty good (at least it looks that way to me, I'm not familiar with that language :/ [which i'm looking to fix])

Posted: Mon Dec 01, 2008 12:48 pm
by 0.Dark.Thought
what language is this?

Posted: Mon Dec 01, 2008 1:37 pm
by BerryTheWest
It was my first language, C# and I suppose it was easy to do. :)

[EDIT]

Well although the code isn't exception handled, it still a makeshift and it just to represent the idea.

Posted: Tue Dec 02, 2008 4:31 am
by PaRaDoX
BerryTheWest wrote:It was my first language, C# and I suppose it was easy to do. :)

[EDIT]

Well although the code isn't exception handled, it still a makeshift and it just to represent the idea.
well, yea lol. in that case, you may wanna add exception handling in thee, especially for things that require internet connections, where a countless number of things can go wrong. >.<

Posted: Tue Dec 02, 2008 6:17 am
by BerryTheWest
PaRaDoX wrote:
BerryTheWest wrote:It was my first language, C# and I suppose it was easy to do. :)

[EDIT]

Well although the code isn't exception handled, it still a makeshift and it just to represent the idea.
well, yea lol. in that case, you may wanna add exception handling in thee, especially for things that require internet connections, where a countless number of things can go wrong. >.<
Only if the program make itself valuable enough to take up my time for that. :)

And I suppose one day, there are going to be a video of... 1001 ways to crash a program.

Posted: Wed Dec 03, 2008 5:42 am
by PaRaDoX
lol are you sure you're up to the 1001 challenge? :O

Posted: Wed Dec 03, 2008 6:05 am
by BerryTheWest
Probably would take years and a lot of illegal software will be required. :)

Of course people will rant on me and such. :(

Posted: Thu Dec 04, 2008 12:04 am
by PaRaDoX
BerryTheWest wrote:Probably would take years and a lot of illegal software will be required. :)

Of course people will rant on me and such. :(
lolz, I'm like the rantiest one here and even i would like to see that ^_^