Help with NetMessageBufferSend()

This is a discussion on Help with NetMessageBufferSend() within the C++ Programming forums, part of the General Programming Boards category; I'm trying to write a 'net send' spoofer and I need some help with the NetMessageBufferSend() function. I read about ...

  1. #1
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209

    Help with NetMessageBufferSend()

    I'm trying to write a 'net send' spoofer and I need some help with the NetMessageBufferSend() function. I read about it at Microsoft's website, but they don't go into much detail about it and it's internal workings (and all of it's parameters). I have a few questions:

    1) I'm assuming this function is part of the Window's API (which I don't really know much when it comes to using it). Is it possible to use this function but still use the regular MS-DOS window? I want it to be a simple program that uses regular input and output (cin/cout).

    2)What header file(s) contain(s) everything I need to use this function?

    Much thanks to anyone who can help out.

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    2) The msdn says you need to include Lm.h, and link Netapi32.lib

  3. #3
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Yes you can use any of the features of the Win32 API from within a console program, a console program is a window after all. Just a special when that you as the programmer are removed from the responsibility of handling directly if you do not want to.

    Hell you can even multitask in a console program if you want to.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  4. #4
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    and link Netapi32.lib
    How do I do that?

  5. #5
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    what compiler?
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  6. #6
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Dev-C++

  7. #7
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735

  8. #8
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Alright, I have the thing down to just 2 errors, but I don't know what to do.

    Line 33 C:\Documents and Settings\Owner\My Documents\John's Documents\Source Files C++\Spammer.cpp cannot convert `const char*' to `const WCHAR*' for argument `2' to `DWORD

    Line 34 C:\Documents and Settings\Owner\My Documents\John's Documents\Source Files C++\Spammer.cpp cannot convert `char*' to `const WCHAR*' for argument `2' to `DWORD

    Here's the code:

    Code:
    #include <iostream>
    #include <cstring>
    #include <windows.h>
    #include <Lm.h>
    
    using namespace std;
    
    int main()
    {
        
        char fromName[20];
        char computerName[20];
        //char netSend[]="net send ";
        char message[100];
        char fake[30];
        char completeCommand[140];
        int num;
        
        cout<<"Welcome, you are about to have the best fun of"
            <<"\nyour typing career at the expense of someone else!"<<endl;
        
        cout<<"Please enter the name of the computer you want to spam: ";
        cin.getline(computerName, 20);
        char* compConst = computerName;
        cout<<"Please enter the message you wish to spam with (must be below 100 chars): ";
        cin.getline(message, 100);
        int length = strlen(message);
        cout<<"Please enter the assumed name: ";
        cin.getline(fake, 30);
         char* nameConst = fake;
        cout<<"Please enter the number of messages you wish to send to that alias: ";
        cin>>num;
        NetMessageNameAdd(NULL,"RECTOR");
        NetMessageBufferSend(NULL,compConst, fake, message, length);
        
        cout<<"Done."<<endl;
        system("PAUSE");
        return 0;
    }
    What is going on here? The bolded is where the errors are occuring.

  9. #9
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    You are using windows functions here and thus must use windows datatypes. Here are the function defs:
    Code:
    NET_API_STATUS NetMessageNameAdd(
      LPCWSTR servername,  
      LPCWSTR msgname      
    );
    and
    Code:
    NET_API_STATUS NetMessageBufferSend(
      LPCWSTR servername,  
      LPCWSTR msgname,     
      LPCWSTR fromname,    
      LPBYTE buf,          
      DWORD buflen         
    );
    Note the functions are expecting to be passed LPCWSTR not char*. So either change your datatypes to WCHAR for your arrays and LPCWSTR for your pointers or do an explicit typecast.

    edit:
    LPCWSTR = Long Pointer Wide Character String.

    edit2:
    These are all windows datatypes. They are essentially just macros. You can find there meanings on MSDN.
    Last edited by andyhunter; 02-14-2005 at 09:18 PM.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  10. #10
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    I'm still not sure if it works right because I don't actually have a lan at my house. We like to use this crap at school. Is it possible for anyone to test this for me? Here's the code once again:

    Code:
    #include <iostream>
    #include <cstring>
    #include <windows.h>
    #include <Lm.h>
    
    using namespace std;
    
    int main()
    {
        
        char fromName[20];
        char computerName[20];
        char message[100];
        char fake[30];
        char completeCommand[140];
        int num;
        
        cout<<"Welcome, you are about to have the best fun of"
            <<"\nyour typing career at the expense of someone else!"<<endl;
        
        cout<<"Please enter the name of the computer you want to spam: ";
        cin.getline(computerName, 20);
        char* compConst = computerName;
        
        cout<<"Please enter the message you wish to spam with (must be below 100 chars): ";
        cin.getline(message, 100);
        
        
        cout<<"Please enter the assumed name: ";
        cin.getline(fake, 30);
        char* nameConst = fake;
        
        cout<<"Please enter the number of messages you wish to send to that alias: ";
        cin>>num;
        
        int msg = strlen(message);
        NetMessageNameAdd(NULL,LPCWSTR("RECTOR"));
        for(int i = 0; i<num; i++){
        NetMessageBufferSend(NULL,(LPCWSTR)compConst, (LPCWSTR)nameConst, (BYTE*)message, msg*2);}
        
        cout<<"Done."<<endl;
        system("PAUSE");
        return 0;
    }

  11. #11
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    What type is the return value of the NetMessageBufferSend() function? I know the microsoft thing actually lists the return values, but what are the types of those values?

    Return Values
    If the function succeeds, the return value is NERR_Success.

    If the function fails, the return value can be one of the following error codes.

    Return code Description
    ERROR_ACCESS_DENIED The user does not have access to the requested information.

    ERROR_INVALID_PARAMETER The specified parameter is invalid.

    ERROR_NOT_SUPPORTED This network request is not supported.

    NERR_NameNotFound The user name could not be found.

    NERR_NetworkError A general failure occurred in the network hardware.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21