Click here to Skip to main content
15,867,704 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 310.9K   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

 
Questionthis app has a virus/malware Pin
Member 1589127311-Jan-23 5:51
Member 1589127311-Jan-23 5:51 
GeneralMy vote of 3 Pin
Mahdi Nejadsahebi17-Feb-12 20:01
Mahdi Nejadsahebi17-Feb-12 20:01 
QuestionDoes it work? Pin
duaatul25-Apr-07 6:18
duaatul25-Apr-07 6:18 
AnswerRe: Does it work? Pin
Sushi00729-May-07 21:23
Sushi00729-May-07 21:23 
Generalpopup shows "???..." in mfc application Pin
DiscoverSK26-Sep-06 20:02
DiscoverSK26-Sep-06 20:02 
Questionhow to send msg in Lan Pin
R.Nagendran28-Aug-06 7:15
R.Nagendran28-Aug-06 7:15 
Questionhow to send msg Pin
ramanes202025-Apr-06 6:50
ramanes202025-Apr-06 6:50 
Questioncan track net send messages?? Pin
Anonymous8-Jul-05 18:37
Anonymous8-Jul-05 18:37 
AnswerRe: can track net send messages?? Pin
Anonymous26-Sep-05 12:26
Anonymous26-Sep-05 12:26 
QuestionRe: can track net send messages?? Pin
Rahul D.11-May-08 22:30
Rahul D.11-May-08 22:30 
GeneralUsing "Net Send" over the internet Pin
infinity86-Jun-05 8:33
infinity86-Jun-05 8:33 
Generalreceive message. Pin
Tailana31-May-05 22:31
Tailana31-May-05 22:31 
Generalreceive message. Pin
Tailana31-May-05 22:30
Tailana31-May-05 22:30 
Generalwat do i type Pin
Robbo_bjm29-Jan-05 12:41
Robbo_bjm29-Jan-05 12:41 
GeneralRe: wat do i type Pin
Chris Nooyen24-Feb-06 2:30
Chris Nooyen24-Feb-06 2:30 
GeneralLogging net send messages Pin
Member 26322427-Jan-05 1:06
Member 26322427-Jan-05 1:06 
GeneralRe: Logging net send messages Pin
Aamir Khan Jadoon7-Jan-05 2:44
Aamir Khan Jadoon7-Jan-05 2:44 
GeneralRe: Logging net send messages Pin
CyKill24-Apr-05 7:20
CyKill24-Apr-05 7:20 
U can access the incomming message at the applucation pop up!!
Right click "My Computer", click "Manage", In the tree view click "event viwer" and then "System". Here u go all the previous netsend u got are here!!
GeneralGreat Work man!!!!! Pin
Member 178714324-Nov-04 9:15
Member 178714324-Nov-04 9:15 
GeneralRe: Great Work man!!!!! Pin
Venomus11823-Feb-05 15:12
sussVenomus11823-Feb-05 15:12 
Generalcan't get this to work Pin
woodcock6826-May-04 3:01
woodcock6826-May-04 3:01 
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 

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.