Click here to Skip to main content
12,831,559 members (31,437 online)
Click here to Skip to main content


33 bookmarked
Posted 7 Jun 2003

Fake (or Anonymous) NetSend for Windows NT/2000/XP

, 17 Jun 2003
The Fake NetSend is a little utility that can be used to send anonymous (or fake) messages through your Windows Network.
	Fake NetSend for Windows NT/2000/XP v1.01
	Written by me (Caio Proiete).

	Copyright (c) 2003.

	If you find any bugs, please notify me!

	You may use it, abuse it, redistribute it, in any way 
	you desire, but don't change the author credits ;)


		2003-06-08 - First version. Bugs: Zero, I hope :)
		2003-06-11 - Version 1.01. Just improving the code.

const char szAbout[] = \
		"Fake NetSend for Windows NT/2000/XP v1.01\n" \
		"by Caio Proiete (\n";

const char szUsage[] = \
		"Usage: FakeSend [Sender] [Receiver] \"[Message]\"\n" \
		"Example: FakeSend James Kevin \"Hi Kevin this is James!\"\n";

const char szMailSlotPath[] = "\\\\%s\\MAILSLOT\\messngr";
const char szMsgFormat[] = "%s\r%s\r%s\r";

const unsigned char nTotalParam = 4;

bool NetSend(const char * szSender, const char * szReceiver, 
			 const char * szMessage);

// Exclude rarelly used Windows stuff

#include <stdio.h>
#include <windows.h>

int main(int argc, char **argv)
	//  What do we expect in argv variable?  //
	// argv[0] = Application PathName        //
	// argv[1] = Sender's Name               //
	// argv[2] = Receiver's Login or Machine //
	// argv[3] = Message                     //

	// We have all needed parameters?
	if (argc == nTotalParam)
		// Just showing a status
		printf("%s\n" \
				"Sending Fake Message:\n" \
				"Sender...: %s\n" \
				"Receiver.: %s\n" \
				"Message..: %s\n",

		if (NetSend(argv[1], argv[2], argv[3]))
			printf("Message sent!\n");
			printf("Error sending the message!\n");
		printf("%s\n%s", szAbout, szUsage); // Show About and Usage descriptions
	return 0;

	This function takes the Sender's and Receiver's Name, 
	the Message and then send the "Fake" message
bool NetSend(const char * szSender, const char * szReceiver, 
			 const char * szMessage)
	// Our main variables
	char * pszMailSlot = NULL;
	unsigned char * pucMessage = NULL;
	unsigned int nMailSlotLen, nMsgFormatLen;

	HANDLE hHandle;
	DWORD dwBytesWritten;
	bool bRet = false;

	// Get the length of the strings
	nMailSlotLen  = strlen(szReceiver) + sizeof(szMailSlotPath);
	nMsgFormatLen = strlen(szSender) + strlen(szReceiver) + 
					strlen(szMessage) + sizeof(szMsgFormat);

	// Allocate necessary memory
	pszMailSlot = new char[nMailSlotLen];
	pucMessage  = new unsigned char[nMsgFormatLen];

	// Network path for <Receiver> MailSlot:
	// "\\Receiver\MAILSLOT\messngr"
	sprintf(pszMailSlot, szMailSlotPath, szReceiver);

	// Message Format:
	// "Sender\0Receiver\0Message\0"
	// sprintf doesn't work with \0 so here I'm using \r
	sprintf((char *)pucMessage, szMsgFormat, szSender, 
								szReceiver, szMessage);
	// Replace all '\r' characters with '\0'
	for (unsigned short i = 0; i < nMsgFormatLen; i++)
		if (pucMessage[i] == '\r')
			pucMessage[i] = '\0';
		else if (pucMessage[i] == '\0')
	// Create the file into Receiver's MailSlot and get a Handle to this file
	hHandle = CreateFile(pszMailSlot, GENERIC_WRITE, FILE_SHARE_READ, NULL, 

	// We have a valid handle?
	if (hHandle)
		// Write the message to file
		bRet = (WriteFile(hHandle, pucMessage, (DWORD)nMsgFormatLen,
					&dwBytesWritten, NULL) == TRUE);

		// Free the handle

	return bRet;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


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

Caio Proiete
Team Leader Nephila Capital
Bermuda Bermuda
Caio Proiete has been programming for over 10 years, having first started with Clipper Summer'87.

He loves software development and reverse engineering. Today his main development technologies includes ASP .NET MVC, jQuery, HTML5, Silverlight, and WCF. He also has the following titles:

MVP - Microsoft Most Valuable Professional;
MCT - Microsoft Certified Trainer;
MCPD - Microsoft Certified Professional Developer;
MCTS - Microsoft Certified Technology Specialist;
MCSD - Microsoft Certified Solution Developer;
MCDBA - Microsoft Certified Database Administrator.

Technical blog:

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 18 Jun 2003
Article Copyright 2003 by Caio Proiete
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid