5,696,038 members and growing! (12,644 online)
Email Password   helpLost your password?
General Programming » Internet / Network » General     Intermediate

Sending Anonymous net send messages in WTL

By M.Shoaib Khan

This article explains how you can can send anonymous net send messages to any host
VC6, VC7, VC7.1, C++Windows, NT4, Win2K, WinXP, Win2003, MFC, WTL, VS6, Visual Studio, Dev

Posted: 26 Jun 2003
Updated: 26 Jun 2003
Views: 185,642
Bookmarked: 13 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
26 votes for this Article.
Popularity: 5.43 Rating: 3.84 out of 5
4 votes, 15.4%
1
3 votes, 11.5%
2
2 votes, 7.7%
3
2 votes, 7.7%
4
15 votes, 57.7%
5

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

About the Author

M.Shoaib Khan


Shoaib Khan is a computer system engineering graduate from GIK Institute Pakistan. He loves to work on distributed computing, AI and Digital Image Processing. He has developed two softwares for LAN Searching i.e LAN Solution. They are freely available at
LAN Solution( Search Engine)
He is currently working for a software company in Pakistan developing Human Machine Interface (HMI) products.

Please feel free to contact him for any thing regarding his articles, project or in general
(sbk_one AT yahoo DOT com)


Occupation: Web Developer
Location: Pakistan Pakistan

Other popular Internet / Network articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 60 (Total in Forum: 60) (Refresh)FirstPrevNext
GeneralDoes it work?memberduaatul7:18 25 Apr '07  
GeneralRe: Does it work?memberSushi00722:23 29 May '07  
Generalpopup shows "???..." in mfc applicationmemberDiscoverSK21:02 26 Sep '06  
Generalhow to send msg in LanmemberR.Nagendran8:15 28 Aug '06  
Generalhow to send msgmemberramanes20207:50 25 Apr '06  
Generalcan track net send messages??sussAnonymous19:37 8 Jul '05  
GeneralRe: can track net send messages??sussAnonymous13:26 26 Sep '05  
QuestionRe: can track net send messages??memberRahul D.23:30 11 May '08  
GeneralUsing "Net Send" over the internetmemberssobada9:33 6 Jun '05  
Generalreceive message.memberTailana23:31 31 May '05  
Generalreceive message.memberTailana23:30 31 May '05  
Generalwat do i typesussScott Robinson13:41 29 Jan '05  
GeneralRe: wat do i typememberChris Nooyen3:30 24 Feb '06  
GeneralLogging net send messagessussAmicusRarus2:06 7 Jan '05  
GeneralRe: Logging net send messagesmemberAamir Khan Jadoon3:44 7 Jan '05  
GeneralRe: Logging net send messagesmemberCyKill8:20 24 Apr '05  
GeneralGreat Work man!!!!!sussujjwal wadhawan10:15 24 Nov '04  
GeneralRe: Great Work man!!!!!sussVenomus11816:12 23 Feb '05  
Generalcan't get this to workmemberwoodcock684:01 26 May '04  
GeneralRe: can't get this to workmemberM.Shoaib Khan9:08 26 May '04  
GeneralRe: can't get this to workmemberwoodcock6810:08 26 May '04  
GeneralMS COMMAND PROMPTmembercoolcars7:26 19 May '04  
GeneralRe: MS COMMAND PROMPTmemberM.Shoaib Khan19:50 24 May '04  
GeneralRe: MS COMMAND PROMPTsussAnonymous0:04 10 Jun '05  
GeneralRe: MS COMMAND PROMPTsussAnonymous9:47 10 Jun '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 26 Jun 2003
Editor: Nishant Sivakumar
Copyright 2003 by M.Shoaib Khan
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project