Announcement

Collapse
No announcement yet.

"net use" error 53 & 1326

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

  • "net use" error 53 & 1326

    Hi,

    I created a simple batch file to quickly map to the IPC$ share with user input. My code is:

    @echo off
    set /p Target=Enter Hostname or IP:
    set /p Usercred=Enter credentials as Domain\username:
    set /p PWD=Enter password:
    echo %Target%
    echo %Usercred%
    net use \\%target%\IPC$ /user:%usercred% %PWD%
    pause
    net use \\%target% /delete

    There are a few things I can't figure out. The code works flawlessly when you run it as it is but weird things happen when I make a few slight and what I thought would be simple modifications.
    If I try to map a drive letter by inserting it in the "net use" command above, I get "System error 53. The network path was not found."
    net use J: \\%target%\IPC$ /user:%usercred% %PWD%

    Another weird thing is that if I copy the same code snippet to another batch file that I run a CHOICE menu to call daily tools that I frequently use, I get "System error 1326. Logon failure: unknown user name or bad password."
    Again, there are absolutely no changes to the code. I simply use "set /p" to call the option from a menu. I don't get why it would throw a bad username/password error when the script works when I run it by itself.

    Any ideas???

  • #2
    Re: "net use" error 53 & 1326

    I've decided to post the complete code for both batch files. They are both in the same directory, on the same computer and both executed when logged on as the same user.

    mapdrive.cmd - This works successfully. Ip maps the drive successfully and disconnects after the pause command.

    psmenu.cmd (See section "MAP_DRIVE".)
    When I select the map drive option under the menu it returns a system error 1326 when attempting to run the "net use" command.

    mapdrive.cmd
    @echo off
    set /p Target=Enter Hostname or IP:
    set /p Usercred=Enter credentials as Domain\username:
    set /p PWD=Enter password:
    echo %Target%
    echo %Usercred%
    net use \\%target%\IPC$ /user:%usercred% %PWD%
    pause
    net use \\%target% /delete

    psmenu.cmd
    @echo off
    setlocal EnableDelayedExpansion
    :choice
    echo ------------------PSTOOLS and Utilities Batch File-------------------
    echo 1 - LIST
    echo 2 - KILL
    echo 3 - SERVICE
    echo 4 - REMOTE_EXEC
    echo 5 - INFO
    echo 6 - PING_TEST
    echo 7 - MAP_DRIVE
    echo 0 - END

    @echo off
    set /P CHOICE=Your Selection.
    :CHOICE
    IF "%choice%" == "7" goto MAP_DRIVE
    IF "%choice%" == "6" goto PING_TEST
    IF "%choice%" == "5" goto INFO
    IF "%choice%" == "4" goto REMOTE_EXEC
    IF "%choice%" == "3" goto SERVICE
    IF "%choice%" == "2" goto KILL
    IF "%choice%" == "1" goto LIST
    IF "%choice%" == "0" goto EXIT
    :LIST
    @echo off
    echo Display running processes.
    set /P Target=Name or IP of the target machine:
    PSLIST \\%TARGET%
    pause
    goto CHOICE
    :KILL
    @echo off
    echo Kill a specified process.
    set /P Target=Name or IP of the target machine:
    set /P PID=Enter the process ID:
    pskill \\%Target% %PID%
    pause
    goto CHOICE
    :Service
    @echo off
    echo Use this command to control a service on a local or remote system.
    set /P Target=Name or IP of the target machine:
    set /P Option=Type the option you want to use. example: (query or start):
    set /P Service=Type the service that you want to control:
    psservice \\%Target% %Option% %Service%
    pause
    goto CHOICE
    :REMOTE_EXEC
    @echo off
    echo Execute a program on a remote system.
    set /P Target=Name or IP of the target machine:
    set /P Command=Type the command you want to execute:
    set /P Argument=Type the command line argument you want to use (or leave blank):
    psexec \\%Target% %Command% %Argument%
    pause
    goto choice
    :INFO
    @echo off
    echo Use this command to query information on a local or remote system.
    set /P Argument=Type the command line argument you want to use (or leave blank). example "-d" displays disk volume information:
    set /P Target=Name or IP of the target machine:
    psinfo %Argument% \\%Target%
    pause
    goto CHOICE
    :PING_TEST
    set /P Target=Name or IP of the target machine:
    set /P Argument=Type the command line argument you want to use (or leave blank). example "-t" does a continuous ping:
    ping %target% %argument%
    pause
    goto choice
    :MAP_DRIVE
    @echo off
    set /p Target=Enter Hostname or IP:
    set /p Usercred=Enter credentials as Domain\username:
    set /p Pass=Enter password:
    echo %Target%
    echo %Usercred%
    pause
    net use \\%Target%\IPC$ /user:%Usercred% %Pass%
    pause
    net use \\%target%\IPC$ /delete
    pause
    goto choice
    :END
    exit

    Comment


    • #3
      Re: "net use" error 53 & 1326

      net helpmsg 1326: Logon failure: unknown user name or bad password.
      net helpmsg 53: The network path was not found.

      Insert an echo statement to print the command with all the parameters. Maybe there is a typo somewhere?

      -vP

      Comment


      • #4
        Re: "net use" error 53 & 1326

        Just gave it a shot and the net use command path and text is correct right down to the letter.

        This makes absolutely no sense! I'm logged in and attempting to run the batch files from the same location. I copied and pasted the code from the working script into the menu script. I don't see how but could this be firewall or HIPS related? Don't see how since the mapdrive.cmd script works successfully. Just throwing it out there.

        Comment


        • #5
          Re: "net use" error 53 & 1326

          I tried both scripts on my home AD lab and they both worked fine. Now I am convinced it is the machine. It has HIPS and McAfee AV on it. I tested the scripts on my VMWARE XP box in my AD lab that has no A/V or 3rd party anti-malware tools or firewalls and I had no issue. I just wish I had some sort of tool that could troubleshoot and pinpoint what exactly is going on.

          Comment


          • #6
            Re: "net use" error 53 & 1326

            I ran a netmon against both scripts and detected the error. As to what the meaning or cause is....I hope somebody out there can figure it out.

            Both the mapdrive.cmd and psmenu.cmd return the same values for the Kerberos request. (Note: I've inserted *** to cover up some details)

            KerberosV5:AS Request Cname: david.*** Realm: *** Sname: krbtgt/***

            But the next part of the handshake is where it goes wrong.

            The successful mapdrive.cmd has

            KerberosV5:AS Response Ticket[Realm: B***, Sname: krbtgt/B***]

            The unsuccessful psmenu.cmd has

            KerberosV5:KRB_ERROR - KDC_ERR_PREAUTH_FAILED (24)

            I am not too familiar with troubleshooting Kerberos errors. Can anybody explain why psmenu.cmd gets a Kerboros error and mapdrive.cmd runs successfully? They are the same exact code snippet launched from the same user on the same session.

            Comment


            • #7
              Re: "net use" error 53 & 1326

              In case anybody is interested I figured out the issue. I removed the ENABLEDELAYEDEXPANSION property from the beginning of the script and now both scripts work as planned.

              Comment

              Working...
              X