实现功能:每隔30分钟生成新动态密码并发送到指定邮箱修改账户后转入登录界面
测试环境:163邮箱,QQ邮箱发邮件报错,强烈建议用163邮箱作为发件人
注:1.由于o,O和0,l和1难以区分,所以取消难以区分的字母,便于输入正确密码
2.此代码具有一定危险性,请谨慎使用,要注意smtp服务器,用户名,密码,发件人和收件人一定要填写正确,
运行代码前可以建立一个管理员用户,如果无法登陆,可以用管理员登陆查看此文件目录下新密码.txt文件或者
用U盘下个PE工具清除密码或者在运行前把源代码中& net user a !key!
&& rundll32.exe user32.dll,LockWorkStation删除只看效果,建议只看效果就行了
实例代码:
@echo off
setlocal enabledelayedexpansion
set index=0::运行次数
:1
if !index! EQU 48 ( ::30分钟运行一次,共运行24小时
exit
)
ping -n 1800 127.0>nul ::间隔30分钟,1800秒
@echo 第!index!个30分钟密码
set key=::密码变量
for /L %%i in (1,1,11) do (::11位密码
set /a num=!random!%%59+1::新建"字典表.txt"中字符数目A-Z,0-9,a-z,取消o,O,l,一共59,每个字符一行,生成1-59的随机数
set idx=1::字典表索引变量
for /F %%j in (字典表.txt) do (
if !num! EQU !idx! (::比较随机数索引和字典表索引,相等则字符串连接索引对应字符
set key=!key!%%j
)
set /a idx+=1::索引递增
)
)
@echo 密码是:!key!
@echo !key!>新密码.txt
::vbs发送邮件开始
echo set sh=WScript.CreateObject("WScript.Shell") >telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "open smtp.163.com 25{ENTER}" >>telnet_tmp.vbs::smtp.163.com修改为自己邮箱的smtp服务器
echo WScript.Sleep 1000 >>telnet_tmp.vbs
echo sh.SendKeys "helo abc{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "auth login{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "YQ=={ENTER}" >>telnet_tmp.vbs::YQ==是邮箱用户名base64加密,这里是a
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "YQ=={ENTER}" >>telnet_tmp.vbs::YQ==是邮箱密码base64加密,这里是a
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "mail from:{ENTER}" >>telnet_tmp.vbs::a@163.com发件人
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "rcpt to:{ENTER}" >>telnet_tmp.vbs::a@163.com收件人
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "data{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "subject:%date:~0,10% %time:~0,8%{ENTER}{ENTER}" >>telnet_tmp.vbs::邮件标题,这里是年-月-日 时:分:秒
echo sh.SendKeys "!key!{ENTER}" >>telnet_tmp.vbs:邮件正文,这里是密码变量
echo sh.SendKeys ".{ENTER}" >>telnet_tmp.vbsstart telnet
::vbs发送邮件结束
::执行vbs,修改账户a密码并切换到登录界面,即30分钟后生成密码,发送密码到邮箱,修改密码并切换到登录界面
cscript //nologo telnet_tmp.vbs && del telnet_tmp.vbs & net user a !key! && rundll32.exe user32.dll,LockWorkStation
set /a index+=1
goto :1