Jump to content
Sign in to follow this  
Armand

BinaryToString() Issue, AU3 Bug ?! [Solved]

Recommended Posts

hey guys, my script is TCPRecv via HTTP1.1 sends a binary code as follows:

0x534B2A474F... 4605 chars...

while trying to parse that binary code into a normal string using "BinaryToString($Bin, 4)" i get only a partial result of that binary converted to a string... a really tiny part: "SK*GOT8/*ttl>*Kaspersky Anti-Virus 7 0 0 125"

now, when i take that entire code and slice it into even parts and use that same function on each and every part it works just fine... any idea?!

PS>> i get that binary code by spitting it one line before the actual send to the "BinaryToString($Bin, 4)" !!!

ConsoleWrite(@CRLF & "ConsoleWrite(@CRLF&BinaryToString('" & String($Bin) & "', 4))", 1)
$DBClientGet = BinaryToString(String($Bin), 4)

Any idea how could that happen ?! is it an AU3 bug ?!

Edited by Armand

Share this post


Link to post
Share on other sites

well, i've just read that the limit script line length is 4095

Maximum length of a single script line: 4,095

but yet even when i use the following:

$pBin = ""
    ;Results are always in binary.
        $Bin584 = StringRegExp($Bin, "[\S\s]{584}|[\S\s]+", 3)
        If @error = 0 Then
            For $i = 0 To UBound($Bin584) - 1
                If $i <> 0 Then $Bin584[$i] = "0x" & $Bin584[$i]
                Debug(@CRLF & "::Converting:: " & $Bin584[$i], 1)
                If $i = UBound($Bin584) - 1 Then
                $pBin &= BinaryToString($Bin584[$i], 4)
                Else
                $pBin &= BinaryToString($Bin584[$i], 4) & @CRLF
                EndIf
            Next
        EndIf

it still doesn't work and still parses the same line... "SK*GOT8/*ttl>*Kaspersky Anti-Virus 7 0 0 125".

any idea ?!

Share this post


Link to post
Share on other sites

For next to come...

-->>the issue is with the presence of a NULL char inside the binary content. [0x00 or just 00]

to avoid it use the following bit-shifter, it's not that fast but it's working.

$pDBClientGet = ""
;Results are always in binary.
    $DBClientGet1024 = StringRegExp($Read, "[\S\s]{4}|[\S\s]+", 3)
    If @error = 0 Then
        For $i = 0 To UBound($DBClientGet1024) - 1
            If $i <> 0 Then $DBClientGet1024[$i] = "0x" & $DBClientGet1024[$i]
            ConsoleWrite(@CRLF & "::Converting:: " & $DBClientGet1024[$i])
            $DBClientGet1024[$i] = StringReplace($DBClientGet1024[$i], "00", "20")
            If $i = UBound($DBClientGet1024) - 1 Then
                $pDBClientGet &= BinaryToString($DBClientGet1024[$i], 4)
            Else
                $pDBClientGet &= BinaryToString($DBClientGet1024[$i], 4)
            EndIf
        Next
    EndIf

Thanks to anyone who has buttered his mind with my issue !!!!!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...