// 请将这行心跳启动代码放在所有脚本之前
dim 心跳ID = Thread.Start (心跳验证)
Delay 1000
//以下所有代码可以放置在你代码任意处
Import "Thread.lua"
Import "Cjson.lua"
Import "ShanHai.lua"
dim checkTimes=0
function f68c9e61a22924d36ac60b41133977561()
Dim rsa公钥 = "-----BEGIN PUBLIC KEY-----\n"&_
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDk1PyUffMhmfT2L92vqMJukwF+\n"&_
"SxQUlNWs9QTuYPmi/asWzkAT4C0QftByWFxRDv0kFZFWT/MGOYNDbDWXHY6LeGZc\n"&_
"vV262kLdlwqcPD8QFz3zNJ4uNxqzfBAcUmauMibYi7AwW7HNqxqoRD+4gqONS4l3\n"&_
"Lk9sLs8reRgDlB8sSwIDAQAB\n"&_
"-----END PUBLIC KEY-----\n"
Dim rsa私钥 = "-----BEGIN RSA PRIVATE KEY-----\n"&_
"MIICXAIBAAKBgQCiecrOmgf/TMT5u4fIEpWEEs3OJ1Blv4F3LjMn5sWHsrT4OVpi\n"&_
"t8teziD/aEaqa6p2zDiKmr7vX8buiTmTuLbcocUpSHn9dvfrl8v0aubvasYQGxrE\n"&_
"HsNDdOU+ymZJY27UXvoG/jtJTuBEMSV11hY8hu318pu9mV+Y8HdouvF+TwIDAQAB\n"&_
"AoGAS518BfgItcfgOkuND0+a1xs7PfDtCVV9pt5Q/4Z2ssc4Uve6OYxJMUekcslw\n"&_
"bdrqvBwiSltndhcwiY5Cxh2muDvCREAck0BwvAorHYA2fw8DGz7ExBEhCTPMQAEH\n"&_
"YVZ2jR2hHNTvnzDNulO7QHxuYUthUbekmiJuorMNybirhokCQQC1FGFCOV5ehwK6\n"&_
"V92yTdO8EZpejlrC/jEe1tGT1ntXHDAJ56FdBg74R7do+vmIn88wXdaIP5Sfa+vN\n"&_
"YoZM3C2ZAkEA5bLs/mbmeNWGSEUCYI1lrpPf+/W2DZ1cMLPNM2k40ytnDjN5r2OI\n"&_
"XgQp4TX+whjbTQO/gWfEA1VTvhfrqbpsJwJBAKkhK+ZK5xWrTKT3xJ3xiz4xwtlm\n"&_
"ZOeTvBVt17oZroIiVcwqiND2A61qbqijIca2XTJzsxj3Kb3tcwUWbRIE5KECQFmz\n"&_
"QvuiQZSkhfkJAgGkljXTx5+Ed+DfN9ZJEPRnveoxQ+B216lXbDSS2av6Qw+XV2S+\n"&_
"9vVZCWHn23kbrEsu4vcCQF1fPpejT7U9i7gOTAkfl7DajWSmVZrDp7jPAD9CXTEt\n"&_
"mjRk3sxVpxVfMC7/Td0KlGhE9fkENQWeRjs2T0xNWRo=\n"&_
"-----END RSA PRIVATE KEY-----\n"
Dim data = Cjson.Decode(Elf.GetGeneralParams())
data["RegCodeToken"] = Thread.GetShareVar("Token")
data["ClientTimestamp"] = time()
Thread.SetShareVar "Token", ""
dim datas = Cjson.Encode(data)
dim sign = RSA_Sign(datas, rsa私钥)
dim postData = "SignContent="& ShanHai.CharToUrl(datas)&"&Signature="& ShanHai.CharToUrl(sign)
dim response = url.post("http://auth2.mobileanjian.com/Script/Check", postData)
'TracePrint left(response, 1),Right(response, 1),response
If left(response, 1) <> "{" or Right(response, 1) <> "}" Then
checkTimes = checkTimes +1
If checkTimes > 10 Then
Thread.SetShareVar "Message", "网络错误!"
f68c9e61a22924d36ac60b41133977561 = False
Else
f68c9e61a22924d36ac60b41133977561 = True
End If
Exit Function
End If
checkTimes = 0
Dim resposte = Cjson.Decode(response)
Dim respostv = RSA_VerifySign(resposte["SignContent"], resposte["Signature"], rsa公钥)
Dim singnafalse = ShanHai.RndEx(0,999) & resposte["Signature"]
If respostv and RSA_VerifySign(resposte["SignContent"], singnafalse, rsa公钥) Then
respostv = False
'TracePrint respostv
End If
Dim resdata = Cjson.Decode(resposte["SignContent"])
If resdata["Code"] = 200 Then
If resdata["Data"]["ExpireTime"] <= data["ClientTimestamp"] Then
Thread.SetShareVar "Message","注册码已到期,请输入新的注册码!"
f68c9e61a22924d36ac60b41133977561 = False
Else
Thread.SetShareVar "Token", resdata["Data"]["RegCodeToken"]
f68c9e61a22924d36ac60b41133977561 = True
End If
Else
Thread.SetShareVar "Message", resdata["Message"]
f68c9e61a22924d36ac60b41133977561 = False
End If
End Function
Function 心跳验证()
Do
If f68c9e61a22924d36ac60b41133977561() Then
Thread.SetShareVar "Message", ""
Else
Thread.SetShareVar "Token", "OnScriptExit"
ExitScript
End If
Delay 180*1000
Loop
End Function
Function OnScriptExit
If 心跳ID Then
Thread.Stop 心跳ID
End If
If Thread.GetShareVar("Message") <> "" and Thread.GetShareVar("Message") <> null Then
Dialog.MsgBox(Thread.GetShareVar("Message"),0)
End If
End Function