China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 01:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] How to generate a purely numeric password dictionary View 3,875 Replies 9
Original Poster Posted 2007-08-29 14:10 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
I want to use batch processing to generate a password dictionary. The user enters the password length, and an automatic dictionary file dictionary.txt is generated. If 3 is entered, the content of dictionary.txt is as follows:
000
001
002
...
998
999

If 4 is entered, the content of dictionary.txt is as follows:
0000
0001
0002
....
9998
9999


Hope an expert can give guidance.

[ Last edited by HAT on 2008-11-12 at 21:39 ]
Floor 2 Posted 2007-08-29 16:42 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
```@echo off
set /p num=input a number:
for /l %%i in (1,1,%num%) do call set max=%%max%%9
call set max=%%max:~0,%num%%%
for /l %%i in (0,1,%max%) do set out=000000000000000000000000%%i&&call echo %%out:~-%num%%%>>dictionary.txt

pause```
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
HAT +4 2007-08-29 22:16
523066680 +5 2008-12-19 10:30
Floor 3 Posted 2007-08-29 22:18 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Thanks, Brother wudixin96.
I will think about pure alphabet passwords and alphanumeric mixed passwords based on this.
I will come to ask for advice if there is any problem.
Floor 4 Posted 2007-08-29 22:18 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Almost forgot to add points
Guilty, guilty
Added it up
Floor 5 Posted 2007-08-30 17:01 ·  中国 江苏 苏州 联通
初级用户
Credits 48
Posts 25
Joined 2007-07-30 17:57
18-year member
UID 94318
Gender Male
Status Offline
Floor 6 Posted 2008-12-19 10:32 ·  中国 广东 揭阳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Also made one, only supports below 9 digits, just for fun嘛

@echo off &setlocal enabledelayedexpansion
title code by hi.baidu.com/523066680
set /p "n=Enter the number of digits, maximum is 9: "

for /l %%x in (1,1,%n%) do (
set fo="for %%%%x in (0 1 2 3 4 5 6 7 8 9) do (!fo!"
set end="!end!)"
set echo=!echo! %%%%x
)

%fo:"=%
echo %echo%
%end:"=%
pause
Floor 7 Posted 2009-01-04 02:47 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
(六) The building speed is so fast, I can't understand.
I practice with a stupid way:
@echo off
cd.>dictionary.txt
set /p in=key a number:
set b=%in%
:ex1
if %b% gtr 0 set /a b-=1&set max=9%max%&goto :ex1
set ba=%max:9=0%
:ex2
if %b% leq %max% set ok=%ba%%b%&call echo %%ok:~-%in%%%>>dictionary.txt&set /a b+=1&goto ex2
type dictionary.txt&pause&goto :eof
精简
=> 个人网志
Floor 8 Posted 2009-01-04 16:11 ·  中国 贵州 安顺 电信
初级用户
Credits 94
Posts 49
Joined 2008-12-14 20:47
17-year member
UID 133884
Gender Male
Status Offline
In terms of efficiency, it should be the simple n loops on the 6th floor that are the fastest. For the 7th floor, if each number has to go through an if check, the efficiency can be imagined. Inspired by the zero padding on the 7th floor, I also came to practice, and the efficiency should be very close to the 6th floor.
@echo off
setlocal enabledelayedexpansion
set /p n=key a number:
for /l %%i in (%n%,-1,1) do (
set z=&set min=&set max=
for /l %%j in (2,1,%%i) do set z=0!z!
for /l %%j in (%n%,-1,%%i) do (set/a min=max+1&set max=9!max!)
if !max! equ 9 set/a min=0
for /l %%j in (!min!,1,!max!) do echo !z!%%j
)


[ Last edited by linee on 2009-1-4 at 18:59 ]
Floor 9 Posted 2009-08-04 08:48 ·  中国 广东 广州 天河区 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Ha. What the 6th floor said is that two variables are used respectively to record the number of layers of for and the number of closing parentheses.

The characters represented by the %var% expression are then executed as commands.

I regard this as an advantage of batch processing.

1. When the number of embedded sentences is unknown, temporary embedding can be carried out by string processing.
2. A lot of characters are saved, just like above, where multi-layer For sentences are all put in variables.

Refer to an article that has been posted.
http://www.cn-dos.net/forum/viewthread.php?tid=45240

[ Last edited by 523066680 on 2009-8-4 at 08:52 ]
Floor 10 Posted 2009-08-04 23:25 ·  中国 福建 龙岩 电信
初级用户
Credits 30
Posts 15
Joined 2008-06-23 23:11
17-year member
UID 120750
Gender Male
Status Offline
```batch
@echo off&setlocal enabledelayedexpansion&set y=9999999999
set/p n=input a number:
for /l %%i in (1,1,!y:~-%n%!) do (set qq=0000000000%%i
echo !qq:~-%n%!)
pause
```
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
netbenton +5 2009-08-05 07:53
Forum Jump: