Password generator script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
fnu
Posts: 1
Joined: 01 Nov 2011 04:15

Password generator script

#1 Post by fnu » 01 Nov 2011 04:32

Hi,

I am trying to create a simple password generator script to create passwords for a set of users.

The specs:
Users will be in this format username<number from 1 to 500>@domain
In other words, starting with username1@domain ending with username500@domain

These users should all have unique passwords, so we are applying some simple math to make it harder to figure out what the other passwords are (don't worry, I'm not working for a bank. I am just generating passwords for a internal service at a smaller company). What I want to do is to multiply the username number with a set of fixed values, for example (<user number> * 123 * 456 * 789).

This is the script I have where I have tried to multiply the user number with 5:

Code: Select all

echo off
set user=username
set domain=@domain
FOR /L %%G IN (1,1,500) DO (
set /a pwresult=%%G*5
echo %user%%%G%domain% %pwresult% >> passwords.txt
)


The script currently generates the following in password.txt

username1@domain 2500
username2@domain 2500
username3@domain 2500
username4@domain 2500
username5@domain 2500
username6@domain 2500
username7@domain 2500
username8@domain 2500
username9@domain 2500


[... to 500]

What I expected it to do is to multiply %%G with 5, creating this result:

username1@domain 5
username2@domain 10
username3@domain 15
username4@domain 20
username5@domain 25
username6@domain 30
username7@domain 35
username8@domain 40
username9@domain 45


What am I doing wrong?

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Password generator script

#2 Post by !k » 01 Nov 2011 07:33

Code: Select all

echo off
setlocal enabledelayedexpansion
set user=username
set domain=@domain
FOR /L %%G IN (1,1,5) DO (
set /a pwresult=%%G*5
echo %user%%%G%domain% !pwresult! >> passwords.txt
)

fnu wrote:What I want to do is to multiply the username number with a set of fixed values, for example (<user number> * 123 * 456 * 789).
bad bad idea
look at this generator viewtopic.php?f=3&t=1663

Rileyh
Posts: 147
Joined: 01 Sep 2011 03:54
Location: Perth, Western Australia

Re: Password generator script

#3 Post by Rileyh » 01 Nov 2011 21:00

!k's script is useful, but you could make your threshold higher and make the script much simpler:

Code: Select all

@echo off
set /p user=Enter Username:
set pass=password
set "pass=%random%"
echo %pass% >password.txt

Post Reply