A Fake Telnet Server effective?

Discussion about hacker.org's server
Post Reply
BerryTheWest
Posts: 205
Joined: Sat Nov 29, 2008 3:19 am

A Fake Telnet Server effective?

Post 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 = "";
                }
            }
        }
    }
}
The Assistant of the Clan. The White Orders.
User avatar
PaRaDoX
Posts: 708
Joined: Fri Aug 22, 2008 5:52 am
Location: In your fridge, waiting to pop out and scare you.

Post 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])
Image

~You are a glitch in my reasoning.
User avatar
0.Dark.Thought
Posts: 103
Joined: Sun Mar 16, 2008 5:56 pm

Post by 0.Dark.Thought »

what language is this?
Education is a progressive discovery of our own ignorance.
BerryTheWest
Posts: 205
Joined: Sat Nov 29, 2008 3:19 am

Post 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.
The Assistant of the Clan. The White Orders.
User avatar
PaRaDoX
Posts: 708
Joined: Fri Aug 22, 2008 5:52 am
Location: In your fridge, waiting to pop out and scare you.

Post 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. >.<
Image

~You are a glitch in my reasoning.
BerryTheWest
Posts: 205
Joined: Sat Nov 29, 2008 3:19 am

Post 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.
The Assistant of the Clan. The White Orders.
User avatar
PaRaDoX
Posts: 708
Joined: Fri Aug 22, 2008 5:52 am
Location: In your fridge, waiting to pop out and scare you.

Post by PaRaDoX »

lol are you sure you're up to the 1001 challenge? :O
Image

~You are a glitch in my reasoning.
BerryTheWest
Posts: 205
Joined: Sat Nov 29, 2008 3:19 am

Post by BerryTheWest »

Probably would take years and a lot of illegal software will be required. :)

Of course people will rant on me and such. :(
The Assistant of the Clan. The White Orders.
User avatar
PaRaDoX
Posts: 708
Joined: Fri Aug 22, 2008 5:52 am
Location: In your fridge, waiting to pop out and scare you.

Post 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 ^_^
Image

~You are a glitch in my reasoning.
Post Reply