| @set @n=0;/*&echo off |
| setlocal enabledelayedexpansion |
| echo 实际开始于 %time%,以下将作延时和引用随机数处理,以测试 TrackBack 是否有效 |
| |
| set /a 层数=200,时间范围=43200 |
| ::层数决定为一个初始种子检测多少层,时间范围设置的是向上追溯多少秒 |
| |
| ping /n !time:~-1! 127.1 >nul |
| ::随机延时 1 次 %random%,拉开时间差 |
| for /l %%a in (1 1 %random:~,2%) do break !random! |
| ::随机引用 n 次 %random%,使种子偏离初始值,对 random 的所有引用次数不能超过预设的层数 |
| |
| echo; |
| echo 调用 :TrackBack 追溯随机数种子于 !time! |
| echo --------------------------------------- |
| call :TrackBack %层数% %时间范围% |
| echo --------------------------------------- |
| echo; |
| |
| if %errorlevel% neq 0 ( |
| set 初始种子=%errorlevel% |
| cscript -nologo -e:javascript %0 !初始种子! "脚本起始运行的时间可能是 yyyy-MM-dd hh:mm:ss" |
| echo 结束于 !time! |
| echo; |
| |
| pause>nul |
| echo !random! |
| ) else ( |
| echo 未能发现种子,可能是因为层数太浅或延时超过 !时间范围! 秒 |
| ) |
| pause |
| exit /b |
| |
| :TrackBack 层数 时间范围 |
| setlocal |
| |
| set /a 层数=%1,时间范围=%2 |
| ::层数决定为一个初始种子检测多少层,时间范围设置的是向上追溯多少秒 |
| |
| set /a rand1=%random%,rand2=%random% |
| ::获取两个用于参照的随机数,与计算结果完全符合时认定为取得种子 |
| |
| for /f "tokens=1-9 delims=:./\- " %%a in ("!date:~,10! !time!") do ( |
| set /a "m=(1%%b+29)%%12,y=%%a-m/10,t=365*y+y/4-y/100+y/400+(m*306+5)/10+1%%c-719569" |
| set /a t=t*86400+%%d*3600+1%%e*60+1%%f-34900,end=t-t%% 时间范围 |
| ) |
| ::换算 1970.1.1 至今的总秒数 |
| |
| for /l %%a in (!t! -1 !end!) do ( |
| title %%a |
| set /a "seed=%%a*0x343fd+0x269ec3,r2=(seed>>0x10)&0x7fff" |
| for /l %%b in (1 1 %层数%) do ( |
| set /a "r1=r2,r2=(seed*0x343fd+0x269ec3>>0x10)&0x7fff,seed=seed*0x343fd+0x269ec3" |
| if !r1!_!r2!==%rand1%_%rand2% ( |
| set /a 时间间隔=t-%%a |
| echo 向前追溯共 !时间间隔! 秒 |
| echo 向上追溯第 %%b 层 |
| echo 初始种子为 %%a |
| exit /b %%a |
| ) |
| ) |
| ) |
| exit /b 0 |
| */ |
| |
| //format 方法引自网络 |
| Date.prototype.format = function(format){ |
| var o = { |
| "M+" : this.getMonth()+1, //month |
| "d+" : this.getDate(), //day |
| "h+" : this.getHours(), //hour |
| "m+" : this.getMinutes(), //minute |
| "s+" : this.getSeconds(), //second |
| "q+" : Math.floor((this.getMonth()+3)/3), //quarter |
| "S" : this.getMilliseconds() //millisecond |
| } |
| |
| if(/(y+)/.test(format)) { |
| format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); |
| } |
| |
| for(var k in o) { |
| if(new RegExp("("+ k +")").test(format)) { |
| format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); |
| } |
| } |
| return format; |
| } |
| |
| WScript.Echo(new Date(WScript.Arguments(0)*1000).format(WScript.Arguments(1)))COPY |