Jump to content

Recommended Posts

Posted

Hello,

I am creating a small webserver which will receive data from an HTML page using TCPRecv. Receving data from a text box is not an issue:

POST / HTTP/1.1
Host: 127.0.0.1
Connection: keep-alive
Content-Length: 298
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://127.0.0.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarywTzBAiQZOQbd43tx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://127.0.0.1/
Accept-Encoding: gzip, deflate, br
Accept-Language: en

------WebKitFormBoundarywTzBAiQZOQbd43tx
Content-Disposition: form-data; name="fileName"

test txt
------WebKitFormBoundarywTzBAiQZOQbd43tx
Content-Disposition: form-data; name="fileContent"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundarywTzBAiQZOQbd43tx--

However if I upload some binary data (e.g. application) that contains non-string chars the conversion from binary to string is only done party or not at all (which is correct, as it is not a string at all). In this case I am not able to parse the header - what is the best approach here to find the header data inside the binary data?

 

 

Posted

Most encoding and decoding is done with gzip or base64.

There are UDF's on the forum for both of those.

Be prepared to spend some time getting familiar with them.

Search the forum for them.

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

I think you may need to download the whole file first.

Some time ago i did a tcp file transfer script, on the receiving part i have this:

Func Receive()
    While 1
    Do
        $Socket = TCPAccept($UpdateDir_MainSocket)
        Sleep(100)
    Until $Socket <> -1
    ConsoleWrite('Connected: ' & $Socket & @CRLF)
    Sleep(500)
    $File = TCPRecv($Socket, $i4KiB, 1)
    ConsoleWrite('TCPRecv: '&BinaryToString($File) &@CRLF& @CRLF)
    $Split = StringSplit(BinaryToString($File), '<Filename>', 1)
    $File = $Split[1]
    $SecSplit = StringToBinary($Split[2])
    ;ConsoleWrite('Recv File: ' & $File & @CRLF& @CRLF)
    Sleep(500)
    ;=============================================================================
    Local $bEOF = Binary(@CRLF & "{EOF}")
    Local $iEOFLen = BinaryLen($bEOF)
    Local $bData = $SecSplit&Binary("")
    Local $iDataLen = 0
    Local $bEOFReached = False
    Do
        $bData &= TCPRecv($Socket, $i4KiB, 1)
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Connection lost, Error code: " & $iError)
            Exit
            Return False
        EndIf
        $iDataLen = BinaryLen($bData)
        ConsoleWrite($bData &@CRLF)
        If $iDataLen = 0 Then ContinueLoop
        If BinaryMid($bData, 1 + $iDataLen - $iEOFLen, $iEOFLen) = $bEOF Then
            $bData = BinaryMid($bData, 1, $iDataLen - $iEOFLen)
            $bEOFReached = True
        EndIf
        Sleep(30)
    Until $bEOFReached
        ;=============================================================================
        $FO = FileOpen('1.txt', 26)
        FileWrite($FO, $bData);"0x" &
        FileClose($FO)
        ;=============================================================================
        DirCreate(@ScriptDir&'\Downloaded\')
        $FO = FileOpen('Downloaded\' & $File, 26)
        FileWrite($FO, $bData)
        FileClose($FO)
        TCPCloseSocket($Socket)
        $bData = ''
        $iDataLen = 0
        Sleep(500)
    WEnd
EndFunc   ;==>

So as you can see, the TCPRevc has the binary flag, Improvements should be made, but this worked and i managed to transfer files within my LAN.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
×
×
  • Create New...