本帖最后由 zch11230 于 2013-7-26 22:32 编辑
我想的是把密码写到EXE文件末端
这个是主程序If FileExists (@ScriptName&".bak") Then FileDelete (@ScriptName&".bak")
$hwnd = FileOpen(@ScriptName, 16)
$file = FileRead($hwnd)
FileClose($hwnd)
$filelen = BinaryLen($file)
$pwdlen = Number(BinaryToString(BinaryMid($file, $filelen - 1)))
$password = BinaryToString(BinaryMid($file, $filelen - $pwdlen - 1, $pwdlen))
$filedata = BinaryMid($file, 1, $filelen - $pwdlen - 2)
Do
$newpwd = InputBox("", "旧密码为: "&$password&@LF&"请输入新密码", "abc123")
Until @error = 0
RunWait(@ComSpec &" /c ren "&@ScriptName&" "&@ScriptName&".bak",@ScriptDir,@SW_HIDE)
$newpwdlen = StringLen($newpwd)
If $newpwdlen < 10 Then $newpwdlen = "0" & $newpwdlen
$open = FileOpen(@ScriptName, 2)
FileWrite($open, $filedata & Binary(String($newpwd)) & Binary(String($newpwdlen)))
FileClose($open)
编译完后需要给它赋一个初始密码$file=FileOpen("test.exe",16)
$fs=FileRead($file)
FileClose($file)
$file=FileOpen("test.exe",17)
FileWrite($file, Binary("zch03"))
FileClose($file)
MsgBox (0,"","Done!")
|