首页
社区
课程
招聘
未解决 [求助]不在cmd下如何执行msg命令?
2021-1-15 02:09 2398

未解决 [求助]不在cmd下如何执行msg命令?

2021-1-15 02:09
2398

MSG {username | sessionname | sessionid | @filename | *}
[/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

 

username 标识指定的用户名。
sessionname 会话名。
sessionid 会话 ID。
@filename 识别这样一个文件,该文件含有将所发消息发送到的用户
名、会话名和会话标识号的列表。

  • 给指定服务器上的所有会话发送信息。
    /SERVER:servername 要联系的服务器(默认值是当前值)。
    /TIME:seconds 等待接收器确认消息的时间延迟。
    /V 显示有关执行的操作的信息。
    /W 等待用户的响应,跟 /V 一起有用。
    message 要发送的消息。如果没有指定,发出提示,或者从 stdin
    读取。

 

OD跟到这一步基本明确了,不是cmd通讯,而是msg。
我先记录,等下再回来更新帖子


[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

最后于 2021-1-15 03:25 被ffashi编辑 ,原因: 更新
收藏
免费 0
打赏
分享
最新回复 (3)
雪    币: 772
活跃值: (977)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
ffashi 2021-1-15 05:40
2
0
搞不定了,
msg %username% /time:5 这是一个提示框具体

cmd.exe ---> msg  ---> csrss 弹出信息框

怎么才能不结果 cmd 和msg 直接 让csrss 弹信息框呢?
 
雪    币: 3898
活跃值: (3923)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
Mxixihaha 2021-1-15 09:55
3
0
ffashi 搞不定了, msg %username% /time:5 这是一个提示框具体 cmd.exe ---> msg  ---> csrss 弹出信息框 怎么才能不结果 cmd 和 ...
/*****************************************************************************
*
*   MAIN
*
*   ENTRY:
*      argc - count of the command line arguments.
*      argv - vector of strings containing the command line arguments.
*
****************************************************************************/

int __cdecl
main(INT argc, CHAR **argv)
{
    // struct tm * pTimeDate;
    // time_t      curtime;
    SYSTEMTIME st;
    WCHAR       TimeStamp[ MAX_TIME_DATE_LEN ];
    WCHAR      *CmdLine;
    WCHAR      **argvW;
    WCHAR       szTitleFormat[50];
    DWORD       dwSize;
    PLOGONID pTerm;
    UINT       TermCount;
    ULONG      Status;
    int        i, rc, TitleLen;
    BOOLEAN MatchedOne = FALSE;

    setlocale(LC_ALL, ".OCP");

    /*
     *  Massage the command line.
     */

    argvW = MassageCommandLine((DWORD)argc);
    if (argvW == NULL) {
        ErrorPrintf(IDS_ERROR_MALLOC);
        return(FAILURE);
    }

    /*
     *  parse the cmd line without parsing the program name (argc-1, argv+1)
     */
    rc = ParseCommandLine(argc-1, argvW+1, ptm, 0);

    /*
     *  Check for error from ParseCommandLine
     */
    if (rc && (rc & PARSE_FLAG_NO_PARMS) )
       help_flag = TRUE;

    if ( help_flag || rc ) {
         if (!help_flag) {
            Usage(TRUE);
            return(FAILURE);

        } else {
            Usage(FALSE);
            return(SUCCESS);
        }
    }

        // If no remote server was specified, then check if we are running under Terminal Server
        if ((!IsTokenPresent(ptm, TOKEN_SERVER) ) && (!AreWeRunningTerminalServices()))
        {
            ErrorPrintf(IDS_ERROR_NOT_TS);
            return(FAILURE);
        }

    /*
     * Open the specified server
     */
    if( ServerName[0] ) {
        hServerName = WinStationOpenServer( ServerName );
        if( hServerName == NULL ) {
            StringErrorPrintf(IDS_ERROR_SERVER,ServerName);
            PutStdErr( GetLastError(), 0 );
            return(FAILURE);
        }
    }

    /*
     * if no timeout was specified, use default
     */
    if ( !IsTokenPresent(ptm, TOKEN_TIME) )
        Seconds = RESPONSE_TIMEOUT;

    /*
     * allocate a buffer for the message header
     */
    if ( (MsgText = (PWCHAR)malloc(MAX_IDS_LEN * sizeof(WCHAR))) == NULL ) {
        ErrorPrintf(IDS_ERROR_MALLOC);
        return(FAILURE);
    }
    MsgText[0] = 0;

    /*
     * set up message header text: sender and timestamp
     */
    GetCurrentUserName(CurrUserName, USERNAME_LENGTH);

    /*
     * Get the current Winstation Id for this process
     */
    gCurrentLogonId = GetCurrentLogonId();

    /*
     * Form message title string.
     */
    dwSize = sizeof(szTitleFormat) / sizeof(WCHAR);

    LoadString(NULL,IDS_TITLE_FORMAT,szTitleFormat,dwSize);
    
    TitleLen = (wcslen(szTitleFormat) + wcslen(CurrUserName) + 1) * sizeof(WCHAR) + ( 2 * sizeof( TimeStamp ) );

    MsgTitle = (PWCHAR)malloc(TitleLen);

    if( MsgTitle == NULL )
    {
        ErrorPrintf(IDS_ERROR_MALLOC);
        return(FAILURE);
    }


    _snwprintf(MsgTitle, TitleLen, szTitleFormat, CurrUserName);

    TimeStamp[0] = 0;

    GetLocalTime( &st );

    GetDateFormat( LOCALE_USER_DEFAULT , 
                   DATE_SHORTDATE ,
                   &st ,
                   NULL ,
                   TimeStamp,
                   MAX_TIME_DATE_LEN );


    wcscat(MsgTitle , TimeStamp);

    TimeStamp[0] = 0;

    GetTimeFormat( LOCALE_USER_DEFAULT , 
                   TIME_NOSECONDS ,
                   &st ,
                   NULL ,
                   TimeStamp,
                   MAX_TIME_DATE_LEN );

    wcscat(MsgTitle , L" " );
    wcscat(MsgTitle , TimeStamp);
    
    /*
     * if message was specified on the command line, add it to MsgText string
     */
    if ( IsTokenPresent(ptm, TOKEN_MESSAGE) ) {

        MsgText = realloc(MsgText, (wcslen(MsgText) + wcslen(MsgLine) + 1) * sizeof(WCHAR));
        if ( MsgText == NULL ) {
            ErrorPrintf(IDS_ERROR_MALLOC);
            return(FAILURE);
        }
        wcscat(MsgText, MsgLine);

    } else {

        /*
         * Message was not on the command line.  If STDIN is connected to
         * the keyboard, then prompt the user for the message to send,
         * otherwise just read STDIN.
         */

        if ( _isatty( _fileno(stdin) ) )
            Message(IDS_MESSAGE_PROMPT);


        while ( wfgets(MsgLine, MAX_IDS_LEN, stdin) != NULL ) {
            MsgText = (PWCHAR)realloc(
                            MsgText,
                            (wcslen(MsgText) + wcslen(MsgLine) + 1) * sizeof(WCHAR) );

            if ( MsgText == NULL ) {
                ErrorPrintf(IDS_ERROR_MALLOC);
                return(FAILURE);
            }
            wcscat(MsgText, MsgLine);
        }

        /*
         * When we fall through, we either have an eof or a problem with
         * STDIN
         */
        if ( feof(stdin) ) {

            /*
             * If we get here then we hit eof on STDIN.  First check to make
             * sure that we did not get an eof on first wfgets
             */
            if ( !wcslen(MsgText) ) {
                ErrorPrintf(IDS_ERROR_EMPTY_MESSAGE);
                return(FAILURE);
            }

        } else {

            /*
             * The return from wfgets was not eof so we have an STDIN
             * problem
             */
            ErrorPrintf(IDS_ERROR_STDIN_PROCESSING);
            return(FAILURE);
        }
    }

    /*
     * Is the ids_input really a file indirection?
     */
    if ( ids_input[0] == L'@' ) {

        /*
         * Open the input file and read the names into the NameList
         */
        if ( !LoadFileToNameList(&ids_input[1]) )
            return(FAILURE);

        /*
         * Ok, let's get in touch
         */
        file_flag = TRUE;

    } else {

        _wcslwr( ids_input );
        NameList = (WCHAR **)malloc( 2 * sizeof( WCHAR * ) );
        if ( NameList == NULL ) {
            ErrorPrintf(IDS_ERROR_MALLOC);
            return(FAILURE);
        }
        NameList[0] = ids_input;
        NameList[1] = NULL;
        NameListCount = 1;
    }

    /*
     * Enumerate across all the WinStations and send the message
     * to them if there are any matches in the NameList
     */
    if ( WinStationEnumerate(hServerName, &pTerm, &TermCount) ) {

        if ( SendMessageIfTarget(pTerm, TermCount, MsgTitle, MsgText) )
            MatchedOne = TRUE;

        WinStationFreeMemory(pTerm);

    } else{

        Status = GetLastError();
        ErrorPrintf(IDS_ERROR_WINSTATION_ENUMERATE, Status);
        return(FAILURE);
    }

    /*
     *  Check for at least one match
     */
    if ( !MatchedOne ) {

        if( file_flag )
            StringErrorPrintf(IDS_ERROR_NO_FILE_MATCHING, &ids_input[1]);
        else
            StringErrorPrintf(IDS_ERROR_NO_MATCHING, ids_input);

        return(FAILURE);

    }

    return(SUCCESS);

}  /* main() */


代码在xp sp1泄露的源代码里面可以看到  最终调用的是  WinStationSendMessageW

最后于 2021-1-15 10:00 被Mxixihaha编辑 ,原因:
雪    币: 772
活跃值: (977)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
ffashi 2021-1-16 11:21
4
0
感谢!真的。
游客
登录 | 注册 方可回帖
返回