Click here to Skip to main content
15,879,535 members
Articles / Desktop Programming / WTL
Article

Sending Anonymous net send messages in WTL

Rate me:
Please Sign up or sign in to vote.
4.32/5 (28 votes)
26 Jun 20035 min read 311.3K   6.9K   23   62
This article explains how you can can send anonymous net send messages to any host

Introduction

This article explains how to send anonymous net send messages across the network. My intent is not to explain how to send junk anonymous messages to tease others. The intent is to explain how this thing can be useful for customized applications.

For beginners, let me first explain what net send utility is all about? What are net messages and how it works?

What is net send, net messages and how does it work?

Net send is used to send messages to any host on network (LAN or the internet) where messenger service is running. Moreover on local computer workstation service should also be enabled. On command prompt or run write this command and press enter.

Net send IPAddress yourmessage

This will send a message to that particular user and a popup dialog box will appear on his screen if his messenger service is running. You can also use hostname of that computer or any "message alias". What?? What is message alias? On windows 2000 and onwards, messenger service maintains a list of message alias in a table known as message name table. Message alias is just a name or any string. By default, computer name and current session name are added to this alias table. But you can add your own message alias by registering it in alias table by using this command.

Net Name newmessagealias

Messenger service receive all messages whose recipients belong to alias table maintained by it. So if some other user on network type "net send newmessagealias message" it would be send to the host containing this message alias. You can retrieve list of registered message aliases by using following command.

Net Name

Following image shows the net send popup dialog box. I hope this is sufficient information for understanding net send and net messages

So how to send anonymous net sends

Now you understand the working of net send so lets come back to our original topic.

Have you ever encountered anonymous net send messages? When you receive a net send message, generally host name of the sender is mentioned there. However, it is not necessary that this name should always be the host name of the sender; it can be any name using the technique provided in this article. But if you are using net send utility to send this message then it always the hostname of the sender. Note that the name which appears on net send dialog box is not the message alias of the sender. Sending anonymous net sends is surprisingly easy.

Sending anonymous messages to some user can sometimes be fun but at times it can create problems for other users. However, it can be useful if you have an application which uses customized names to send messages to each host. So the use depends on your needs.

Net Send utility uses APIs provided by Microsoft LAN Manager. To send a message, you have to register the message alias in message name table. This is done through NetMessageNameAdd function. Only members of local administrator group can execute this function. As mentioned earlier, host name of computer is by default added to message alias table, so you can even send messages without registering a new alias. But I am doing so for explaining the whole process. However, this is not the actual thing which makes anonymous net sends possible. Once you have registered any message alias in message name table, you can use NetMessageBufferSend function to send the popup message to any host.

The sample application provided with this article is a dialog based WTL application which can send anonymous messages to many hosts at a time. Using this utility you can even send message to more than a thousand hosts. You need to provide a list of IP Addresses in a file named checkhost.txt. This program expects one IP Address in one line of this text file. For further information, you can open the file provided with sample and check it. NetMessageBufferSend accepts 5 arguments. First one is server name which is local host if it is NULL, second is message alias which you created, third is the name of the sender ( Got any idea how this works?), fourth is the pointer to message itself and last is the size if the message. So it is the “from” field of this function which makes it all possible. It can be any anonymous name. Following code shows how to send this message

USES_CONVERSION:
  NetMessageNameAdd(NULL,A2W("RECTOR"));
// we have added a message alias of RECTOR

NetMessageBufferSend( NULL, server, from,
 (byte *) &msg,wcslen( msg ) * 2 );

NetMessageNameDel(NULL,A2W("RECTOR"));

// "server" is a Unicode string containing IP Address  
// whom you want to send
// "from" is the actual field which makes it all happen.  
//It is Unicode string and it contains the name from
// which this message is coming from. So you can specify
// any anonymous name and it will appear on receiver end
// we are multiplying the length of message by 2 
//because it is a Unicode string which 
//corresponds to 2 Bytes for a single character

This is not the actual code taken from sample application. This is just to demonstrate the whole process.

