中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-08 04:59
48,041 topics / 350,128 posts / today 3 new / 48,253 members
DOS批处理 & 脚本技术(批处理室) » Regarding the password input hiding in batch processing, my teacher's explanation
Printable Version  11,290 / 49
Floor1 bjsh Posted 2007-04-19 21:25
银牌会员 Posts 621 Credits 2,000
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
Floor2 sisos Posted 2007-04-19 23:32
初级用户 Posts 10 Credits 20
Although a bit confusing to read, I basically understand what's going on. Thanks, LZ
Floor3 htysm Posted 2007-04-20 00:26
高级用户 Posts 415 Credits 866
Floor4 wydos Posted 2007-04-20 01:00
中级用户 Posts 117 Credits 304
Strong! But still don't understand!
Floor5 estar Posted 2007-04-20 02:00
中级用户 Posts 103 Credits 346
Come late, add points and top!
Floor6 hulongzhuo Posted 2007-04-20 04:26
中级用户 Posts 135 Credits 294
That's good, just what I need for such a code!!!!
Floor7 13579246810 Posted 2007-04-20 06:22
初级用户 Posts 21 Credits 45
Grateful beyond words!! So great!
Floor8 flyinspace Posted 2007-04-20 07:23
银牌会员 Posts 517 Credits 1,206
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.
Floor9 zqz0012005 Posted 2007-04-20 07:49
中级用户 Posts 135 Credits 297
Oh my goodness! The echo command has such a function!
Floor10 caucfeiyu Posted 2007-04-24 09:46
初级用户 Posts 35 Credits 108 From 河北廊坊
Newbie, don't understand! Still need to continue learning! There's no end to learning!
Floor11 yzshde007 Posted 2007-04-25 23:44
新手上路 Posts 3 Credits 5
Heheh, there's no such thing as absolute forever. I believe I can surpass you.
Floor12 lxmxn Posted 2007-04-26 01:52
版主 Posts 4,938 Credits 11,386
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.
Floor13 wert123 Posted 2007-06-02 10:22
中级用户 Posts 135 Credits 301
Wow, impressive~~~

[ Last edited by wert123 on 2007-6-2 at 10:25 AM ]
Floor14 qzwqzw Posted 2007-06-02 10:37
银牌会员 Posts 636 Credits 2,343
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.
Floor15 tyh Posted 2007-06-02 11:29
初级用户 Posts 43 Credits 80
Got confused later on.
1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023