|
uiopuiop
中级用户
  
积分 400
发帖 211
注册 2007-9-30
状态 离线
|
『楼 主』:
如何把密码加密存放,供批处理运行时调用?
使用 LLM 解释/回答一下
如何把密码加密存放,供批处理运行时调用?
Last edited by uiopuiop on 2011-1-10 at 23:58 ]
How to store passwords encrypted for calling during batch processing?
Last edited by uiopuiop on 2011-1-10 at 23:58 ]
|
|
2011-1-10 23:57 |
|
|
Hanyeguxing
银牌会员
     正在学习中的菜鸟...
积分 1039
发帖 897
注册 2009-3-1 来自 在地狱中仰望天堂
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
密码的规则是什么?纯数字?数字加字母?还是常用字符?
加密的算法要求是什么?
存放的位置指定在哪?注册表还是文件?
What are the password rules? Pure numbers? Numbers plus letters? Or common characters? What are the requirements for the encryption algorithm? Where is the storage location specified? In the registry or a file?
|

批处理之家 http://bbs.bathome.net/forum-5-1.html |
|
2011-1-11 00:35 |
|
|
Hanyeguxing
银牌会员
     正在学习中的菜鸟...
积分 1039
发帖 897
注册 2009-3-1 来自 在地狱中仰望天堂
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
写了个简单的,密码要求为纯数字,保存在注册表: @echo off&setlocal enabledelayedexpansion
set x0=!random!!random!!random!!random!!random!&echo !x0!原始
set r=hkcu\Software\hanye
:x1:加密算法
if not "!x0:~%n%,1!"=="" set/a a=!x0:~%n%,1!+!n:~-1!,n+=1&set x1=!x1!!a:~-1!&goto:x1
echo %x1%加密
reg add %r% /ve /d %x1% /f>nul
for /f "tokens=3 delims=这里是制符" %%a in ('reg query %r% /ve') do set x3=%%a
:x2:解密算法
if not "!x3:~%m%,1!"=="" set/a a=1!x3:~%m%,1!-!m:~-1!,m+=1&set x2=!x2!!a:~-1!&goto:x2
echo %x2%解密
pause
reg delete %r% /f>nul
Last edited by Hanyeguxing on 2011-1-11 at 01:54 ]
I wrote a simple one, the password requirement is pure numbers, saved in the registry:
@echo off&setlocal enabledelayedexpansion
set x0=!random!!random!!random!!random!!random!&echo !x0! original
set r=hkcu\Software\hanye
:x1: encryption algorithm
if not "!x0:~%n%,1!"=="" set/a a=!x0:~%n%,1!+!n:~-1!,n+=1&set x1=!x1!!a:~-1!&goto:x1
echo %x1% encrypted
reg add %r% /ve /d %x1% /f>nul
for /f "tokens=3 delims=这里是制符" %%a in ('reg query %r% /ve') do set x3=%%a
:x2: decryption algorithm
if not "!x3:~%m%,1!"=="" set/a a=1!x3:~%m%,1!-!m:~-1!,m+=1&set x2=!x2!!a:~-1!&goto:x2
echo %x2% decrypted
pause
reg delete %r% /f>nul
Last edited by Hanyeguxing on 2011-1-11 at 01:54 ]
|

批处理之家 http://bbs.bathome.net/forum-5-1.html |
|
2011-1-11 01:13 |
|
|
uiopuiop
中级用户
  
积分 400
发帖 211
注册 2007-9-30
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by Hanyeguxing at 2011-1-11 12:35 AM:
密码的规则是什么?纯数字?数字加字母?还是常用字符?
加密的算法要求是什么?
存放的位置指定在哪?注册表还是文件?
re: 密码的规则是什么?- 字母数字的混合(当然如果能带特殊符号更好)
re: 加密的算法要求是什么? - 一般不容易破解即可,当然如果能用高级点的加密更好(MD5, dsa, rsa, etc.)
re; 存放的位置指定在哪?最好能存放在一个文件里。
批处理可以调用第三方命令行工具。
PS. 是否能解释一下三楼代码的加密原理,谢谢!
Originally posted by Hanyeguxing at 2011-1-11 12:35 AM:
What are the password rules? Pure numbers? Numbers plus letters? Or common characters?
What are the requirements for the encryption algorithm?
Where is the storage location specified? In the registry or in a file?
re: What are the password rules? - A mix of letters and numbers (of course, it would be better if special symbols can be included)
re: What are the requirements for the encryption algorithm? - Generally, it should be not easy to crack. Of course, if a more advanced encryption can be used (MD5, DSA, RSA, etc.)
re; Where is the storage location specified? It is best to store it in a file.
Batch processing can call third-party command-line tools.
PS. Can you explain the encryption principle of the code on the third floor, thank you!
|
|
2011-1-11 19:27 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
加再多,把if取消……
写的bat的代码,大部分核心操作都要依赖与密码
然后把密码加密MD5在bat里面比较下。如果对了执行。。。
这样看到你的bat源码,如果不比较,随便的password是不行的。
set password=
if md5(password)=fde3494783dfd854
操作的核心部分都要和%passord%有关,中间的某个字符啊,某个
字符再运算变形啊。。。
这个没有正确的password跳过判断下来执行也是不能工作的才可以。
Add more, remove the if...
The written bat code, most of the core operations rely on the password.
Then encrypt the password with MD5 and compare it in the bat. If correct, execute...
So if you see your bat source code, if there is no comparison, a random password is not acceptable.
set password=
if md5(password)=fde3494783dfd854
The core part of the operation is all related to %password%, some character in the middle, some character is re-operated and deformed...
Only when there is no correct password and skip the judgment and execute next can it not work.
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2011-1-12 13:43 |
|
|
uiopuiop
中级用户
  
