[IDEA] Hide password for NETUSE

Discussion in 'Scripting' started by Chibi ANUBIS, Feb 21, 2022.

  1. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,201
    881
    60
    Hello !
    I need a help for hide password when I use NETUSE, is possible to hide the password with encrypt/decrypt hash in the bat script ?

    Thanks for all for the help :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,201
    881
    60
    So I use echo off and convert to exe, is not bad lol
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    2,441
    2,950
    90
    Little advice
    Pass it as args's instead
    And make a shortcut to your script & some arg's
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,201
    881
    60
    Oh yes ! With arg's is work too, work also by the registry for arg's, I looking many way :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,201
    881
    60
    #5 Chibi ANUBIS, Oct 25, 2022
    Last edited: Nov 10, 2022
    (OP)
    Now I use this, by the registry because the guest can't open regedit:

    ConnectDriveNetwork.bat
    Code:
    @echo off
    TITLE Connect Drive Network - Chibi ANUBIS
    COLOR F0
    PUSHD %TEMP%
    SET KEYREGISTRY=HKEY_CURRENT_USER\SOFTWARE\ConnectDriveNetwork
    reg query "%KEYREGISTRY%" >nul 2>nul
    IF %ERRORLEVEL%==1 exit
    ECHO Preparing...
    SET var=1
    SET SHAREREG=%KEYREGISTRY%\%var%
    for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
      set "DEL=%%a"
    )
    for /f "Tokens=2,*" %%G in ('reg query "%KEYREGISTRY%" /v "USERNAME" 2^> nul ') DO (SET USERNAME=%%H)
    for /f "Tokens=2,*" %%G in ('reg query "%KEYREGISTRY%" /v "PWD" 2^> nul ') DO (SET PWD=%%H)
    for /f "Tokens=2,*" %%G in ('reg query "%KEYREGISTRY%" /v "LOCALACCOUNT"') DO (SET LOCALACCOUNT=%%H)
    
    :LoopDriveConnect
    reg query "%SHAREREG%" /v Activated | find "0x1" >nul 2>nul
    IF %ERRORLEVEL%==1 CALL :NetWorkIncrement
    for /f "Tokens=2,*" %%G in ('reg query "%SHAREREG%" /v "LETTER"') DO (SET LETTER=%%H)
    for /f "Tokens=2,*" %%G in ('reg query "%SHAREREG%" /v "NETWORK"') DO (SET NETWORK=%%H)
    ECHO.
    ECHO ***************************************
    ECHO Connecting Drive %LETTER%: Please Wait ...
    ECHO ***************************************
    NET USE | find "%LETTER%:" >nul 2>nul
    IF %ERRORLEVEL%==0 NET USE "%LETTER%:" /delete /y >nul 2>nul
    IF %LOCALACCOUNT%==yes (
    NET USE "%LETTER%:" "%NETWORK%" >nul 2>nul
    )
    IF  %LOCALACCOUNT%==no (
    NET USE "%LETTER%:" "%NETWORK%" /USER:"%USERNAME%" "%PWD%" >nul 2>nul
    )
    IF %ERRORLEVEL%==0 (
    call :chooseColor FA "SUCCESS"
    echo.
    ) ELSE (
    call :chooseColor FC "ERROR"
    echo.
    )
    CALL :NetWorkIncrement
    exit
    
    :NetWorkIncrement
    SET /a var=%var%+1
    SET SHAREREG=%KEYREGISTRY%\%var%
    reg query "%SHAREREG%" >nul 2>nul
    IF %ERRORLEVEL%==0 goto LoopDriveConnect
    goto :EOF
    
    :chooseColor
    echo off
    <nul set /p ".=%DEL%" > "%~2"
    findstr /v /a:%1 /R "^$" "%~2" nul
    del "%~2" > nul 2>&1i
    goto :EOF
    
    ConnectDriveNetwork.reg
    Code:
    Windows Registry Editor Version 5.00
    ; Connect Drive Network - Chibi ANUBIS
    ; Here change if you want to use a local account yes/no and you can remove USERNAME and PWD if is yes
    [HKEY_CURRENT_USER\SOFTWARE\ConnectDriveNetwork]
    "USERNAME"="domain\\Mike Brant"
    "PWD"="music"
    "LOCALACCOUNT"="no"
    
    ; Here change all you need and activated by 0 or 1
    ; Insert a new line with new numbers +1 for more drives
    [HKEY_CURRENT_USER\SOFTWARE\ConnectDriveNetwork\1]
    "Activated"=dword:00000001
    "LETTER"="W"
    "NETWORK"="\\\\My-PC\\test1"
    
    [HKEY_CURRENT_USER\SOFTWARE\ConnectDriveNetwork\2]
    "Activated"=dword:00000001
    "LETTER"="X"
    "NETWORK"="\\\\My-PC\\test2"
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,201
    881
    60
    I finish to rewrite my script :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...