$INI = @ScriptDir & "\key.ini"
if iniread($INI, "authorization", "key", "") = "" Then
IniWrite($INI, "authorization", "key", "")
EndIf
$key = IniRead($INI, "authorization", "key", "")
if StringRegExp($key,_GetKey(_UniqueHardwareID(0x01 + 0x02))) = 1 Then
MsgBox(0,"","ключ найден")
_start()
Else
MsgBox(0,"","ключ не найден")
ClipPut(_UniqueHardwareID(0x01 + 0x02))
MsgBox(0,"","ключ скопирован в буфер обмена, отправьте его автору")
_authorization()
EndIf
Func _start()
EndFunc
Func _authorization()
$key = InputBox("Проверка безопасности", "Введите ключ", "")
if $key = _GetKey(_UniqueHardwareID(0x01 + 0x02)) Then
IniWrite($Ini, "authorization", "key", $key)
MsgBox(0,"Внимание","Ключ указан верно")
_start()
Else
MsgBox(0,"Внимание","Неверный ключ")
exit
EndIf
EndFunc
Func _GetKey($userid)
$hash = __md5($userid)
Return StringMid($hash, 1, 7) & "-" & StringMid($hash, 9, 7) & "-" & StringMid($hash, 13, 7) & "-" & StringMid($hash, 17, 7) & "-" & StringMid($hash, 21, 7)
EndFunc
Func _UniqueHardwareID($iFlags = 0)
Local $oService = ObjGet('winmgmts:\\.\root\cimv2')
If Not IsObj($oService) Then
Return SetError(1, 0, '')
EndIf
Local $oItems, $Hash, $Text, $Hw = '', $Result = 0
$oItems = $oService.ExecQuery('SELECT * FROM Win32_ComputerSystemProduct')
If Not IsObj($oItems) Then
Return SetError(2, 0, '')
EndIf
For $Property In $oItems
$Hw &= $Property.IdentifyingNumber
$Hw &= $Property.Name
$Hw &= $Property.SKUNumber
$Hw &= $Property.UUID
$Hw &= $Property.Vendor
$Hw &= $Property.Version
Next
$Hw = StringStripWS($Hw, 8)
If Not $Hw Then
Return SetError(3, 0, '')
EndIf
If BitAND($iFlags, 0x0001) Then
$oItems = $oService.ExecQuery('SELECT * FROM Win32_BIOS')
If Not IsObj($oItems) Then
Return SetError(2, 0, '')
EndIf
$Text = ''
For $Property In $oItems
$Text &= $Property.IdentificationCode
$Text &= $Property.Manufacturer
$Text &= $Property.Name
$Text &= $Property.SerialNumber
$Text &= $Property.SMBIOSMajorVersion
$Text &= $Property.SMBIOSMinorVersion
Next
$Text = StringStripWS($Text, 8)
If $Text Then
$Result += 0x0001
$Hw &= $Text
EndIf
EndIf
If BitAND($iFlags, 0x0002) Then
$oItems = $oService.ExecQuery('SELECT * FROM Win32_Processor')
If Not IsObj($oItems) Then
Return SetError(2, 0, '')
EndIf
$Text = ''
For $Property In $oItems
$Text &= $Property.Architecture
$Text &= $Property.Family
$Text &= $Property.Level
$Text &= $Property.Manufacturer
$Text &= $Property.Name
$Text &= $Property.ProcessorId
$Text &= $Property.Revision
$Text &= $Property.Version
Next
$Text = StringStripWS($Text, 8)
If $Text Then
$Result += 0x0002
$Hw &= $Text
EndIf
EndIf
$Hash = __MD5($Hw)
If Not $Hash Then
Return SetError(4, 0, '')
EndIf
Return SetError(0, $Result, $Hash)
Return SetError(0, $Result, '{' & StringMid($Hash, 1, 8) & '-' & StringMid($Hash, 9, 4) & '-' & StringMid($Hash, 13, 4) & '-' & StringMid($Hash, 17, 4) & '-' & StringMid($Hash, 21, 12) & '}')
EndFunc
Func __MD5($sData)
Local $Ret, $hProv, $hHash, $tData, $Error = 1
$hProv = DllCall('advapi32.dll', 'int', 'CryptAcquireContextW', 'ptr*', 0, 'ptr', 0, 'ptr', 0, 'dword', 3, 'dword', 0xF0000000)
If (@error) Or (Not $hProv[0]) Then
Return ''
EndIf
Do
$hHash = DllCall('advapi32.dll', 'int', 'CryptCreateHash', 'ptr', $hProv[1], 'uint', 0x00008003, 'ptr', 0, 'dword', 0, 'ptr*', 0)
If (@error) Or (Not $hProv[0]) Then
$hHash = 0
ExitLoop
EndIf
$hHash = $hHash[5]
$tData = DllStructCreate('byte[' & BinaryLen($sData) & ']')
DllStructSetData($tData, 1, $sData)
$Ret = DllCall('advapi32.dll', 'int', 'CryptHashData', 'ptr', $hHash, 'ptr', DllStructGetPtr($tData), 'dword', DllStructGetSize($tData), 'dword', 1)
If (@error) Or (Not $Ret[0]) Then
ExitLoop
EndIf
$tData = DllStructCreate('byte[16]')
$Ret = DllCall('advapi32.dll', 'int', 'CryptGetHashParam', 'ptr', $hHash, 'dword', 2, 'ptr', DllStructGetPtr($tData), 'dword*', 16, 'dword', 0)
If (@error) Or (Not $Ret[0]) Then
ExitLoop
EndIf
$Error = 0
Until 1
If $hHash Then
DllCall('advapi32.dll', 'int', 'CryptDestroyHash', 'ptr', $hHash)
EndIf
If $Error Then
Return ''
EndIf
Return StringTrimLeft(DllStructGetData($tData, 1), 2)
EndFunc