Announcement

Collapse
No announcement yet.

Need to test for correct admin password

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to test for correct admin password

    Good day all, I am working in a domain environment with multiple domains as well as multiple local admin account passwords. Good thing is, I only need info regarding the local admin accounts.


    What I need to do is, on the XP Pro machines, determine which 1 out of 4 passwords is being used for the local admin account.


    ie - Local admin account name - roscoe
    Possible admin passwords - Password1, or Password2, or Password3, or Password4.


    What I need to happen is, for the batch or VBS to check, attempt to authenticate, or whatever, password #1 and if it fails to go try the second one and so-on until it gets a success, then store the successful one as a variable that I can use in other parts of the batch.
    Can anyone give me a shove in the right direction?

  • #2
    Re: Need to test for correct admin password

    Ok, I've gotten this much....

    net use \\computername\IPC$ /user:computername\Administrator password
    So if I get an exit code of 0, that means that password was correct.

    Last part of the equation is, storing that particular password as a variable for use later......

    Comment


    • #3
      Re: Need to test for correct admin password

      Well..... Roadblock #1.

      It seems that the local admin accounts do not have the ability to "logon" via the net use command, so here's what I have learned.

      Using the command given I get 2 different results.

      1) Error 1326 - Bad username or password. (When PW is incorrect)

      2) Error 1385 - User has not been granted the requested logon type. (When PW is correct)

      Unfortunately, both errors generate an exit code of 2 so errorlevel isn't being much help...

      Is there anything anyone can add to this to help me along?

      Comment


      • #4
        Re: Need to test for correct admin password

        Originally posted by keno1964 View Post
        <...>

        Using the command given I get 2 different results.
        1. Error 1326 - Bad username or password.
        2. Error 1385 - User has not been granted the requested logon type. (When PW is correct)

        Unfortunately, both errors generate an exit code of 2 so errorlevel isn't being much help...

        Is there anything anyone can add to this to help me along?
        By running a command in a FOR~ statement you are able to capture the output of the command and use it in the ~DO statements. Unfortunately not all returned messages can be captured this easy. To capture the "Error Descriptions" you mensioned returned from the net command you'll have to use a 'redirect' little trick.
        Code:
        net.exe use \\computername\IPC$ /user:computername\roscoe password1 2>&1>nul
        as you can find it in the sample below,
        Code:
        @echo off
        
        Set "AdminAcc=roscoe"
        
        :: lists
        (Set PWs="Password1", "Password2", "Password3", "Password4")
        (Set remotecomputers="computerA", "computerB", "computerC", "computerD", "computerE")
        
        for %%a in (%remotecomputers%) do call:test %%a
        
        PAUSE
        
        goto :EOF
        ----------------------------------------------------------------
        :connect using local admin account (computer, admin, pass)
        If defined Pass exit /b 0
        echo.|net.exe use \\%~1 /d /y
        for /f "tokens=*" %%! in (
        'net.exe use \\%~1\IPC$ /user:%~1\%~2 %3 /p:NO 2^>^&1'
        ) do (
        echo.%%!|findstr /rc:"\<1385\>" &&(Set Pass=%3)
        )
        net.exe use \\%~1 /d /y &&set Pass=%3
        exit /b 0
        ----------------------------------------------------------------
        
        
        :test per computer    *** My batch ***
        ECHO computer name: %~1
        set "Pass="
        >nul (ping -n 2 -w 1 %~1|find /i "ttl=")&&(
        for %%b in (%PWs%) do >nul 2>&1 call:connect %~1 %AdminAcc% %%b
        )||(set "Pass= ~ the computer did not respond in time ~")
        ECHO Local admin  : %AdminAcc%
        ECHO Password     : %Pass%
        echo.
        exit /b 0
        /Rems
        Last edited by Rems; 19th October 2011, 17:27.

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X