对2000/NT系统

解决方案 »

  1.   

    /* Please Use MS VC to create new console(empty) project and add this source 
        to build the NetSend.exe NetSend send message to target computer use 135/udp
    just like "net send" provide with nt/2000, difference: many times, fake source    For 2000 only. In nt4, it does work, but
          1. it request the true source,
          2. stop for a while to send next message to the target, Even if u use "net send".
          3. use computer name and cannot use ip.
        All these will happen Error 2273. So don't use this on NT4 Notes: If u don't want this to bother u, just stop Messenger service
    use: net stop messenger
            --- [email protected] Win2000 pro/server only store 26 new messages,
        and u can press ENTER(keep it, not release) to eliminate received messages.
        (2K Adv server store more than 200, and cannot use pressing ENTER to eliminate message)
        So u maynot use NetSend as a flood-tools.
    **/#include <stdio.h>
    #include <stdlib.h>
    #include <wchar.h>
    #include <windows.h>
    #include <locale.h>
    #include <lm.h>#define UNICODE
    #define _UNICODE #pragma comment(lib, "netapi32.lib")#define DEFAULT_TIMES 1int Usage(const wchar_t *prog)
    {
    printf("  Usage:\r\n    %S <target> [from] [times] [msg]\r\n", prog);
    puts("\t target : send target");
    puts("\t from\t: fake source what u want, default = your computer name");
    puts("\t times\t: send times, default = 1, set 0 for infinite");
    puts("\t msg\t: what message u want, include with \" & \""); exit(-1);
    return 0;
    }int wmain(int argc, wchar_t *argv[])
    { puts("  NetSend For Win2000 send message to target computer use 135/udp, --bingle\n");
    if(argc < 2)Usage(argv[0]);//must provide target wchar_t  wfrom[100], *wtarget, buff[400];
    DWORD ret;    wtarget = argv[1];
    if(argc > 2)wcscpy(wfrom, argv[2]);
    else{
    ret = 100;
    GetComputerNameW(wfrom, &ret);
    }    int times = DEFAULT_TIMES;
        bool bAlways = false;
    if(argc > 3)times = _wtoi(argv[3]);
    if(times == 0 && argv[3][0] == '\0') bAlways = true;//specify times = 0 for infinite
        if(times == 0 && !bAlways)
        {
          printf(" Please specify Times to send!!\n");
          return 0;
        } wchar_t msg[] = L"Alert! A Error ocurred in your Explorer.exe, System will shut down!";
    buff[sizeof(buff)/sizeof(*buff) - 1] = '\0';
        if(argc > 4)wcsncpy(buff, argv[4], sizeof(buff)/sizeof(*buff) - 1);
        else wcscpy(buff, msg); //parameter phase finish, print out
    setlocale(LC_ALL, "");
        wprintf(L"  Sending message '%s'  From %s TO %s", buff, wfrom, wtarget);
        if(!bAlways)printf("  Total %d times.\n\n", times);
        else puts("  Infinitely!\n"); HANDLE hcons = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO coninfo;
    GetConsoleScreenBufferInfo(hcons, &coninfo);
    COORD coord = coninfo.dwCursorPosition;
        if(coord.Y >= coninfo.dwSize.Y - 1)puts(""); char out[5] = "|/-\\";
    // srand( (unsigned)time(0) );
    //win2000 pro only store up to 26 new messages
    for(int i = 0; bAlways || i < times; i ++)
    {
            /*
            如果已经到了屏幕最后一行,再输出,就把所有内容向上推了,因此可以如下方法解决
              1. 在屏幕输出时根本不换行
              2. 每次判断是否到了最后一行,如果是向上推一行
            */
            if(coord.Y >= coninfo.dwSize.Y - 1)coord.Y--;
            SetConsoleCursorPosition(hcons, coord);
    //output times counter
            printf("Sending %4u time %c\n", i + 1, out[i%4]); //if(buff[0] == L'~')buff[0]= L'!';
    //buff[0] ++;
    ret = NetMessageBufferSend(NULL, wtarget, wfrom, (unsigned char *)buff, wcslen(buff)*2); //sleep for a while,
    //if(i % 5 == 0)Sleep(1000);//rand() *5 /RAND_MAX * 1000);
    if(NERR_Success == ret)continue;
    if(NERR_NameNotFound == ret)printf("Net Error Target or Source Name Not Found, ");
    if(ERROR_INVALID_PARAMETER == ret)printf("Net ERROR INVALID PARAMETER, ");
    if(NERR_NetworkError == ret)printf("Net Error Network Error, ");
    printf("Error %u occurred, Send break.\n", ret);
    break;
    }
    CloseHandle(hcons);
    return 0;
    }/*
    DWORD TestConsoleCursorPos()
    {
      int j,k;
      CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo, test;
      float m;
      HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
      int iTotal = 50;  puts("puts test");
      //获得当前光标位置
      if(!GetConsoleScreenBufferInfo(hStdout,&ConsoleScreenBufferInfo))
      {
        printf("GetConsoleScreenBufferInfo");
        return 1;
      }
      COORD coord;  for(j=0;j<iTotal;j++)
      {
        Sleep(100);    coord = ConsoleScreenBufferInfo.dwCursorPosition;
        coord.X = 0;
        if(coord.Y >= ConsoleScreenBufferInfo.dwSize.Y - 1)coord.Y--;    //如果已经到了屏幕最后一行,再输出,就把所有内容向上推了,因此可以如下方法解决
        //  1. 在屏幕输出时根本不换行
        //  2. 每次判断是否到了最后一行,如果是向上推一行    SetConsoleCursorPosition(hStdout, coord);    //已经完成的百分比
        m=(j+1)*100.00/iTotal;
        //显示进度
        k=j%4;
        printf("%d : %d [%d/%d] %%%0.3g \n",coord.X,coord.Y,j, iTotal,m);
        GetConsoleScreenBufferInfo(hStdout,&test);    /*如果没有到最后一行,输出这个也没事,SetConsoleCursorPosition会设置恢复到原来的位置
        //不过要是到了最后一行,这行又会把屏幕缓冲向上推   // printf("test, %d : %d\n", test.dwCursorPosition.X, test.dwCursorPosition.Y);  }//end of for
      return 0;
    }
    */
      

  2.   

    关注,偶想知道netmessagebuffsend函数对广播消息,如nend send中的/domain:domainname和/user或*这些情况如何实现呢?