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.
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
NetMessageBufferSend( NULL, server, from,
(byte *) &msg,wcslen( msg ) * 2 );
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