Zagor Posted September 19, 2014 Share Posted September 19, 2014 Hello Im trying to protect my app with online hwid system but Im stuck on this.Program dont read txt file from my website and there is always error msg "HWID NotFound" can someone help me with this? #include <Array.au3> #include <String.au3> If _GetHWID('7390647.387001DEXIF20') Then MsgBox(4096, '', 'HWID Found.') Else MsgBox(4096, '', 'HWID NOT Found.') ProcessClose("test.exe") EndIf Func _GetHWID($sHWID) Local $aArray = StringSplit(BinaryToString(InetRead('http://mywebsite.com/hwid.txt')), @LF) If @error Then Return SetError(1, 0, 0) EndIf Return _ArrayBinarySearch($aArray, $sHWID) > 0 EndFunc ;==>_GetHWID Func _HWID() Local $sOSDrive = StringLeft(@SystemDir, 3) Local $sHWID = '0' & @CPUArch & @KBLayout & DriveGetSerial(@HomeDrive) & StringUpper(DriveGetType($sOSDrive)) & DriveSpaceTotal($sOSDrive) $sHWID = StringMid($sHWID, Round(StringLen($sHWID) / 2), Round(StringLen($sHWID) / 2)) $sHWID = _StringReverse($sHWID) Return $sHWID EndFunc ;==>_HWID MsgBox(4096, '', 'Hello this is test.') Link to comment Share on other sites More sharing options...
Developers Jos Posted September 20, 2014 Developers Share Posted September 20, 2014 Test should be: If _getwhid() = ".." Then Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Zagor Posted September 20, 2014 Author Share Posted September 20, 2014 Test should be: If _getwhid() = ".." Then Jos Still same "HWID NotFound" Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 Do have you tried to verify if you can connect to the site and you can download hwid.txt from it? Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 (edited) Zagor, You are returning the HTML from your site, not a .txt file edit: www.mywebsite.com just happens to be a valid URL. Edited September 20, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 When run like this... #include <Array.au3> #include <String.au3> If _GetHWID('7390647.387001DEXIF20') Then MsgBox(4096, '', 'HWID Found.') Else MsgBox(4096, '', 'HWID NOT Found.') ProcessClose("test.exe") EndIf Func _GetHWID($sHWID) Local $aArray = StringSplit(BinaryToString(InetRead('http://mywebsite.com/hwid.txt')), @LF) If @error Then Return SetError(1, 0, 0) EndIf ;Return _ArrayBinarySearch($aArray, $sHWID) > 0 Return true EndFunc ;==>_GetHWID Func _HWID() Local $sOSDrive = StringLeft(@SystemDir, 3) Local $sHWID = '0' & @CPUArch & @KBLayout & DriveGetSerial(@HomeDrive) & StringUpper(DriveGetType($sOSDrive)) & DriveSpaceTotal($sOSDrive) $sHWID = StringMid($sHWID, Round(StringLen($sHWID) / 2), Round(StringLen($sHWID) / 2)) ;$sHWID = _StringReverse($sHWID) Return $sHWID EndFunc ;==>_HWID MsgBox(4096, '', 'Hello this is test.') the logic works therefore the HWID you are looking for is not on the file or the file is not being downloaded. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 I think it's just an example... Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 j0kky - Yea, I'm still laughing my ass off Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
Zagor Posted September 20, 2014 Author Share Posted September 20, 2014 Do have you tried to verify if you can connect to the site and you can download hwid.txt from it? I can connect and can dl file. Permision is 777 Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 Can you post the file or a sample of it? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 (edited) Zagor, _arraybinarysearch requires the input to be sorted. Use _arraysearch or sort the array before searching... kylomas edit: if you don't want to goof around with arrays you might consider an SRE like this... Func _GetHWID($sHWID) Local $sHWIDS = BinaryToString(InetRead('http://mywebsite.com/hwid.txt')) If @error Then Return SetError(1, 0, 0) EndIf return stringregexp($sHWIDs,'(?m)^' & $sHWID & '\R') EndFunc ;==>_GetHWID note - tested against a file only Edited September 20, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
j0kky Posted September 21, 2014 Share Posted September 21, 2014 (edited) I think the errors reside in this line: Return _ArrayBinarySearch($aArray, $sHWID) > 0 - _ArrayBinarySearch has to be replaced by _ArraySearch - The right condition is "> -1" instead of "> 0" So the correct line is: Return _ArraySearch($aArray, $sHWID, 0, 0, 1) > -1 ;case sensitive match Edited September 21, 2014 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now