In sample application on clicking the broadcast button, first i retreive text from editbox and convert the char string to unicode character string using mbstowcs function ( these network functions require unicode string).Then i go in loop and create a thread for each message i want to send.In thread i simply send the message using NetMessageBufferSend function.Thats it :).

To send messages to your own hosts, you need to change the checkhosts.txt file to remove my added IP addresses and add those hostnames or IP Addresses whom you want to send message.

I hope you enjoyed this small article :)

Updates ( 29th June 2003)

  • Added more explanation about working of net send and net messages
  • Added explanation about sample code

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: can't get this to work Pin
abc87626-May-04 8:08
abc87626-May-04 8:08 
GeneralRe: can't get this to work Pin
woodcock6826-May-04 9:08
woodcock6826-May-04 9:08 
GeneralMS COMMAND PROMPT Pin
coolcars19-May-04 6:26
coolcars19-May-04 6:26 
GeneralRe: MS COMMAND PROMPT Pin
abc87624-May-04 18:50
abc87624-May-04 18:50 
GeneralRe: MS COMMAND PROMPT Pin
Anonymous9-Jun-05 23:04
Anonymous9-Jun-05 23:04 
GeneralRe: MS COMMAND PROMPT Pin
Anonymous10-Jun-05 8:47
Anonymous10-Jun-05 8:47 
GeneralDoesn't seem to work Pin
trihoangto22-Apr-04 3:05
trihoangto22-Apr-04 3:05 
GeneralC++ Pin
soan-wah20-Apr-04 5:52
soan-wah20-Apr-04 5:52 
please can someone send me the c++ code for sending out text message reminders to other mobile phones? please can you reply as soon as possible as i need it before this friday.
General1-TO-1 OR 1-TO-MANY Pin
Baldeep Birak26-Feb-04 7:18
Baldeep Birak26-Feb-04 7:18 
GeneralRe: 1-TO-1 OR 1-TO-MANY Pin
abc87626-Feb-04 10:49
abc87626-Feb-04 10:49 
GeneralGreat work ;) Pin
Jein21-Feb-04 4:51
Jein21-Feb-04 4:51 
GeneralRe: Great work ;) Pin
abc87626-Feb-04 10:51
abc87626-Feb-04 10:51 
QuestionIs there anyway to do this with a simple batch file? Pin
Anonymous16-Feb-04 18:13
Anonymous16-Feb-04 18:13 
AnswerRe: Is there anyway to do this with a simple batch file? Pin
Anonymous26-Sep-05 12:27
Anonymous26-Sep-05 12:27 
GeneralSerious trick! Pin
Anonymous22-Jan-04 9:58
Anonymous22-Jan-04 9:58 
GeneralRe: Serious trick! Pin
abc87616-Feb-04 18:29
abc87616-Feb-04 18:29 
GeneralWinExec one line Pin
Member 72619429-Nov-03 12:58
Member 72619429-Nov-03 12:58 
GeneralRe: WinExec one line Pin
abc8766-Dec-03 10:47
abc8766-Dec-03 10:47 
QuestionIs NetMessageNameAdd needed? Pin
v1ncent6-Nov-03 5:52
v1ncent6-Nov-03 5:52 
QuestionHow can I send msg to my(or other)workgroup ? Pin
clonesheep1-Nov-03 20:21
clonesheep1-Nov-03 20:21 
AnswerRe: How can I send msg to my(or other)workgroup ? Pin
abc8763-Nov-03 13:18
abc8763-Nov-03 13:18 
GeneralI can't compile your source Pin
DarkLion14-Oct-03 3:48
DarkLion14-Oct-03 3:48 
GeneralRe: I can't compile your source Pin
abc87614-Oct-03 6:24
abc87614-Oct-03 6:24 
QuestionHow To Know "Machine's Name Send Anonymous messages" Pin
Anonymous7-Oct-03 17:05
Anonymous7-Oct-03 17:05 
QuestionHow To Know "Who Send Anonymous messages" Pin
Anonymous4-Oct-03 23:19
Anonymous4-Oct-03 23:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.