Golbez Posted November 14, 2022 Share Posted November 14, 2022 (edited) Hi guys, im trying to convert my ini file (i labeled them kik) to a binary file so i can then read them off the internet without having to download anything. i cant seem to get it to work, and im unsure as to how to fix. code: #include <Inet.au3> #include <MsgBoxConstants.au3> ;fun2.kik = Normal INI, fun3.kik = converted binary Global $fun2 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun2.kik' Global $fun3 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun3.kik' Global $location Global $location convertBItoKIK() ConvertKIKtoBI() Func convertBItoKIK() $location= @ScriptDir & "\fun2.kik" MsgBox(0, "Convert Binary: " & $location, "1: inetread " & InetRead($location) & @CRLF & @CRLF & "2:Binarytoscring " & StringToBinary($location) & @CRLF & @CRLF & "3: binary " & Binary($location)) ClipPut(Binary($location)) EndFunc func ConvertKIKtoBI() $location= @ScriptDir & "\fun3.kik" MsgBox(0, "Convert KIK: " & $location, "1: inetread " & InetRead($location) & @CRLF & @CRLF & "2:Binarytoscring " & StringToBinary($location) & @CRLF & @CRLF & "3: binary " & Binary($location)) EndFunc funs2.kik [KEY] funtime = yes funs3.kik 0x433A5C55736572735C7264735C4465736B746F705C4E657720666F6C6465725C66756E322E6B696B i think funs3 is just the location but it is not converting it like it should Edited November 14, 2022 by Golbez Link to comment Share on other sites More sharing options...
Nine Posted November 14, 2022 Share Posted November 14, 2022 $location is a string representing a file name. Using StringToBinary or Binary will not convert its content, only the file name... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to comment Share on other sites More sharing options...
Golbez Posted November 14, 2022 Author Share Posted November 14, 2022 (edited) im attempting to turn the whole ini binary or have the result be binary which i would read from online. expandcollapse popup#include <Inet.au3> #include <MsgBoxConstants.au3> ;fun2.kik = Normal INI, fun3.kik = converted binary Global $fun2 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun2.kik' Global $fun3 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun3.kik' Global $location ConvertBItoKIK() ConvertKIKtoBI() Exit Func ConvertBItoKIK() $location= @ScriptDir & "\fun2.kik" local $BItoKIK = IniRead($location, "KEY", "funtime", "") MsgBox(0, "Convert Binary: " & $location, "1: BItoKIK: " & $BItoKIK & @CRLF & @CRLF _ & "2: Location: " & $location & @CRLF & @CRLF _ & "2: Kik2: " & $fun2 & @CRLF & @CRLF _ & "3: InetRead kik2: " & InetRead($fun2) & @CRLF & @CRLF _ & "4: StringToBinary: " & StringToBinary($BItoKIK) & @CRLF & @CRLF _ & "5: Binary: " & Binary($BItoKIK)) ClipPut(Binary($location)) EndFunc func ConvertKIKtoBI() $location= @ScriptDir & "\fun3.kik" local $KIKtoBI = FileReadLine ($location, 1) MsgBox(0, "Convert KIK: " & $location, "1: KIKtoBI: " & $KIKtoBI & @CRLF & @CRLF _ & "2: Location: " & $location & @CRLF & @CRLF _ & "2: Kik3: " & $fun3 & @CRLF & @CRLF _ & "3: InetRead kik2: " & InetRead($fun2) & @CRLF & @CRLF _ & "4: BinaryToString: " & BinaryToString($KIKtoBI) & @CRLF & @CRLF _ & "5: Binary: " & Binary($KIKtoBI)& @CRLF & @CRLF _ & "6: String: " & $KIKtoBI & @CRLF & @CRLF _ & "7: INetSource: " & _INetGetSource($fun3) & @CRLF _ & "8: INetSource Convert: " & BinaryToString(_INetGetSource($fun3, false))) EndFunc #cs converted file: file location. 0x5B4B45595D0A70686F6E65686F6D65203D207965730A converted files: means yes: 0x796573 converted fun2.kik 0x433A5C55736572735C7264735C4465736B746F705C4E657720666F6C6465725C66756E322E6B696B 0x433A5C55736572735C7264735C4465736B746F705C4E657720666F6C6465725C66756E322E6B696B #ce with this code, i can get the info off the website but it doesnt seem to be converting it correctly BinaryToString(_INetGetSource($fun3, false))) this is what isnt working for some reason, it just returns the Binary value Edited November 15, 2022 by Golbez Link to comment Share on other sites More sharing options...
rudi Posted November 17, 2022 Share Posted November 17, 2022 Hello. I miss why you want to convert your ini to binary, then back to string: You can read their content straight away to a string value: #include <Inet.au3> $URL="https://raw.githubusercontent.com/Zephino/funs/main/fun2.kik" $content=_INetGetSource($URL,true) MsgBox(0, '', $content) Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Golbez Posted November 17, 2022 Author Share Posted November 17, 2022 (edited) okay i understand i can read it but it is not the same as when i try to compare it to what i know it says. heres another test i did, it does not equal the same. expandcollapse popup#include <Inet.au3> #include <String.au3> #include <MsgBoxConstants.au3> ;fun2.kik = Normal INI, fun3.kik = converted binary Global $fun2 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun2.kik' Global $fun3 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun3.kik' Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $location ;ConvertBItoKIK() ;ConvertKIKtoBI() if String(_INetGetSource($fun4)) = "yes" then MsgBox(0,"","") Else Local $webcode = String(_INetGetSource($fun4, True)) local $bi= Binary($webcode) local $co= BinaryToString($bi) Local $key = 'yes' MsgBox(0, "", "1: Webcode: " & $webcode & @CRLF _ & "2: CapWebCode: " & StringUpper($co) & @CRLF _ & "2: binary: " & $bi & @CRLF & @CRLF _ & "3: Converted: " & $co & @CRLF _ & "4: Compare: " & StringCompare($co, _StringInsert(Binary($key),"0A", 8), 0) & @CRLF & @CRLF _ & "5: Key Convert: " & Binary($key)& @CRLF & @CRLF _ & "6: Key Insert: " & _StringInsert(Binary($key),"0A", 8)) If StringUpper($co) = "YES" Then MsgBox(0,"yay","yay") EndIf Exit Func ConvertBItoKIK() $location= @ScriptDir & "\fun2.kik" local $BItoKIK = IniRead($location, "KEY", "funtime", "") MsgBox(0, "Convert Binary: " & $location, "1: BItoKIK: " & $BItoKIK & @CRLF & @CRLF _ & "2: Location: " & $location & @CRLF & @CRLF _ & "2: Kik2: " & $fun2 & @CRLF & @CRLF _ & "3: InetRead kik2: " & InetRead($fun2) & @CRLF & @CRLF _ & "4: StringToBinary: " & StringToBinary($BItoKIK) & @CRLF & @CRLF _ & "5: Binary: " & Binary($BItoKIK)) ClipPut(Binary($BItoKIK)) EndFunc func ConvertKIKtoBI() $location= @ScriptDir & "\fun3.kik" local $KIKtoBI = FileReadLine ($location, 1) MsgBox(0, "Convert KIK: " & $location, "1: KIKtoBI: " & $KIKtoBI & @CRLF & @CRLF _ & "2: Location: " & $location & @CRLF & @CRLF _ & "2: Kik3: " & $fun3 & @CRLF & @CRLF _ & "3: InetRead kik2: " & InetRead($fun2) & @CRLF & @CRLF _ & "4: BinaryToString: " & BinaryToString($KIKtoBI) & @CRLF & @CRLF _ & "5: Binary: " & Binary($KIKtoBI)& @CRLF & @CRLF _ & "6: String: " & $KIKtoBI & @CRLF & @CRLF _ & "7: INetSource: " & _INetGetSource($fun3) & @CRLF & @CRLF _ & "8: INetSource Convert: " & BinaryToString(String(_INetGetSource($fun3, False))) & @CRLF & @CRLF _ & "9: is a binary?: " & IsBinary(BinaryToString(String(_INetGetSource($fun3, False)))) & @CRLF & @CRLF _ & "7: funs4: " & _INetGetSource($fun4)) EndFunc #cs converted file: file location. 0x5B4B45595D0A70686F6E65686F6D65203D207965730A converted files: means yes: 0x796573 converted fun2.kik 0x433A5C55736572735C7264735C4465736B746F705C4E657720666F6C6465725C66756E322E6B696B 0x433A5C55736572735C7264735C4465736B746F705C4E657720666F6C6465725C66756E322E6B696B #ce Edited November 17, 2022 by Golbez Link to comment Share on other sites More sharing options...
rudi Posted November 18, 2022 Share Posted November 18, 2022 Again: I cannot see at all why you want to double convert the content. Pls. try this one, which works perfectly for me with the URLs you provided: #include <Inet.au3> #include <File.au3> $URL="https://raw.githubusercontent.com/Zephino/funs/main/fun2.kik" $IniTmpFile=_TempFile(@TempDir,"IniTmpFile_",".kik") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $IniTmpFile = ' & $IniTmpFile & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $content=_INetGetSource($URL,true) $hINI=FileOpen($IniTmpFile,2+8) FileWrite($hINI,$content) FileClose($hINI) $Section="Key" $Key="Funs" $Value=IniRead($IniTmpFile,$Section,$Key,"!-Read-Error-!") MsgBox(0,"Content",$IniTmpFile & @CRLF & _ "Section = " & $Section & @CRLF & _ "Key = " & $Key & @CRLF & _ "Value found = " & $Value) Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Golbez Posted November 18, 2022 Author Share Posted November 18, 2022 (edited) i am not trying to write a file, i am trying to just pull a value and compare it with what i know it should be and it does not work. if you pull any value from the links provided and compare them with the known value example: #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' if _INetGetSource($fun4, True) = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","Webcode: " & _INetGetSource($fun4, True)) EndIf this should work, and it does not Edited November 18, 2022 by Golbez Link to comment Share on other sites More sharing options...
TheXman Posted November 18, 2022 Share Posted November 18, 2022 (edited) The response from _InetGetSource() is: "yes<LF>". So when you compare "yes<LF>" to "yes", it does not match. * <LF> = Line Feed (0x0A) #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $sResponse $sResponse = _INetGetSource($fun4, True) ConsoleWrite("fun4.kik (Binary): =>" & Binary($sResponse) & "<=" & @CRLF) ConsoleWrite("fun4.kik (String): =>" & $sResponse & "<=" & @CRLF) if $sResponse = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","Webcode: " & _INetGetSource($fun4, True)) EndIf Console output: fun4.kik (Binary): =>0x7965730A<= fun4.kik (String): =>yes <= Edited November 18, 2022 by TheXman CryptoNG UDF: Cryptography API: Next Genjq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON ProcessorXml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example ScriptAbout Me "Any fool can know. The point is to understand." -Albert Einstein The more you know, the more you understand how little you know. That's why ignorant people think they know so much. Link to comment Share on other sites More sharing options...
Golbez Posted November 18, 2022 Author Share Posted November 18, 2022 (edited) 2 hours ago, TheXman said: The response from _InetGetSource() is: "yes<LF>". So when you compare "yes<LF>" to "yes", it does not match. * <LF> = Line Feed (0x0A) #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $sResponse $sResponse = _INetGetSource($fun4, True) ConsoleWrite("fun4.kik (Binary): =>" & Binary($sResponse) & "<=" & @CRLF) ConsoleWrite("fun4.kik (String): =>" & $sResponse & "<=" & @CRLF) if $sResponse = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","Webcode: " & _INetGetSource($fun4, True)) EndIf Console output: fun4.kik (Binary): =>0x7965730A<= fun4.kik (String): =>yes <= #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $sResponse $sResponse = _INetGetSource($fun4, True) ConsoleWrite("fun4.kik (Binary): =>" & Binary($sResponse) & "<=" & @CRLF) ConsoleWrite("fun4.kik (String): =>" & $sResponse & "<=" & @CRLF) if $sResponse = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","$sReponse: " & $sResponse & @CRLF _ & "Binary of $sReponse: " & Binary($sResponse) & @CRLF _ & "String: " & _INetGetSource($fun4, True) & @CRLF _ & "Binary: " & _INetGetSource($fun4, False) & @CRLF _ & "Binary of 'yes': " & Binary("yes") & @CRLF _ & "BinarytoString of 'yes': " & StringToBinary("yes", 1) & @CRLF _ & "Compare $fun4 & 'yes': " & StringCompare( _INetGetSource($fun4, True),"yes") & @CRLF _ & "Compare $sResonse & 'yes': " & StringCompare( _INetGetSource($sResponse, True),"yes") & @CRLF _ & "Compare $sResonse & $fun4: " & StringCompare( _INetGetSource($sResponse, True), $fun4)) ;0: string1 and string2 are equal ;> 0: string1 is greater than string2 ;< 0: string1 is less than string2 EndIf i added the compare in, im not sure what is different between them or why it does not work. i have a slight feeling it involves the amount of characters it is returning in the binary code Edited November 18, 2022 by Golbez Link to comment Share on other sites More sharing options...
TheXman Posted November 18, 2022 Share Posted November 18, 2022 (edited) 1 hour ago, Golbez said: im not sure what is different between them or why it does not work. i have a slight feeling it involves the amount of characters it is returning in the binary code The contents of your fun4.kik file looks like this: If you want the contents of the file to match the literal "yes", then get rid of the extra line". Right now it is "yes" + a line feed (0x0A) character. Make it look like this: (No extra line) Edited November 18, 2022 by TheXman CryptoNG UDF: Cryptography API: Next Genjq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON ProcessorXml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example ScriptAbout Me "Any fool can know. The point is to understand." -Albert Einstein The more you know, the more you understand how little you know. That's why ignorant people think they know so much. Link to comment Share on other sites More sharing options...
Golbez Posted November 18, 2022 Author Share Posted November 18, 2022 2 hours ago, TheXman said: The contents of your fun4.kik file looks like this: If you want the contents of the file to match the literal "yes", then get rid of the extra line". Right now it is "yes" + a line feed (0x0A) character. Make it look like this: (No extra line) soo i went to edit it like you suggested.. it is 1 line already. Link to comment Share on other sites More sharing options...
Solution TheXman Posted November 18, 2022 Solution Share Posted November 18, 2022 (edited) Then I don't know where the trailing LF is coming from. I just created a one line text file in a github repo. After saving it, an extraneous LF was added to the end of the file. So that is where it is coming from. So just strip it before doing your comparison: #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $sResponse $sResponse = _INetGetSource($fun4, True) ConsoleWrite("fun4.kik (Binary): =>" & Binary($sResponse) & "<=" & @CRLF) ConsoleWrite("fun4.kik (String): =>" & $sResponse & "<=" & @CRLF) if StringStripWS($sResponse, $STR_STRIPTRAILING) = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","Webcode: " & _INetGetSource($fun4, True)) EndIf Edited November 18, 2022 by TheXman CryptoNG UDF: Cryptography API: Next Genjq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON ProcessorXml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example ScriptAbout Me "Any fool can know. The point is to understand." -Albert Einstein The more you know, the more you understand how little you know. That's why ignorant people think they know so much. Link to comment Share on other sites More sharing options...
Golbez Posted November 20, 2022 Author Share Posted November 20, 2022 On 11/18/2022 at 4:37 PM, TheXman said: Then I don't know where the trailing LF is coming from. I just created a one line text file in a github repo. After saving it, an extraneous LF was added to the end of the file. So that is where it is coming from. So just strip it before doing your comparison: #include <Inet.au3> #include <String.au3> Global $fun4 = 'https://raw.githubusercontent.com/Zephino/funs/main/fun4.kik' Global $sResponse $sResponse = _INetGetSource($fun4, True) ConsoleWrite("fun4.kik (Binary): =>" & Binary($sResponse) & "<=" & @CRLF) ConsoleWrite("fun4.kik (String): =>" & $sResponse & "<=" & @CRLF) if StringStripWS($sResponse, $STR_STRIPTRAILING) = "yes" then MsgBox(0,"works","works") Else MsgBox(0,"Does Not Work","Webcode: " & _INetGetSource($fun4, True)) EndIf ty much that works 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