[Mini tutorial] Chat using telnet server

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

[Mini tutorial] Chat using telnet server

#1 Post by carlos » 22 Dec 2013 17:15

Hello. I post this because some user ask for a way for do a lan chat.


Screenshots:
for connect you need write chat as password for connect, because empty password is not allowed.
Image


connection 1:
Image

connection 2:
Image

communication:
Image


A possiblity of lan chat is using a microsoft telnet server. The last time that I use it was years ago on Windows xp pro. I wrote the idea again on a windows xp pro and works.

In the server machine you install Microsoft Telnet Server. The way of installation is different on windows xp and windows 7. (In windows xp you only need start the telnet service.)

In the client side, you need telnet.exe (that come by default with windows xp, but you need install in windows vista/7).

On server:

once microsoft telnet server intallation is done, configure it:

Code: Select all

::max connections 15
Tlntadmn config maxconn=15
::only use password authentication
Tlntadmn config sec=-NTLM+passwd
::set 1 attempt of login
Tlntadmn config maxfail=1

::create the user account for use the chat:
net user chat /add
::set that password never expires:
net user chat expires:off
::set password chat to user chat, (write chat two times at prompt)
net user chat *

With microsoft telnet server, all accounts need a password, a empty password is not accepted.

In the server the chat account will use Tlntadmn.exe that needs Administrative rights:

Code: Select all

net localgroup Administradores chat /add
::(In english Administradores should be Administrators)
net localgroup Usuarios chat /del
::(In english Usuarios should be Users)



Create local group TelnetClients and assign it to chat account:

Code: Select all

net localgroup TelnetClients /add
net localgroup TelnetClients chat /add


Now, on the server modify C:\WINDOWS\system32\login.cmd

with this (that is the code for the chat):

login.cmd

Code: Select all

@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion
Cls
Echo Connections:
For /F "skip=4 tokens=1,4" %%a in (
'Tlntadmn -s ^| findstr /v "\<-"'
) Do Echo Ip: %%b Id: %%a

:setNickName
Set "NickName="
Set /P "NickName=Write your nickname:"
If Not Defined NickName Goto :setNickName
Cls

:GetText
Set "text="
Set /P "text="
Tlntadmn -m All "!NickName! wrote: !text!" >Nul
Goto :GetText



Then in the client machine (replace the ip with the ip of server):

client.cmd

Code: Select all

@telnet.exe -t ansi -l chat 169.254.108.57
::write chat


If you look, telnet server show what is the user account and computer name from the message come.

In this case the communication is with all users.

Note: In the login.cmd we prevent any command injection problem, using delayed expansion.

Post Reply