积分 400
发帖 211
注册 2007-9-30
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by slore at 2011-1-12 01:43 PM:
加再多,把if取消……
写的bat的代码,大部分核心操作都要依赖与密码
然后把密码加密MD5在bat里面比较下。如果对了执行。。。
这样看到你的 ...
一般自动化脚本都是自动运行的,不会有人工干预,所以不能人工输入密码。
你MD5加密后,如何解密呢?密码在批处理运行时又必须是明文的,运行时候肯定要解密后在穿给相应的命令的,MD5没法认啊。
Originally posted by slore at 2011-1-12 01:43 PM:
Add more, cancel the if...
The written bat code, most core operations depend on the password.
Then encrypt the password with MD5 and compare it in the bat. If it is correct, execute...
So seeing your...
Generally, automated scripts run automatically without manual intervention, so there can be no manual input of the password.
After you encrypt with MD5, how do you decrypt it? The password must be in plain text when the batch processing runs. When running, it must be decrypted and then passed to the corresponding command. MD5 cannot recognize it.
|
|
2011-1-12 23:37 |
|
|
then0011
新手上路

积分 5
发帖 9
注册 2008-8-28
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
厉害 我菜鸟 所以 只有看的分
Great! I'm a newbie! So I can only watch and can't contribute much.
|
|
2011-1-12 23:53 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by uiopuiop at 2011-1-12 23:37:
一般自动化脚本都是自动运行的,不会有人工干预,所以不能人工输入密码。
你MD5加密后,如何解密呢?密码在批处理运行时又必须是明文的,运行时候肯定要解密后在穿给相应的命令的,MD5没法认啊。
你要无人干预就不要设置密码。。。。
我这里明文是用set /p pw=
让人输入的,然后md5计算下,和md5相比较。。。能过下面的操作和你输入的密码相关系,所以错误的密码是不能用的。
如果你单纯的密码设置了,而只是自动读取?自动判断。。。
把判断注掉了,你有什么加密可言?
Originally posted by uiopuiop at 2011-1-12 23:37:
Most automated scripts run automatically without manual intervention, so passwords cannot be entered manually.
After you encrypt with MD5, how do you decrypt it? The password must be in plain text when the batch file runs. It must be decrypted and then passed to the corresponding command during execution. MD5 can't recognize it.
You don't set a password if you want no intervention...
Here, plain text is entered using set /p pw=
Then calculate MD5 and compare it with the MD5... There is a relationship with the password you entered through the following operations, so an incorrect password cannot be used.
If you simply set a password and just read it automatically? Automatically judge...
If you comment out the judgment, what encryption do you have?
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2011-1-13 09:54 |
|
|
acaigg
初级用户
 
积分 115
发帖 92
注册 2010-12-24
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
我是很菜的,代码不太懂。但看得出slore的思维比较严谨。
I'm quite green, not very familiar with code. But I can see that slore's thinking is relatively rigorous.
|
|
2011-1-13 21:34 |
|
|
uiopuiop
中级用户
  
积分 400
发帖 211
注册 2007-9-30
状态 离线
|
|
2011-1-16 19:50 |
|
|
cyn01livecn
初级用户
 
积分 28
发帖 23
注册 2010-11-26
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
简单,替换文字就行了,例如把“1”替换成“X”让人看不懂,调用时再把他换回来。
Simple, just replace the text. For example, replace "1" with "X" to make it unreadable, and then replace it back when calling.
|
|
2011-1-18 12:18 |
|
|
goltaxhs
新手上路

积分 8
发帖 8
注册 2017-8-21
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
1、用C编个最简单的int main(int argc, char * argv[]) 程序, char * argv[]就是第一个参数,程序会对第一个参数进行检查(就是密码),如果成功返回T,失败返回F。
2、在批处理中做一个SE /P PWD=要求输入密码,再将输入值传给第一步的程序,进行参数即密码,进行判断。
3、批处理根据%errorlevel%返回值T/F判断输入的密码是否正确,正确处理下一步,不正确提示再次输入。
4、这样密码保存在c编译好的exe文件中,一般是看不到的,除非破解。
1、Write the simplest int main(int argc, char * argv) program in C. char * argv is the first parameter. The program will check the first parameter (which is the password). If successful, return T; if failed, return F.
2、In batch processing, make a SE /P PWD= to require entering the password, and then pass the input value to the program in the first step as the parameter, which is the password, and make a judgment.
3、The batch processing judges whether the input password is correct according to the %errorlevel% return value T/F. If correct, handle the next step; if incorrect, prompt to enter again.
4、In this way, the password is saved in the compiled exe file, generally not visible, unless cracked.
|
|
2017-8-26 21:48 |
|