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-24 00:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Regarding the password input hiding in batch processing, my teacher's explanation View 10,787 Replies 49
Original Poster Posted 2007-04-19 21:25 ·  中国 浙江 杭州 华数宽带
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Regarding that part



  1. : by Herbert Kleebauer
  2. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. @echo off
  4. echo hP1X500Pf3/f1/5++u5x>in.com
  5. set /p password=Enter password:<nul
  6. for /f "tokens=*" %%i in ('in.com') do set password=%%i
  7. pause
  8. del in.com
  9. echo.
  10. echo The Password is:"%password%"
  11. pause
BJSH posted on: 2007-04-19 08:13


In the line
echo hP1X500Pf3/f1/5++u5x>in.com
I asked my teacher; he explained it to me like this: I think it's clearer and easier to understand;
Share it

In this example, the file name is enclosed in single quotes, which means it's an external command,
that is, it is to be executed.

After disassembling in.com, the code is as follows:

00000000: 685031 push 3150
00000003: 58 pop ax ; AX=3150
00000004: 353030 xor ax,3030 ; AX=0160
00000007: 50 push ax
00000008: 5B pop bx ; BX=0160
00000009: 50 push ax
0000000A: 5A pop dx ; DX=0160
0000000B: 42 inc dx
0000000C: 42 inc dx
0000000D: 42 inc dx ; DX=0163
0000000E: 666823622323 push 23236223
00000014: 6658 pop eax ; EAX=23236223
00000016: 662D56406024 sub eax,24604056 ; EAX=FEC321CD
0000001C: 6650 push eax
0000001E: 665D pop ebp ; EBP=FEC321CD
00000020: 66332F xor ebp,dword ptr ; EBP=EBP ^
00000023: 66312F xor dword ptr ,ebp ; =FEC321CD
; +0160 CD
; +0161 21
; +0162 C3
; +0163 FE
Among them, the two bytes CD 21 in +0160 and +0161 are disassembled into the int 21h instruction
C3 in +0162 is disassembled into the ret instruction
The last FE in +163 is the parameter of DOS input function 0Ah (the previous DX=0163 points to this FE),
Indicates that up to 254 characters (including carriage return) can be entered
00000026: 352B2B xor ax,2B2B ; AX=0AE6, where 0Ah is the DOS function number,
; E6 is useless
00000029: 7535 jnz 00000060 ; Here it will definitely jump, equivalent to jmp 160
0000002B: 78 ; The last 78 is useless
0000002C: 0D ; 0D and 0A are automatically when echoing
0000002D: 0A ; Generated carriage return and line feed characters
After the program jumps to 160, it will execute the following instructions:
int 21h ; At this time AH=0Ah, DX=0163h, so execute DOS input function,
; The input content is automatically saved in the buffer starting from +165, and the for loop will read each character one by one
ret ; The program returns to the operating system and automatically ends

To sum up, the function of this in.com is to input a string of characters from the keyboard, with a length not exceeding 254 (including carriage return).
This batch processing is relatively clever. It uses a string of displayable strings to construct an executable code to realize
Keyboard input function, cooperate with for loop to make it possible to realize non-echo input in batch processing.

P.S.: According to the analysis, the last
The character in the garbled code in the echo statement of this batch processing (that is, the x in ++u5x before >) can be deleted. That is to say,
echo hP1X500Pf3/f1/5++u5x>in.com
can be changed to
echo hP1X500Pf3/f1/5++u5>in.com
Recent Ratings for This Post ( 5 in total) Click for details
RaterScoreTime
vkill +2 2007-04-20 01:35
estar +4 2007-04-20 01:59
lxmxn +4 2007-04-26 01:49
不得不爱 +5 2007-10-16 18:17
mmfy -1 2009-07-27 03:42
Floor 2 Posted 2007-04-19 23:32 ·  中国 天津 电信
初级用户
Credits 20
Posts 10
Joined 2007-04-15 10:51
19-year member
UID 85267
Gender Male
Status Offline
Although a bit confusing to read, I basically understand what's going on. Thanks, LZ
Floor 3 Posted 2007-04-20 00:26 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
欢迎你到批处理爱好者联盟QQ群:18023953
Floor 4 Posted 2007-04-20 01:00 ·  中国 贵州 贵阳 电信
中级用户
★★
Credits 304
Posts 117
Joined 2006-04-04 18:43
20-year member
UID 53325
Gender Male
Status Offline
Strong! But still don't understand!
Floor 5 Posted 2007-04-20 02:00 ·  中国 四川 成都 联通
中级用户
★★
Credits 346
Posts 103
Joined 2004-04-06 00:00
22-year member
UID 21852
Gender Male
Status Offline
Come late, add points and top!
Floor 6 Posted 2007-04-20 04:26 ·  中国 广东 东莞 电信
中级用户
★★
Credits 294
Posts 135
Joined 2007-03-09 14:47
19-year member
UID 81212
Gender Male
Status Offline
That's good, just what I need for such a code!!!!
Floor 7 Posted 2007-04-20 06:22 ·  中国 上海 徐汇区 电信
初级用户
Credits 45
Posts 21
Joined 2007-03-14 23:10
19-year member
UID 81739
Gender Male
Status Offline
Grateful beyond words!! So great!
Floor 8 Posted 2007-04-20 07:23 ·  中国 广东 广州 联通
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
Originally posted by bjsh at 2007-4-19 08:25 AM:
Regarding that part

In the
echo hP1X500Pf3/f1/5++u5x>in.com
This sentence asked my teacher; he explained to me like this: I think it is clearer and easier to understand;
Take it out and divide ...


Oh. This is clear...

But it's not as clever as he thought : ) There are assembly masters here.
知,不觉多。不知,乃求知
Floor 9 Posted 2007-04-20 07:49 ·  中国 四川 成都 电信
中级用户
★★
Credits 297
Posts 135
Joined 2006-10-21 12:00
19-year member
UID 67627
Gender Male
Status Offline
Oh my goodness! The echo command has such a function!
Floor 10 Posted 2007-04-24 09:46 ·  中国 河北 廊坊 联通
初级用户
Credits 108
Posts 35
Joined 2007-04-12 15:23
19-year member
UID 84897
Gender Male
From 河北廊坊
Status Offline
Newbie, don't understand! Still need to continue learning! There's no end to learning!
Floor 11 Posted 2007-04-25 23:44 ·  中国 湖南 长沙 电信
新手上路
Credits 5
Posts 3
Joined 2007-03-25 01:25
19-year member
UID 82821
Gender Male
Status Offline
Heheh, there's no such thing as absolute forever. I believe I can surpass you.
Floor 12 Posted 2007-04-26 01:52 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Not bad, finally can explain what the principle of that paragraph is.

I think that for some simple functions that batch processing cannot complete in the future, if the assembly code is all displayable characters in ASCII code, it should all be constructible using this method.
Floor 13 Posted 2007-06-02 10:22 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 301
Posts 135
Joined 2007-05-15 16:49
19-year member
UID 88615
Gender Male
Status Offline
Wow, impressive~~~

[ Last edited by wert123 on 2007-6-2 at 10:25 AM ]
Floor 14 Posted 2007-06-02 10:37 ·  中国 江西 南昌 电信
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
This is a discussion on usenet about in.com, mentioning that the source code of in.com is Motorola assembly code and it's a bit difficult to understand. The content includes various code snippets and discussions about password input in batch scripts, comparing scripting in different systems, etc. The quoted parts contain detailed code analysis and exchanges about how to handle password input without echoing, the structure of assembly code for in.com, and comparisons between different scripting environments.
Floor 15 Posted 2007-06-02 11:29 ·  中国 江苏 无锡 电信
初级用户
Credits 80
Posts 43
Joined 2007-04-21 23:44
19-year member
UID 86017
Gender Male
Status Offline
Got confused later on.
Forum Jump: