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-08-05 12:21
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » P File Encryption and Decryption + P-Style Keylogger View 1,503 Replies 6
Original Poster Posted 2007-07-28 20:16 ·  中国 广东 佛山 顺德区 电信
初级用户
★★
Credits 193
Posts 98
Joined 2007-01-17 11:56
19-year member
UID 76803
Gender Male
Status Offline
Batch File Encryption and Decryption
Many people like to encrypt batch files after writing them to prevent others from modifying the copyright, and the most commonly used method is to compile them into EXE files. There is a relatively special encryption method, which is to add a FFEF file header to the batch file, so that text editors like Notepad will open the batch file in UNICODE mode, of course, it will display garbled characters, but Windows does not consider this file as a UNICODE format file, and still executes each command in the file in sequence, and the batch file can still be used normally.

Next, analyze that when opening the encrypted batch file with UltralEdit32, switch to the hexadecimal mode to display the following code:
00000000h: FF FE 0D 0A 63 6C 73 0D 0A FF FE 0D 0A 63 6C 73 ; ??.cls..??.cls
00000010h: 0D 0A ; ..

Obviously, if the UNICODE file header FFFE is forcibly added to the batch file header, it will definitely cause an error in the execution of the first command of the batch file. The author adds a 0D0A after FFFE, which is a carriage return and line feed, so it will not affect the execution of the first command of the encrypted file, but an error message of "is not an internal or external command, nor a runnable program or batch file" will appear on the screen. The author adds a cls after this command to immediately clear the error message on the screen, which is quite clever.

By this point, everyone should be able to see the decryption method. The method is very simple: just use a hex editor to delete the file header FF FE 0D 0A 63 6C 73 0D 0A of the encrypted file. If you are afraid of trouble, just delete the preceding FFFE and then modify it with Notepad again.

If you want to encrypt your batch file well, try Quick Batch File Compiler. It can not only compile batch files into EXE files, but also package the external commands used by the batch file into the executable file.



============
Alternative Decryption Method: copy name.bat con

copy is the copy command, no need to explain more.
con is the abbreviation of DOS device file. In DOS, many external devices are regarded as files, called device files. DOS has such a regulation: con console (keyboard/display) aux (or com1) first serial port lpt1 first parallel printer interface, nul non-existent device
Example: copy con abc.txt
Function: Copy the text entered from the keyboard to the file abc.txt, so after entering this command, enter characters, and press ctrl+z to end. The text you entered will be saved to the abc.txt file.
Example: copy abc.txt con
Function: Copy the text in abc.txt to the screen, that is, display it.

Put forward a question: copy con abc.txt copies the text entered from the keyboard to the file abc.txt,
It can only record the text entered in DOS. If it can monitor all keyboard inputs and record them to abc.txt! ----- To put it simply, it is a BAT version keylogger
Veterans, come and discuss together to realize this function. . .

[ Last edited by luowei14 on 2007-7-28 at 08:17 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
wudixin96 +3 2007-07-28 20:20
这家伙很聪明 什么都没留下
Floor 2 Posted 2007-07-28 20:20 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Hehe, this is already known. Thanks for your enthusiasm
Floor 3 Posted 2007-07-28 20:24 ·  中国 广东 佛山 顺德区 电信
初级用户
★★
Credits 193
Posts 98
Joined 2007-01-17 11:56
19-year member
UID 76803
Gender Male
Status Offline
... Everyone, don't just look and leave... My problem hasn't been solved yet. With my current BAT knowledge, I can't complete this work, so I posted it on the forum. Let's discuss together how to implement a BAT version keyboard logger. copy con abc.txt copies the text input from the keyboard to the file abc.txt. Monitor all keyboard inputs and record them to a certain file!
这家伙很聪明 什么都没留下
Floor 4 Posted 2007-07-28 20:39 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Monitoring keyboard input is not BAT's strong suit; you can't do it without third-party tools
Floor 5 Posted 2007-07-30 20:18 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Use the right tool for the right job
Floor 6 Posted 2007-07-30 20:31 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
copy con cannot be used for keylogging
Because enabling it will cause all commands to fail to execute
This is similar to editing a text file with Notepad

There are corresponding keylogging tools under dos/cmd
You can search online
Even if it is used in a batch file, it is achieved with a batch file
Floor 7 Posted 2007-07-31 00:16 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Compiling with Quick Batch File Compiler, in fact, you can get the batch file without cracking. It's just in the temp directory, which is simpler. Whereas the encryption method still requires you to handle the file manually.
Windows 一键还原
http://www.yjhy.com
Forum Jump: